mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-24 18:07:39 +01:00
124 lines
5.8 KiB
Diff
124 lines
5.8 KiB
Diff
--- a/net/minecraft/server/BlockSkull.java
|
|
+++ b/net/minecraft/server/BlockSkull.java
|
|
@@ -5,6 +5,11 @@
|
|
import java.util.Random;
|
|
import javax.annotation.Nullable;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BlockSkull extends BlockTileEntity {
|
|
|
|
public static final BlockStateDirection FACING = BlockDirectional.FACING;
|
|
@@ -82,7 +87,29 @@
|
|
return new ItemStack(Items.SKULL, 1, i);
|
|
}
|
|
|
|
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
|
|
+ // CraftBukkit start - Special case dropping so we can get info from the tile entity
|
|
+ @Override
|
|
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
|
|
+ if (world.random.nextFloat() < f) {
|
|
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
|
+
|
|
+ if (tileentity instanceof TileEntitySkull) {
|
|
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
|
|
+ ItemStack itemstack = this.a(world, blockposition, iblockdata);
|
|
+
|
|
+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
|
|
+ itemstack.setTag(new NBTTagCompound());
|
|
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
|
|
+
|
|
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
|
|
+ itemstack.getTag().set("SkullOwner", nbttagcompound);
|
|
+ }
|
|
+
|
|
+ a(world, blockposition, itemstack);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
|
|
if (entityhuman.abilities.canInstantlyBuild) {
|
|
@@ -95,7 +122,10 @@
|
|
|
|
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
|
if (!world.isClientSide) {
|
|
- if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
|
|
+ // CraftBukkit start - Drop item in code above, not here
|
|
+ // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
|
|
+ if (false) {
|
|
+ // CraftBukkit end
|
|
TileEntity tileentity = world.getTileEntity(blockposition);
|
|
|
|
if (tileentity instanceof TileEntitySkull) {
|
|
@@ -127,24 +157,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.isClientSide) {
|
|
ShapeDetector shapedetector = this.g();
|
|
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
|
|
|
|
if (shapedetector_shapedetectorcollection != null) {
|
|
+ // CraftBukkit start - Use BlockStateListPopulator
|
|
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
|
|
int i;
|
|
|
|
for (i = 0; i < 3; ++i) {
|
|
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0);
|
|
|
|
- world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
|
|
+ // CraftBukkit start
|
|
+ // world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
|
|
+ BlockPosition pos = shapedetectorblock.getPosition();
|
|
+ IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true));
|
|
+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2);
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
for (i = 0; i < shapedetector.c(); ++i) {
|
|
for (int j = 0; j < shapedetector.b(); ++j) {
|
|
ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(i, j, 0);
|
|
|
|
- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
|
|
+ // CraftBukkit start
|
|
+ // world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
|
|
+ BlockPosition pos = shapedetectorblock1.getPosition();
|
|
+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2);
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -157,14 +199,16 @@
|
|
entitywither.o();
|
|
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator();
|
|
|
|
+ // CraftBukkit start
|
|
+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
|
|
+ blockList.updateList();
|
|
+
|
|
while (iterator.hasNext()) {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
|
|
entityhuman.b((Statistic) AchievementList.I);
|
|
}
|
|
|
|
- world.addEntity(entitywither);
|
|
-
|
|
int k;
|
|
|
|
for (k = 0; k < 120; ++k) {
|
|
@@ -178,6 +222,7 @@
|
|
world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false);
|
|
}
|
|
}
|
|
+ } // CraftBukkit end
|
|
|
|
}
|
|
}
|