Search in sources :

Example 81 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class EntityAIRestrictFenceGateUse method shouldExecute.

@Override
public boolean shouldExecute() {
    if (entityObj.world.isDaytime()) {
        return false;
    } else {
        BlockPos blockpos = new BlockPos(entityObj);
        PigtificateVillage village = PigtificateVillageManager.getPigtificateVillages(entityObj.getEntityWorld()).getNearestVillage(blockpos, 16);
        if (village == null) {
            return false;
        } else {
            fenceGate = village.getNearestFenceGate(blockpos);
            return fenceGate != null && (double) fenceGate.getDistanceToInsideBlockSq(blockpos) < 2.25D;
        }
    }
}
Also used : PigtificateVillage(nex.village.PigtificateVillage) BlockPos(net.minecraft.util.math.BlockPos)

Example 82 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class BlockNetherPortal method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    EnumFacing.Axis axis = state.getValue(AXIS);
    if (axis == EnumFacing.Axis.X) {
        if (world.isAirBlock(pos.down()) || world.isAirBlock(pos.up()) || world.isAirBlock(pos.north()) || world.isAirBlock(pos.south())) {
            world.setBlockToAir(pos);
        }
    } else if (axis == EnumFacing.Axis.Y) {
        if (world.isAirBlock(pos.north()) || world.isAirBlock(pos.south()) || world.isAirBlock(pos.west()) || world.isAirBlock(pos.east())) {
            world.setBlockToAir(pos);
        }
    } else if (axis == EnumFacing.Axis.Z) {
        if (world.isAirBlock(pos.down()) || world.isAirBlock(pos.up()) || world.isAirBlock(pos.west()) || world.isAirBlock(pos.east())) {
            world.setBlockToAir(pos);
        }
    }
    if (ConfigHandler.block.netherPortal.allowPigmanSpawning) {
        if (world.provider.isSurfaceWorld() && world.getGameRules().getBoolean("doMobSpawning") && rand.nextInt(ConfigHandler.block.netherPortal.pigmanSpawnRarity) < world.getDifficulty().getDifficultyId()) {
            int i = pos.getY();
            BlockPos blockPos;
            for (blockPos = pos; !world.getBlockState(blockPos).isSideSolid(world, blockPos, EnumFacing.UP) && blockPos.getY() > 0; blockPos = blockPos.down()) {
            }
            if (i > 0 && !world.getBlockState(blockPos.up()).isNormalCube()) {
                Entity entity = ItemMonsterPlacer.spawnCreature(world, EntityList.getKey(EntityPigZombie.class), (double) blockPos.getX() + 0.5D, (double) blockPos.getY() + 1.1D, (double) blockPos.getZ() + 0.5D);
                if (entity != null) {
                    entity.timeUntilPortal = entity.getPortalCooldown();
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPigZombie(net.minecraft.entity.monster.EntityPigZombie) BlockPos(net.minecraft.util.math.BlockPos)

Example 83 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class EntityAIFenceGateInteract method shouldExecute.

@Override
public boolean shouldExecute() {
    if (!theEntity.isCollidedHorizontally) {
        return false;
    } else {
        PathNavigateGround pathnavigateground = (PathNavigateGround) theEntity.getNavigator();
        Path path = pathnavigateground.getPath();
        if (path != null && !path.isFinished() && pathnavigateground.getEnterDoors()) {
            for (int i = 0; i < Math.min(path.getCurrentPathIndex() + 2, path.getCurrentPathLength()); ++i) {
                PathPoint pathpoint = path.getPathPointFromIndex(i);
                fenceGatePos = new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord);
                if (theEntity.getDistanceSq((double) fenceGatePos.getX(), theEntity.posY, (double) fenceGatePos.getZ()) <= 2.25D) {
                    fenceGate = getFenceGate(fenceGatePos);
                    if (fenceGate != null) {
                        return true;
                    }
                }
            }
            fenceGatePos = (new BlockPos(theEntity));
            fenceGate = getFenceGate(fenceGatePos);
            return fenceGate != null;
        } else {
            return false;
        }
    }
}
Also used : Path(net.minecraft.pathfinding.Path) PathPoint(net.minecraft.pathfinding.PathPoint) BlockPos(net.minecraft.util.math.BlockPos) PathPoint(net.minecraft.pathfinding.PathPoint) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Example 84 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class BlockHyphae method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    if (!world.isRemote && ConfigHandler.block.hyphae.doesSpread) {
        if (world.getLightFromNeighbors(pos.up()) < 4 && world.getBlockState(pos.up()).getLightOpacity(world, pos.up()) > 2) {
            world.setBlockState(pos, NetherExBlocks.BLOCK_NETHERRACK.getDefaultState().withProperty(BlockNetherrack.TYPE, BlockNetherrack.EnumType.LIVELY));
        } else {
            if (world.getLightFromNeighbors(pos.up()) >= 9) {
                for (int i = 0; i < 4; ++i) {
                    BlockPos newPos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
                    IBlockState blockState = world.getBlockState(newPos);
                    IBlockState blockState1 = world.getBlockState(newPos.up());
                    if (blockState.getBlock() == NetherExBlocks.BLOCK_NETHERRACK && blockState.getValue(BlockNetherrack.TYPE) == BlockNetherrack.EnumType.LIVELY && world.getLightFromNeighbors(newPos.up()) >= 4 && blockState1.getLightOpacity(world, newPos.up()) <= 2) {
                        world.setBlockState(newPos, getDefaultState());
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 85 with BlockPos

use of net.minecraft.util.math.BlockPos in project NetherEx by LogicTechCorp.

the class EntityGhastQueen method readEntityFromNBT.

@Override
public void readEntityFromNBT(NBTTagCompound compound) {
    super.readEntityFromNBT(compound);
    setUrnPos(new BlockPos(compound.getIntArray("UrnPos")[0], compound.getIntArray("UrnPos")[1], compound.getIntArray("UrnPos")[2]));
    setCooldown(compound.getInteger("Cooldown"));
    setStage(compound.getInteger("Stage"));
    for (int i = 0; i < stageStarted.length; i++) {
        setStageStarted(i, compound.getBoolean("StageStarted" + i));
    }
    setShouldSpawnGhastlings(compound.getBoolean("SpawnGhast"));
    if (hasCustomName()) {
        bossInfo.setName(getDisplayName());
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)864 IBlockState (net.minecraft.block.state.IBlockState)220 TileEntity (net.minecraft.tileentity.TileEntity)135 Block (net.minecraft.block.Block)103 EnumFacing (net.minecraft.util.EnumFacing)95 ItemStack (net.minecraft.item.ItemStack)81 World (net.minecraft.world.World)77 EntityPlayer (net.minecraft.entity.player.EntityPlayer)54 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)46 Vec3d (net.minecraft.util.math.Vec3d)44 NotNull (org.jetbrains.annotations.NotNull)44 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)31 Entity (net.minecraft.entity.Entity)30 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)29 Nullable (org.jetbrains.annotations.Nullable)26 ArrayList (java.util.ArrayList)23 EntityLivingBase (net.minecraft.entity.EntityLivingBase)23 WorldServer (net.minecraft.world.WorldServer)23 TextComponentString (net.minecraft.util.text.TextComponentString)22