1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/block/BlockPumpkin.java.patch

127 lines
7.0 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../src-base/minecraft/net/minecraft/block/BlockPumpkin.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPumpkin.java
@@ -14,6 +14,12 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockPumpkin extends BlockDirectional
{
private boolean field_149985_a;
@@ -45,15 +51,18 @@
{
if (!p_149726_1_.isRemote)
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2);
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149726_1_.getWorld());
+ blockList.setTypeId(p_149726_2_, p_149726_3_, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 2, p_149726_4_, 0);
EntitySnowman entitysnowman = new EntitySnowman(p_149726_1_);
- entitysnowman.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F);
- p_149726_1_.spawnEntityInWorld(entitysnowman);
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0));
+ entitysnowman.setLocationAndAngles((double) p_149726_2_ + 0.5D, (double) p_149726_3_ - 1.95D, (double) p_149726_4_ + 0.5D, 0.0F, 0.0F);
+
+ if (p_149726_1_.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN))
+ {
+ blockList.updateList();
+ }
}
for (int i1 = 0; i1 < 120; ++i1)
@@ -68,45 +77,38 @@
if (flag || flag1)
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2);
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149726_1_.getWorld());
+ blockList.setTypeId(p_149726_2_, p_149726_3_, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 2, p_149726_4_, 0);
if (flag)
{
- p_149726_1_.setBlock(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
+ blockList.setTypeId(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, 0);
}
else
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0), 0, 2);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, 0);
}
EntityIronGolem entityirongolem = new EntityIronGolem(p_149726_1_);
entityirongolem.setPlayerCreated(true);
- entityirongolem.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F);
- p_149726_1_.spawnEntityInWorld(entityirongolem);
+ entityirongolem.setLocationAndAngles((double) p_149726_2_ + 0.5D, (double) p_149726_3_ - 1.95D, (double) p_149726_4_ + 0.5D, 0.0F, 0.0F);
- for (int l = 0; l < 120; ++l)
+ if (p_149726_1_.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM))
{
- p_149726_1_.spawnParticle("snowballpoof", (double)p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 3.9D, (double)p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
- }
+ for (int i1 = 0; i1 < 120; ++i1)
+ {
+ p_149726_1_.spawnParticle("snowballpoof", (double) p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 3.9D, (double) p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
+ }
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0));
-
- if (flag)
- {
- p_149726_1_.notifyBlockChange(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
+ blockList.updateList();
}
- else
- {
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0));
- }
+
+ // CraftBukkit end
}
}
}
@@ -122,6 +124,19 @@
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2);
}
+ // CraftBukkit start
+ public void onNeighborBlockChange(World world, int i, int j, int k, Block block)
+ {
+ if (block != null && block.canProvidePower())
+ {
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
+ int power = bukkitBlock.getBlockPower();
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ }
+ }
+ // CraftBukkit end
+
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{