Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Location spawnLocation = origin.clone();
- ItemStack itemStack;
- World world = ((CraftWorld) spawnLocation.getWorld()).getHandle();
- net.minecraft.server.v1_8_R3.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
- Field maxStack = null;
- try {
- maxStack = getField(itemStack.getItem().getClass(), "maxStackSize");
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- }
- maxStack.setAccessible(true);
- try {
- maxStack.setInt(itemStack.getItem(), 1);
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- EntityItem itemEnt = new EntityItem(world, origin.getX(), spawnLocation.getY(), spawnLocation.getZ(), nmsItemStack);
- world.addEntity(itemEnt, CreatureSpawnEvent.SpawnReason.CUSTOM);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement