From ef4baf821060b7bb722de6f9ef8b37fb1e514525 Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:43:40 -0400 Subject: [PATCH] updated antimatter and gt utility, made conveyor and pump covers observe the filter in the filter slot now --- AntimatterAPI | 2 +- .../multi/BlockEntityLargeTank.java | 6 ++- .../multi/BlockEntityLargeTurbine.java | 3 +- .../blockentity/single/BlockEntityBuffer.java | 4 +- .../single/BlockEntityCoalBoiler.java | 6 +-- .../single/BlockEntityInfiniteFluid.java | 4 +- .../single/BlockEntityItemFilter.java | 3 +- .../single/BlockEntityLavaBoiler.java | 6 +-- .../single/BlockEntitySolarBoiler.java | 6 +-- .../single/BlockEntitySteamMachine.java | 12 ++--- .../gregtech/cover/CoverConveyor.java | 47 +++++++++++++++--- .../gregtech/cover/CoverFluidFilter.java | 9 +++- .../gregtech/cover/CoverItemFilter.java | 10 +++- .../muramasa/gregtech/cover/CoverPump.java | 49 +++++++++++++++++++ .../gregtech/cover/base/CoverFilter.java | 5 ++ .../muramasa/gregtech/data/SlotTypes.java | 3 +- gradle.properties | 2 +- 17 files changed, 136 insertions(+), 41 deletions(-) diff --git a/AntimatterAPI b/AntimatterAPI index d266aeeed..80c379f03 160000 --- a/AntimatterAPI +++ b/AntimatterAPI @@ -1 +1 @@ -Subproject commit d266aeeed105cc35a1d125c64e755beb5f40ffe1 +Subproject commit 80c379f037ca587748d1b184bfdcb3a73d2a6562 diff --git a/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTank.java b/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTank.java index 5dc5fe904..7ea4bb695 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTank.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTank.java @@ -114,8 +114,10 @@ public long insertFluid(FluidHolder fluid, boolean simulate) { } } if (!tile.tankMachine.isAcidProof() && fluid.getFluid().is(AntimatterTags.ACID)){ - tile.getLevel().setBlock(tile.getBlockPos(), Blocks.AIR.defaultBlockState(), 3); - return 16; + if (!simulate) { + tile.getLevel().setBlock(tile.getBlockPos(), Blocks.AIR.defaultBlockState(), 3); + } + return Math.min(16L, fluid.getFluidAmount()); } return super.insertFluid(fluid, simulate); } diff --git a/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTurbine.java b/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTurbine.java index 2c1a1f7f5..498e3158f 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTurbine.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/multi/BlockEntityLargeTurbine.java @@ -11,7 +11,6 @@ import muramasa.antimatter.gui.widget.WidgetSupplier; import muramasa.antimatter.integration.jeirei.renderer.IInfoRenderer; import muramasa.antimatter.machine.MachineState; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.machine.event.IMachineEvent; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.recipe.IRecipe; @@ -72,7 +71,7 @@ public void checkRecipe() { @Override public void onMachineEvent(IMachineEvent event, Object... data) { super.onMachineEvent(event, data); - if (event == ContentEvent.ITEM_INPUT_CHANGED){ + if (event == SlotType.IT_IN){ ItemStack stack = itemHandler.map(i -> i.getHandler(SlotType.STORAGE).getStackInSlot(0)).orElse(ItemStack.EMPTY); ItemTurbineRotor rotor = stack.getItem() instanceof ItemTurbineRotor rotor1 ? rotor1 : null; if (rotor == null) { diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java index 74503885f..8532c77c5 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityBuffer.java @@ -10,13 +10,11 @@ import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.gui.event.GuiEvents; import muramasa.antimatter.gui.event.IGuiEvent; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.tool.AntimatterToolType; import muramasa.antimatter.util.AntimatterPlatformUtils; import muramasa.antimatter.util.Utils; import muramasa.gregtech.data.Machines; -import muramasa.gregtech.data.SlotTypes; import muramasa.gregtech.gui.ButtonOverlays; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -189,7 +187,7 @@ public static class BufferItemHandler extends MachineItemHandler(tile, SlotType.STORAGE, count, true, true, (t, s) -> true, ContentEvent.ITEM_INPUT_CHANGED){ + this.inventories.put(SlotType.STORAGE, new TrackedItemHandler<>(tile, SlotType.STORAGE, count, true, true, (t, s) -> true){ @NotNull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityCoalBoiler.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityCoalBoiler.java index 1889e72c3..4cda34ed1 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityCoalBoiler.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityCoalBoiler.java @@ -5,8 +5,8 @@ import muramasa.antimatter.capability.fluid.FluidTanks; import muramasa.antimatter.capability.machine.MachineFluidHandler; import muramasa.antimatter.capability.machine.MachineRecipeHandler; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.MachineState; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.util.Utils; @@ -267,11 +267,11 @@ public static class CoalBoilerFluidHandler extends MachineFluidHandler { + tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> { b.tank(16000); return b; })); - tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> { + tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> { b.tank(16000); return b; })); diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityInfiniteFluid.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityInfiniteFluid.java index 9b7bfaa24..ba16745a4 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityInfiniteFluid.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityInfiniteFluid.java @@ -7,7 +7,7 @@ import muramasa.antimatter.capability.machine.MachineFluidHandler; import muramasa.antimatter.cover.CoverOutput; import muramasa.antimatter.cover.ICover; -import muramasa.antimatter.machine.event.ContentEvent; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.types.Machine; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -77,7 +77,7 @@ protected static class InfiniteFluidHandler extends MachineFluidHandler { + tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> { b.tank(Integer.MAX_VALUE); return b; })); diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java index 231aeb313..88cedda4f 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityItemFilter.java @@ -8,7 +8,6 @@ import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.gui.event.GuiEvents; import muramasa.antimatter.gui.event.IGuiEvent; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.machine.event.IMachineEvent; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.util.AntimatterPlatformUtils; @@ -122,7 +121,7 @@ public void serverTick(Level level, BlockPos pos, BlockState state) { @Override public void onMachineEvent(IMachineEvent event, Object... data) { super.onMachineEvent(event, data); - if ((event == ContentEvent.ITEM_OUTPUT_CHANGED || event == ContentEvent.ITEM_INPUT_CHANGED) && outputRedstone && !this.getLevel().isClientSide()){ + if ((event == SlotType.IT_OUT || event == SlotType.IT_IN) && outputRedstone && !this.getLevel().isClientSide()){ // level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512); } diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityLavaBoiler.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityLavaBoiler.java index a2ce1abd8..4ac92a0cc 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityLavaBoiler.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntityLavaBoiler.java @@ -6,7 +6,7 @@ import muramasa.antimatter.capability.fluid.FluidTanks; import muramasa.antimatter.capability.machine.MachineFluidHandler; import muramasa.antimatter.capability.machine.MachineRecipeHandler; -import muramasa.antimatter.machine.event.ContentEvent; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.util.Utils; import net.minecraft.core.BlockPos; @@ -189,12 +189,12 @@ public void deserialize(CompoundTag nbt) { public static class LavaBoilerFluidHandler extends MachineFluidHandler { public LavaBoilerFluidHandler(BlockEntityLavaBoiler tile) { super(tile, 16000, 1000 * (250 + tile.getMachineTier().getIntegerId())); - tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, ContentEvent.FLUID_INPUT_CHANGED, b -> { + tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> { b.tank(p -> p.getFluid() == Fluids.WATER || p.getFluid() == DistilledWater.getLiquid(), 16000) .tank(p -> p.getFluid() == Fluids.LAVA, 16000); return b; })); - tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> { + tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> { b.tank(16000); return b; })); diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySolarBoiler.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySolarBoiler.java index d2b874062..4b0faf95d 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySolarBoiler.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySolarBoiler.java @@ -5,7 +5,7 @@ import muramasa.antimatter.capability.fluid.FluidTanks; import muramasa.antimatter.capability.machine.MachineFluidHandler; import muramasa.antimatter.capability.machine.MachineRecipeHandler; -import muramasa.antimatter.machine.event.ContentEvent; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.util.Utils; @@ -179,11 +179,11 @@ public void deserialize(CompoundTag nbt) { public static class LavaBoilerFluidHandler extends MachineFluidHandler { public LavaBoilerFluidHandler(BlockEntitySolarBoiler tile) { super(tile, 16000, 1000 * (250 + tile.getMachineTier().getIntegerId())); - tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, ContentEvent.FLUID_INPUT_CHANGED, b -> { + tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> { b.tank(p -> p.getFluid() == Fluids.WATER || p.getFluid() == DistilledWater.getLiquid(), 16000); return b; })); - tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> { + tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> { b.tank(16000); return b; })); diff --git a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySteamMachine.java b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySteamMachine.java index 660ad9a85..c72d35885 100644 --- a/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySteamMachine.java +++ b/common/src/main/java/muramasa/gregtech/blockentity/single/BlockEntitySteamMachine.java @@ -3,8 +3,8 @@ import earth.terrarium.botarium.common.fluid.base.FluidHolder; import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.capability.machine.MachineRecipeHandler; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.Tier; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.machine.event.IMachineEvent; import muramasa.antimatter.machine.types.Machine; import muramasa.antimatter.recipe.IRecipe; @@ -88,12 +88,10 @@ protected boolean consumeGeneratorResources(boolean simulate) { @Override public void onMachineEvent(IMachineEvent event, Object... data) { super.onMachineEvent(event, data); - if (event instanceof ContentEvent) { - if (event == ContentEvent.FLUID_INPUT_CHANGED) { - if (data != null && data.length > 0) { - if (data[0] instanceof FluidHolder && ((FluidHolder)data[0]).getFluid().builtInRegistryHolder().is(GregTechTags.STEAM)) { - checkRecipe(); - } + if (event == SlotType.FL_IN) { + if (data != null && data.length > 0) { + if (data[0] instanceof FluidHolder && ((FluidHolder) data[0]).getFluid().builtInRegistryHolder().is(GregTechTags.STEAM)) { + checkRecipe(); } } } diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java index 561484ba8..f5bea5b8e 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java @@ -2,11 +2,14 @@ import com.google.common.collect.ImmutableMap; import muramasa.antimatter.AntimatterAPI; +import muramasa.antimatter.blockentity.BlockEntityMachine; import muramasa.antimatter.capability.ICoverHandler; +import muramasa.antimatter.capability.IGuiHandler; import muramasa.antimatter.cover.CoverFactory; import muramasa.antimatter.gui.*; import muramasa.antimatter.gui.event.IGuiEvent; import muramasa.antimatter.machine.Tier; +import muramasa.antimatter.machine.event.IMachineEvent; import muramasa.antimatter.util.Utils; import muramasa.gregtech.cover.base.CoverBasicTransport; import muramasa.gregtech.data.GregTechData; @@ -37,6 +40,7 @@ public class CoverConveyor extends CoverBasicTransport implements IFilterable { public static String ID = "conveyor"; private boolean extracting = true; + private final CoverItemFilter filter; public static final Map speeds = ImmutableMap.builder(). put(Tier.LV, 400) @@ -47,6 +51,8 @@ public class CoverConveyor extends CoverBasicTransport implements IFilterable { public CoverConveyor(ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { super(source, tier, side, factory); + this.filter = new CoverItemFilter(source, null, side, GregTechData.COVER_ITEM_FILTER); + filter.onCreate(); Objects.requireNonNull(tier); this.gui.getSlots().add(SlotTypes.FILTERABLE, 79, 53); } @@ -55,12 +61,7 @@ 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 filter.onTransfer(stack, inputSide, simulate); } return super.onTransfer(object, inputSide, simulate); } @@ -135,4 +136,38 @@ protected boolean canMove(Direction side){ public boolean accepts(ItemStack stack) { return stack.getItem() == GregTechData.COVER_ITEM_FILTER.getItem().getItem(); } + + @Override + public void onMachineEvent(IGuiHandler tile, IMachineEvent event, int... data) { + if (tile == this && event == SlotTypes.FILTERABLE){ + ItemStack slotStack = getInventory(SlotTypes.FILTERABLE).getItem(data[0]); + if (slotStack.isEmpty()){ + filter.clearFilter(); + } else { + filter.addInfoFromStack(slotStack); + } + } + super.onMachineEvent(tile, event, data); + } + + @Override + public void addInfoFromStack(ItemStack stack) { + super.addInfoFromStack(stack); + onMachineEvent(this, SlotTypes.FILTERABLE, 0); + } + + @Override + public void deserialize(CompoundTag nbt) { + super.deserialize(nbt); + if (nbt.contains("filter")) { + filter.deserialize(nbt.getCompound("filter")); + } + } + + @Override + public CompoundTag serialize() { + CompoundTag nbt = super.serialize(); + nbt.put("filter", filter.serialize()); + return nbt; + } } diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java b/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java index ca7a275fe..464ebdd82 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverFluidFilter.java @@ -19,6 +19,11 @@ public CoverFluidFilter(@NotNull ICoverHandler source, @Nullable Tier tier, D super(source, tier, side, factory); getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25); } + @Override + public void clearFilter(){ + super.clearFilter(); + getInventory(SlotType.DISPLAY_SETTABLE).clearContent(); + } @Override public boolean blocksCapability(Class cap, @Nullable Direction side) { @@ -26,8 +31,8 @@ public boolean blocksCapability(Class cap, @Nullable Direction side) { } @Override - public boolean onTransfer(Object object, boolean inputSide, boolean execute) { - super.onTransfer(object, inputSide, execute); + public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { + super.onTransfer(object, inputSide, simulate); if (object instanceof FluidHolder fluidHolder) { ItemStack filter = getInventory(SlotType.DISPLAY_SETTABLE).getItem(0); boolean empty = filter.isEmpty() || FluidHooks.safeGetItemFluidManager(filter).map(f -> { diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java b/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java index faf70e6e3..4678c584c 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java @@ -20,14 +20,20 @@ public CoverItemFilter(@NotNull ICoverHandler source, @Nullable Tier tier, Di getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25); } + @Override + public void clearFilter(){ + super.clearFilter(); + getInventory(SlotType.DISPLAY_SETTABLE).clearContent(); + } + @Override public boolean blocksCapability(Class cap, @Nullable Direction side) { return false; } @Override - public boolean onTransfer(Object object, boolean inputSide, boolean execute) { - super.onTransfer(object, inputSide, execute); + public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { + super.onTransfer(object, inputSide, simulate); if (object instanceof ItemStack item) { ItemStack filter = getInventory(SlotType.DISPLAY_SETTABLE).getItem(0); boolean empty = filter.isEmpty(); diff --git a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java index 26b1a3926..03a863d05 100644 --- a/common/src/main/java/muramasa/gregtech/cover/CoverPump.java +++ b/common/src/main/java/muramasa/gregtech/cover/CoverPump.java @@ -2,9 +2,12 @@ import com.google.common.collect.ImmutableMap; import earth.terrarium.botarium.common.fluid.base.FluidContainer; +import earth.terrarium.botarium.common.fluid.base.FluidHolder; import muramasa.antimatter.capability.ICoverHandler; +import muramasa.antimatter.capability.IGuiHandler; import muramasa.antimatter.cover.CoverFactory; import muramasa.antimatter.machine.Tier; +import muramasa.antimatter.machine.event.IMachineEvent; import muramasa.antimatter.util.Utils; import muramasa.gregtech.cover.base.CoverBasicTransport; import muramasa.gregtech.data.GregTechData; @@ -12,6 +15,7 @@ import muramasa.gregtech.blockentity.single.IFilterable; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; @@ -24,6 +28,7 @@ public class CoverPump extends CoverBasicTransport implements IFilterable { public static String ID = "pump"; + private final CoverFluidFilter filter; public static final Map speeds = ImmutableMap.builder(). put(Tier.LV, 640 / 20) @@ -35,6 +40,8 @@ public class CoverPump extends CoverBasicTransport implements IFilterable { public CoverPump(ICoverHandler source, @Nullable Tier tier, Direction side, CoverFactory factory) { super(source, tier, side, factory); Objects.requireNonNull(tier); + this.filter = new CoverFluidFilter(source, null, side, GregTechData.COVER_FLUID_FILTER); + filter.onCreate(); this.gui.getSlots().add(SlotTypes.FILTERABLE, 79, 53); } @@ -44,6 +51,14 @@ public ResourceLocation getModel(String type, Direction dir) { return getBasicDepthModel(); } + @Override + public boolean onTransfer(Object object, boolean inputSide, boolean simulate) { + if (object instanceof FluidHolder stack){ + return filter.onTransfer(stack, inputSide, simulate); + } + return super.onTransfer(object, inputSide, simulate); + } + @Override public boolean blocksCapability(Class cap, Direction side) { return cap != FluidContainer.class; @@ -92,4 +107,38 @@ protected boolean canMove(Direction side){ public boolean accepts(ItemStack stack) { return stack.getItem() == GregTechData.COVER_FLUID_FILTER.getItem().getItem(); } + + @Override + public void onMachineEvent(IGuiHandler tile, IMachineEvent event, int... data) { + if (tile == this && event == SlotTypes.FILTERABLE){ + ItemStack slotStack = getInventory(SlotTypes.FILTERABLE).getItem(data[0]); + if (slotStack.isEmpty()){ + filter.clearFilter(); + } else { + filter.addInfoFromStack(slotStack); + } + } + super.onMachineEvent(tile, event, data); + } + + @Override + public void addInfoFromStack(ItemStack stack) { + super.addInfoFromStack(stack); + onMachineEvent(this, SlotTypes.FILTERABLE, 0); + } + + @Override + public void deserialize(CompoundTag nbt) { + super.deserialize(nbt); + if (nbt.contains("filter")) { + filter.deserialize(nbt.getCompound("filter")); + } + } + + @Override + public CompoundTag serialize() { + CompoundTag nbt = super.serialize(); + nbt.put("filter", filter.serialize()); + return nbt; + } } 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 b6e6e217c..b529bc166 100644 --- a/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java +++ b/common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java @@ -17,6 +17,11 @@ public CoverFilter(@NotNull ICoverHandler source, @Nullable Tier tier, Direct super(source, tier, side, factory); } + public void clearFilter(){ + blacklist = false; + ignoreNBT = false; + } + @Override public ItemStack getDroppedStack() { ItemStack stack = super.getDroppedStack(); diff --git a/common/src/main/java/muramasa/gregtech/data/SlotTypes.java b/common/src/main/java/muramasa/gregtech/data/SlotTypes.java index aa310ea3a..c5e27ece4 100644 --- a/common/src/main/java/muramasa/gregtech/data/SlotTypes.java +++ b/common/src/main/java/muramasa/gregtech/data/SlotTypes.java @@ -3,7 +3,6 @@ import muramasa.antimatter.capability.item.EmptyContainer; import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.gui.slot.AbstractSlot; -import muramasa.antimatter.machine.event.ContentEvent; import muramasa.gregtech.blockentity.single.IFilterable; public class SlotTypes { @@ -12,5 +11,5 @@ public class SlotTypes { return ((IFilterable)t).accepts(i); } return true; - },ContentEvent.ITEM_INPUT_CHANGED, true, true); + }, true, true); } diff --git a/gradle.properties b/gradle.properties index b78da6d02..2bc7c4835 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ fabric_transfer_api_version=1.6.+ fabric_loader_version=0.14.6 gt_rubber_version=0.2.3.2-pre1 -gt_utility_version=0.1-pre15 +gt_utility_version=0.1-pre16 terraform_version=3.1.4 networkapi_version=0.1.1-rc2 jei_version=10.2.1.1004