Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer523 committed Jul 29, 2024
1 parent 405d56b commit e0678c6
Show file tree
Hide file tree
Showing 24 changed files with 712 additions and 564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
import com.gregtechceu.gtceu.integration.ae2.machine.MEOutputBusPartMachine;
import com.gregtechceu.gtceu.integration.ae2.machine.MEOutputHatchPartMachine;

import com.gregtechceu.gtceu.integration.ae2.machine.MEStockingBusPartMachine;
import com.gregtechceu.gtceu.integration.ae2.machine.MEStockingHatchPartMachine;
import net.minecraft.network.chat.Component;

import static com.gregtechceu.gtceu.api.GTValues.EV;
import static com.gregtechceu.gtceu.api.GTValues.LuV;
import static com.gregtechceu.gtceu.common.registry.GTRegistration.REGISTRATE;

@SuppressWarnings("unused")
public class GTAEMachines {

public final static MachineDefinition ITEM_IMPORT_BUS = REGISTRATE
public final static MachineDefinition ITEM_IMPORT_BUS_ME = REGISTRATE
.machine("me_input_bus", MEInputBusPartMachine::new)
.langValue("ME Stocking Input Bus")
.langValue("ME Input Bus")
.tier(EV)
.rotationState(RotationState.ALL)
.abilities(PartAbility.IMPORT_ITEMS)
Expand All @@ -27,7 +30,18 @@ public class GTAEMachines {
.compassNode("item_bus")
.register();

public final static MachineDefinition ITEM_EXPORT_BUS = REGISTRATE
public final static MachineDefinition STOCKING_IMPORT_BUS_ME = REGISTRATE
.machine("me_stocking_input_bus", MEStockingBusPartMachine::new)
.langValue("ME Stocking Input Bus")
.tier(LuV)
.rotationState(RotationState.ALL)
.abilities(PartAbility.IMPORT_ITEMS)
.overlayTieredHullRenderer("me_item_bus.import")
.tooltips(Component.translatable("gtceu.machine.item_bus.import.tooltip"))
.compassNode("item_bus")
.register();

public final static MachineDefinition ITEM_EXPORT_BUS_ME = REGISTRATE
.machine("me_output_bus", MEOutputBusPartMachine::new)
.langValue("ME Output Bus")
.tier(EV)
Expand All @@ -41,9 +55,9 @@ public class GTAEMachines {
.compassNode("item_bus")
.register();

public final static MachineDefinition FLUID_IMPORT_HATCH = REGISTRATE
public final static MachineDefinition FLUID_IMPORT_HATCH_ME = REGISTRATE
.machine("me_input_hatch", MEInputHatchPartMachine::new)
.langValue("ME Stocking Input Hatch")
.langValue("ME Input Hatch")
.tier(EV)
.rotationState(RotationState.ALL)
.abilities(PartAbility.IMPORT_FLUIDS)
Expand All @@ -52,7 +66,18 @@ public class GTAEMachines {
.compassNode("fluid_hatch")
.register();

public final static MachineDefinition FLUID_EXPORT_HATCH = REGISTRATE
public final static MachineDefinition STOCKING_IMPORT_HATCH_ME = REGISTRATE
.machine("me_stocking_input_hatch", MEStockingHatchPartMachine::new)
.langValue("ME Stocking Input Hatch")
.tier(LuV)
.rotationState(RotationState.ALL)
.abilities(PartAbility.IMPORT_FLUIDS)
.overlayTieredHullRenderer("me_fluid_hatch.import")
.tooltips(Component.translatable("gtceu.machine.fluid_hatch.import.tooltip"))
.compassNode("fluid_hatch")
.register();

public final static MachineDefinition FLUID_EXPORT_HATCH_ME = REGISTRATE
.machine("me_output_hatch", MEOutputHatchPartMachine::new)
.langValue("ME Output Hatch")
.tier(EV)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,29 +779,47 @@ public static void init(Consumer<FinishedRecipe> provider) {
.inputItems(FLUID_EXPORT_HATCH[EV])
.inputItems(meInterface.copy())
.inputItems(accelerationCard.copy())
.outputItems(GTAEMachines.FLUID_EXPORT_HATCH.asStack())
.outputItems(GTAEMachines.FLUID_EXPORT_HATCH_ME)
.duration(300).EUt(VA[HV]).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("me_import_hatch")
.inputItems(FLUID_IMPORT_HATCH[EV])
.inputItems(meInterface.copy())
.inputItems(accelerationCard.copy())
.outputItems(GTAEMachines.FLUID_IMPORT_HATCH.asStack())
.outputItems(GTAEMachines.FLUID_IMPORT_HATCH_ME)
.duration(300).EUt(VA[HV]).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("me_export_bus")
.inputItems(ITEM_EXPORT_BUS[EV])
.inputItems(meInterface.copy())
.inputItems(accelerationCard.copy())
.outputItems(GTAEMachines.ITEM_EXPORT_BUS.asStack())
.outputItems(GTAEMachines.ITEM_EXPORT_BUS_ME)
.duration(300).EUt(VA[HV]).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("me_import_bus")
.inputItems(ITEM_IMPORT_BUS[EV])
.inputItems(meInterface.copy())
.inputItems(accelerationCard.copy())
.outputItems(GTAEMachines.ITEM_IMPORT_BUS.asStack())
.outputItems(GTAEMachines.ITEM_IMPORT_BUS_ME)
.duration(300).EUt(VA[HV]).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("me_stocking_import_bus")
.inputItems(ITEM_IMPORT_BUS[IV])
.inputItems(meInterface.copy())
.inputItems(CONVEYOR_MODULE_IV)
.inputItems(SENSOR_IV)
.inputItems(accelerationCard.copyWithCount(4))
.outputItems(GTAEMachines.STOCKING_IMPORT_BUS_ME)
.duration(300).EUt(VA[IV]).save(provider);

ASSEMBLER_RECIPES.recipeBuilder("me_stocking_import_hatch")
.inputItems(FLUID_IMPORT_HATCH[IV])
.inputItems(meInterface.copy())
.inputItems(ELECTRIC_PUMP_IV)
.inputItems(SENSOR_IV)
.inputItems(accelerationCard.copyWithCount(4))
.outputItems(GTAEMachines.STOCKING_IMPORT_HATCH_ME)
.duration(300).EUt(VA[IV]).save(provider);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;

import com.gregtechceu.gtceu.integration.ae2.gui.widget.slot.AEFluidConfigSlotWidget;
import com.gregtechceu.gtceu.integration.ae2.machine.MEInputHatchPartMachine;
import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

/**
* @Author GlodBlock
* @Description Display {@link com.lowdragmc.lowdraglib.side.fluid.FluidStack} config
* @Date 2023/4/21-1:45
*/
public class AEFluidConfigWidget extends AEConfigWidget {
public class AEFluidConfigWidget extends ConfigWidget {

public AEFluidConfigWidget(int x, int y, IConfigurableSlot[] config) {
super(x, y, config);
Expand All @@ -20,10 +22,10 @@ void init() {
this.displayList = new IConfigurableSlot[this.config.length];
this.cached = new IConfigurableSlot[this.config.length];
for (int index = 0; index < this.config.length; index++) {
this.displayList[index] = new MEInputHatchPartMachine.ExportOnlyAEFluid();
this.cached[index] = new MEInputHatchPartMachine.ExportOnlyAEFluid();
this.displayList[index] = new ExportOnlyAEFluidSlot();
this.cached[index] = new ExportOnlyAEFluidSlot();
line = index / 8;
this.addWidget(new AEFluidConfigSlot((index - line * 8) * 18, line * (18 * 2 + 2), this, index));
this.addWidget(new AEFluidConfigSlotWidget((index - line * 8) * 18, line * (18 * 2 + 2), this, index));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;

import com.gregtechceu.gtceu.integration.ae2.gui.widget.slot.AEItemConfigSlotWidget;
import com.gregtechceu.gtceu.integration.ae2.machine.MEInputBusPartMachine;
import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEItemSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

/**
* @Author GlodBlock
* @Description Display {@link net.minecraft.world.item.ItemStack} config
* @Date 2023/4/22-1:02
*/
public class AEItemConfigWidget extends AEConfigWidget {
public class AEItemConfigWidget extends ConfigWidget {

public AEItemConfigWidget(int x, int y, IConfigurableSlot[] config) {
super(x, y, config);
Expand All @@ -20,10 +22,10 @@ void init() {
this.displayList = new IConfigurableSlot[this.config.length];
this.cached = new IConfigurableSlot[this.config.length];
for (int index = 0; index < this.config.length; index++) {
this.displayList[index] = new MEInputBusPartMachine.ExportOnlyAEItem();
this.cached[index] = new MEInputBusPartMachine.ExportOnlyAEItem();
this.displayList[index] = new ExportOnlyAEItemSlot();
this.cached[index] = new ExportOnlyAEItemSlot();
line = index / 8;
this.addWidget(new AEItemConfigSlot((index - line * 8) * 18, line * (18 * 2 + 2), this, index));
this.addWidget(new AEItemConfigSlotWidget((index - line * 8) * 18, line * (18 * 2 + 2), this, index));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

import com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
Expand All @@ -21,14 +21,14 @@
* @Description The amount set widget for config slot
* @Date 2023/4/21-21:20
*/
public class AmountSetSlot extends Widget {
public class AmountSetWidget extends Widget {

private int index = -1;
@Getter
private final TextFieldWidget amountText;
private final AEConfigWidget parentWidget;
private final ConfigWidget parentWidget;

public AmountSetSlot(int x, int y, AEConfigWidget widget) {
public AmountSetWidget(int x, int y, ConfigWidget widget) {
super(x, y, 80, 30);
this.parentWidget = widget;
this.amountText = new TextFieldWidget(x + 3, y + 12, 65, 13, this::getAmountStr, this::setNewAmount)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;

import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.gui.widget.slot.AEConfigSlotWidget;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup;
Expand All @@ -13,20 +14,20 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

public abstract class AEConfigWidget extends WidgetGroup {
public abstract class ConfigWidget extends WidgetGroup {

protected final IConfigurableSlot[] config;
protected IConfigurableSlot[] cached;
protected Int2ObjectMap<IConfigurableSlot> changeMap = new Int2ObjectOpenHashMap<>();
protected IConfigurableSlot[] displayList;
protected AmountSetSlot amountSetWidget;
protected AmountSetWidget amountSetWidget;
protected final static int UPDATE_ID = 1000;

public AEConfigWidget(int x, int y, IConfigurableSlot[] config) {
public ConfigWidget(int x, int y, IConfigurableSlot[] config) {
super(new Position(x, y), new Size(config.length / 2 * 18, 18 * 4 + 2));
this.config = config;
this.init();
this.amountSetWidget = new AmountSetSlot(31, -50, this);
this.amountSetWidget = new AmountSetWidget(31, -50, this);
this.addWidget(this.amountSetWidget);
this.addWidget(this.amountSetWidget.getAmountText());
this.amountSetWidget.setVisible(false);
Expand All @@ -53,7 +54,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}
}
for (Widget w : this.widgets) {
if (w instanceof AEConfigSlot slot) {
if (w instanceof AEConfigSlotWidget slot) {
slot.setSelect(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.list;

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.client.TooltipsHandler;
Expand All @@ -24,7 +24,7 @@
import java.util.List;
import java.util.Optional;

import static com.gregtechceu.gtceu.integration.ae2.gui.widget.AEConfigSlot.drawSelectionOverlay;
import static com.gregtechceu.gtceu.integration.ae2.gui.widget.slot.AEConfigSlotWidget.drawSelectionOverlay;
import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawText;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.list;

import com.gregtechceu.gtceu.api.gui.GuiTextures;

Expand All @@ -14,7 +14,7 @@
import appeng.api.stacks.GenericStack;
import org.jetbrains.annotations.NotNull;

import static com.gregtechceu.gtceu.integration.ae2.gui.widget.AEConfigSlot.drawSelectionOverlay;
import static com.gregtechceu.gtceu.integration.ae2.gui.widget.slot.AEConfigSlotWidget.drawSelectionOverlay;
import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawItemStack;
import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawText;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.list;

import com.gregtechceu.gtceu.integration.ae2.utils.KeyStorage;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.slot;

import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.gui.widget.ConfigWidget;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget;
import com.lowdragmc.lowdraglib.gui.ingredient.Target;
Expand Down Expand Up @@ -29,17 +30,17 @@
* @Description A configurable slot
* @Date 2023/4/22-0:30
*/
public class AEConfigSlot extends Widget implements IGhostIngredientTarget {
public class AEConfigSlotWidget extends Widget implements IGhostIngredientTarget {

protected AEConfigWidget parentWidget;
protected ConfigWidget parentWidget;
protected int index;
protected final static int REMOVE_ID = 1000;
protected final static int UPDATE_ID = 1001;
protected final static int AMOUNT_CHANGE_ID = 1002;
protected final static int PICK_UP_ID = 1003;
protected boolean select = false;

public AEConfigSlot(Position pos, Size size, AEConfigWidget widget, int index) {
public AEConfigSlotWidget(Position pos, Size size, ConfigWidget widget, int index) {
super(pos, size);
this.parentWidget = widget;
this.index = index;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.slot;

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.integration.ae2.gui.widget.ConfigWidget;
import com.gregtechceu.gtceu.integration.ae2.machine.MEInputHatchPartMachine;
import com.gregtechceu.gtceu.integration.ae2.utils.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAEFluidSlot;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

import com.lowdragmc.lowdraglib.gui.ingredient.Target;
import com.lowdragmc.lowdraglib.gui.util.DrawerHelper;
Expand Down Expand Up @@ -42,11 +44,11 @@
* @Description A configurable slot for {@link com.lowdragmc.lowdraglib.side.fluid.FluidStack}
* @Date 2023/4/21-0:50
*/
public class AEFluidConfigSlot extends AEConfigSlot {
public class AEFluidConfigSlotWidget extends AEConfigSlotWidget {

public static final int LOAD_PHANTOM_FLUID_STACK_FROM_NBT = 13;

public AEFluidConfigSlot(int x, int y, AEConfigWidget widget, int index) {
public AEFluidConfigSlotWidget(int x, int y, ConfigWidget widget, int index) {
super(new Position(x, y), new Size(18, 18 * 2), widget, index);
}

Expand Down Expand Up @@ -263,8 +265,8 @@ public boolean mouseWheelMove(double mouseX, double mouseY, double wheelDelta) {
}

private int tryClickContainer(boolean isShiftKeyDown) {
MEInputHatchPartMachine.ExportOnlyAEFluid fluidTank = this.parentWidget
.getConfig(this.index) instanceof MEInputHatchPartMachine.ExportOnlyAEFluid fluid ? fluid : null;
ExportOnlyAEFluidSlot fluidTank = this.parentWidget
.getConfig(this.index) instanceof ExportOnlyAEFluidSlot fluid ? fluid : null;
if (fluidTank == null) return -1;
Player player = gui.entityPlayer;
ItemStack currentStack = gui.getModularUIContainer().getCarried();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.gregtechceu.gtceu.integration.ae2.gui.widget;
package com.gregtechceu.gtceu.integration.ae2.gui.widget.slot;

import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.integration.ae2.utils.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.utils.IConfigurableSlot;
import com.gregtechceu.gtceu.integration.ae2.gui.widget.ConfigWidget;
import com.gregtechceu.gtceu.integration.ae2.slot.ExportOnlyAESlot;
import com.gregtechceu.gtceu.integration.ae2.slot.IConfigurableSlot;

import com.lowdragmc.lowdraglib.gui.ingredient.Target;
import com.lowdragmc.lowdraglib.gui.util.TextFormattingUtil;
Expand Down Expand Up @@ -31,9 +32,9 @@
* @Description A configurable slot for {@link ItemStack}
* @Date 2023/4/22-0:48
*/
public class AEItemConfigSlot extends AEConfigSlot {
public class AEItemConfigSlotWidget extends AEConfigSlotWidget {

public AEItemConfigSlot(int x, int y, AEConfigWidget widget, int index) {
public AEItemConfigSlotWidget(int x, int y, ConfigWidget widget, int index) {
super(new Position(x, y), new Size(18, 18 * 2), widget, index);
}

Expand Down
Loading

0 comments on commit e0678c6

Please sign in to comment.