Created
February 24, 2023 18:17
-
-
Save OMAR-3OOV/fec9489dbe9201333aa4014ed02adb6a to your computer and use it in GitHub Desktop.
NMS 1.19.3 SPIGOT, Change ItemStack Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChangeMaxStackSize { | |
private net.minecraft.world.item.ItemStack stack; | |
private Item nmsItem; | |
private ItemStack item; | |
public ChangeMaxStackSize(ItemStack itemStack, int maxStackSize) throws NoSuchFieldException, IllegalAccessException { | |
this.item = itemStack; | |
this.stack = CraftItemStack.asNMSCopy(itemStack); | |
this.nmsItem = stack.o().c(); | |
setMaxStackSize(maxStackSize); | |
} | |
private void setMaxStackSize(int size) throws NoSuchFieldException, IllegalAccessException { | |
Field field = this.nmsItem.getClass().getSuperclass().getDeclaredField("d"); | |
field.setAccessible(true); | |
field.setInt(this.nmsItem, size); | |
} | |
public Item getNmsItem() { | |
return nmsItem; | |
} | |
public net.minecraft.world.item.ItemStack getStack() { | |
return stack; | |
} | |
public ItemStack getItem() { | |
return item; | |
} | |
public ItemStack itemStack() { | |
return CraftItemStack.asBukkitCopy(this.stack); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment