Advertisement
Guest User

Untitled

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