Files
2019-02-24 22:29:41 +08:00

121 lines
7.4 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockPumpkin.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPumpkin.java
@@ -25,6 +25,8 @@
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent;
public class BlockPumpkin extends BlockHorizontal
{
@@ -62,34 +64,35 @@
private void trySpawnGolem(World worldIn, BlockPos pos)
{
BlockPattern.PatternHelper blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos);
-
+ BlockStateListPopulator blockList = new BlockStateListPopulator(worldIn.getWorld());
if (blockpattern$patternhelper != null)
{
for (int i = 0; i < this.getSnowmanPattern().getThumbLength(); ++i)
{
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(0, i, 0);
- worldIn.setBlockState(blockworldstate.getPos(), Blocks.AIR.getDefaultState(), 2);
+// worldIn.setBlockState(blockworldstate.getPos(), Blocks.AIR.getDefaultState(), 2);
+ BlockPos pos1 = blockworldstate.getPos();
+ blockList.setTypeId(pos1.getX(), pos1.getY(), pos1.getZ(), 0);
}
EntitySnowman entitysnowman = new EntitySnowman(worldIn);
BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(0, 2, 0).getPos();
entitysnowman.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.05D, (double)blockpos1.getZ() + 0.5D, 0.0F, 0.0F);
- worldIn.spawnEntity(entitysnowman);
+ if (worldIn.addEntity(entitysnowman, CreatureSpawnEvent.SpawnReason.BUILD_SNOWMAN)) {
+ blockList.updateList();
- for (EntityPlayerMP entityplayermp : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entitysnowman.getEntityBoundingBox().grow(5.0D)))
- {
- CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp, entitysnowman);
- }
+ for (EntityPlayerMP entityplayermp : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entitysnowman.getEntityBoundingBox().grow(5.0D))) {
+ CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp, entitysnowman);
+ }
- for (int l = 0; l < 120; ++l)
- {
- worldIn.spawnParticle(EnumParticleTypes.SNOW_SHOVEL, (double)blockpos1.getX() + worldIn.rand.nextDouble(), (double)blockpos1.getY() + worldIn.rand.nextDouble() * 2.5D, (double)blockpos1.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
- }
+ for (int l = 0; l < 120; ++l) {
+ worldIn.spawnParticle(EnumParticleTypes.SNOW_SHOVEL, (double) blockpos1.getX() + worldIn.rand.nextDouble(), (double) blockpos1.getY() + worldIn.rand.nextDouble() * 2.5D, (double) blockpos1.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
+ }
- for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
- {
- BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(0, i1, 0);
- worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
+ for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1) {
+ BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(0, i1, 0);
+ worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
+ }
}
}
else
@@ -102,7 +105,9 @@
{
for (int k = 0; k < this.getGolemPattern().getThumbLength(); ++k)
{
- worldIn.setBlockState(blockpattern$patternhelper.translateOffset(j, k, 0).getPos(), Blocks.AIR.getDefaultState(), 2);
+// worldIn.setBlockState(blockpattern$patternhelper.translateOffset(j, k, 0).getPos(), Blocks.AIR.getDefaultState(), 2);
+ BlockPos pos2 = blockpattern$patternhelper.translateOffset(j, k, 0).getPos();
+ blockList.setTypeId(pos2.getX(), pos2.getY(), pos2.getZ(), 0);
}
}
@@ -110,24 +115,22 @@
EntityIronGolem entityirongolem = new EntityIronGolem(worldIn);
entityirongolem.setPlayerCreated(true);
entityirongolem.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.05D, (double)blockpos.getZ() + 0.5D, 0.0F, 0.0F);
- worldIn.spawnEntity(entityirongolem);
+ if (worldIn.addEntity(entityirongolem, CreatureSpawnEvent.SpawnReason.BUILD_IRONGOLEM)) {
+ blockList.updateList();
- for (EntityPlayerMP entityplayermp1 : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entityirongolem.getEntityBoundingBox().grow(5.0D)))
- {
- CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp1, entityirongolem);
- }
+ for (EntityPlayerMP entityplayermp1 : worldIn.getEntitiesWithinAABB(EntityPlayerMP.class, entityirongolem.getEntityBoundingBox().grow(5.0D))) {
+ CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayermp1, entityirongolem);
+ }
- for (int j1 = 0; j1 < 120; ++j1)
- {
- worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double)blockpos.getX() + worldIn.rand.nextDouble(), (double)blockpos.getY() + worldIn.rand.nextDouble() * 3.9D, (double)blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
- }
+ for (int j1 = 0; j1 < 120; ++j1) {
+ worldIn.spawnParticle(EnumParticleTypes.SNOWBALL, (double) blockpos.getX() + worldIn.rand.nextDouble(), (double) blockpos.getY() + worldIn.rand.nextDouble() * 3.9D, (double) blockpos.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
+ }
- for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
- {
- for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
- {
- BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
- worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.AIR, false);
+ for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1) {
+ for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1) {
+ BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
+ worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.AIR, false);
+ }
}
}
}
@@ -136,7 +139,7 @@
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
- return worldIn.getBlockState(pos).getBlock().blockMaterial.isReplaceable() && worldIn.getBlockState(pos.down()).isTopSolid();
+ return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && worldIn.isSideSolid(pos.down(), EnumFacing.UP);
}
public IBlockState withRotation(IBlockState state, Rotation rot)