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 @Override
public void draw(SandPaperPolishingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) { public void draw(SandPaperPolishingRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
matrixStack.push();
AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 28); AllGuiTextures.JEI_SLOT.draw(matrixStack, 26, 28);
getRenderedSlot(recipe, 0).draw(matrixStack, 131, 28); getRenderedSlot(recipe, 0).draw(matrixStack, 131, 28);
AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 21); AllGuiTextures.JEI_SHADOW.draw(matrixStack, 61, 21);
@ -65,7 +66,7 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
if (matchingStacks.length == 0) if (matchingStacks.length == 0)
return; return;
matrixStack.push();
CompoundNBT tag = renderedSandpaper.getOrCreateTag(); CompoundNBT tag = renderedSandpaper.getOrCreateTag();
tag.put("Polishing", matchingStacks[0].serializeNBT()); tag.put("Polishing", matchingStacks[0].serializeNBT());
tag.putBoolean("JEI", true); 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.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.item.crafting.IRecipe; 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> { public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends CreateRecipeCategory<T> {
@ -30,7 +32,7 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
} }
@Override @Override
public void setRecipe(IRecipeLayout recipeLayout, T recipe, IIngredients ingredients) { public void setRecipe(IRecipeLayout recipeLayout, T recipe, @Nullable IIngredients ingredients) {
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
itemStacks.init(0, true, 20, 47); itemStacks.init(0, true, 20, 47);
itemStacks.set(0, Arrays.asList(recipe.getIngredients() itemStacks.set(0, Arrays.asList(recipe.getIngredients()
@ -50,12 +52,14 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
} }
@Override @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); renderWidgets(matrixStack, recipe, mouseX, mouseY);
matrixStack.push(); matrixStack.push();
matrixStack.translate(56, 33, 0); matrixStack.translate(56, 33, 0);
matrixStack.multiply(new Quaternion( -12.5f, 1, 0, 0)); matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-12.5f));
matrixStack.multiply(new Quaternion( 22.5f, 0, 1, 0)); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 24; int scale = 24;
GuiGameElement.of(AllBlockPartials.ENCASED_FAN_INNER) 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 com.simibubi.create.foundation.gui.GuiGameElement;
import mezz.jei.api.gui.drawable.IDrawable; 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 { public class AnimatedBlazeBurner implements IDrawable {
@ -21,8 +21,8 @@ public class AnimatedBlazeBurner implements IDrawable {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
matrixStack.push(); matrixStack.push();
matrixStack.translate(xOffset, yOffset, 200); matrixStack.translate(xOffset, yOffset, 200);
matrixStack.multiply(new Quaternion(-15.5f, 1, 0, 0)); matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f));
matrixStack.multiply(new Quaternion(22.5f, 0, 1, 0)); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 23; int scale = 23;
GuiGameElement.of(AllBlocks.BLAZE_BURNER.getDefaultState()) 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.block.BlockState;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction.Axis; 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 { public class AnimatedCrushingWheels extends AnimatedKinetics {
@ -16,8 +16,7 @@ public class AnimatedCrushingWheels extends AnimatedKinetics {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
RenderSystem.enableDepthTest(); RenderSystem.enableDepthTest();
matrixStack.translate(xOffset, yOffset, 100); matrixStack.translate(xOffset, yOffset, 100);
matrixStack.multiply(new Quaternion(-22.5f, 0, 1, 0)); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-22.5f));
// RenderSystem.rotatef(-22.5f, 0, 1, 0);
int scale = 22; int scale = 22;
BlockState wheel = AllBlocks.CRUSHING_WHEEL.get() 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 com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.util.math.MathHelper; 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 { public class AnimatedMixer extends AnimatedKinetics {
@ -15,8 +15,8 @@ public class AnimatedMixer extends AnimatedKinetics {
public void draw(MatrixStack matrixStack, int xOffset, int yOffset) { public void draw(MatrixStack matrixStack, int xOffset, int yOffset) {
matrixStack.push(); matrixStack.push();
matrixStack.translate(xOffset, yOffset, 200); matrixStack.translate(xOffset, yOffset, 200);
matrixStack.multiply(new Quaternion(-15.5f, 1, 0, 0)); matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-15.5f));
matrixStack.multiply(new Quaternion( 22.5f, 0, 1, 0)); matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(22.5f));
int scale = 23; int scale = 23;
GuiGameElement.of(cogwheel()) GuiGameElement.of(cogwheel())

View file

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

View file

@ -71,9 +71,9 @@ public class SandPaperItemRenderer extends ItemStackTileEntityRenderer {
if (itemInUseCount > 0) { if (itemInUseCount > 0) {
int modifier = leftHand ? -1 : 1; int modifier = leftHand ? -1 : 1;
ms.translate(modifier * .5f, 0, -.25f); ms.translate(modifier * .5f, 0, -.25f);
ms.multiply(new Quaternion(modifier * 40, 0, 0, 1)); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(modifier * 40));
ms.multiply(new Quaternion(modifier * 10, 1, 0, 0)); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(modifier * 10));
ms.multiply(new Quaternion(modifier * 90, 0, 1, 0)); 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.CompoundNBT;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.Hand; 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.ITextComponent;
import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
@ -142,7 +142,7 @@ public class ZapperScreen extends AbstractSimiScreen {
protected void renderBlock(MatrixStack matrixStack) { protected void renderBlock(MatrixStack matrixStack) {
matrixStack.push(); matrixStack.push();
matrixStack.translate(guiLeft + 7f, guiTop + 43.5f, 120); 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); matrixStack.scale(20, 20, 20);
BlockState state = Blocks.AIR.getDefaultState(); BlockState state = Blocks.AIR.getDefaultState();

View file

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