Skip to content

Commit

Permalink
added contains utility method for HandledInventory
Browse files Browse the repository at this point in the history
  • Loading branch information
JR1811 committed Sep 2, 2024
1 parent 7c8bbb2 commit 4d59972
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -77,6 +78,20 @@ default ItemStack removeStack(int slot, int amount) {
return stack;
}

default boolean contains(Item item) {
for (ItemStack stack : this.getItems()) {
if (stack.getItem().equals(item)) return true;
}
return false;
}

default boolean contains(ItemStack stack) {
for (ItemStack entry : this.getItems()) {
if (entry.equals(stack)) return true;
}
return false;
}

@Override
default boolean canPlayerUse(PlayerEntity player) {
return true;
Expand All @@ -87,4 +102,8 @@ default void clear() {
getItems().clear();
markDirty();
}

default void markDirty() {

}
}

0 comments on commit 4d59972

Please sign in to comment.