Search in sources :

Example 1 with MatrixStack

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();
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IMagnifyingGlassInspector(com.infinityraider.agricraft.api.v1.client.IMagnifyingGlassInspector) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with MatrixStack

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));
}
Also used : java.util(java.util) IRecipeCatalystRegistration(mezz.jei.api.registration.IRecipeCatalystRegistration) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) AgriSeason(com.infinityraider.agricraft.api.v1.requirement.AgriSeason) IDrawable(mezz.jei.api.gui.drawable.IDrawable) IIngredients(mezz.jei.api.ingredients.IIngredients) AgriItemRegistry(com.infinityraider.agricraft.content.AgriItemRegistry) AbstractBlock(net.minecraft.block.AbstractBlock) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) Function(java.util.function.Function) ITextComponent(net.minecraft.util.text.ITextComponent) Dist(net.minecraftforge.api.distmarker.Dist) BooleanSupplier(java.util.function.BooleanSupplier) I18n(net.minecraft.client.resources.I18n) ItemStack(net.minecraft.item.ItemStack) ImmutableList(com.google.common.collect.ImmutableList) AgriToolTips(com.infinityraider.agricraft.reference.AgriToolTips) Minecraft(net.minecraft.client.Minecraft) IRecipeCategory(mezz.jei.api.recipe.category.IRecipeCategory) IRecipeRegistration(mezz.jei.api.registration.IRecipeRegistration) IRenderUtilities(com.infinityraider.infinitylib.render.IRenderUtilities) StringTextComponent(net.minecraft.util.text.StringTextComponent) IAgriSoil(com.infinityraider.agricraft.api.v1.requirement.IAgriSoil) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) Nonnull(javax.annotation.Nonnull) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) AgriCraft(com.infinityraider.agricraft.AgriCraft) IAgriPlant(com.infinityraider.agricraft.api.v1.plant.IAgriPlant) ImmutableSet(com.google.common.collect.ImmutableSet) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) GuiUtils(net.minecraftforge.fml.client.gui.GuiUtils) Predicate(java.util.function.Predicate) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Blocks(net.minecraft.block.Blocks) AbstractGui(net.minecraft.client.gui.AbstractGui) IAgriGrowthRequirement(com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement) ResourceLocation(net.minecraft.util.ResourceLocation) VanillaTypes(mezz.jei.api.constants.VanillaTypes) IAgriGrowthRequirement(com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement) IAgriGrowthStage(com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)

Example 3 with MatrixStack

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();
    }
}
Also used : Matrix4f(net.minecraft.util.math.vector.Matrix4f) Matrix3f(net.minecraft.util.math.vector.Matrix3f) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation)

Example 4 with MatrixStack

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);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 5 with MatrixStack

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);
    }
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)6 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 AgriCraft (com.infinityraider.agricraft.AgriCraft)1 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)1 IMagnifyingGlassInspector (com.infinityraider.agricraft.api.v1.client.IMagnifyingGlassInspector)1 IAgriGrowthStage (com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage)1 IAgriPlant (com.infinityraider.agricraft.api.v1.plant.IAgriPlant)1 AgriSeason (com.infinityraider.agricraft.api.v1.requirement.AgriSeason)1 IAgriGrowthRequirement (com.infinityraider.agricraft.api.v1.requirement.IAgriGrowthRequirement)1 IAgriSoil (com.infinityraider.agricraft.api.v1.requirement.IAgriSoil)1 AgriItemRegistry (com.infinityraider.agricraft.content.AgriItemRegistry)1 AgriToolTips (com.infinityraider.agricraft.reference.AgriToolTips)1 IRenderUtilities (com.infinityraider.infinitylib.render.IRenderUtilities)1 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 java.util (java.util)1 BooleanSupplier (java.util.function.BooleanSupplier)1