use of com.mojang.blaze3d.matrix.MatrixStack in project AgriCraft by AgriCraft.
the class MagnifyingGlassViewHandler method inspectionRender.
@SubscribeEvent
@SuppressWarnings("unused")
public void inspectionRender(RenderWorldLastEvent event) {
// Check if the player is in first person
if (!Minecraft.getInstance().gameSettings.getPointOfView().func_243192_a()) {
return;
}
// Check if an inspection renderer is present and cache it (another thread might set it to null)
IMagnifyingGlassInspector inspector = this.inspector;
if (inspector == null) {
return;
}
// Check if the inspector has a target and cache (another thread might set it to null)
Target target = this.lastTarget;
if (target == null) {
return;
}
// Fetch and push matrix to the matrix stack
MatrixStack transforms = event.getMatrixStack();
transforms.push();
// Correct for render view
Vector3d projectedView = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
transforms.translate(-projectedView.x, -projectedView.y, -projectedView.z);
// Move to the player's eye position
Vector3d eyes = this.getPlayer().getEyePosition(event.getPartialTicks());
transforms.translate(eyes.getX(), eyes.getY(), eyes.getZ());
// Fetch the player's target
Vector3d hit = target.getTargetVector(event.getPartialTicks());
Vector3d view = hit.subtract(eyes).normalize();
// Translate offset
transforms.translate(GENOME_OFFSET * view.getX(), GENOME_OFFSET * view.getY(), GENOME_OFFSET * view.getZ());
// Fetch player look orientation;
float yaw = (float) (Math.PI * this.getPlayer().getYaw(event.getPartialTicks())) / 180;
float pitch = (float) (Math.PI * this.getPlayer().getPitch(event.getPartialTicks())) / 180;
// Rotate for yaw
transforms.rotate(Vector3f.YP.rotation(-yaw));
// Render
transforms.push();
inspector.doInspectionRender(transforms, event.getPartialTicks(), target.getTargetEntity());
transforms.pop();
// Pop last transformation matrix from the stack
transforms.pop();
}
use of com.mojang.blaze3d.matrix.MatrixStack in project AgriCraft by AgriCraft.
the class AgriRecipeCategoryGrowthRequirements method draw.
@Override
public void draw(@Nonnull IAgriPlant plant, @Nonnull MatrixStack transforms, double mouseX, double mouseY) {
// Fetch strength and stage
PlantRenderState state = this.getState(plant);
int strength = state.getStrength();
IAgriGrowthStage stage = state.getStage();
IAgriGrowthRequirement req = plant.getGrowthRequirement(stage);
// Tell the renderer to render with a custom growth stage
AgriIngredientPlant.RENDERER.useGrowthStageForNextRenderCall(plant, stage);
// Draw increments
IncrementRenderer.getInstance().renderStrengthIncrements(transforms, strength);
IncrementRenderer.getInstance().renderGrowthStageIncrements(transforms, stage);
// Draw light levels
LightLevelRenderer.getInstance().renderLightLevels(transforms, 32, 26, mouseX, mouseY, light -> req.getLightLevelResponse(light, strength).isFertile());
// Draw Property icons
Arrays.stream(IAgriSoil.Humidity.values()).filter(IAgriSoil.Humidity::isValid).filter(humidity -> req.getSoilHumidityResponse(humidity, strength).isFertile()).forEach(humidity -> SoilPropertyIconRenderer.getInstance().drawHumidityIcon(humidity, transforms, 37, 83, mouseX, mouseY));
Arrays.stream(IAgriSoil.Acidity.values()).filter(IAgriSoil.Acidity::isValid).filter(acidity -> req.getSoilAcidityResponse(acidity, strength).isFertile()).forEach(acidity -> SoilPropertyIconRenderer.getInstance().drawAcidityIcon(acidity, transforms, 37, 96, mouseX, mouseY));
Arrays.stream(IAgriSoil.Nutrients.values()).filter(IAgriSoil.Nutrients::isValid).filter(nutrients -> req.getSoilNutrientsResponse(nutrients, strength).isFertile()).forEach(nutrients -> SoilPropertyIconRenderer.getInstance().drawNutrientsIcon(nutrients, transforms, 37, 109, mouseX, mouseY));
// Draw seasons
SeasonRenderer.getInstance().renderSeasons(transforms, 17, 24, season -> req.getSeasonResponse(season, strength).isFertile());
// Draw buttons
state.updateStageButtons(102, 10);
state.updateStrengthButtons(114, 10);
state.drawGrowthStageButtons(transforms, mouseX, mouseY);
state.drawStrengthButtons(transforms, mouseX, mouseY);
// Draw tooltips
this.tooltips.forEach(tooltip -> tooltip.drawTooltip(transforms, mouseX, mouseY, state));
}
use of com.mojang.blaze3d.matrix.MatrixStack in project BluePower by Qmunity.
the class RenderHelper method drawColoredCube.
/**
* Draws a colored cube with the size of vector. All faces have the specified color. This uses OpenGL
*
* @author Koen Beckers (K4Unl) and Amadornes
* @param vector
*/
public static void drawColoredCube(AxisAlignedBB vector, IVertexBuilder vertexBuilder, MatrixStack matrixStack, int r, int g, int b, int a, int light, boolean... renderFaces) {
MatrixStack.Entry entry = matrixStack.last();
Matrix4f positionMatrix = entry.pose();
Matrix3f normalMatrix = entry.normal();
TextureAtlasSprite sprite = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation("minecraft:white_concrete", "")).getParticleIcon();
float minU = sprite.getU0();
float maxU = sprite.getU1();
float minV = sprite.getV0();
float maxV = sprite.getV1();
// Top side
if (renderFaces.length < 1 || renderFaces[0]) {
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
}
// Bottom side
if (renderFaces.length < 2 || renderFaces[1]) {
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
}
// Draw west side:
if (renderFaces.length < 3 || renderFaces[5]) {
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
}
// Draw east side:
if (renderFaces.length < 4 || renderFaces[4]) {
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
}
// Draw north side
if (renderFaces.length < 5 || renderFaces[3]) {
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
}
// Draw south side
if (renderFaces.length < 6 || renderFaces[2]) {
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
}
}
use of com.mojang.blaze3d.matrix.MatrixStack in project NetherEx by LogicTechCorp.
the class RenderEventHandler method onRenderLivingPost.
@SubscribeEvent
public static void onRenderLivingPost(RenderLivingEvent.Post<?, ?> event) {
MatrixStack matrixStack = event.getMatrixStack();
IRenderTypeBuffer renderTypeBuffer = event.getBuffers();
LivingEntity entity = event.getEntity();
if (entity.isPotionActive(NetherExEffects.FIRE_BURNING.get())) {
renderThirdPersonBlueFire(matrixStack, renderTypeBuffer, entity);
}
}
use of com.mojang.blaze3d.matrix.MatrixStack in project NetherEx by LogicTechCorp.
the class RenderEventHandler method onRenderSpecificHand.
@SubscribeEvent
public static void onRenderSpecificHand(RenderHandEvent event) {
PlayerEntity player = MINECRAFT.player;
MatrixStack matrixStack = event.getMatrixStack();
if (player != null && player.isPotionActive(NetherExEffects.FIRE_BURNING.get())) {
renderFirstPersonBlueFire(matrixStack);
}
}
Aggregations