Skip to content

Commit

Permalink
Fixed needless overriding of vanilla item values
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed May 8, 2024
1 parent 69d9bbd commit abdff8f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/turniplabs/halplibe/helper/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public final class ItemBuilder implements Cloneable {
private String textureKey = null;
@Nullable
private Tag<Item>[] tags = null;
private int stackSize = 64;
private int maxDamage = 0;
private Integer stackSize = null;
private Integer maxDamage = null;
@Nullable
private Supplier<Item> containerItemSupplier = null;
@NotNull
Expand Down Expand Up @@ -164,11 +164,15 @@ public <T extends Item> T build(T item){
if (containerItemSupplier != null){
item.setContainerItem(containerItemSupplier.get());
}
item.setMaxStackSize(stackSize);
try {
item.getClass().getMethod("setMaxDamage", int.class).invoke(item, maxDamage);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
if (stackSize != null){
item.setMaxStackSize(stackSize);
}
if (maxDamage != null){
try {
item.getClass().getMethod("setMaxDamage", int.class).invoke(item, maxDamage);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}

List<String> newTokens = new ArrayList<>();
Expand Down

0 comments on commit abdff8f

Please sign in to comment.