mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-08 11:50:32 +01:00
SPIGOT-465: Allow cancelling BlockPlaceEvent to preven wither spawns
This commit is contained in:
parent
d3d1361042
commit
386dc55b83
@ -1,5 +1,5 @@
|
|||||||
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockSkull.java 2014-11-28 17:43:42.961707438 +0000
|
--- ../work/decompile-8eb82bde//net/minecraft/server/BlockSkull.java 2015-02-02 21:55:13.808077826 +0000
|
||||||
+++ src/main/java/net/minecraft/server/BlockSkull.java 2014-11-28 17:38:23.000000000 +0000
|
+++ src/main/java/net/minecraft/server/BlockSkull.java 2015-02-02 21:55:13.808077826 +0000
|
||||||
@@ -4,6 +4,11 @@
|
@@ -4,6 +4,11 @@
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -51,7 +51,13 @@
|
|||||||
TileEntity tileentity = world.getTileEntity(blockposition);
|
TileEntity tileentity = world.getTileEntity(blockposition);
|
||||||
|
|
||||||
if (tileentity instanceof TileEntitySkull) {
|
if (tileentity instanceof TileEntitySkull) {
|
||||||
@@ -120,19 +145,30 @@
|
@@ -115,24 +140,36 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
|
||||||
|
+ if (world.captureBlockStates) return; // CraftBukkit
|
||||||
|
if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isStatic) {
|
||||||
|
ShapeDetector shapedetector = this.l();
|
||||||
ShapeDetectorCollection shapedetectorcollection = shapedetector.a(world, blockposition);
|
ShapeDetectorCollection shapedetectorcollection = shapedetector.a(world, blockposition);
|
||||||
|
|
||||||
if (shapedetectorcollection != null) {
|
if (shapedetectorcollection != null) {
|
||||||
@ -84,7 +90,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,28 +181,31 @@
|
@@ -145,28 +182,31 @@
|
||||||
entitywither.n();
|
entitywither.n();
|
||||||
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D)).iterator();
|
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D)).iterator();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- ../work/decompile-8eb82bde//net/minecraft/server/ItemStack.java 2014-11-29 21:16:43.705017876 +0000
|
--- ../work/decompile-8eb82bde//net/minecraft/server/ItemStack.java 2015-02-02 21:55:14.596077817 +0000
|
||||||
+++ src/main/java/net/minecraft/server/ItemStack.java 2014-11-29 21:16:36.581018034 +0000
|
+++ src/main/java/net/minecraft/server/ItemStack.java 2015-02-02 21:55:14.596077817 +0000
|
||||||
@@ -5,6 +5,18 @@
|
@@ -5,6 +5,18 @@
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -38,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createStack(NBTTagCompound nbttagcompound) {
|
public static ItemStack createStack(NBTTagCompound nbttagcompound) {
|
||||||
@@ -83,11 +97,96 @@
|
@@ -83,11 +97,114 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
|
public boolean placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
|
||||||
@ -128,6 +128,24 @@
|
|||||||
+
|
+
|
||||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block.getBlock(), updateFlag); // send null chunk as chunk.k() returns false by this point
|
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block.getBlock(), updateFlag); // send null chunk as chunk.k() returns false by this point
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ if (this.getItem() == Items.SKULL) { // Special case skulls to allow wither spawns to be cancelled
|
||||||
|
+ BlockPosition bp = blockposition;
|
||||||
|
+ if (!world.getType(blockposition).getBlock().f(world, blockposition)) {
|
||||||
|
+ if (!world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
|
||||||
|
+ bp = null;
|
||||||
|
+ } else {
|
||||||
|
+ bp = bp.shift(enumdirection);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (bp != null) {
|
||||||
|
+ TileEntity te = world.getTileEntity(bp);
|
||||||
|
+ if (te instanceof TileEntitySkull) {
|
||||||
|
+ Blocks.SKULL.a(world, bp, (TileEntitySkull) te);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]);
|
+ entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]);
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
@ -136,7 +154,7 @@
|
|||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
@@ -111,7 +210,7 @@
|
@@ -111,7 +228,7 @@
|
||||||
nbttagcompound.setByte("Count", (byte) this.count);
|
nbttagcompound.setByte("Count", (byte) this.count);
|
||||||
nbttagcompound.setShort("Damage", (short) this.damage);
|
nbttagcompound.setShort("Damage", (short) this.damage);
|
||||||
if (this.tag != null) {
|
if (this.tag != null) {
|
||||||
@ -145,7 +163,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nbttagcompound;
|
return nbttagcompound;
|
||||||
@@ -125,13 +224,18 @@
|
@@ -125,13 +242,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.count = nbttagcompound.getByte("Count");
|
this.count = nbttagcompound.getByte("Count");
|
||||||
@ -165,7 +183,7 @@
|
|||||||
if (this.item != null) {
|
if (this.item != null) {
|
||||||
this.item.a(this.tag);
|
this.item.a(this.tag);
|
||||||
}
|
}
|
||||||
@@ -168,8 +272,29 @@
|
@@ -168,8 +290,29 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(int i) {
|
public void setData(int i) {
|
||||||
@ -196,7 +214,7 @@
|
|||||||
this.damage = 0;
|
this.damage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +347,12 @@
|
@@ -222,6 +365,12 @@
|
||||||
if (this.count < 0) {
|
if (this.count < 0) {
|
||||||
this.count = 0;
|
this.count = 0;
|
||||||
}
|
}
|
||||||
@ -209,7 +227,7 @@
|
|||||||
|
|
||||||
this.damage = 0;
|
this.damage = 0;
|
||||||
}
|
}
|
||||||
@@ -489,6 +620,7 @@
|
@@ -489,6 +638,7 @@
|
||||||
|
|
||||||
public void setItem(Item item) {
|
public void setItem(Item item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
|
Loading…
Reference in New Issue
Block a user