Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wireless Crafting Terminal #5656

Conversation

Mari023
Copy link
Contributor

@Mari023 Mari023 commented Nov 9, 2021

Closes #401

  • the CraftingTermMenu and WirelessCraftingTermMenu will be very similar, so ideally, the later one should extend the first
  • make a common WirelessTerminalGuiObject, there are probably differences extending it seams to be enough
  • make a common WirelessTerminalItem extending WirelessTerminalItem is enough
    the texture is made by Ridanisaurus based on the Wireless Terminal and originally used in my mod
  • WirelessCraftingTermMenu#broadcastChanges has a lot duplicated code with WirelessTermMenu, but there is no way around this as it extends MEPortableCellMenu. It could maybe be put in a common subclass (ItemTerminalMenu, or probably even MEMonitorableMenu to account for wireless fluid terminals) has to be AEBaseMenu for InterfaceTerminal
  • decide what to do with items in the crafting slots when closed (store, put in me, put in player inventory) (for now: store)
  • implement that
  • add a recipe for the crafting terminal
  • make Transferring recipes using JEI/REI possible (I don't really know why it doesn't work)
  • write javadoc.
  • update ae2wtlib to use the new stuff

Not directly related to the Wireless Crafting Terminal:

  • make PatternTermMenu and InterfaceTerminalMenu extendable too (so add-ons don't have to copy their code)
  • same for PatternTerminalScreen and InterfaceTerminalScreen
  • Prepare for Wireless Fluid Terminal. That would be another PR, but a lot of changes here also apply to it

@Mari023
Copy link
Contributor Author

Mari023 commented Nov 15, 2021

when I cherry pick my commits to the latest base branch, should I switch to master or stay on fabric/1.17 ?

@shartte
Copy link
Member

shartte commented Nov 16, 2021

@Mari023 Let me know if I should rebase your branch for you. I'd target 1.18 with this, which means -> master :)

@Mari023 Mari023 force-pushed the fabric/feature-wireless-crafting-terminal branch from 7fd4db9 to 306c964 Compare November 16, 2021 20:25
@Mari023 Mari023 changed the base branch from fabric/1.17 to master November 16, 2021 20:58
@Mari023 Mari023 marked this pull request as ready for review November 17, 2021 08:44

void setFluidSubstitution(boolean canSubstitute);

default void fixCraftingRecipes() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It came from PatternTerminalPart

I tried moving as much methods as possible from PatternTerminalPart to IPatternTerminalHost
turns out not much was possible

import appeng.menu.me.items.MEPortableCellMenu;
import appeng.menu.me.items.PatternTermMenu;
import appeng.menu.me.items.WirelessTermMenu;
import appeng.menu.me.items.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, spotless should have fixed that.

Comment on lines +107 to +111
@Nullable
@Override
public IGuiItemObject getGuiObject(ItemStack is, int playerInventorySlot, Level level, @Nullable BlockPos pos) {
return null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above. We should investigate and remove this after the merge

Comment on lines +140 to +143
public IConfigManager getConfigManager(final ItemStack target) {// TODO maybe provide an easy way for other
// Terminals to overwrite this without making
// their own IWirelessTerminalHandler that
// mostly copies this one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the TODO and make an issue for it? Otherwise this TODO may still be here by 2025 :D

Comment on lines +838 to +881
/**
* Can only be used with a host that implements {@link IEnergySource} only call once per broadcastChanges()
*/
protected void updateItemPowerStatus() {
if ((guiItem instanceof IEnergySource energySource)) {
this.powerTicks++;
if (this.powerTicks > 10) {
energySource.extractAEPower(this.powerMultiplier * this.powerTicks, Actionable.MODULATE,
PowerMultiplier.CONFIG);
this.powerTicks = 0;
}
}
}

/**
* Can only be used with a host that extends {@link WirelessTerminalGuiObject}
*/
protected void checkWirelessRange() {
if (guiItem instanceof WirelessTerminalGuiObject wirelessTerminalGUIObject) {
if (!wirelessTerminalGUIObject.rangeCheck()) {
if (isServer() && this.isValidMenu()) {
this.getPlayerInventory().player.sendMessage(PlayerMessages.OutOfRange.get(), Util.NIL_UUID);
}

this.setValidMenu(false);
} else {
powerMultiplier = AEConfig.instance().wireless_getDrainRate(wirelessTerminalGUIObject.getRange());
}
}
}

/**
* Can only be used with a host that implements {@link IInventorySlotAware}
*/
protected boolean checkGuiItemNotInSlot() {
if (guiItem instanceof IInventorySlotAware iInventorySlotAware) {
if (!ensureGuiItemIsInSlot(guiItem, iInventorySlotAware.getInventorySlot())) {
this.setValidMenu(false);
return true;
}
}
return false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to find another home for this. AEBaseMenu is already a god-class, we should avoid putting this here

if (hostInterface.isInstance(guiObject)) {
return hostInterface.cast(guiObject);
}
}

if (hostInterface.isAssignableFrom(WirelessTerminalGuiObject.class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, if you remove this here (which I think is good), why did you keep the actual WirelessTerminals class? :D

@@ -78,8 +83,6 @@ public CraftingTermMenu(int id, final Inventory ip, final ITerminalHost host) {
this.addSlot(this.outputSlot = new CraftingTermSlot(this.getPlayerInventory().player, this.getActionSource(),
this.powerSource, host, craftingGridInv, craftingGridInv, this), SlotSemantic.CRAFTING_RESULT);

this.createPlayerInventorySlots(ip);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point behind this was that the player slots were always created last (because they are in order), but I honestly don't remember why that would be important.

/**
* Can only be used with a host that implements {@link IInventorySlotAware}
*/
protected boolean checkGuiItemNotInSlot() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected boolean checkGuiItemNotInSlot() {
protected boolean hasMenuHostItemBeenRemoved() {

@shartte shartte merged commit 736c951 into AppliedEnergistics:master Nov 18, 2021
@Mari023 Mari023 deleted the fabric/feature-wireless-crafting-terminal branch May 1, 2022 22:55
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wireless "Crafting" Terminal
2 participants