Fix matrix stack rotations

This commit is contained in:
grimmauld 2020-10-04 15:39:32 +02:00
parent eda8bfd0a1
commit 33b8d2bd85
10 changed files with 44 additions and 48 deletions

View file

@ -55,6 +55,7 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
@Override
public void draw(SandPaperPolishingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
matrixStack.push();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 28);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 28);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 21);
@ -65,7 +66,7 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
if (matchingStacks.length == 0)
return;
matrixStack.push();
CompoundNBT tag = renderedSandpaper.getOrCreateTag();
tag.put("Polishing", matchingStacks[0].serializeNBT());
tag.putBoolean("JEI", true);

View file

@ -15,7 +15,9 @@ import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import javax.annotation.Nullable;
public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends CreateRecipeCategory<T> {
@ -30,7 +32,7 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, T recipe, IIngredients ingredients) {
public void setRecipe(IRecipeLayout recipeLayout, T recipe, @Nullable IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 20, 47);
itemStacks.set(0, Arrays.asList(recipe.getIngredients()
@ -50,12 +52,14 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
}
@Override
public void draw(T recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
public void draw(@Nullable T recipe, @Nullable MatrixStack matrixStack, double mouseX, double mouseY) {
if (matrixStack == null)
return;
renderWidgets(matrixStack, recipe, mouseX, mouseY);
matrixStack.push();
matrixStack.translate(56, 33, 0);
matrixStack.multiply(new Quaternion( -12.5f, 1, 0, 0));
matrixStack.multiply(new Quaternion( 22.5f, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-12.5f));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 24;
GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER)

View file

@ -7,7 +7,7 @@ import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlo
import com.simibubi.create.foundation.gui.GuiGameElement;
import mezz.jei.api.gui.drawable.IDrawable;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class AnimatedBlazeBurner implements IDrawable {
@ -21,8 +21,8 @@ public class AnimatedBlazeBurner implements IDrawable {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
matrixStack.push();
matrixStack.translate(xOffset, yOffset, 200);
matrixStack.multiply(new Quaternion(-15.5f, 1, 0, 0));
matrixStack.multiply(new Quaternion(22.5f, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 23;
GuiGameElement.of(AllBlocks.BLAZE_BURNER.getDefaultState())

View file

@ -8,7 +8,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import net.minecraft.block.BlockState;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class AnimatedCrushingWheels extends AnimatedKinetics {
@ -16,8 +16,7 @@ public class AnimatedCrushingWheels extends AnimatedKinetics {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
RenderSystem.enableDepthTest();
matrixStack.translate(xOffset, yOffset, 100);
matrixStack.multiply(new Quaternion(-22.5f, 0, 1, 0));
// RenderSystem.rotatef(-22.5f, 0, 1, 0);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f));
int scale = 22;
BlockState wheel = AllBlocks.CRUSHING_WHEEL.get()

View file

@ -7,7 +7,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class AnimatedMixer extends AnimatedKinetics {
@ -15,8 +15,8 @@ public class AnimatedMixer extends AnimatedKinetics {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
matrixStack.push();
matrixStack.translate(xOffset, yOffset, 200);
matrixStack.multiply(new Quaternion(-15.5f, 1, 0, 0));
matrixStack.multiply(new Quaternion( 22.5f, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 23;
GuiGameElement.of(cogwheel())

View file

@ -9,7 +9,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class AnimatedPress extends AnimatedKinetics {
@ -23,8 +23,8 @@ public class AnimatedPress extends AnimatedKinetics {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
matrixStack.push();
matrixStack.translate(xOffset, yOffset, 100);
matrixStack.multiply(new Quaternion( -15.5f, 1, 0, 0));
matrixStack.multiply(new Quaternion( 22.5f, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = basin ? 20 : 24;
GuiGameElement.of(shaft(Axis.Z))

View file

@ -8,7 +8,7 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
public class AnimatedSaw extends AnimatedKinetics {
@ -20,8 +20,8 @@ public class AnimatedSaw extends AnimatedKinetics {
matrixStack.translate(0, 0, 200);
matrixStack.translate(-6, 19, 0);
matrixStack.multiply(new Quaternion( -22.5f, 1, 0, 0));
matrixStack.multiply(new Quaternion(90 - 22.5f, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-22.5f));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90-225f));
int scale = 25;
GuiGameElement.of(shaft(Axis.X))

View file

@ -71,9 +71,9 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
if (itemInUseCount > 0) {
int modifier = leftHand ? -1 : 1;
ms.translate(modifier * .5f, 0, -.25f);
ms.multiply(new Quaternion(modifier * 40, 0, 0, 1));
ms.multiply(new Quaternion(modifier * 10, 1, 0, 0));
ms.multiply(new Quaternion(modifier * 90, 0, 1, 0));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(modifier * 40));
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(modifier * 10));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(modifier * 90));
}
}

View file

@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.Hand;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@ -142,7 +142,7 @@ public class ZapperScreen extends AbstractSimiScreen {
protected void renderBlock(MatrixStack matrixStack) {
matrixStack.push();
matrixStack.translate(guiLeft + 7f, guiTop + 43.5f, 120);
matrixStack.multiply(new Quaternion( -30f, .5f, .9f, -.1f));
matrixStack.multiply(new Vector3f(.5f, .9f, -.1f).getDegreesQuaternion(-30f));
matrixStack.scale(20, 20, 20);
BlockState state = Blocks.AIR.getDefaultState();

View file

@ -1,5 +1,6 @@
package com.simibubi.create.foundation.gui;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.mojang.blaze3d.matrix.MatrixStack;
@ -35,8 +36,8 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraftforge.client.model.data.EmptyModelData;
@ -115,16 +116,8 @@ public class GuiGameElement {
public abstract void render(MatrixStack matrixStack);
protected void prepare() {
RenderSystem.pushMatrix();
RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest();
RenderHelper.enableGuiDepthLighting();
RenderSystem.alphaFunc(516, 0.1F);
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@Deprecated
protected void prepare() {}
protected void prepareMatrix(MatrixStack matrixStack) {
matrixStack.push();
@ -137,6 +130,7 @@ public class GuiGameElement {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@Deprecated
protected void transform() {
RenderSystem.translated(xBeforeScale, yBeforeScale, 0);
RenderSystem.scaled(scale, scale, scale);
@ -155,17 +149,14 @@ public class GuiGameElement {
matrixStack.translate(x, y, z);
matrixStack.scale(1, -1, 1);
matrixStack.translate(rotationOffset.x, rotationOffset.y, rotationOffset.z);
matrixStack.multiply(new Quaternion((float) zRot, 0, 0, 1));
matrixStack.multiply(new Quaternion((float) xRot, 1, 0, 0));
matrixStack.multiply(new Quaternion((float) yRot, 0, 1, 0));
matrixStack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion((float) zRot));
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion((float) xRot));
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((float) yRot));
matrixStack.translate(-rotationOffset.x, -rotationOffset.y, -rotationOffset.z);
}
protected void cleanUp() {
RenderSystem.popMatrix();
RenderSystem.disableAlphaTest();
RenderSystem.disableRescaleNormal();
}
@Deprecated
protected void cleanUp() {}
protected void cleanUpMatrix(MatrixStack matrixStack) {
matrixStack.pop();
@ -259,8 +250,8 @@ public class GuiGameElement {
ms.push();
ms.translate(.5, .5, .5);
ms.multiply(new Quaternion(AngleHelper.horizontalAngle(d), 0, 1, 0));
ms.multiply(new Quaternion(AngleHelper.verticalAngle(d) - 90, 0, 0, 1));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(AngleHelper.horizontalAngle(d)));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(AngleHelper.verticalAngle(d) - 90));
ms.translate(-.5, -.5, -.5);
blockRenderer.renderFluid(new BlockPos(0, 1, 0), renderWorld, vb, blockState.getFluidState());
buffer.draw(type);
@ -315,11 +306,12 @@ public class GuiGameElement {
}
@Override
public int getLightLevel(LightType p_226658_1_, BlockPos p_226658_2_) {
public int getLightLevel(@Nullable LightType p_226658_1_, @Nullable BlockPos p_226658_2_) {
return 15;
}
@Override
@Nonnull
public BlockState getBlockState(BlockPos pos) {
return Blocks.AIR.getDefaultState();
}