use of net.minecraft.profiler.Profiler in project BuildCraft by BuildCraft.
the class RenderHeatExchange method render.
@Override
public void render(TileHeatExchange tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
super.render(tile, x, y, z, partialTicks, destroyStage, alpha);
if (!tile.isStart()) {
return;
}
ExchangeSectionStart section = (ExchangeSectionStart) tile.getSection();
ExchangeSectionEnd sectionEnd = section.getEndSection();
IBlockState state = tile.getCurrentStateForBlock(BCFactoryBlocks.heatExchange);
if (state == null) {
return;
}
Profiler profiler = Minecraft.getMinecraft().mcProfiler;
profiler.startSection("bc");
profiler.startSection("heat_exchange");
int combinedLight = tile.getWorld().getCombinedLight(tile.getPos(), 0);
// gl state setup
RenderHelper.disableStandardItemLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.enableBlend();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
// buffer setup
BufferBuilder bb = Tessellator.getInstance().getBuffer();
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
bb.setTranslation(x, y, z);
profiler.startSection("tank");
EnumFacing face = state.getValue(BlockBCBase_Neptune.PROP_FACING).rotateYCCW();
TankSideData sideTank = TANK_SIDES.get(face);
renderTank(TANK_BOTTOM, section.smoothedTankInput, combinedLight, partialTicks, bb);
renderTank(sideTank.start, section.smoothedTankOutput, combinedLight, partialTicks, bb);
int middles = section.middleCount;
if (sectionEnd != null) {
// TODO: Move this into the other renderer!
BlockPos diff = sectionEnd.tile.getPos().subtract(tile.getPos());
bb.setTranslation(x + diff.getX(), y + diff.getY(), z + diff.getZ());
renderTank(TANK_TOP, sectionEnd.smoothedTankOutput, combinedLight, partialTicks, bb);
renderTank(sideTank.end, sectionEnd.smoothedTankInput, combinedLight, partialTicks, bb);
bb.setTranslation(x, y, z);
}
profiler.endStartSection("flow");
if (middles > 0 && sectionEnd != null) {
EnumProgressState progressState = section.getProgressState();
double progress = section.getProgress(partialTicks);
if (progress > 0) {
double length = middles + 1 - 4 / 16.0 - 0.02;
double p0 = 2 / 16.0 + 0.01;
double p1 = p0 + length - 0.01;
double progressStart = p0;
double progressEnd = p0 + length * progress;
boolean flip = progressState == EnumProgressState.PREPARING;
flip ^= face.getAxisDirection() == AxisDirection.NEGATIVE;
if (flip) {
progressStart = p1 - length * progress;
progressEnd = p1;
}
BlockPos diff = BlockPos.ORIGIN;
if (face.getAxisDirection() == AxisDirection.NEGATIVE) {
diff = diff.offset(face, middles);
}
double otherStart = flip ? p0 : p1 - length * progress;
double otherEnd = flip ? p0 + length * progress : p1;
Vec3d vDiff = new Vec3d(diff).addVector(x, y, z);
renderFlow(vDiff, face, bb, progressStart + 0.01, progressEnd - 0.01, sectionEnd.smoothedTankInput.getFluidForRender(), 4, partialTicks);
renderFlow(vDiff, face.getOpposite(), bb, otherStart, otherEnd, section.smoothedTankInput.getFluidForRender(), 2, partialTicks);
}
}
// buffer finish
bb.setTranslation(0, 0, 0);
profiler.endStartSection("draw");
Tessellator.getInstance().draw();
// gl state finish
RenderHelper.enableStandardItemLighting();
profiler.endSection();
profiler.endSection();
profiler.endSection();
}
use of net.minecraft.profiler.Profiler in project BuildCraft by BuildCraft.
the class FluidRenderer method renderFluid.
/**
* Render's a fluid cuboid to the given vertex buffer. The cube shouldn't cross over any {@literal 0->1} boundary
* (so the cube must be contained within a block).
*
* @param type The type of sprite to use. See {@link FluidSpriteType} for more details.
* @param fluid The stack that represents the fluid to render. Note that the amount from the stack is NOT used.
* @param amount The actual amount of fluid in the stack. Is a "double" rather than an "int" as then you can
* interpolate between frames.
* @param cap The maximum amount of fluid that could be in the stack. Usually the capacity of the tank.
* @param min The minimum coordinate that the tank should be rendered from
* @param max The maximum coordinate that the tank will be rendered to.
* @param bbIn The {@link BufferBuilder} that the fluid will be rendered into.
* @param sideRender A size 6 boolean array that determines if the face will be rendered. If it is null then all
* faces will be rendered. The indexes are determined by what {@link EnumFacing#ordinal()} returns.
*/
public static void renderFluid(FluidSpriteType type, FluidStack fluid, double amount, double cap, Vec3d min, Vec3d max, BufferBuilder bbIn, boolean[] sideRender) {
if (fluid == null || fluid.getFluid() == null || amount <= 0) {
return;
}
Profiler prof = Minecraft.getMinecraft().mcProfiler;
prof.startSection("fluid");
if (sideRender == null) {
sideRender = DEFAULT_FACES;
}
double height = MathHelper.clamp(amount / cap, 0, 1);
final Vec3d realMin, realMax;
if (fluid.getFluid().isGaseous(fluid)) {
realMin = VecUtil.replaceValue(min, Axis.Y, MathUtil.interp(1 - height, min.y, max.y));
realMax = max;
} else {
realMin = min;
realMax = VecUtil.replaceValue(max, Axis.Y, MathUtil.interp(height, min.y, max.y));
}
bb = bbIn;
if (type == null) {
type = FluidSpriteType.STILL;
}
sprite = fluidSprites.get(type).get(fluid.getFluid());
if (sprite == null) {
sprite = Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
}
final double xs = realMin.x;
final double ys = realMin.y;
final double zs = realMin.z;
final double xb = realMax.x;
final double yb = realMax.y;
final double zb = realMax.z;
if (type == FluidSpriteType.FROZEN) {
if (min.x > 1) {
xTexDiff = Math.floor(min.x);
} else if (min.x < 0) {
xTexDiff = Math.floor(min.x);
} else {
xTexDiff = 0;
}
if (min.y > 1) {
yTexDiff = Math.floor(min.y);
} else if (min.y < 0) {
yTexDiff = Math.floor(min.y);
} else {
yTexDiff = 0;
}
if (min.z > 1) {
zTexDiff = Math.floor(min.z);
} else if (min.z < 0) {
zTexDiff = Math.floor(min.z);
} else {
zTexDiff = 0;
}
} else {
xTexDiff = 0;
yTexDiff = 0;
zTexDiff = 0;
}
vertex.colouri(RenderUtil.swapARGBforABGR(fluid.getFluid().getColor(fluid)));
texmap = TexMap.XZ;
// TODO: Enable/disable inversion for the correct faces
invertU = false;
invertV = false;
if (sideRender[EnumFacing.UP.ordinal()]) {
vertex(xs, yb, zb);
vertex(xb, yb, zb);
vertex(xb, yb, zs);
vertex(xs, yb, zs);
}
if (sideRender[EnumFacing.DOWN.ordinal()]) {
vertex(xs, ys, zs);
vertex(xb, ys, zs);
vertex(xb, ys, zb);
vertex(xs, ys, zb);
}
texmap = TexMap.ZY;
if (sideRender[EnumFacing.WEST.ordinal()]) {
vertex(xs, ys, zs);
vertex(xs, ys, zb);
vertex(xs, yb, zb);
vertex(xs, yb, zs);
}
if (sideRender[EnumFacing.EAST.ordinal()]) {
vertex(xb, yb, zs);
vertex(xb, yb, zb);
vertex(xb, ys, zb);
vertex(xb, ys, zs);
}
texmap = TexMap.XY;
if (sideRender[EnumFacing.NORTH.ordinal()]) {
vertex(xs, yb, zs);
vertex(xb, yb, zs);
vertex(xb, ys, zs);
vertex(xs, ys, zs);
}
if (sideRender[EnumFacing.SOUTH.ordinal()]) {
vertex(xs, ys, zb);
vertex(xb, ys, zb);
vertex(xb, yb, zb);
vertex(xs, yb, zb);
}
sprite = null;
texmap = null;
bb = null;
prof.endSection();
}
use of net.minecraft.profiler.Profiler in project BuildCraft by BuildCraft.
the class LaserRenderer_BC8 method renderLaserStatic.
public static void renderLaserStatic(LaserData_BC8 data) {
Profiler profiler = Minecraft.getMinecraft().mcProfiler;
profiler.startSection("compute");
LaserCompiledList compiled = COMPILED_STATIC_LASERS.getUnchecked(data);
profiler.endStartSection("render");
SpriteUtil.bindBlockTextureMap();
compiled.render();
profiler.endSection();
}
use of net.minecraft.profiler.Profiler 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();
}
use of net.minecraft.profiler.Profiler in project EnderIO by SleepyTrousers.
the class ItemTools method move.
// private static void startProfiler(Profiler profiler, @Nonnull String section, String data) {
// if (profiler != null) {
// profiler.startSection("dummy1"); // the profiler ignore categories with less than 3 entries :-(
// profiler.endStartSection("dummy2");
// profiler.endStartSection(section + NullHelper.first(data, "(unknown)"));
// }
// }
//
// private static void endProfiler(Profiler profiler) {
// if (profiler != null) {
// profiler.endSection();
// }
// }
//
public static MoveResult move(@Nonnull Limit limit, @Nonnull IBlockAccess world, @Nonnull BlockPos sourcePos, @Nonnull EnumFacing sourceFacing, @Nonnull BlockPos targetPos, @Nonnull EnumFacing targetFacing) {
if (!limit.canWork()) {
return MoveResult.LIMITED;
}
Profiler profiler = world instanceof World ? ((World) world).profiler : null;
boolean movedSomething = false;
TileEntity source = world.getTileEntity(sourcePos);
if (source != null && source.hasWorld() && !source.getWorld().isRemote && canPullFrom(source, sourceFacing)) {
Prof.start(profiler, "from_", source);
TileEntity target = world.getTileEntity(targetPos);
if (target != null && target.hasWorld() && canPutInto(target, targetFacing)) {
Prof.start(profiler, "to_", target);
IItemHandler sourceHandler = getExternalInventory(world, sourcePos, sourceFacing);
if (sourceHandler != null && hasItems(sourceHandler)) {
IItemHandler targetHandler = getExternalInventory(world, targetPos, targetFacing);
if (targetHandler != null && hasFreeSpace(targetHandler)) {
for (int i = 0; i < sourceHandler.getSlots(); i++) {
ItemStack removable = sourceHandler.extractItem(i, limit.getItems(), true);
if (Prep.isValid(removable)) {
// <---
ItemStack unacceptable = insertItemStacked(targetHandler, removable, true);
int movable = removable.getCount() - unacceptable.getCount();
if (movable > 0) {
ItemStack removed = sourceHandler.extractItem(i, movable, false);
if (Prep.isValid(removed)) {
ItemStack targetRejected = insertItemStacked(targetHandler, removed, false);
if (Prep.isValid(targetRejected)) {
ItemStack sourceRejected = insertItemStacked(sourceHandler, targetRejected, false);
if (Prep.isValid(sourceRejected)) {
EntityItem drop = new EntityItem(source.getWorld(), sourcePos.getX() + 0.5, sourcePos.getY() + 0.5, sourcePos.getZ() + 0.5, sourceRejected);
source.getWorld().spawnEntity(drop);
Prof.stop(profiler, 2);
return MoveResult.MOVED;
}
}
}
movedSomething = true;
limit.useItems(movable);
if (!limit.canWork()) {
Prof.stop(profiler, 2);
return MoveResult.MOVED;
}
}
}
}
} else {
Prof.stop(profiler, 2);
return MoveResult.TARGET_FULL;
}
} else {
Prof.stop(profiler, 2);
return MoveResult.SOURCE_EMPTY;
}
Prof.stop(profiler);
} else {
Prof.stop(profiler);
return MoveResult.TARGET_FULL;
}
Prof.stop(profiler);
} else {
return MoveResult.SOURCE_EMPTY;
}
return movedSomething ? MoveResult.MOVED : MoveResult.NO_ACTION;
}
Aggregations