use of net.minecraft.client.render.Camera in project BlockMeter by ModProg.
the class BlockMeterClient method renderOverlay.
public void renderOverlay(float partialTicks, MatrixStack stack) {
final MinecraftClient client = MinecraftClient.getInstance();
final Camera camera = client.gameRenderer.getCamera();
final Identifier currentDimension = client.player.world.getRegistryKey().getValue();
final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
// MEH! but this seems to be needed to get the first background
// rectangle
client.textRenderer.draw(stack, "XXX", -100, -100, 0);
if (this.active || cfg.showBoxesWhenDisabled)
if (cfg.showOtherUsersBoxes) {
if (otherUsersBoxes != null && otherUsersBoxes.size() > 0) {
this.otherUsersBoxes.forEach((playerText, boxList) -> {
boxList.forEach(box -> box.render(camera, stack, currentDimension, playerText));
});
this.boxes.forEach(box -> {
if (!box.isFinished())
box.render(camera, stack, currentDimension);
});
}
if (!cfg.sendBoxes)
this.boxes.forEach(box -> {
if (box.isFinished())
box.render(camera, stack, currentDimension, client.player.getDisplayName());
else
box.render(camera, stack, currentDimension);
});
} else
this.boxes.forEach(box -> box.render(camera, stack, currentDimension));
}
use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.
the class RenderUtils method matrixFrom.
// -------------------- Utils --------------------
public static MatrixStack matrixFrom(double x, double y, double z) {
MatrixStack matrices = new MatrixStack();
Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera();
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
return matrices;
}
use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.
the class RenderUtilsLiving method drawText.
/**
* Draws text in the world. *
*/
public static void drawText(Text text, double x, double y, double z, double offX, double offY, double scale, boolean fill) {
MatrixStack matrices = matrixFrom(x, y, z);
Camera camera = mc.gameRenderer.getCamera();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
matrices.translate(offX, offY, 0);
matrices.scale(-0.025f * (float) scale, -0.025f * (float) scale, 1);
int halfWidth = mc.textRenderer.getWidth(text) / 2;
VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
if (fill) {
int opacity = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24;
mc.textRenderer.draw(text, -halfWidth, 0f, 553648127, false, matrices.peek().getPositionMatrix(), immediate, true, opacity, 0xf000f0);
immediate.draw();
} else {
matrices.push();
matrices.translate(1, 1, 0);
mc.textRenderer.draw(text.copy(), -halfWidth, 0f, 0x202020, false, matrices.peek().getPositionMatrix(), immediate, true, 0, 0xf000f0);
immediate.draw();
matrices.pop();
}
mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getPositionMatrix(), immediate, true, 0, 0xf000f0);
immediate.draw();
RenderSystem.disableBlend();
}
use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.
the class RenderUtilsLiving method drawGuiItem.
/**
* Draws a 2D gui items somewhere in the world. *
*/
public static void drawGuiItem(double x, double y, double z, double offX, double offY, double scale, ItemStack item) {
if (item.isEmpty()) {
return;
}
MatrixStack matrices = matrixFrom(x, y, z);
Camera camera = mc.gameRenderer.getCamera();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw()));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrices.translate(offX, offY, 0);
matrices.scale((float) scale, (float) scale, 0.001f);
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f));
// mc.getBufferBuilders().getEntityVertexConsumers().draw();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
Vec3f[] currentLight = getCurrentLight();
DiffuseLighting.disableGuiDepthLighting();
mc.getBufferBuilders().getEntityVertexConsumers().draw();
mc.getItemRenderer().renderItem(item, ModelTransformation.Mode.GUI, 0xF000F0, OverlayTexture.DEFAULT_UV, matrices, mc.getBufferBuilders().getEntityVertexConsumers(), 0);
mc.getBufferBuilders().getEntityVertexConsumers().draw();
RenderSystem.setShaderLights(currentLight[0], currentLight[1]);
RenderSystem.disableBlend();
}
use of net.minecraft.client.render.Camera in project Skyblocker by LifeIsAParadox.
the class RenderUtilsLiving method matrixFrom.
public static MatrixStack matrixFrom(double x, double y, double z) {
MatrixStack matrices = new MatrixStack();
Camera camera = mc.gameRenderer.getCamera();
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch()));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F));
matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z);
return matrices;
}
Aggregations