Advertisement
Guest User

Untitled

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