use of net.minecraft.client.render.Camera in project BleachHack by BleachDrinker420.
the class WorldRenderer 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().getModel(), 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().getModel(), immediate, true, 0, 0xf000f0);
immediate.draw();
matrices.pop();
}
mc.textRenderer.draw(text, -halfWidth, 0f, -1, false, matrices.peek().getModel(), immediate, true, 0, 0xf000f0);
immediate.draw();
RenderSystem.disableBlend();
}
use of net.minecraft.client.render.Camera in project BleachHack by BleachDrinker420.
the class WorldRenderer 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;
}
use of net.minecraft.client.render.Camera in project BleachHack by BleachDrinker420.
the class WorldRenderer 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 = shaderLight.clone();
DiffuseLighting.disableGuiDepthLighting();
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 sodium-fabric by CaffeineMC.
the class ChunkGraph method init.
private boolean init(BlockPos blockPos, Camera camera, Vec3d cameraPos, Frustum frustum, int frame, boolean spectator) {
MinecraftClient client = MinecraftClient.getInstance();
ObjectArrayFIFOQueue<ChunkGraphNode<T>> queue = this.iterationQueue;
boolean cull = client.chunkCullingEnabled;
ChunkGraphNode<T> node = this.getOrCreateNode(blockPos);
if (node != null) {
node.reset();
// Player is within bounds and inside a node
Set<Direction> openFaces = this.getOpenChunkFaces(blockPos);
if (openFaces.size() == 1) {
Vector3f vector3f = camera.getHorizontalPlane();
Direction direction = Direction.getFacing(vector3f.getX(), vector3f.getY(), vector3f.getZ()).getOpposite();
openFaces.remove(direction);
}
if (openFaces.isEmpty() && !spectator) {
this.visibleNodes.add(node);
} else {
if (spectator && this.world.getBlockState(blockPos).isFullOpaque(this.world, blockPos)) {
cull = false;
}
node.setRebuildFrame(frame);
queue.enqueue(node);
}
} else {
// Player is out-of-bounds
int y = blockPos.getY() > 0 ? 248 : 8;
int x = MathHelper.floor(cameraPos.x / 16.0D) * 16;
int z = MathHelper.floor(cameraPos.z / 16.0D) * 16;
List<ChunkGraphNode<T>> list = Lists.newArrayList();
for (int x2 = -this.renderDistance; x2 <= this.renderDistance; ++x2) {
for (int z2 = -this.renderDistance; z2 <= this.renderDistance; ++z2) {
ChunkGraphNode<T> chunk = this.getOrCreateNode(new BlockPos(x + (x2 << 4) + 8, y, z + (z2 << 4) + 8));
if (chunk == null) {
continue;
}
if (frustum.isVisible(chunk.getBoundingBox())) {
chunk.setRebuildFrame(frame);
chunk.reset();
list.add(chunk);
}
}
}
list.sort(Comparator.comparingDouble(o -> blockPos.getSquaredDistance(o.chunk.getOrigin().add(8, 8, 8))));
for (ChunkGraphNode<T> n : list) {
queue.enqueue(n);
}
}
return cull;
}
use of net.minecraft.client.render.Camera in project ImmersivePortalsMod by qouteall.
the class MyRenderHelper method setupCameraTransformation.
public static void setupCameraTransformation() {
MinecraftClient mc = MinecraftClient.getInstance();
// rendering post processing shader may change view port
if (OFInterface.isShaders.getAsBoolean()) {
// Shaders.setViewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
} else {
GlStateManager.viewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
}
((IEGameRenderer) PortalRenderer.mc.gameRenderer).applyCameraTransformations_(partialTicks);
Camera camera = PortalRenderer.mc.gameRenderer.getCamera();
camera.update(PortalRenderer.mc.world, (Entity) (PortalRenderer.mc.getCameraEntity() == null ? PortalRenderer.mc.player : PortalRenderer.mc.getCameraEntity()), PortalRenderer.mc.options.perspective > 0, PortalRenderer.mc.options.perspective == 2, partialTicks);
}
Aggregations