Advertisement
iSach

How to spawn unmerging items.

Nov 2nd, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. Location spawnLocation = origin.clone();
  2. ItemStack itemStack;
  3. World world = ((CraftWorld) spawnLocation.getWorld()).getHandle();
  4. net.minecraft.server.v1_8_R3.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
  5. Field maxStack = null;
  6. try {
  7.     maxStack = getField(itemStack.getItem().getClass(), "maxStackSize");
  8. } catch (NoSuchFieldException e) {
  9.     e.printStackTrace();
  10. }
  11. maxStack.setAccessible(true);
  12. try {
  13.     maxStack.setInt(itemStack.getItem(), 1);
  14. } catch (IllegalAccessException e) {
  15.     e.printStackTrace();
  16. }
  17. EntityItem itemEnt = new EntityItem(world, origin.getX(), spawnLocation.getY(), spawnLocation.getZ(), nmsItemStack);
  18. world.addEntity(itemEnt, CreatureSpawnEvent.SpawnReason.CUSTOM);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement