Skip to content

Commit

Permalink
movedmultiple item check into CombinedInvWrapper so it only acts upon…
Browse files Browse the repository at this point in the history
… outside insertions, not player container insertions
  • Loading branch information
Trinsdar committed Nov 28, 2023
1 parent 55dc2c6 commit 277f9b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package muramasa.antimatter.capability.item;

import muramasa.antimatter.blockentity.multi.BlockEntityHatch;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.util.Utils;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -59,11 +62,20 @@ protected int getSlotFromIndex(int slot, int index)

@Override
@NotNull
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate)
{
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {

int index = getIndexForSlot(slot);
ExtendedItemContainer handler = getHandlerFromIndex(index);
slot = getSlotFromIndex(slot, index);
if (handler instanceof TrackedItemHandler<?> trackedItemHandler){
if (trackedItemHandler.getType() == SlotType.IT_IN && !(trackedItemHandler.getTile() instanceof BlockEntityHatch<?>)){
for (int i = 0; i < trackedItemHandler.getSize(); i++){
if (i == slot) continue;
if (trackedItemHandler.getItem(i).isEmpty()) continue;
if (Utils.equals(trackedItemHandler.getItem(i), stack)) return stack;
}
}
}
return handler.insertItem(slot, stack, simulate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ public void onContentsChanged(int slot) {
@NotNull
@Override
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
if (this.type == SlotType.IT_IN && !(tile instanceof BlockEntityHatch<?>)){
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 = !(tile instanceof IFilterableHandler filterableHandler) || filterableHandler.test(type, slot, stack);
Expand Down

0 comments on commit 277f9b2

Please sign in to comment.