Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. Item wantedItem = Items.bone;
  2. Set<Item> set = new TreeSet<Item>();
  3. set.add(wantedItem);
  4.  
  5. if (bookSpawnDelay > 0) bookSpawnDelay--;
  6. else
  7. {
  8. @SuppressWarnings("unchecked")
  9. List<Entity> entities = world.loadedEntityList;
  10. for (int i = 0; i < entities.size(); i++)
  11. {
  12. EntityItem item = (EntityItem)entities.get(i);
  13. if(item.getEntityItem().getItem() == Items.book) {
  14. int xBound = item.getPosition().getX() + 3;
  15. int yBound = item.getPosition().getY() + 3;
  16. int zBound = item.getPosition().getZ() + 3;
  17. List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(item, new AxisAlignedBB(item.getPosition(), new BlockPos(xBound, yBound, zBound)));
  18. for(int j = 0; j < list.size(); j++) {
  19. Entity entity = list.get(j);
  20. if(entity instanceof EntityItem) {
  21. EntityItem entityItem = (EntityItem)entity;
  22. if(entityItem.getEntityItem().getItem() == wantedItem) {
  23. set.remove(wantedItem);
  24. if(set.isEmpty()) {
  25. bookSpawnDelay += 20;
  26. int x = item.getPosition().getX();
  27. int y = item.getPosition().getY();
  28. int z = item.getPosition().getZ();
  29. WorldServer worldServer = (WorldServer) world;
  30. worldServer.spawnParticle(EnumParticleTypes.SMOKE_LARGE,
  31. false, x + 0.5D, y + 1.0D, z + 0.5D, 1, 0.0D,
  32. 0.0D, 0.0D, 0.0D, new int[0]);
  33. world.spawnEntityInWorld(new EntityItem(world, x, y, z,
  34. new ItemStack(ARKCraftItems.info_book)));
  35. entityItem.getEntityItem().stackSize--;
  36. item.getEntityItem().stackSize--;
  37. if(entityItem.getEntityItem().stackSize <= 0) entityItem.setDead();
  38. if(item.getEntityItem().stackSize <= 0) item.setDead();
  39. }
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement