Java Code Examples for net.minecraft.world.World.notifyNeighborsRespectDebug()

The following are Jave code examples for showing how to use notifyNeighborsRespectDebug() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
            entitywither.renderYawOffset = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
            entitywither.func_82206_m();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expand(50.0D, 50.0D, 50.0D)))
            {
                entityplayer.triggerAchievement(AchievementList.spawnWither);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper;

    if ((blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != 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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air);
        }
    }
    else if ((blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos)) != null)
    {
        for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
        {
            for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
            {
                worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.air.getDefaultState(), 2);
            }
        }

        BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
        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.spawnEntityInWorld(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, new int[0]);
        }

        for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
        {
            for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
            {
                BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
            }
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
            entitywither.renderYawOffset = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
            entitywither.func_82206_m();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expand(50.0D, 50.0D, 50.0D)))
            {
                entityplayer.triggerAchievement(AchievementList.spawnWither);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper;

    if ((blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != 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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air);
        }
    }
    else if ((blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos)) != null)
    {
        for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
        {
            for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
            {
                worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.air.getDefaultState(), 2);
            }
        }

        BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
        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.spawnEntityInWorld(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, new int[0]);
        }

        for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
        {
            for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
            {
                BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
            }
        }
    }
}
 
Example 5
Project: BaseClient   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
            entitywither.renderYawOffset = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
            entitywither.func_82206_m();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expand(50.0D, 50.0D, 50.0D)))
            {
                entityplayer.triggerAchievement(AchievementList.spawnWither);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 6
Project: BaseClient   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper;

    if ((blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != 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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air);
        }
    }
    else if ((blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos)) != null)
    {
        for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
        {
            for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
            {
                worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.air.getDefaultState(), 2);
            }
        }

        BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
        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.spawnEntityInWorld(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, new int[0]);
        }

        for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
        {
            for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
            {
                BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
            }
        }
    }
}
 
Example 7
Project: BaseClient   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            entitywither.setLocationAndAngles((double)blockpos1.getX() + 0.5D, (double)blockpos1.getY() + 0.55D, (double)blockpos1.getZ() + 0.5D, blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F, 0.0F);
            entitywither.renderYawOffset = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? 0.0F : 90.0F;
            entitywither.func_82206_m();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expand(50.0D, 50.0D, 50.0D)))
            {
                entityplayer.triggerAchievement(AchievementList.spawnWither);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 8
Project: BaseClient   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper;

    if ((blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos)) != 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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.air);
        }
    }
    else if ((blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos)) != null)
    {
        for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
        {
            for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
            {
                worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.air.getDefaultState(), 2);
            }
        }

        BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
        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.spawnEntityInWorld(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, new int[0]);
        }

        for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
        {
            for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
            {
                BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.air);
            }
        }
    }
}
 
Example 9
Project: Backmemed   File: ItemBed.java   View Source Code Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    if (playerIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else if (hand != EnumFacing.UP)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = playerIn.getBlockState(worldIn);
        Block block = iblockstate.getBlock();
        boolean flag = block.isReplaceable(playerIn, worldIn);

        if (!flag)
        {
            worldIn = worldIn.up();
        }

        int i = MathHelper.floor((double)(stack.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        EnumFacing enumfacing = EnumFacing.getHorizontal(i);
        BlockPos blockpos = worldIn.offset(enumfacing);
        ItemStack itemstack = stack.getHeldItem(pos);

        if (stack.canPlayerEdit(worldIn, hand, itemstack) && stack.canPlayerEdit(blockpos, hand, itemstack))
        {
            IBlockState iblockstate1 = playerIn.getBlockState(blockpos);
            boolean flag1 = iblockstate1.getBlock().isReplaceable(playerIn, blockpos);
            boolean flag2 = flag || playerIn.isAirBlock(worldIn);
            boolean flag3 = flag1 || playerIn.isAirBlock(blockpos);

            if (flag2 && flag3 && playerIn.getBlockState(worldIn.down()).isFullyOpaque() && playerIn.getBlockState(blockpos.down()).isFullyOpaque())
            {
                IBlockState iblockstate2 = Blocks.BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
                playerIn.setBlockState(worldIn, iblockstate2, 10);
                playerIn.setBlockState(blockpos, iblockstate2.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD), 10);
                playerIn.notifyNeighborsRespectDebug(worldIn, block, false);
                playerIn.notifyNeighborsRespectDebug(blockpos, iblockstate1.getBlock(), false);
                SoundType soundtype = iblockstate2.getBlock().getSoundType();
                playerIn.playSound((EntityPlayer)null, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                itemstack.func_190918_g(1);
                return EnumActionResult.SUCCESS;
            }
            else
            {
                return EnumActionResult.FAIL;
            }
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
}
 
Example 10
Project: Backmemed   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            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();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expandXyz(50.0D)))
            {
                entityplayer.addStat(AchievementList.SPAWN_WITHER);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 11
Project: Backmemed   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos);

    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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.AIR, false);
        }
    }
    else
    {
        blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
            {
                for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
                {
                    worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.AIR.getDefaultState(), 2);
                }
            }

            BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            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.spawnEntityInWorld(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, new int[0]);
            }

            for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
            {
                for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
                {
                    BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                    worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR, false);
                }
            }
        }
    }
}
 
Example 12
Project: CustomWorldGen   File: BlockSkull.java   View Source Code Vote up 4 votes
public void checkWitherSpawn(World worldIn, BlockPos pos, TileEntitySkull te)
{
    if (te.getSkullType() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote)
    {
        BlockPattern blockpattern = this.getWitherPattern();
        BlockPattern.PatternHelper blockpattern$patternhelper = blockpattern.match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            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);
            }

            for (int j = 0; j < blockpattern.getPalmLength(); ++j)
            {
                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 blockpos = blockpattern$patternhelper.translateOffset(1, 0, 0).getPos();
            EntityWither entitywither = new EntityWither(worldIn);
            BlockPos blockpos1 = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            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();

            for (EntityPlayer entityplayer : worldIn.getEntitiesWithinAABB(EntityPlayer.class, entitywither.getEntityBoundingBox().expandXyz(50.0D)))
            {
                entityplayer.addStat(AchievementList.SPAWN_WITHER);
            }

            worldIn.spawnEntityInWorld(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, new int[0]);
            }

            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);
                }
            }
        }
    }
}
 
Example 13
Project: CustomWorldGen   File: BlockPumpkin.java   View Source Code Vote up 4 votes
private void trySpawnGolem(World worldIn, BlockPos pos)
{
    BlockPattern.PatternHelper blockpattern$patternhelper = this.getSnowmanPattern().match(worldIn, pos);

    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);
        }

        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.spawnEntityInWorld(entitysnowman);

        for (int j = 0; j < 120; ++j)
        {
            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, new int[0]);
        }

        for (int i1 = 0; i1 < this.getSnowmanPattern().getThumbLength(); ++i1)
        {
            BlockWorldState blockworldstate1 = blockpattern$patternhelper.translateOffset(0, i1, 0);
            worldIn.notifyNeighborsRespectDebug(blockworldstate1.getPos(), Blocks.AIR);
        }
    }
    else
    {
        blockpattern$patternhelper = this.getGolemPattern().match(worldIn, pos);

        if (blockpattern$patternhelper != null)
        {
            for (int k = 0; k < this.getGolemPattern().getPalmLength(); ++k)
            {
                for (int l = 0; l < this.getGolemPattern().getThumbLength(); ++l)
                {
                    worldIn.setBlockState(blockpattern$patternhelper.translateOffset(k, l, 0).getPos(), Blocks.AIR.getDefaultState(), 2);
                }
            }

            BlockPos blockpos = blockpattern$patternhelper.translateOffset(1, 2, 0).getPos();
            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.spawnEntityInWorld(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, new int[0]);
            }

            for (int k1 = 0; k1 < this.getGolemPattern().getPalmLength(); ++k1)
            {
                for (int l1 = 0; l1 < this.getGolemPattern().getThumbLength(); ++l1)
                {
                    BlockWorldState blockworldstate2 = blockpattern$patternhelper.translateOffset(k1, l1, 0);
                    worldIn.notifyNeighborsRespectDebug(blockworldstate2.getPos(), Blocks.AIR);
                }
            }
        }
    }
}