use of buildcraft.builders.tile.TileQuarry in project BuildCraft by BuildCraft.
the class BlockQuarry method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileQuarry) {
for (BlockPos blockPos : ((TileQuarry) tile).framePoses) {
if (world.getBlockState(blockPos).getBlock() == BCBuildersBlocks.frame) {
world.setBlockToAir(blockPos);
}
}
}
super.breakBlock(world, pos, state);
}
use of buildcraft.builders.tile.TileQuarry in project BuildCraft by BuildCraft.
the class AdvDebuggerQuarry method render.
@Override
public void render(EntityPlayer player, float partialTicks) {
TileQuarry tile = tileReference.get();
if (tile == null || !tile.frameBox.isInitialized()) {
return;
}
List<ChunkPos> chunkPoses = new ArrayList<>(ChunkLoaderManager.getChunksToLoad(tile));
chunkPoses.sort(Comparator.comparingDouble(chunkPos -> -player.getPositionEyes(partialTicks).distanceTo(new Vec3d(chunkPos.getXStart() + 0.5 + (chunkPos.getXEnd() - chunkPos.getXStart()) / 2, player.getPositionEyes(partialTicks).y, chunkPos.getZStart() + 0.5 + (chunkPos.getZEnd() - chunkPos.getZStart()) / 2))));
GlStateManager.enableBlend();
BufferBuilder bb = Tessellator.getInstance().getBuffer();
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
for (ChunkPos chunkPos : chunkPoses) {
DebugRenderHelper.renderAABB(bb, new AxisAlignedBB(chunkPos.getXStart() + 0.5D, tile.frameBox.min().getY() + 0.5D, chunkPos.getZStart() + 0.5D, chunkPos.getXEnd() + 0.5D, tile.frameBox.max().getY() + 0.5D, chunkPos.getZEnd() + 0.5D), COLOUR_CHUNK);
}
Tessellator.getInstance().draw();
GlStateManager.disableBlend();
}
use of buildcraft.builders.tile.TileQuarry in project BuildCraft by BuildCraft.
the class RenderQuarry method render.
@Override
public void render(TileQuarry tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Profiler profiler = Minecraft.getMinecraft().mcProfiler;
profiler.startSection("bc");
profiler.startSection("quarry");
profiler.startSection("setup");
SpriteUtil.bindBlockTextureMap();
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend();
GlStateManager.enableCull();
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
GlStateManager.pushMatrix();
GlStateManager.translate(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
final BlockPos min = tile.frameBox.min();
final BlockPos max = tile.frameBox.max();
profiler.endSection();
if (tile.frameBox.isInitialized()) {
double yOffset = 1 + 4 / 16D;
profiler.startSection("laser");
if (tile.currentTask != null && tile.currentTask instanceof TileQuarry.TaskBreakBlock) {
TileQuarry.TaskBreakBlock taskBreakBlock = (TileQuarry.TaskBreakBlock) tile.currentTask;
BlockPos pos = taskBreakBlock.breakPos;
if (tile.drillPos == null) {
if (taskBreakBlock.clientPower != 0) {
// Don't render a laser before we have any power
Vec3d from = VecUtil.convertCenter(tile.getPos());
Vec3d to = VecUtil.convertCenter(pos);
LaserData_BC8 laser = new LaserData_BC8(LASER, from, to, 1 / 16.0);
LaserRenderer_BC8.renderLaserStatic(laser);
}
} else {
long power = (long) (taskBreakBlock.prevClientPower + (taskBreakBlock.clientPower - taskBreakBlock.prevClientPower) * (double) partialTicks);
AxisAlignedBB aabb = tile.getWorld().getBlockState(pos).getBoundingBox(tile.getWorld(), pos);
double value = (double) power / taskBreakBlock.getTarget();
if (value < 0.9) {
value = 1 - value / 0.9;
} else {
value = (value - 0.9) / 0.1;
}
double scaleMin = 1 - (1 - aabb.maxY) - (aabb.maxY - aabb.minY) / 2;
double scaleMax = 1 + 4 / 16D;
yOffset = scaleMin + value * (scaleMax - scaleMin);
}
}
profiler.endStartSection("frame");
if (tile.clientDrillPos != null && tile.prevClientDrillPos != null) {
Vec3d interpolatedPos = tile.prevClientDrillPos.add(tile.clientDrillPos.subtract(tile.prevClientDrillPos).scale(partialTicks));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
FRAME, //
new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z), //
new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, max.getZ() + 12 / 16D), 1 / 16D, true, true, 0));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
FRAME, //
new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z), //
new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, min.getZ() + 4 / 16D), 1 / 16D, true, true, 0));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
FRAME, //
new Vec3d(interpolatedPos.x, max.getY() + 0.5, interpolatedPos.z + 0.5), //
new Vec3d(max.getX() + 12 / 16D, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
FRAME, //
new Vec3d(interpolatedPos.x, max.getY() + 0.5, interpolatedPos.z + 0.5), //
new Vec3d(min.getX() + 4 / 16D, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
FRAME_BOTTOM, //
new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + 1 + 4 / 16D, interpolatedPos.z + 0.5), //
new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
LaserRenderer_BC8.renderLaserStatic(new //
LaserData_BC8(//
DRILL, //
new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + 1 + yOffset, interpolatedPos.z + 0.5), //
new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + yOffset, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
} else {
LaserBoxRenderer.renderLaserBoxStatic(tile.frameBox, BuildCraftLaserManager.STRIPES_WRITE, true);
}
profiler.endSection();
}
GlStateManager.popMatrix();
profiler.startSection("items");
if (tile.frameBox.isInitialized() && false) {
TileQuarry.TaskAddFrame currentTask = (TileQuarry.TaskAddFrame) tile.currentTask;
int index = tile.framePoses.indexOf(currentTask.framePos);
if (index > 1) {
double progress = (double) currentTask.power / currentTask.getTarget() * (index - 1) / tile.framePoses.size();
double progress1 = //
(progress >= 0 && progress <= 0.25) ? //
progress * 4 : //
(progress >= 0.25 && progress <= 0.5) ? //
1 : //
(progress >= 0.5 && progress <= 0.75) ? //
1 - (progress - 0.5) * 4 : (progress >= 0.75 && progress <= 1) ? 0 : -1;
double progress2 = (progress >= 0 && progress <= 0.25) ? 1 : (progress >= 0.25 && progress <= 0.5) ? 1 - (progress - 0.25) * 4 : (progress >= 0.5 && progress <= 0.75) ? 0 : (progress >= 0.75 && progress <= 1) ? (progress - 0.75) * 4 : -1;
double xProgress = -1;
double zProgress = -1;
EnumFacing side = tile.getWorld().getBlockState(tile.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
BlockPos firstPos = tile.getPos().offset(side);
switch(side) {
case SOUTH:
if (firstPos.getX() == min.getX()) {
xProgress = 1 - progress2;
zProgress = progress1;
} else {
xProgress = progress2;
zProgress = progress1;
}
break;
case WEST:
if (firstPos.getZ() == min.getZ()) {
xProgress = 1 - progress1;
zProgress = 1 - progress2;
} else {
xProgress = 1 - progress1;
zProgress = progress2;
}
break;
case NORTH:
if (firstPos.getX() == min.getX()) {
xProgress = 1 - progress2;
zProgress = 1 - progress1;
} else {
xProgress = progress2;
zProgress = 1 - progress1;
}
break;
case EAST:
if (firstPos.getZ() == min.getZ()) {
xProgress = progress1;
zProgress = 1 - progress2;
} else {
xProgress = progress1;
zProgress = progress2;
}
break;
}
double xResult = min.getX() + (max.getX() - min.getX()) * xProgress;
double zResult = min.getZ() + (max.getZ() - min.getZ()) * zProgress;
ItemStack stack = new ItemStack(BCBuildersBlocks.frame);
RenderHelper.disableStandardItemLighting();
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.disableTexture2D();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
GlStateManager.pushMatrix();
GlStateManager.translate(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
GlStateManager.pushMatrix();
GlStateManager.translate(xResult + 0.5, tile.getPos().getY(), zResult + 0.5);
GlStateManager.scale(3, 3, 3);
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
}
}
RenderHelper.enableStandardItemLighting();
profiler.endSection();
profiler.endSection();
profiler.endSection();
}
Aggregations