implement drops

This commit is contained in:
Minecon724 2022-02-03 13:16:35 +01:00
parent f4f8f09a06
commit 1b18fc9ac0

View file

@ -25,6 +25,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -160,6 +161,14 @@ public class Main extends JavaPlugin implements Listener {
LivingEntity entity = e.getEntity(); LivingEntity entity = e.getEntity();
if (entity.getType() == EntityType.GIANT) { if (entity.getType() == EntityType.GIANT) {
giants.remove(entity); giants.remove(entity);
for (Entry<Material, List<Integer>> d : drops.entrySet()) {
int max = d.getValue().get(0);
int min = d.getValue().get(1);
ItemStack is = new ItemStack(d.getKey(), rnd.nextInt((max - min) + 1) + min);
if (rnd.nextInt(100) < d.getValue().get(2)) {
entity.getWorld().dropItemNaturally(entity.getLocation(), is);
}
}
for (Entity p : entity.getPassengers()) ((LivingEntity) p).setHealth(0); for (Entity p : entity.getPassengers()) ((LivingEntity) p).setHealth(0);
} }
} }