mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-20 01:15:15 +01:00
Add defensive copy for ItemStack
This commit is contained in:
parent
ce2dfd993b
commit
21280b0b1f
@ -56,17 +56,21 @@ public abstract class BaseItemLine extends BaseTouchableLine implements Standard
|
||||
|
||||
@Override
|
||||
public @Nullable ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
return clone(itemStack);
|
||||
}
|
||||
|
||||
public void setItemStack(@Nullable ItemStack itemStack) {
|
||||
if (itemStack != null) {
|
||||
Preconditions.checkArgument(0 < itemStack.getAmount() && itemStack.getAmount() <= 64, "itemStack's amount must be between 1 and 64");
|
||||
}
|
||||
this.itemStack = itemStack;
|
||||
this.itemStack = clone(itemStack);
|
||||
setChanged();
|
||||
}
|
||||
|
||||
private ItemStack clone(@Nullable ItemStack itemStack) {
|
||||
return itemStack != null ? itemStack.clone() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHeight() {
|
||||
return 0.7;
|
||||
|
Loading…
Reference in New Issue
Block a user