mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
JEI structure render fixes
This commit is contained in:
@@ -21,7 +21,7 @@ apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = '1.16.5-0.1.55-B' + getVersionNumber()
|
||||
version = '1.16.5-0.1.57-B' + getVersionNumber()
|
||||
group = 'com.ticticboooom.mods.mm' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'MasterfulMachinery'
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ticticboooom.mods.mm.data.MachineStructureRecipe;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureBlockPos;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructurePort;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureRecipeKeyModel;
|
||||
import com.ticticboooom.mods.mm.helper.GLScissor;
|
||||
import com.ticticboooom.mods.mm.helper.RLUtils;
|
||||
import com.ticticboooom.mods.mm.registration.MMLoader;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
@@ -31,6 +32,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector4f;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -51,6 +53,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
private float yRotation = 0;
|
||||
private double yLastMousePosition = 0;
|
||||
private int scrollLastPos = 0;
|
||||
private Vector3f prePos;
|
||||
|
||||
private int sliceY = 0;
|
||||
private boolean slicingActive = false;
|
||||
@@ -116,6 +119,8 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
|
||||
this.variantIndices.clear();
|
||||
this.tickTimer = 0;
|
||||
float tx = 6.75f, ty = -5, tz = 10;
|
||||
prePos = new Vector3f(tx, ty, tz);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +134,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
}
|
||||
|
||||
// Do mouse rotations
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_1) != 0) {
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_1) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == 0) {
|
||||
double relMoveX = mouseX - xLastMousePosition;
|
||||
double relMoveY = mouseY - yLastMousePosition;
|
||||
xRotation += relMoveX;
|
||||
@@ -153,7 +158,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
}
|
||||
|
||||
// Do mouse scroll zoom
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != 0) {
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == 0) {
|
||||
if (scrollLastPos == 0) {
|
||||
scrollLastPos = (int) mouseY;
|
||||
}
|
||||
@@ -172,10 +177,17 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
}
|
||||
|
||||
//float tx = 6.5f, ty = -5, tz = 10;
|
||||
float tx = 6.75f, ty = -5, tz = 10;
|
||||
Vector3f prePos = new Vector3f(tx, ty, tz);
|
||||
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) != 0){
|
||||
double relMoveX = mouseX - xLastMousePosition;
|
||||
double relMoveY = mouseY - yLastMousePosition;
|
||||
prePos.add((float)relMoveX * 0.08f, (float)-relMoveY * 0.08f, 0);
|
||||
}
|
||||
Vector3f offset = new Vector3f(-minX - 0.5f - centreX, -minY - 0.5f - centerY, -minZ - 0.5f + centreZ);
|
||||
|
||||
Vector4f zero = new Vector4f(0, 0, 0, 1);
|
||||
zero.transform(matrixStack.getLast().getMatrix().copy());
|
||||
GLScissor.enable((int)zero.getX(), (int)zero.getY(), 160, 120);
|
||||
// Render the block parts
|
||||
for (MachineStructureRecipeKeyModel part : parts) {
|
||||
this.variantIndices.putIfAbsent(part.getPos(), 0);
|
||||
@@ -252,6 +264,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
renderBlock(defaultState, new BlockPos(0, 0, 0), prePos, offset, matrixStack);
|
||||
}
|
||||
}
|
||||
GLScissor.disable();
|
||||
|
||||
// End tick
|
||||
xLastMousePosition = mouseX;
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
@@ -78,18 +79,18 @@ public class GuiBlockRenderBuilder {
|
||||
}
|
||||
|
||||
private void prepareRender() {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderHelper.setupGui3DDiffuseLighting();
|
||||
RenderSystem.alphaFunc(516, 0.1F);
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// RenderSystem.enableBlend();
|
||||
// RenderSystem.enableRescaleNormal();
|
||||
// RenderSystem.enableAlphaTest();
|
||||
// RenderHelper.setupGui3DDiffuseLighting();
|
||||
// RenderSystem.alphaFunc(516, 0.1F);
|
||||
// RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
// RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private void cleanupRender() {
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
// RenderSystem.disableAlphaTest();
|
||||
// RenderSystem.disableRescaleNormal();
|
||||
}
|
||||
|
||||
public void finalize(MatrixStack ms) {
|
||||
@@ -116,7 +117,11 @@ public class GuiBlockRenderBuilder {
|
||||
ms.push();
|
||||
try {
|
||||
if (ter != null) {
|
||||
ter.render(tile, 1.f, ms, buf, 0xF000F0, OverlayTexture.NO_OVERLAY);
|
||||
MatrixStack isolatedStack = new MatrixStack();
|
||||
isolatedStack.push();
|
||||
isolatedStack.getLast().getMatrix().set(ms.getLast().getMatrix().copy());
|
||||
isolatedStack.getLast().getNormal().set(ms.getLast().getNormal().copy());
|
||||
ter.render(tile, 1.f, isolatedStack, buf, 0xF000F0, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
39
src/main/java/com/ticticboooom/mods/mm/helper/GLScissor.java
Normal file
39
src/main/java/com/ticticboooom/mods/mm/helper/GLScissor.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.ticticboooom.mods.mm.helper;
|
||||
|
||||
//once again robbed kindly from https://github.com/vincentmetevelis/CustomQuests2/blob/1.16.5-2.1.0/src/main/java/com/vincentmet/customquests/helpers/rendering/GLScissor.java Thanks Vince ;)
|
||||
|
||||
|
||||
import net.minecraft.client.*;
|
||||
import net.minecraftforge.api.distmarker.*;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GLScissor{
|
||||
public static void enable(int x, int y, int width, int height){
|
||||
MainWindow mw = Minecraft.getInstance().getMainWindow();
|
||||
double s = mw.getGuiScaleFactor();
|
||||
|
||||
if(width<0)width=0;
|
||||
if(height<0)height=0;
|
||||
if(x<0)x=0;
|
||||
if(y<0)y=0;
|
||||
GL11.glPushMatrix();
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glScissor(
|
||||
(int)(x * s),
|
||||
(int)(mw.getFramebufferHeight() - ((double)(y + height) * s)),
|
||||
(int)(width * s),
|
||||
(int)(height * s)
|
||||
);
|
||||
}
|
||||
|
||||
public static void disable(){
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static boolean isEnabled(){
|
||||
return glIsEnabled(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
#Wed Sep 29 13:34:35 BST 2021
|
||||
VERSION_CODE=798
|
||||
#Thu Oct 21 09:55:37 BST 2021
|
||||
VERSION_CODE=851
|
||||
|
||||
Reference in New Issue
Block a user