diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java index c6a4b4c0e..c2683eaf9 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java @@ -8,9 +8,11 @@ import muramasa.antimatter.gui.event.IGuiEvent; import muramasa.antimatter.machine.Tier; import muramasa.antimatter.util.Utils; +import muramasa.gregtech.cover.base.CoverBasicTransport; import muramasa.gregtech.data.GregTechData; import muramasa.gregtech.data.SlotTypes; import muramasa.gregtech.blockentity.single.IFilterable; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; @@ -32,10 +34,6 @@ public class CoverConveyor extends CoverBasicTransport implements IFilterable { - static { - CoverGuiEvent.init(); - } - public static String ID = "conveyor"; private boolean extracting = true; @@ -54,6 +52,19 @@ public CoverConveyor(ICoverHandler source, @Nullable Tier tier, Direction sid } + @Override + public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { + if (object instanceof ItemStack stack){ + ItemStack compare = getInventory(SlotTypes.FILTERABLE).getItem(0); + if (compare.hasTag()){ + CompoundTag nbt = compare.getTag(); + boolean blacklist = nbt.getBoolean("blacklist"); + + } + } + return super.onTransfer(object, inputSide, simulate); + } + @Override public boolean blocksCapability(Class cap, Direction side) { return side == null && cap != ExtendedItemContainer.class; @@ -124,57 +135,4 @@ protected boolean canMove(Direction side){ public boolean accepts(ItemStack stack) { return stack.getItem() == GregTechData.COVER_ITEM_FILTER.getItem().getItem(); } - - - static class CoverGuiEvent implements IGuiEvent { - - public static void init() { - - } - enum ConveyorEvent { - INPUT_OUTPUT, - } - public final ConveyorEvent event; - public CoverGuiEvent(IGuiEventFactory fac, FriendlyByteBuf buffer) { - this.event = ConveyorEvent.values()[buffer.readVarInt()]; - } - - public CoverGuiEvent(ConveyorEvent ev) { - this.event = ev; - } - - @Override - public boolean forward() { - return false; - } - - @Override - public void write(FriendlyByteBuf buffer) { - buffer.writeVarInt(event.ordinal()); - } - - @Override - public void handle(Player player, GuiInstance instance) { - CoverConveyor source = (CoverConveyor) instance.handler; - switch (event) { - case INPUT_OUTPUT -> source.extracting = !source.extracting; - } - } - public static final IGuiEvent.IGuiEventFactory INSTANCE = AntimatterAPI.register(IGuiEventFactory.class, new IGuiEventFactory() { - @Override - public BiFunction factory() { - return CoverGuiEvent::new; - } - - @Override - public String getId() { - return "cover_gui_factory"; - } - }); - - @Override - public IGuiEventFactory getFactory() { - return INSTANCE; - } - } } diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java b/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java index c6df7651a..ca7a275fe 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java @@ -7,16 +7,14 @@ import muramasa.antimatter.cover.CoverFactory; import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.Tier; +import muramasa.gregtech.cover.base.CoverFilter; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import tesseract.util.ItemHandlerUtils; -public class CoverFluidFilter extends BaseCover { - boolean blacklist = false; - boolean ignoreNBt = false; +public class CoverFluidFilter extends CoverFilter { public CoverFluidFilter(@NotNull ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { super(source, tier, side, factory); getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25); @@ -47,7 +45,7 @@ public boolean onTransfer(Object object, boolean inputSide, boolean execute) { } boolean matches = FluidHooks.safeGetItemFluidManager(filter).map(f -> { for (int i = 0; i < f.getTankAmount(); i++){ - boolean match = ignoreNBt ? fluidHolder.getFluid() == f.getFluidInTank(i).getFluid() : f.getFluidInTank(i).matches(fluidHolder); + boolean match = ignoreNBT ? fluidHolder.getFluid() == f.getFluidInTank(i).getFluid() : f.getFluidInTank(i).matches(fluidHolder); if (match){ return true; } @@ -63,12 +61,12 @@ public boolean onTransfer(Object object, boolean inputSide, boolean execute) { @Override protected String getRenderId() { - return "item_filter"; + return "fluid_filter"; } @Override public String getId() { - return "item_filter"; + return "fluid_filter"; } @Override diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java b/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java index e3831d02c..faf70e6e3 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java @@ -6,6 +6,7 @@ import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.Tier; import muramasa.antimatter.util.AntimatterPlatformUtils; +import muramasa.gregtech.cover.base.CoverFilter; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -13,9 +14,7 @@ import org.jetbrains.annotations.Nullable; import tesseract.util.ItemHandlerUtils; -public class CoverItemFilter extends BaseCover { - boolean blacklist = false; - boolean ignoreNBt = false; +public class CoverItemFilter extends CoverFilter { public CoverItemFilter(@NotNull ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { super(source, tier, side, factory); getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25); @@ -30,7 +29,6 @@ public boolean blocksCapability(Class cap, @Nullable Direction side) { public boolean onTransfer(Object object, boolean inputSide, boolean execute) { super.onTransfer(object, inputSide, execute); if (object instanceof ItemStack item) { - boolean stop = false; ItemStack filter = getInventory(SlotType.DISPLAY_SETTABLE).getItem(0); boolean empty = filter.isEmpty(); if (empty) { @@ -38,7 +36,7 @@ public boolean onTransfer(Object object, boolean inputSide, boolean execute) { return true; } } - boolean matches = ignoreNBt ? item.is(filter.getItem()) : ItemHandlerUtils.canItemStacksStack(item, filter); + boolean matches = ignoreNBT ? item.is(filter.getItem()) : ItemHandlerUtils.canItemStacksStack(item, filter); if (blacklist == matches){ return true; } diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java index 4d64fde54..a058f470b 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java @@ -6,6 +6,7 @@ import muramasa.antimatter.cover.CoverFactory; import muramasa.antimatter.machine.Tier; import muramasa.antimatter.util.Utils; +import muramasa.gregtech.cover.base.CoverBasicTransport; import muramasa.gregtech.data.GregTechData; import muramasa.gregtech.data.SlotTypes; import muramasa.gregtech.blockentity.single.IFilterable; diff --git a/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicRedstone.java b/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicRedstone.java index 847405eef..2b956e4ba 100644 --- a/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicRedstone.java +++ b/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicRedstone.java @@ -1,4 +1,4 @@ -package muramasa.gregtech.cover; +package muramasa.gregtech.cover.base; import muramasa.antimatter.capability.ICoverHandler; import muramasa.antimatter.cover.BaseCover; @@ -8,6 +8,7 @@ import muramasa.antimatter.machine.Tier; import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.blockentity.pipe.BlockEntityPipe; +import muramasa.gregtech.cover.RedstoneMode; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; diff --git a/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicTransport.java b/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicTransport.java index 083a08a91..ad5c64f05 100644 --- a/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicTransport.java +++ b/common/src/main/java/muramasa/gregtech/cover/base/CoverBasicTransport.java @@ -1,4 +1,4 @@ -package muramasa.gregtech.cover; +package muramasa.gregtech.cover.base; import muramasa.antimatter.capability.ICoverHandler; import muramasa.antimatter.cover.CoverFactory; @@ -9,6 +9,9 @@ import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.blockentity.pipe.BlockEntityPipe; import muramasa.gregtech.GTIRef; +import muramasa.gregtech.cover.ICoverRedstoneSensitive; +import muramasa.gregtech.cover.ImportExportMode; +import muramasa.gregtech.cover.RedstoneMode; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; @@ -27,6 +30,7 @@ public abstract class CoverBasicTransport extends CoverBasicRedstone implements public CoverBasicTransport(ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { super(source, tier, side, factory); this.exportMode = source.getTile() instanceof BlockEntityPipe ? IMPORT : EXPORT; + redstoneMode = RedstoneMode.NO_WORK; coverModeInt = exportMode.ordinal(); addGuiCallback(t -> { t.addCycleButton(70, 34, 16, 16, h -> ((CoverBasicRedstone)h).redstoneMode.ordinal(), i -> "tooltip.gti.redstone_mode." + i, ButtonOverlay.TORCH_OFF, ButtonOverlay.TORCH_ON, ButtonOverlay.REDSTONE); diff --git a/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java b/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java index 30401502d..f76da3fb8 100644 --- a/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java @@ -1,2 +1,40 @@ -package muramasa.gregtech.cover.base;public class CoverFilter { +package muramasa.gregtech.cover.base; + +import muramasa.antimatter.capability.ICoverHandler; +import muramasa.antimatter.cover.BaseCover; +import muramasa.antimatter.cover.CoverFactory; +import muramasa.antimatter.machine.Tier; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class CoverFilter extends BaseCover { + protected boolean blacklist = false; + protected boolean ignoreNBT = false; + public CoverFilter(@NotNull ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { + super(source, tier, side, factory); + } + + @Override + public ItemStack getDroppedStack() { + ItemStack stack = super.getDroppedStack(); + stack.getOrCreateTag().putBoolean("blacklist", blacklist); + stack.getOrCreateTag().putBoolean("ignoreNBT", ignoreNBT); + return stack; + } + + @Override + public void addInfoFromStack(ItemStack stack) { + super.addInfoFromStack(stack); + CompoundTag tag = stack.getTag(); + blacklist = tag.getBoolean("blacklist"); + ignoreNBT = tag.getBoolean("ignoreNBT"); + } + + @Override + public void onUpdate() { + super.onUpdate(); + } } diff --git a/common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneMachineController.java b/common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneMachineController.java index a2300f93e..83e43a694 100644 --- a/common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneMachineController.java +++ b/common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneMachineController.java @@ -10,8 +10,6 @@ import muramasa.antimatter.gui.event.IGuiEvent; import muramasa.antimatter.machine.MachineState; import muramasa.antimatter.machine.Tier; -import muramasa.gregtech.cover.CoverBasicRedstone; -import muramasa.gregtech.cover.RedstoneMode; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation;