use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class EntityButterfly method getBlockPathWeight.
@Override
public float getBlockPathWeight(BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return -100f;
}
float weight = 0.0f;
double distanceToHome = getHomePosition().distanceSq(pos);
if (!isWithinHomeDistanceFromPosition(distanceToHome)) {
weight -= 7.5f + 0.005 * (distanceToHome / 4);
}
if (!getButterfly().isAcceptedEnvironment(world, pos.getX(), pos.getY(), pos.getZ())) {
weight -= 15.0f;
}
if (!world.getEntitiesWithinAABB(EntityButterfly.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)).isEmpty()) {
weight -= 1.0f;
}
int depth = getFluidDepth(pos);
if (depth > 0) {
weight -= 0.1f * depth;
} else {
IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (block instanceof BlockFlower) {
weight += 2.0f;
} else if (block instanceof IPlantable) {
weight += 1.5f;
} else if (block instanceof IGrowable) {
weight += 1.0f;
} else if (blockState.getMaterial() == Material.PLANTS) {
weight += 1.0f;
}
BlockPos posBelow = pos.down();
IBlockState blockStateBelow = world.getBlockState(posBelow);
Block blockBelow = blockStateBelow.getBlock();
if (blockBelow.isLeaves(blockStateBelow, world, posBelow)) {
weight += 2.5f;
} else if (blockBelow instanceof BlockFence) {
weight += 1.0f;
} else if (blockBelow instanceof BlockWall) {
weight += 1.0f;
}
}
weight += world.getLightBrightness(pos);
return weight;
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class MultiblockEventHandlerClient method onWorldRenderLast.
@SubscribeEvent
public void onWorldRenderLast(RenderWorldLastEvent event) {
if (GeneticsUtil.hasNaturalistEye(Minecraft.getMinecraft().player)) {
try {
World world = Minecraft.getMinecraft().world;
Set<IMultiblockControllerInternal> controllers = MultiblockRegistry.getControllersFromWorld(world);
if (!controllers.isEmpty()) {
float partialTicks = event.getPartialTicks();
EntityPlayer player = Minecraft.getMinecraft().player;
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
GlStateManager.glLineWidth(2.0F);
GlStateManager.depthMask(false);
for (IMultiblockController controller : controllers) {
if (controller != null) {
BlockPos lastErrorPosition = controller.getLastValidationErrorPosition();
if (lastErrorPosition != null) {
if (world.isBlockLoaded(lastErrorPosition) && player.getDistanceSq(lastErrorPosition) < 64F) {
AxisAlignedBB box = Block.FULL_BLOCK_AABB.offset(lastErrorPosition.getX() - playerX, lastErrorPosition.getY() - playerY, lastErrorPosition.getZ() - playerZ);
RenderGlobal.drawSelectionBoundingBox(box, 1.0F, 0.0F, 0.0F, 0.25F);
RenderGlobal.renderFilledBox(box, 1.0F, 0.0F, 0.0F, 0.125F);
}
}
}
}
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
} catch (Exception e) {
Log.error("Failed to render the position of a multiblock exception.", e);
}
}
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class ParticleHelper method addBlockHitEffects.
@SideOnly(Side.CLIENT)
public static boolean addBlockHitEffects(World world, BlockPos pos, EnumFacing side, ParticleManager effectRenderer, Callback callback) {
IBlockState iblockstate = world.getBlockState(pos);
if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
float f = 0.1F;
AxisAlignedBB axisalignedbb = iblockstate.getBoundingBox(world, pos);
double px = x + world.rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - f * 2.0F) + f + axisalignedbb.minX;
double py = y + world.rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - f * 2.0F) + f + axisalignedbb.minY;
double pz = z + world.rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - f * 2.0F) + f + axisalignedbb.minZ;
if (side == EnumFacing.DOWN) {
py = y + axisalignedbb.minY - f;
}
if (side == EnumFacing.UP) {
py = y + axisalignedbb.maxY + f;
}
if (side == EnumFacing.NORTH) {
pz = z + axisalignedbb.minZ - f;
}
if (side == EnumFacing.SOUTH) {
pz = z + axisalignedbb.maxZ + f;
}
if (side == EnumFacing.WEST) {
px = x + axisalignedbb.minX - f;
}
if (side == EnumFacing.EAST) {
px = x + axisalignedbb.maxX + f;
}
ParticleDigging fx = (ParticleDigging) effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(), px, py, pz, 0.0D, 0.0D, 0.0D, Block.getStateId(iblockstate));
if (fx != null) {
callback.addHitEffects(fx, world, pos, iblockstate);
effectRenderer.addEffect(fx.setBlockPos(new BlockPos(x, y, z)).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
}
return true;
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class WallBlockHandler method isAirBlock.
/**
* Same as {@link World#isAirBlock(BlockPos)} but faster
*/
private boolean isAirBlock(World world, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos);
AxisAlignedBB collisionBB = blockState.getCollisionBoundingBox(world, pos);
return collisionBB == null || collisionBB.equals(Block.NULL_AABB) || blockState.getBlock().isLeaves(blockState, world, pos);
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class GreenhouseProviderServer method getHeight.
public int getHeight(BlockPos pos, int maximalHeight) {
int worldHeight = world.getHeight();
BlockPos.MutableBlockPos position = new BlockPos.MutableBlockPos(pos);
int height = -1;
while (position.getY() <= worldHeight && position.getY() <= maximalHeight && height == -1) {
IBlockState blockState = world.getBlockState(position);
AxisAlignedBB collisionBB = blockState.getCollisionBoundingBox(world, pos);
if (collisionBB == null || collisionBB.equals(Block.NULL_AABB) || blockState.getBlock().isLeaves(blockState, world, pos)) {
position.move(EnumFacing.UP);
} else {
height = position.down().getY();
}
}
return height;
}
Aggregations