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