private void trySpawnGolem(World worldIn, BlockPos pos) { BlockPattern.PatternHelper patternhelper; int i; int j; if ((patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != null) { for (i = 0; i < this.getSnowmanPattern().getThumbLength(); ++i) { BlockWorldState blockworldstate = patternhelper.translateOffset(0, i, 0); worldIn.setBlockState(blockworldstate.getPos(), Blocks.air.getDefaultState(), 2); } EntitySnowman entitysnowman = new EntitySnowman(worldIn); BlockPos blockpos2 = patternhelper.translateOffset(0, 2, 0).getPos(); entitysnowman.setLocationAndAngles( (double) blockpos2.getX() + 0.5D, (double) blockpos2.getY() + 0.05D, (double) blockpos2.getZ() + 0.5D, 0.0F, 0.0F); worldIn.spawnEntityInWorld(entitysnowman); for (j = 0; j < 120; ++j) { worldIn.spawnParticle( EnumParticleTypes.SNOW_SHOVEL, (double) blockpos2.getX() + worldIn.rand.nextDouble(), (double) blockpos2.getY() + worldIn.rand.nextDouble() * 2.5D, (double) blockpos2.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (j = 0; j < this.getSnowmanPattern().getThumbLength(); ++j) { BlockWorldState blockworldstate1 = patternhelper.translateOffset(0, j, 0); worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air); } } else if ((patternhelper = this.getGolemPattern().match(worldIn, pos)) != null) { for (i = 0; i < this.getGolemPattern().getPalmLength(); ++i) { for (int k = 0; k < this.getGolemPattern().getThumbLength(); ++k) { worldIn.setBlockState( patternhelper.translateOffset(i, k, 0).getPos(), Blocks.air.getDefaultState(), 2); } } BlockPos blockpos1 = patternhelper.translateOffset(1, 2, 0).getPos(); EntityIronGolem entityirongolem = new EntityIronGolem(worldIn); entityirongolem.setPlayerCreated(true); entityirongolem.setLocationAndAngles( (double) blockpos1.getX() + 0.5D, (double) blockpos1.getY() + 0.05D, (double) blockpos1.getZ() + 0.5D, 0.0F, 0.0F); worldIn.spawnEntityInWorld(entityirongolem); for (j = 0; j < 120; ++j) { worldIn.spawnParticle( EnumParticleTypes.SNOWBALL, (double) blockpos1.getX() + worldIn.rand.nextDouble(), (double) blockpos1.getY() + worldIn.rand.nextDouble() * 3.9D, (double) blockpos1.getZ() + worldIn.rand.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); } for (j = 0; j < this.getGolemPattern().getPalmLength(); ++j) { for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l) { BlockWorldState blockworldstate2 = patternhelper.translateOffset(j, l, 0); worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air); } } } }
/** Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); if (par1World.getBlockId(par2, par3 - 1, par4) == Block.blockSnow.blockID && par1World.getBlockId(par2, par3 - 2, par4) == Block.blockSnow.blockID) { if (!par1World.isRemote) { par1World.setBlock(par2, par3, par4, 0); par1World.setBlock(par2, par3 - 1, par4, 0); par1World.setBlock(par2, par3 - 2, par4, 0); EntitySnowman var9 = new EntitySnowman(par1World); var9.setLocationAndAngles( (double) par2 + 0.5D, (double) par3 - 1.95D, (double) par4 + 0.5D, 0.0F, 0.0F); par1World.spawnEntityInWorld(var9); par1World.notifyBlockChange(par2, par3, par4, 0); par1World.notifyBlockChange(par2, par3 - 1, par4, 0); par1World.notifyBlockChange(par2, par3 - 2, par4, 0); } for (int var10 = 0; var10 < 120; ++var10) { par1World.spawnParticle( "snowshovel", (double) par2 + par1World.rand.nextDouble(), (double) (par3 - 2) + par1World.rand.nextDouble() * 2.5D, (double) par4 + par1World.rand.nextDouble(), 0.0D, 0.0D, 0.0D); } } else if (par1World.getBlockId(par2, par3 - 1, par4) == Block.blockSteel.blockID && par1World.getBlockId(par2, par3 - 2, par4) == Block.blockSteel.blockID) { boolean var5 = par1World.getBlockId(par2 - 1, par3 - 1, par4) == Block.blockSteel.blockID && par1World.getBlockId(par2 + 1, par3 - 1, par4) == Block.blockSteel.blockID; boolean var6 = par1World.getBlockId(par2, par3 - 1, par4 - 1) == Block.blockSteel.blockID && par1World.getBlockId(par2, par3 - 1, par4 + 1) == Block.blockSteel.blockID; if (var5 || var6) { par1World.setBlock(par2, par3, par4, 0); par1World.setBlock(par2, par3 - 1, par4, 0); par1World.setBlock(par2, par3 - 2, par4, 0); if (var5) { par1World.setBlock(par2 - 1, par3 - 1, par4, 0); par1World.setBlock(par2 + 1, par3 - 1, par4, 0); } else { par1World.setBlock(par2, par3 - 1, par4 - 1, 0); par1World.setBlock(par2, par3 - 1, par4 + 1, 0); } EntityIronGolem var7 = new EntityIronGolem(par1World); var7.setPlayerCreated(true); var7.setLocationAndAngles( (double) par2 + 0.5D, (double) par3 - 1.95D, (double) par4 + 0.5D, 0.0F, 0.0F); par1World.spawnEntityInWorld(var7); for (int var8 = 0; var8 < 120; ++var8) { par1World.spawnParticle( "snowballpoof", (double) par2 + par1World.rand.nextDouble(), (double) (par3 - 2) + par1World.rand.nextDouble() * 3.9D, (double) par4 + par1World.rand.nextDouble(), 0.0D, 0.0D, 0.0D); } par1World.notifyBlockChange(par2, par3, par4, 0); par1World.notifyBlockChange(par2, par3 - 1, par4, 0); par1World.notifyBlockChange(par2, par3 - 2, par4, 0); if (var5) { par1World.notifyBlockChange(par2 - 1, par3 - 1, par4, 0); par1World.notifyBlockChange(par2 + 1, par3 - 1, par4, 0); } else { par1World.notifyBlockChange(par2, par3 - 1, par4 - 1, 0); par1World.notifyBlockChange(par2, par3 - 1, par4 + 1, 0); } } } }