diff --git a/common/src/main/java/muramasa/antimatter/capability/item/FakeTrackedItemHandler.java b/common/src/main/java/muramasa/antimatter/capability/item/FakeTrackedItemHandler.java index df10f6897..38365d207 100644 --- a/common/src/main/java/muramasa/antimatter/capability/item/FakeTrackedItemHandler.java +++ b/common/src/main/java/muramasa/antimatter/capability/item/FakeTrackedItemHandler.java @@ -1,6 +1,7 @@ package muramasa.antimatter.capability.item; import muramasa.antimatter.capability.IGuiHandler; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.event.ContentEvent; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; @@ -8,8 +9,8 @@ import java.util.function.BiPredicate; public class FakeTrackedItemHandler extends TrackedItemHandler { - public FakeTrackedItemHandler(T tile, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent) { - super(tile, size, output, input, validator, contentEvent); + public FakeTrackedItemHandler(T tile, SlotType type, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent) { + super(tile, type, size, output, input, validator, contentEvent); } @NotNull diff --git a/common/src/main/java/muramasa/antimatter/capability/item/TrackedItemHandler.java b/common/src/main/java/muramasa/antimatter/capability/item/TrackedItemHandler.java index 5ea3e53c4..dc46359d1 100644 --- a/common/src/main/java/muramasa/antimatter/capability/item/TrackedItemHandler.java +++ b/common/src/main/java/muramasa/antimatter/capability/item/TrackedItemHandler.java @@ -2,8 +2,10 @@ import muramasa.antimatter.capability.IGuiHandler; import muramasa.antimatter.cover.ICover; +import muramasa.antimatter.gui.SlotType; import muramasa.antimatter.machine.event.ContentEvent; import muramasa.antimatter.blockentity.BlockEntityMachine; +import muramasa.antimatter.util.Utils; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; @@ -19,12 +21,13 @@ public class TrackedItemHandler extends ItemStackHandler private final BiPredicate validator; private final int limit; private final int size; + private final SlotType type; - public TrackedItemHandler(T tile, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent) { - this(tile, size, output, input, validator, contentEvent, 64); + public TrackedItemHandler(T tile, SlotType type, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent) { + this(tile, type, size, output, input, validator, contentEvent, 64); } - public TrackedItemHandler(T tile, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent, int limit) { + public TrackedItemHandler(T tile, SlotType type, int size, boolean output, boolean input, BiPredicate validator, ContentEvent contentEvent, int limit) { super(size); this.tile = tile; this.output = output; @@ -33,6 +36,7 @@ public TrackedItemHandler(T tile, int size, boolean output, boolean input, BiPre this.validator = validator; this.limit = limit; this.size = size; + this.type = type; } @Override @@ -54,6 +58,13 @@ public void onContentsChanged(int slot) { @NotNull @Override public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { + if (this.type == SlotType.IT_IN){ + for (int i = 0; i < size; i++){ + if (i == slot) continue; + if (this.getItem(i).isEmpty()) continue; + if (Utils.equals(this.getItem(i), stack)) return stack; + } + } if (!input) return stack; boolean validate = validator.test(tile, stack); diff --git a/common/src/main/java/muramasa/antimatter/capability/machine/MachineItemHandler.java b/common/src/main/java/muramasa/antimatter/capability/machine/MachineItemHandler.java index 37000f884..d68eec5c5 100644 --- a/common/src/main/java/muramasa/antimatter/capability/machine/MachineItemHandler.java +++ b/common/src/main/java/muramasa/antimatter/capability/machine/MachineItemHandler.java @@ -49,14 +49,14 @@ public MachineItemHandler(T tile) { SlotType type = entry.getKey(); int count = tile.getMachineType().getCount(tile.getMachineTier(), entry.getKey()); if (type == SlotType.DISPLAY_SETTABLE || type == SlotType.DISPLAY) { - inventories.put(type, new FakeTrackedItemHandler<>(tile, count, type.output, type.input, type.tester, type.ev)); + inventories.put(type, new FakeTrackedItemHandler<>(tile, type, count, type.output, type.input, type.tester, type.ev)); } else { - inventories.put(type, new TrackedItemHandler<>(tile, count, type.output, type.input, type.tester, type.ev)); + inventories.put(type, new TrackedItemHandler<>(tile, type, count, type.output, type.input, type.tester, type.ev)); } } } - inventories.defaultReturnValue(new TrackedItemHandler<>(tile, 0, false, false, (a, b) -> false, null)); + inventories.defaultReturnValue(new TrackedItemHandler<>(tile, SlotType.STORAGE, 0, false, false, (a, b) -> false, null)); } public Map, ExtendedItemContainer> getAll() { diff --git a/common/src/main/java/muramasa/antimatter/cover/BaseCover.java b/common/src/main/java/muramasa/antimatter/cover/BaseCover.java index b8c0c305a..e76738f3b 100644 --- a/common/src/main/java/muramasa/antimatter/cover/BaseCover.java +++ b/common/src/main/java/muramasa/antimatter/cover/BaseCover.java @@ -113,9 +113,9 @@ private void setInventory(){ SlotType type = entry.getKey(); int count = gui.getSlots().getCount(tier, entry.getKey()); if (type == SlotType.DISPLAY_SETTABLE || type == SlotType.DISPLAY) { - inventories.put(type, new FakeTrackedItemHandler<>(this, count, type.output, type.input, type.tester, type.ev)); + inventories.put(type, new FakeTrackedItemHandler<>(this, type, count, type.output, type.input, type.tester, type.ev)); } else { - inventories.put(type, new TrackedItemHandler<>(this, count, type.output, type.input, type.tester, type.ev)); + inventories.put(type, new TrackedItemHandler<>(this, type, count, type.output, type.input, type.tester, type.ev)); } } diff --git a/common/src/main/resources/assets/antimatter/icon.png b/common/src/main/resources/assets/antimatter/icon.png new file mode 100644 index 000000000..353c846a0 Binary files /dev/null and b/common/src/main/resources/assets/antimatter/icon.png differ