use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class SemiBlockRendererHeatFrame method render.
@Override
public void render(SemiBlockHeatFrame semiBlock, float partialTick) {
GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(Textures.MODEL_HEAT_FRAME);
int heatLevel = semiBlock.getHeatLevel();
double[] color = TileEntityCompressedIronBlock.getColorForHeatLevel(heatLevel);
GL11.glColor4d(color[0], color[1], color[2], 1);
AxisAlignedBB aabb;
if (semiBlock.getWorld() != null) {
semiBlock.getBlock().setBlockBoundsBasedOnState(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
aabb = semiBlock.getBlock().getSelectedBoundingBoxFromPool(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
aabb.minX -= semiBlock.getX();
aabb.maxX -= semiBlock.getX();
aabb.minY -= semiBlock.getY();
aabb.maxY -= semiBlock.getY();
aabb.minZ -= semiBlock.getZ();
aabb.maxZ -= semiBlock.getZ();
} else {
aabb = AxisAlignedBB.getBoundingBox(1 / 16D, 1 / 16D, 1 / 16D, 15 / 16D, 15 / 16D, 15 / 16D);
}
GL11.glTranslated(aabb.minX, aabb.minY, aabb.minZ);
GL11.glScaled(aabb.maxX - aabb.minX, aabb.maxY - aabb.minY, aabb.maxZ - aabb.minZ);
GL11.glTranslated(0.5, -0.5, 0.5);
model.render(null, 0, 0, 0, 0, 0, 1 / 16F);
GL11.glPopMatrix();
GL11.glColor4d(1, 1, 1, 1);
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class SemiBlockRendererLogistics method render.
@Override
public void render(SemiBlockLogistics semiBlock, float partialTick) {
int alpha = semiBlock.getAlpha();
if (alpha == 0)
return;
GL11.glDisable(GL11.GL_TEXTURE_2D);
//GL11.glColor4d(1, 0, 0, 1);
if (alpha < 255)
GL11.glEnable(GL11.GL_BLEND);
RenderUtils.glColorHex((alpha << 24 | 0x00FFFFFF) & semiBlock.getColor());
double fw = 1 / 32D;
AxisAlignedBB aabb;
if (semiBlock.getWorld() != null) {
semiBlock.getBlock().setBlockBoundsBasedOnState(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
aabb = semiBlock.getBlock().getSelectedBoundingBoxFromPool(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
} else {
aabb = AxisAlignedBB.getBoundingBox(0 + fw, 0 + fw, 0 + fw, 1 - fw, 1 - fw, 1 - fw);
}
if (semiBlock.getPos() != null)
GL11.glTranslated(-semiBlock.getPos().chunkPosX, -semiBlock.getPos().chunkPosY, -semiBlock.getPos().chunkPosZ);
renderFrame(aabb, fw);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4d(1, 1, 1, 1);
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class ModuleAirGrate method update.
@Override
public void update() {
super.update();
World worldObj = pressureTube.world();
int xCoord = pressureTube.x();
int yCoord = pressureTube.y();
int zCoord = pressureTube.z();
Vec3 tileVec = Vec3.createVectorHelper(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D);
if (!worldObj.isRemote) {
int oldGrateRange = grateRange;
grateRange = getRange();
pressureTube.getAirHandler().addAir((vacuum ? 1 : -1) * grateRange * PneumaticValues.USAGE_AIR_GRATE, ForgeDirection.UNKNOWN);
if (oldGrateRange != grateRange)
sendDescriptionPacket();
checkForPlantsAndFarm(worldObj, xCoord, yCoord, zCoord, grateRange);
coolHeatSinks(worldObj, xCoord, yCoord, zCoord, grateRange);
} else {
rangeLineRenderer.update();
/* updateParticleTargets(tileVec, grateRange);
for(Vec3 particleVec : particleTargets) {
//if(worldObj.rand.nextInt(10) == 0) {
Vec3 motionVec = particleVec.subtract(tileVec);
double force = 0.1D;
motionVec.xCoord *= force;
motionVec.yCoord *= force;
motionVec.zCoord *= force;
if(vacuum) {
worldObj.spawnParticle("smoke", particleVec.xCoord, particleVec.yCoord, particleVec.zCoord, -motionVec.xCoord, -motionVec.yCoord, -motionVec.zCoord);
} else {
worldObj.spawnParticle("smoke", tileVec.xCoord, tileVec.yCoord, tileVec.zCoord, motionVec.xCoord, motionVec.yCoord, motionVec.zCoord);
}
// }
}*/
}
AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(xCoord - grateRange, yCoord - grateRange, zCoord - grateRange, xCoord + grateRange + 1, yCoord + grateRange + 1, zCoord + grateRange + 1);
List<Entity> entities = worldObj.selectEntitiesWithinAABB(Entity.class, bbBox, new StringFilterEntitySelector().setFilter(entityFilter));
double d0 = grateRange + 0.5D;
for (Entity entity : entities) {
if (!entity.worldObj.isRemote && entity.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) < 0.6D && entity instanceof EntityItem && !entity.isDead) {
List<IInventory> inventories = new ArrayList<IInventory>();
List<Integer> sides = new ArrayList<Integer>();
for (int i = 0; i < 6; i++) {
IInventory inventory = TileEntityHopper.func_145893_b(worldObj, xCoord + Facing.offsetsXForSide[i], yCoord + Facing.offsetsYForSide[i], zCoord + Facing.offsetsZForSide[i]);
if (inventory != null) {
inventories.add(inventory);
sides.add(i);
}
}
// if there isn't a
if (inventories.size() == 0)
continue;
// inventory attached,
// stop handling.
int inventoryIndexSelected = new Random().nextInt(inventories.size());
IInventory inventory = inventories.get(inventoryIndexSelected);
int side = sides.get(inventoryIndexSelected);
side = Facing.oppositeSide[side];
ItemStack leftoverStack = TileEntityHopper.func_145889_a(inventory, ((EntityItem) entity).getEntityItem(), side);
if (leftoverStack == null || leftoverStack.stackSize == 0) {
entity.setDead();
}
} else {
if (!(entity instanceof EntityPlayer) || !((EntityPlayer) entity).capabilities.isCreativeMode) {
Vec3 entityVec = Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ);
MovingObjectPosition trace = worldObj.rayTraceBlocks(entityVec, tileVec);
if (trace != null && trace.blockX == xCoord && trace.blockY == yCoord && trace.blockZ == zCoord) {
double d1 = (entity.posX - xCoord - 0.5D) / d0;
double d2 = (entity.posY - yCoord - 0.5D) / d0;
double d3 = (entity.posZ - zCoord - 0.5D) / d0;
double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
double d5 = 1.0D - d4;
if (d5 > 0.0D) {
d5 *= d5;
if (!vacuum)
d5 *= -1;
entity.motionX -= d1 / d4 * d5 * 0.1D;
entity.motionY -= d2 / d4 * d5 * 0.1D;
entity.motionZ -= d3 / d4 * d5 * 0.1D;
}
}
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class TileEntityElevatorBase method moveEntities.
private void moveEntities(float moveBy) {
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + extension + 1, zCoord + 1);
List<Entity> entityList = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
for (Entity entity : entityList) {
if (entity instanceof EntityPlayer) {
} else
entity.moveEntity(0, moveBy + 0.05F, 0);
}
}
use of net.minecraft.util.AxisAlignedBB in project PneumaticCraft by MineMaarten.
the class TileEntityPneumaticDoorBase method shouldOpen.
private boolean shouldOpen() {
switch(redstoneMode) {
case 0:
case 1:
int range = TileEntityConstants.RANGE_PNEUMATIC_DOOR_BASE + this.getUpgrades(ItemMachineUpgrade.UPGRADE_RANGE);
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1);
List<EntityPlayer> players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, aabb);
for (EntityPlayer player : players) {
if (PneumaticCraftUtils.getProtectingSecurityStations(worldObj, xCoord, yCoord, zCoord, player, false, false) == 0) {
if (redstoneMode == 0) {
return true;
} else {
((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = true;
//max range = range * sqrt(2).
ChunkPosition lookedPosition = PneumaticCraftUtils.getEntityLookedBlock(player, range * 1.41F);
((BlockPneumaticDoor) Blockss.pneumaticDoor).isTrackingPlayerEye = false;
if (lookedPosition != null) {
if (lookedPosition.equals(new ChunkPosition(xCoord, yCoord, zCoord))) {
return true;
} else {
if (door != null) {
if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord, door.zCoord)))
return true;
if (lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord + (door.getBlockMetadata() < 6 ? 1 : -1), door.zCoord)))
return true;
}
}
}
}
}
}
return false;
case 2:
return opening;
}
return false;
}
Aggregations