geforkt von Mirrors/Paper
Implemented ENTITY_DEATH for monsters and animals
Dieser Commit ist enthalten in:
Ursprung
0bc5bd54bd
Commit
914688e2a0
@ -1,11 +1,19 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public abstract class EntityLiving extends Entity {
|
public abstract class EntityLiving extends Entity {
|
||||||
@ -435,15 +443,25 @@ public abstract class EntityLiving extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void g_() {
|
protected void g_() {
|
||||||
int i = this.h();
|
// Craftbukkit start - whole method
|
||||||
|
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||||
|
int drop = this.h();
|
||||||
|
int count = random.nextInt(3);
|
||||||
|
|
||||||
if (i > 0) {
|
if ((drop > 0) && (count > 0)) {
|
||||||
int j = this.random.nextInt(3);
|
loot.add(new org.bukkit.inventory.ItemStack(drop, count));
|
||||||
|
|
||||||
for (int k = 0; k < j; ++k) {
|
|
||||||
this.a(i, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CraftEntity entity = (CraftEntity)getBukkitEntity();
|
||||||
|
EntityDeathEvent event = new EntityDeathEvent(Type.ENTITY_DEATH, entity, loot);
|
||||||
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
||||||
|
Server server = ((WorldServer)world).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||||
|
cworld.dropItemNaturally(entity.getLocation(), stack);
|
||||||
|
}
|
||||||
|
// Craftbukkit end
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int h() {
|
protected int h() {
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntitySkeleton extends EntityMonster {
|
public class EntitySkeleton extends EntityMonster {
|
||||||
@ -84,18 +90,28 @@ public class EntitySkeleton extends EntityMonster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void g_() {
|
protected void g_() {
|
||||||
int i = this.random.nextInt(3);
|
// Craftbukkit start - whole method
|
||||||
|
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||||
|
|
||||||
int j;
|
int count = this.random.nextInt(3);
|
||||||
|
if (count > 0) {
|
||||||
for (j = 0; j < i; ++j) {
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count));
|
||||||
this.a(Item.ARROW.id, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = this.random.nextInt(3);
|
count = this.random.nextInt(3);
|
||||||
|
if (count > 0) {
|
||||||
for (j = 0; j < i; ++j) {
|
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count));
|
||||||
this.a(Item.BONE.id, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CraftEntity entity = (CraftEntity)getBukkitEntity();
|
||||||
|
EntityDeathEvent event = new EntityDeathEvent(Type.ENTITY_DEATH, entity, loot);
|
||||||
|
CraftWorld cworld = ((WorldServer)world).getWorld();
|
||||||
|
Server server = ((WorldServer)world).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||||
|
cworld.dropItemNaturally(entity.getLocation(), stack);
|
||||||
|
}
|
||||||
|
// Craftbukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren