[Bleeding] Added getting and setting drops to all appropriate events. Fixes BUKKIT-397 and fixes BUKKIT-1252
- Allows drops in creative mode by adding items to the getDrops() list - Contents of containers are not reported - Contents of storage minecarts are not reported
This commit is contained in:
committed by
EvilSeph
parent
8d62de7055
commit
5ba8928041
@@ -1,9 +1,11 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
@@ -111,7 +113,19 @@ public class EntityBoat extends Entity {
|
||||
this.aV();
|
||||
if (this.getDamage() > 40) {
|
||||
// CraftBukkit start
|
||||
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
|
||||
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 3; ++j) {
|
||||
drops.add(new CraftItemStack(Block.WOOD.id, 1));
|
||||
}
|
||||
|
||||
for (j = 0; j < 2; ++j) {
|
||||
drops.add(new CraftItemStack(Item.STICK.id,1));
|
||||
}
|
||||
|
||||
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker, drops);
|
||||
this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
||||
|
||||
if (destroyEvent.isCancelled()) {
|
||||
@@ -124,6 +138,7 @@ public class EntityBoat extends Entity {
|
||||
this.passenger.mount(this);
|
||||
}
|
||||
|
||||
/* CraftBukkit - This logic has been moved up before the event firing
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 3; ++j) {
|
||||
@@ -133,8 +148,14 @@ public class EntityBoat extends Entity {
|
||||
for (j = 0; j < 2; ++j) {
|
||||
this.a(Item.STICK.id, 1, 0.0F);
|
||||
}
|
||||
// */
|
||||
|
||||
this.die();
|
||||
// CraftBukkit start
|
||||
for (org.bukkit.inventory.ItemStack stack : drops) {
|
||||
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -302,24 +323,39 @@ public class EntityBoat extends Entity {
|
||||
if (this.positionChanged && d3 > 0.2D) {
|
||||
if (!this.world.isStatic) {
|
||||
// CraftBukkit start
|
||||
List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
/* CraftBukkit end
|
||||
this.die();
|
||||
// CraftBukkit - deferred to after the event */
|
||||
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 3; ++k) {
|
||||
/* CraftBukkit - add to drop list instead of immediately dropping
|
||||
this.a(Block.WOOD.id, 1, 0.0F);
|
||||
// */
|
||||
drops.add(new CraftItemStack(Block.WOOD.id, 1));
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; ++k) {
|
||||
/* CraftBukkit - add to drop list instead of immediately dropping
|
||||
this.a(Item.STICK.id, 1, 0.0F);
|
||||
// */
|
||||
drops.add(new CraftItemStack(Item.STICK.id,1));
|
||||
}
|
||||
// CraftBukkit start
|
||||
drops.add(new CraftItemStack(Item.MINECART.id,1));
|
||||
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
|
||||
VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null, drops);
|
||||
this.world.getServer().getPluginManager().callEvent(destroyEvent);
|
||||
|
||||
if (!destroyEvent.isCancelled()) {
|
||||
// CraftBukkit end
|
||||
this.die();
|
||||
|
||||
int k;
|
||||
|
||||
for (k = 0; k < 3; ++k) {
|
||||
this.a(Block.WOOD.id, 1, 0.0F);
|
||||
for (org.bukkit.inventory.ItemStack stack : drops) {
|
||||
this.a(CraftItemStack.createNMSItemStack(stack), 0.0f);
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; ++k) {
|
||||
this.a(Item.STICK.id, 1, 0.0F);
|
||||
}
|
||||
} // CraftBukkit
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
} else {
|
||||
this.motX *= 0.9900000095367432D;
|
||||
|
||||
Reference in New Issue
Block a user