3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/BlockSkull.patch

120 Zeilen
5.6 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/BlockSkull.java
+++ b/net/minecraft/server/BlockSkull.java
2016-05-10 13:47:39 +02:00
@@ -5,6 +5,11 @@
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
2016-02-29 22:32:46 +01:00
public class BlockSkull extends BlockTileEntity {
2016-02-29 22:32:46 +01:00
public static final BlockStateDirection FACING = BlockDirectional.FACING;
2016-05-10 13:47:39 +02:00
@@ -82,7 +87,25 @@
2016-02-29 22:32:46 +01:00
return new ItemStack(Items.SKULL, 1, i);
}
2016-02-29 22:32:46 +01:00
- 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
2015-02-26 23:41:06 +01:00
+ @Override
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+ if (world.random.nextFloat() < f) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition);
2016-02-29 22:32:46 +01:00
+ 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);
+ }
2016-02-29 22:32:46 +01:00
+
+ a(world, blockposition, itemstack);
+ }
+ }
+ // CraftBukkit end
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.abilities.canInstantlyBuild) {
2016-05-10 13:47:39 +02:00
@@ -95,7 +118,10 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
2015-02-26 23:41:06 +01:00
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) {
2016-05-10 13:47:39 +02:00
@@ -128,24 +154,36 @@
}
public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
+ if (world.captureBlockStates) return; // CraftBukkit
2015-02-26 23:41:06 +01:00
if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide) {
2016-02-29 22:32:46 +01:00
ShapeDetector shapedetector = this.g();
2015-02-26 23:41:06 +01:00
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
2015-02-26 23:41:06 +01:00
if (shapedetector_shapedetectorcollection != null) {
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
int i;
for (i = 0; i < 3; ++i) {
2015-02-26 23:41:06 +01:00
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0);
2015-07-30 08:56:52 +02:00
- world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
+ // CraftBukkit start
2015-07-30 08:56:52 +02:00
+ // 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) {
2015-02-26 23:41:06 +01:00
ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(i, j, 0);
2015-07-30 08:56:52 +02:00
- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
+ // CraftBukkit start
2015-07-30 08:56:52 +02:00
+ // 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
}
}
2016-05-10 13:47:39 +02:00
@@ -158,14 +196,16 @@
2016-02-29 22:32:46 +01:00
entitywither.o();
Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator();
+ // CraftBukkit start
2015-02-26 23:41:06 +01:00
+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ blockList.updateList();
2016-02-29 22:32:46 +01:00
+
2015-02-26 23:41:06 +01:00
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
entityhuman.b((Statistic) AchievementList.I);
}
- world.addEntity(entitywither);
2015-02-26 23:41:06 +01:00
-
int k;
2015-02-26 23:41:06 +01:00
for (k = 0; k < 120; ++k) {
2016-05-10 13:47:39 +02:00
@@ -179,6 +219,7 @@
2015-07-30 08:56:52 +02:00
world.update(shapedetectorblock2.getPosition(), Blocks.AIR);
}
}
2015-02-26 23:41:06 +01:00
+ } // CraftBukkit end
}
}