Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.HIGHEST)
  2. public void ironGolemToIngot(SpawnerSpawnEvent e)
  3. {
  4. if(e.isCancelled())
  5. return;
  6.  
  7. if(e.getEntity() instanceof IronGolem)
  8. {
  9. e.setCancelled(true);
  10. int n = new Random().nextInt(2);
  11. if (n==0) return;
  12. Location l = e.getLocation();
  13. CreatureSpawner cs = e.getSpawner();
  14.  
  15. if(cs.getMaxSpawnDelay() != MAX_TICK)
  16. {
  17. ArrayList<Location> lel = getCircle(cs.getLocation(), 1, 50);
  18. World w = l.getWorld();
  19.  
  20. Particle particle = Particle.VILLAGER_HAPPY;
  21.  
  22. for(Location loc : lel)
  23. {
  24. w.spawnParticle(particle, loc, 1);
  25. }
  26. }
  27.  
  28. if(cs.getSpawnCount() != 1)
  29. {
  30. cs.setSpawnCount(1);
  31. cs.update();
  32. }
  33.  
  34. spawn(l, SPAWNING_RATE);
  35. }
  36. }
  37.  
  38. public void spawn(Location l, int num)
  39. {
  40. l.getWorld().dropItem(l, new ItemStack(Material.IRON_INGOT, num));
  41. l.getWorld().dropItem(l, new ItemStack(Material.RED_ROSE, num));
  42. }
  43.  
  44. public ArrayList<Location> getCircle(Location center, double radius, int amount)
  45. {
  46. World world = center.getWorld();
  47. double increment = (2 * Math.PI) / amount;
  48. ArrayList<Location> locations = new ArrayList<Location>();
  49. for(int i = 0; i < amount; i++)
  50. {
  51. double angle = i * increment;
  52. double x = center.getX() + (radius * Math.cos(angle));
  53. double z = center.getZ() + (radius * Math.sin(angle));
  54. locations.add(new Location(world, x + 0.6, center.getY() + 0.5, z + 0.6));
  55. }
  56.  
  57. return locations;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement