3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00

Seriously fix natural drops. Fixes BUKKIT-1297 and fixes BUKKIT-1295

Dieser Commit ist enthalten in:
feildmaster 2012-03-23 06:08:54 -05:00 committet von EvilSeph
Ursprung ff22e4e341
Commit 40e0962735
11 geänderte Dateien mit 27 neuen und 35 gelöschten Zeilen

Datei anzeigen

@ -164,7 +164,7 @@ public class Block {
public final Material material;
public float frictionFactor;
private String name;
protected ArrayList<ItemStack> dropList; // CraftBukkit
protected ArrayList<ItemStack> dropList = new ArrayList<ItemStack>(); // CraftBukkit
protected Block(int i, Material material) {
this.bR = true;
@ -339,6 +339,7 @@ public class Block {
public final void b(World world, int i, int j, int k, int l, int i1) {
this.dropNaturally(world, i, j, k, l, 1.0F, i1);
this.doActualDrop(world, i, j, k); // CraftBukkit
}
public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
@ -360,15 +361,11 @@ public class Block {
protected void a(World world, int i, int j, int k, ItemStack itemstack) {
// CraftBukkit start - the logic of this function is moved into finishDrop
if (this.dropList != null) {
this.dropList.add(itemstack);
} else {
this.finishDrop(world, i, j, k, itemstack);
}
// This is such a hackish change it's rediculous.
this.dropList.add(itemstack);
}
public final void finishDrop(World world, int i, int j, int k, ItemStack itemstack) {
this.dropList = null;
// CraftBukkit end
if (!world.isStatic) {
float f = 0.7F;
@ -542,13 +539,14 @@ public class Block {
entityhuman.a(StatisticList.C[this.id], 1);
entityhuman.c(0.025F);
// CraftBukkit start - A way to separate statistics from the logic of determining what to drop
this.doActualDrop(world, entityhuman, i, j, k, l);
this.doActualDrop(world, i, j, k);
}
public void doActualDrop(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
for (ItemStack stack : dropList) {
public void doActualDrop(World world, int i, int j, int k) {
for (ItemStack stack : this.dropList) {
finishDrop(world, i, j, k, stack);
}
this.dropList.clear();
}
public void setDrops(ArrayList<ItemStack> drops) {
@ -556,7 +554,6 @@ public class Block {
}
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
this.dropList = new ArrayList<ItemStack>();
// CraftBukkit end
if (this.h() && EnchantmentManager.hasSilkTouchEnchantment(entityhuman.inventory)) {
ItemStack itemstack = this.a_(l);

Datei anzeigen

@ -30,7 +30,7 @@ public class BlockDeadBush extends BlockFlower {
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l));
*/
this.doActualDrop(world, entityhuman, i, j, k, l);
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
@ -40,9 +40,8 @@ public class BlockDeadBush extends BlockFlower {
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Block.DEAD_BUSH, 1, l));
return super.dropList;
return this.dropList;
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}

Datei anzeigen

@ -165,7 +165,7 @@ public class BlockLeaves extends BlockTransparant {
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3));
*/
this.doActualDrop(world, entityhuman, i, j, k, l);
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
@ -175,9 +175,8 @@ public class BlockLeaves extends BlockTransparant {
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Block.LEAVES.id, 1, l & 3));
return super.dropList;
return this.dropList;
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}

Datei anzeigen

@ -30,7 +30,7 @@ public class BlockLongGrass extends BlockFlower {
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l));
*/
this.doActualDrop(world, entityhuman, i, j, k, l);
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);
@ -40,9 +40,8 @@ public class BlockLongGrass extends BlockFlower {
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
if (!world.isStatic && entityhuman.U() != null && entityhuman.U().id == Item.SHEARS.id) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Block.LONG_GRASS, 1, l));
return super.dropList;
return this.dropList;
} else {
return super.calculateDrops(world, entityhuman, i, j, k, l);
}

Datei anzeigen

@ -17,7 +17,7 @@ public class BlockPistonExtension extends Block {
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int d) {
super.calculateDrops(world, entityhuman, i, j, k, d);
int l = world.getData(i, j, k) & 0x7;
if (l > 5 || l < 0) return super.dropList;
if (l > 5 || l < 0) return this.dropList;
int i1 = Facing.OPPOSITE_FACING[b(l)];
i += Facing.b[i1];
@ -26,9 +26,9 @@ public class BlockPistonExtension extends Block {
int j1 = world.getTypeId(i, j, k);
if (j1 == Block.PISTON.id || j1 == Block.PISTON_STICKY.id) {
super.dropList.add(new ItemStack(Block.byId[j1], 1));
this.dropList.add(new ItemStack(Block.byId[j1], 1));
}
return super.dropList;
return this.dropList;
}
// CraftBukkit end

Datei anzeigen

@ -66,8 +66,8 @@ public class BlockSnow extends Block {
entityitem.pickupDelay = 10;
world.addEntity(entityitem);
// */
super.doActualDrop(world, entityhuman, i, j, k, l);
*/
this.doActualDrop(world, i, j, k);
// CraftBukkit end
world.setTypeId(i, j, k, 0);
entityhuman.a(StatisticList.C[this.id], 1);
@ -75,9 +75,8 @@ public class BlockSnow extends Block {
// CraftBukkit start - Calculate drops
public ArrayList<ItemStack> calculateDrops(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
super.dropList = new ArrayList<ItemStack>();
this.a(world, i, j, k, new ItemStack(Item.SNOW_BALL.id, 1, 1));
return super.dropList;
return this.dropList;
}
// CraftBukkit end

Datei anzeigen

@ -290,7 +290,7 @@ public class BlockVine extends Block {
/* CraftBukkit start - moved this line into calculateDrops
this.a(world, i, j, k, new ItemStack(Block.VINE, 1, 0));
*/
this.doActualDrop(world, entityhuman, i, j, k, l);
this.doActualDrop(world, i, j, k);
// CraftBukkit end
} else {
super.a(world, entityhuman, i, j, k, l);

Datei anzeigen

@ -243,10 +243,11 @@ public class Explosion {
this.world.a("smoke", d0, d1, d2, d3, d4, d5);
}
// CraftBukkit - stop explosions from putting out fire
// CraftBukkit start - stop explosions from putting out fire
if (i1 > 0 && i1 != Block.FIRE.id) {
// CraftBukkit
Block.byId[i1].dropNaturally(this.world, j, k, l, this.world.getData(j, k, l), event.getYield(), 0);
Block.byId[i1].doActualDrop(this.world, j, k, l);
// CraftBukkit end
this.world.setTypeId(j, k, l, 0);
Block.byId[i1].wasExploded(this.world, j, k, l);
}

Datei anzeigen

@ -218,7 +218,7 @@ public class ItemInWorldManager {
if (this.isCreative()) {
// CraftBukkit start - honour additions to drop list
Block.byId[l].doActualDrop(this.world, this.player, i, j, k, i1);
Block.byId[l].doActualDrop(this.world, i, j, k);
// CraftBukkit end
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
} else {

Datei anzeigen

@ -1056,6 +1056,7 @@ public class CraftWorld implements World {
int blockZ = block.getZ();
// following code is lifted from Explosion.a(boolean), and modified
net.minecraft.server.Block.byId[blockId].dropNaturally(this.world, blockX, blockY, blockZ, block.getData(), yield, 0);
net.minecraft.server.Block.byId[blockId].doActualDrop(this.world, blockX, blockY, blockZ);
block.setType(org.bukkit.Material.AIR);
// not sure what this does, seems to have something to do with the 'base' material of a block.
// For example, WOODEN_STAIRS does something with WOOD in this method

Datei anzeigen

@ -348,10 +348,7 @@ public class CraftBlock implements Block {
setTypeId(Material.AIR.getId());
if (block != null) {
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
for (ItemStack item : getDrops()) {
block.finishDrop(chunk.getHandle().world, x, y, z, CraftItemStack.createNMSItemStack(item));
}
block.b(chunk.getHandle().world, x, y, z, data, 0);
return true;
}
return false;