diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java index c2683eaf9..561484ba8 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java @@ -67,7 +67,7 @@ public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { @Override public boolean blocksCapability(Class cap, Direction side) { - return side == null && cap != ExtendedItemContainer.class; + return cap != ExtendedItemContainer.class; } @Override @@ -94,7 +94,7 @@ public void onUpdate() { return; BlockState state = handler.getTile().getLevel().getBlockState(handler.getTile().getBlockPos().relative(side)); //Drop into world. - if (state == Blocks.AIR.defaultBlockState() && exportMode.name.contains("output")) { + if (state == Blocks.AIR.defaultBlockState() && exportMode.isExport()) { Level world = handler.getTile().getLevel(); BlockPos pos = handler.getTile().getBlockPos(); ItemStack stack = TesseractCapUtils.getItemHandler(handler.getTile(), side).map(Utils::extractAny).orElse(ItemStack.EMPTY); diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java index a058f470b..26b1a3926 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java @@ -46,7 +46,7 @@ public ResourceLocation getModel(String type, Direction dir) { @Override public boolean blocksCapability(Class cap, Direction side) { - return side == null && cap != FluidContainer.class; + return cap != FluidContainer.class; } @Override diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverRobotArm.java b/common/src/main/java/muramasa/gregtech/cover/CoverRobotArm.java new file mode 100644 index 000000000..1eaf30216 --- /dev/null +++ b/common/src/main/java/muramasa/gregtech/cover/CoverRobotArm.java @@ -0,0 +1,106 @@ +package muramasa.gregtech.cover; + +import muramasa.antimatter.blockentity.BlockEntityMachine; +import muramasa.antimatter.blockentity.pipe.BlockEntityPipe; +import muramasa.antimatter.capability.ICoverHandler; +import muramasa.antimatter.cover.CoverFactory; +import muramasa.antimatter.gui.SlotType; +import muramasa.antimatter.gui.event.GuiEvents; +import muramasa.antimatter.gui.event.IGuiEvent; +import muramasa.antimatter.machine.Tier; +import muramasa.antimatter.util.Utils; +import muramasa.gregtech.cover.base.CoverBasicTransport; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +public class CoverRobotArm extends CoverBasicTransport { + int slot = 0; + public CoverRobotArm(ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { + super(source, tier, side, factory); + addGuiCallback(t -> { + t.addTextButton(70, 53, 36, 12, h -> ((CoverRobotArm)h).slot, i -> Utils.literal("Slot: ").append("" + i), 0, true); + }); + } + + @Override + protected String getRenderId() { + return "conveyor"; + } + + @Override + public ResourceLocation getModel(String type, Direction dir) { + if (type.equals("pipe")) return PIPE_COVER_MODEL; + return getBasicDepthModel(); + } + + @Override + public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { + if (object instanceof ItemStack stack && !exportMode.isExport() && handler.getTile() instanceof BlockEntityMachine machine && inputSide) { + if (machine.itemHandler.map(h -> h.getInputCount() > 0).orElse(false)){ + machine.itemHandler.ifPresent(h -> { + + }); + } + } + return false; + } + + @Override + public void onGuiEvent(IGuiEvent event, Player playerEntity) { + ImportExportMode previous = exportMode; + super.onGuiEvent(event, playerEntity); + if (event.getFactory() == GuiEvents.EXTRA_BUTTON){ + + GuiEvents.GuiEvent ev = (GuiEvents.GuiEvent) event; + if (ev.data[1] == 1){ + if (previous.isExport() != exportMode.isExport()){ + slot = 0; + if (handler.getTile() instanceof BlockEntityMachine machine) machine.onBlockUpdate(machine.getBlockPos()); + } + } + if (ev.data[1] == 2){ + if (handler.getTile() instanceof BlockEntityMachine machine){ + machine.itemHandler.ifPresent(h -> { + if (exportMode.isExport()){ + if (h.getOutputCount() > 0){ + slot++; + if (slot >= h.getOutputCount()) slot = 0; + } else { + slot = 0; + } + } + if (!exportMode.isExport()){ + if (h.getInputCount() > 0){ + slot++; + if (slot >= h.getInputCount()) slot = 0; + } else if (h.getHandler(SlotType.STORAGE).getContainerSize() > 0){ + slot++; + if (slot >= h.getHandler(SlotType.STORAGE).getContainerSize()) slot = 0; + }else { + slot = 0; + } + } + machine.onBlockUpdate(machine.getBlockPos()); + }); + } + } + } + } + + @Override + public void deserialize(CompoundTag nbt) { + super.deserialize(nbt); + slot = nbt.getInt("slot"); + } + + @Override + public CompoundTag serialize() { + CompoundTag nbt = super.serialize(); + nbt.putInt("slot", slot); + return nbt; + } +} diff --git a/common/src/main/java/muramasa/gregtech/cover/ImportExportMode.java b/common/src/main/java/muramasa/gregtech/cover/ImportExportMode.java index 7a309fcd0..44ceb62a2 100644 --- a/common/src/main/java/muramasa/gregtech/cover/ImportExportMode.java +++ b/common/src/main/java/muramasa/gregtech/cover/ImportExportMode.java @@ -2,34 +2,20 @@ import muramasa.antimatter.cover.ICoverMode; -public enum ImportExportMode implements ICoverMode { - EXPORT("Export",88, 24), - IMPORT("Import",34, 24), - EXPORT_IMPORT("Export Import",88, 42), - IMPORT_EXPORT("Import Export",34, 42); +public enum ImportExportMode { + EXPORT(true), + IMPORT(false), + EXPORT_IMPORT(true), + IMPORT_EXPORT(false); - int x, y; - String name; + boolean export; - ImportExportMode(String name, int x, int y){ - this.name = name; - this.x = x; - this.y = y; + ImportExportMode(boolean export){ + this.export = export; } - @Override - public int getX() { - return x; - } - - @Override - public int getY() { - return y; - } - - @Override - public String getName() { - return name; + public boolean isExport() { + return export; } public ImportExportMode next(){ diff --git a/common/src/main/java/muramasa/gregtech/data/GregTechData.java b/common/src/main/java/muramasa/gregtech/data/GregTechData.java index f0dd7e6c8..6ff0cc286 100644 --- a/common/src/main/java/muramasa/gregtech/data/GregTechData.java +++ b/common/src/main/java/muramasa/gregtech/data/GregTechData.java @@ -62,6 +62,9 @@ public static void init(Side side) { public static final CoverFactory COVER_PUMP = CoverFactory.builder(CoverPump::new).gui().item((a,b) -> new ItemCover(a.getDomain(), a.getId(), b).tip(String.format("%d L/s (as Cover)", CoverPump.speeds.get(b)))) .addTextures(new Texture(GTIRef.ID, "block/cover/pump")).setTiers(Tier.getStandard()).build(GTIRef.ID, "pump"); + public static final CoverFactory COVER_ROBOT_ARM = CoverFactory.builder(CoverRobotArm::new).gui().item((a,b) -> + new ItemCover(a.getDomain(), a.getId(), b).tip(String.format("1 Stack every %ds (as Cover)", CoverConveyor.speeds.get(b)))) + .addTextures(new Texture(GTIRef.ID, "block/cover/conveyor")).setTiers(Tier.getStandard()).build(GTIRef.ID, "robot_arm"); public static final CoverFactory COVER_DRAIN = CoverFactory.builder(CoverDrain::new).item((a, b) -> new ItemCover(GTIRef.ID, "drain").tip("Can be placed on machines/pipes as a cover")).addTextures(new Texture(GTIRef.ID, "block/cover/drain")).build(GTIRef.ID, "drain"); public static final CoverFactory COVER_AIR_VENT = CoverFactory.builder(CoverAirVent::new).item((a, b) -> @@ -129,11 +132,6 @@ public static void init(Side side) { public static ItemBasic PistonHV = new ItemBasic<>(GTIRef.ID, "piston_hv"); public static ItemBasic PistonEV = new ItemBasic<>(GTIRef.ID, "piston_ev"); public static ItemBasic PistonIV = new ItemBasic<>(GTIRef.ID, "piston_iv"); - public static ItemBasic RobotArmLV = new ItemBasic<>(GTIRef.ID, "robot_arm_lv").tip("Insets into specific Slots (as Cover)"); - public static ItemBasic RobotArmMV = new ItemBasic<>(GTIRef.ID, "robot_arm_mv").tip("Insets into specific Slots (as Cover)"); - public static ItemBasic RobotArmHV = new ItemBasic<>(GTIRef.ID, "robot_arm_hv").tip("Insets into specific Slots (as Cover)"); - public static ItemBasic RobotArmEV = new ItemBasic<>(GTIRef.ID, "robot_arm_ev").tip("Insets into specific Slots (as Cover)"); - public static ItemBasic RobotArmIV = new ItemBasic<>(GTIRef.ID, "robot_arm_iv").tip("Insets into specific Slots (as Cover)"); public static ItemBasic FieldGenLV = new ItemBasic<>(GTIRef.ID, "field_gen_lv"); public static ItemBasic FieldGenMV = new ItemBasic<>(GTIRef.ID, "field_gen_mv"); public static ItemBasic FieldGenHV = new ItemBasic<>(GTIRef.ID, "field_gen_hv"); diff --git a/common/src/main/java/muramasa/gregtech/loader/crafting/Machines.java b/common/src/main/java/muramasa/gregtech/loader/crafting/Machines.java index d160e9d4d..082f10071 100644 --- a/common/src/main/java/muramasa/gregtech/loader/crafting/Machines.java +++ b/common/src/main/java/muramasa/gregtech/loader/crafting/Machines.java @@ -52,7 +52,7 @@ public static void loadRecipes(Consumer output, AntimatterRecipe if (motor == null) return; Item piston = GregTech.get(ItemBasic.class, "piston_"+tier.getId()); if (piston == null) return; - Item arm = GregTech.get(ItemBasic.class, "robot_arm_"+tier.getId()); + Item arm = GregTech.get(ItemCover.class, "robot_arm_"+tier.getId()); if (arm == null) return; Item conveyor = GregTech.get(ItemCover.class, "conveyor_"+tier.getId()); if (conveyor == null) return; @@ -751,7 +751,7 @@ private static void addMultiblockRecipes(Consumer output, Antima add(NUCLEAR_REACTOR, EV, (m, item) -> provider.addItemRecipe(output, "machines", "has_wrench", provider.hasSafeItem(WRENCH.getTag()), item, ImmutableMap.builder() .put('H', HULL_EV) - .put('A', RobotArmEV) + .put('A', COVER_ROBOT_ARM.getItem(EV)) .put('G', GEAR.get(NiobiumTitanium)) .put('P', PLATE.get(Iridium)) .put('T', PLATE_DENSE.get(Thorium)).build(), "GTG", "AHA", "PTP")); diff --git a/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java b/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java index b37c72e2a..24a11bb0d 100644 --- a/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java +++ b/common/src/main/java/muramasa/gregtech/loader/crafting/Parts.java @@ -97,7 +97,7 @@ private static void tieredItems(Consumer output, AntimatterRecip Item motor = GregTech.get(ItemBasic.class, "motor_" + t.getId()); Item piston = GregTech.get(ItemBasic.class, "piston_" + t.getId()); - Item robotArm = GregTech.get(ItemBasic.class, "robot_arm_" + t.getId()); + Item robotArm = GregTech.get(ItemCover.class, "robot_arm_" + t.getId()); Item emitter = GregTech.get(ItemBasic.class, "emitter_" + t.getId()); Item sensor = GregTech.get(ItemBasic.class, "sensor_" + t.getId()); Item pump = GregTech.get(ItemCover.class, "pump_" + t.getId());