Files
CatServer/patches/net/minecraft/block/BlockSkull.java.patch
2019-02-24 22:29:41 +08:00

140 lines
7.2 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockSkull.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSkull.java
@@ -40,6 +40,8 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent;
public class BlockSkull extends BlockContainer
{
@@ -128,10 +130,6 @@
return new ItemStack(Items.SKULL, 1, i);
}
- public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
- {
- }
-
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.capabilities.isCreativeMode)
@@ -139,13 +137,17 @@
state = state.withProperty(NODROP, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 4);
}
+ this.dropBlockAsItem(worldIn, pos, state, 0);
super.onBlockHarvested(worldIn, pos, state, player);
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
- if (!worldIn.isRemote)
+ super.breakBlock(worldIn, pos, state);
+ }
+ public void getDrops(net.minecraft.util.NonNullList<ItemStack> drops, IBlockAccess worldIn, BlockPos pos, IBlockState state, int fortune)
+ {
{
if (!((Boolean)state.getValue(NODROP)).booleanValue())
{
@@ -154,7 +156,7 @@
if (tileentity instanceof TileEntitySkull)
{
TileEntitySkull tileentityskull = (TileEntitySkull)tileentity;
- ItemStack itemstack = this.getItem(worldIn, pos, state);
+ ItemStack itemstack = new ItemStack(Items.SKULL, 1, tileentityskull.getSkullType());
if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null)
{
@@ -164,11 +166,9 @@
itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
}
- spawnAsEntity(worldIn, pos, itemstack);
+ drops.add(itemstack);
}
}
-
- super.breakBlock(worldIn, pos, state);
}
}
@@ -191,6 +191,7 @@
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
+ if (worldIn.captureBlockSnapshots) return;
if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
{
BlockPattern blockpattern = this.getWitherPattern();
@@ -198,10 +199,14 @@
if (blockpattern$patternhelper != null)
{
+ BlockStateListPopulator blockList = new BlockStateListPopulator(worldIn.getWorld());
for (int i = 0; i < 3; ++i)
{
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, 0, 0);
- worldIn.setBlockState(blockworldstate.getPos(), blockworldstate.getBlockState().withProperty(NODROP, Boolean.valueOf(true)), 2);
+ BlockPos pos1 = blockworldstate.getPos();
+ IBlockState data = blockworldstate.getBlockState().withProperty(BlockSkull.NODROP, true);
+ blockList.setTypeAndData(pos1.getX(), pos1.getY(), pos1.getZ(), data.getBlock(), data.getBlock().getMetaFromState(data), 2);
+// worldIn.setBlockState(blockworldstate.getPos(), blockworldstate.getBlockState().withProperty(NODROP, Boolean.valueOf(true)), 2);
}
for (int j = 0; j < blockpattern.getPalmLength(); ++j)
@@ -209,7 +214,10 @@
for (int k = 0; k < blockpattern.getThumbLength(); ++k)
{
BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(j, k, 0);
- worldIn.setBlockState(blockworldstate1.getPos(), Blocks.AIR.getDefaultState(), 2);
+ BlockPos pos1 = blockworldstate1.getPos();
+ blockList.setTypeAndData(pos1.getX(), pos1.getY(), pos1.getZ(), Blocks.AIR, 0, 2);
+// worldIn.setBlockState(blockworldstate1.getPos(), Blocks.AIR.getDefaultState(), 2);
+
}
}
@@ -219,25 +227,24 @@
entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
entitywither.renderYawOffset = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
entitywither.ignite();
+ if (worldIn.addEntity(entitywither, CreatureSpawnEvent.SpawnReason.BUILD_WITHER)) {
+ blockList.updateList();
- for (EntityPlayerMP entityplayermp : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entitywither.getEntityBoundingBox().grow(50.0D)))
- {
- CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp, entitywither);
- }
+ for (EntityPlayerMP entityplayermp : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entitywither.getEntityBoundingBox().grow(50.0D))) {
+ CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp, entitywither);
+ }
- worldIn.spawnEntity(entitywither);
+// worldIn.spawnEntity(entitywither);
- for (int l = 0; l < 120; ++l)
- {
- worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double)blockpos.getX() + worldIn.rand.nextDouble(), (double)(blockpos.getY() - 2) + worldIn.rand.nextDouble() * 3.9D, (double)blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
- }
+ for (int l = 0; l < 120; ++l) {
+ worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double) blockpos.getX() + worldIn.rand.nextDouble(), (double) (blockpos.getY() - 2) + worldIn.rand.nextDouble() * 3.9D, (double) blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
+ }
- for (int i1 = 0; i1 < blockpattern.getPalmLength(); ++i1)
- {
- for (int j1 = 0; j1 < blockpattern.getThumbLength(); ++j1)
- {
- BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(i1, j1, 0);
- worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
+ for (int i1 = 0; i1 < blockpattern.getPalmLength(); ++i1) {
+ for (int j1 = 0; j1 < blockpattern.getThumbLength(); ++j1) {
+ BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(i1, j1, 0);
+ worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
+ }
}
}
}