Skip to content

Commit

Permalink
fix tree tap nbt
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Mar 23, 2024
1 parent 0c1e1fc commit 806a9ff
Showing 1 changed file with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean canExtract(int slot, ItemStack stack, Direction dir) {

@Override
public @NotNull HopperStrategy getHopperStrategy() {
return HopperStrategy.IN_ANY_OUT_BOTTOM;
return HopperStrategy.IN_ANY;
}

@Override
Expand All @@ -72,31 +72,17 @@ public void setStack(int slot, ItemStack stack) {
stack.setCount(1);
}
inventoryChanged();
System.out.println(getItems());
}

@Override
public ItemStack removeStack(int slot, int count) {
ItemStack stack = Inventories.splitStack(getItems(), slot, count);
inventoryChanged();
return stack;
}

@Override
public ItemStack removeStack(int slot) {
var stack = Inventories.removeStack(getItems(), slot);
inventoryChanged();
return stack;
}

private void inventoryChanged() {
this.markDirty();
markDirty();
if (world != null && !world.isClient) updateInClientWorld();
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
this.inventory.clear();
Inventories.readNbt(nbt, inventory);
}

Expand All @@ -122,12 +108,9 @@ public void tryCraft() {
stack.decrement(1);

// TODO: play a sound?
if (stack.isEmpty()) {
this.inventory.set(0, output);
updateInClientWorld();
} else {
ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), output);
}
this.inventory.set(0, ItemStack.EMPTY);
inventoryChanged();
ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), output);
}
}

Expand Down

0 comments on commit 806a9ff

Please sign in to comment.