Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.HIGHEST)
- public void ironGolemToIngot(SpawnerSpawnEvent e)
- {
- if(e.isCancelled())
- return;
- if(e.getEntity() instanceof IronGolem)
- {
- e.setCancelled(true);
- Random r = new Random();
- int n = r.nextInt(1);
- if (n==0) return;
- Location l = e.getLocation();
- CreatureSpawner cs = e.getSpawner();
- if(cs.getMaxSpawnDelay() != MAX_TICK)
- {
- ArrayList<Location> lel = getCircle(cs.getLocation(), 1, 50);
- World w = l.getWorld();
- Particle particle = Particle.VILLAGER_HAPPY;
- for(Location loc : lel)
- {
- w.spawnParticle(particle, loc, 1);
- }
- }
- if(cs.getSpawnCount() != 1)
- {
- cs.setSpawnCount(1);
- cs.update();
- }
- spawn(l, SPAWNING_RATE);
- }
- }
- public void spawn(Location l, int num)
- {
- l.getWorld().dropItem(l, new ItemStack(Material.IRON_INGOT, num));
- l.getWorld().dropItem(l, new ItemStack(Material.RED_ROSE, num));
- }
- public ArrayList<Location> getCircle(Location center, double radius, int amount)
- {
- World world = center.getWorld();
- double increment = (2 * Math.PI) / amount;
- ArrayList<Location> locations = new ArrayList<Location>();
- for(int i = 0; i < amount; i++)
- {
- double angle = i * increment;
- double x = center.getX() + (radius * Math.cos(angle));
- double z = center.getZ() + (radius * Math.sin(angle));
- locations.add(new Location(world, x + 0.6, center.getY() + 0.5, z + 0.6));
- }
- return locations;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement