Fixes Z fighting on the storage monitor and adds a flat look for items displayed on it. Fixes #2768
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
### 1.9.13
|
||||
|
||||
- Fixed count on Storage Monitor having Z fighting (tivec)
|
||||
- Fixed items on Storage Monitor not being flat (raoulvdberge)
|
||||
- Removed experimental pipeline nagging message (raoulvdberge)
|
||||
- Fixed crash when using an External Storage on a fluid inventory (jeremiahwinsley)
|
||||
- Added some performance improvements for autocrafting (necauqua, Darkere)
|
||||
|
@@ -1,17 +1,20 @@
|
||||
package com.refinedmods.refinedstorage.render.tesr;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.block.StorageMonitorBlock;
|
||||
import com.refinedmods.refinedstorage.tile.StorageMonitorTile;
|
||||
import com.refinedmods.refinedstorage.tile.config.IType;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -22,6 +25,7 @@ import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
@@ -71,9 +75,9 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
||||
|
||||
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
||||
matrixStack.translate(
|
||||
((float) direction.getXOffset() * 0.5F) + (direction.getZOffset() * stringOffset),
|
||||
-0.275,
|
||||
((float) direction.getZOffset() * 0.5F) - (direction.getXOffset() * stringOffset)
|
||||
((float) direction.getXOffset() * 0.501F) + (direction.getZOffset() * stringOffset),
|
||||
-0.275,
|
||||
((float) direction.getZOffset() * 0.501F) - (direction.getXOffset() * stringOffset)
|
||||
);
|
||||
|
||||
matrixStack.rotate(TransformationHelper.quatFromXYZ(new Vector3f(direction.getXOffset() * 180, 0, direction.getZOffset() * 180), true));
|
||||
@@ -82,16 +86,16 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
||||
matrixStack.scale(0.01F, 0.01F, 0.01F);
|
||||
|
||||
Minecraft.getInstance().fontRenderer.renderString(
|
||||
amount,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
false,
|
||||
matrixStack.getLast().getMatrix(),
|
||||
renderTypeBuffer,
|
||||
false,
|
||||
0,
|
||||
light
|
||||
amount,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
false,
|
||||
matrixStack.getLast().getMatrix(),
|
||||
renderTypeBuffer,
|
||||
false,
|
||||
0,
|
||||
light
|
||||
);
|
||||
|
||||
matrixStack.pop();
|
||||
@@ -101,19 +105,36 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
||||
private void renderItem(MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, Direction direction, float rotation, int light, ItemStack itemStack) {
|
||||
matrixStack.push();
|
||||
|
||||
// Put it in the middle, outwards, and facing the correct direction
|
||||
matrixStack.translate(0.5D, 0.5D, 0.5D);
|
||||
matrixStack.translate((float) direction.getXOffset() * 0.5F, 0, (float) direction.getZOffset() * 0.5F);
|
||||
matrixStack.translate((float) direction.getXOffset() * 0.501F, 0, (float) direction.getZOffset() * 0.501F);
|
||||
matrixStack.rotate(TransformationHelper.quatFromXYZ(new Vector3f(0, rotation, 0), false));
|
||||
|
||||
matrixStack.scale(0.5F, 0.5F, 0.5F);
|
||||
// Make it look "flat"
|
||||
matrixStack.scale(0.5F, -0.5F, -0.00005f);
|
||||
|
||||
// Fix rotation after making it look flat
|
||||
matrixStack.rotate(TransformationHelper.quatFromXYZ(new Vector3f(0, 0, 180), true));
|
||||
|
||||
IBakedModel itemModel = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(itemStack, null, null);
|
||||
boolean render3D = itemModel.isGui3d();
|
||||
|
||||
if (render3D) {
|
||||
RenderHelper.setupGui3DDiffuseLighting();
|
||||
} else {
|
||||
RenderHelper.setupGuiFlatDiffuseLighting();
|
||||
}
|
||||
|
||||
matrixStack.getLast().getNormal().set(Matrix3f.makeScaleMatrix(1, -1, 1));
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(
|
||||
itemStack,
|
||||
ItemCameraTransforms.TransformType.FIXED,
|
||||
light,
|
||||
OverlayTexture.NO_OVERLAY,
|
||||
matrixStack,
|
||||
renderTypeBuffer
|
||||
itemStack,
|
||||
ItemCameraTransforms.TransformType.GUI,
|
||||
false,
|
||||
matrixStack,
|
||||
renderTypeBuffer,
|
||||
light,
|
||||
OverlayTexture.NO_OVERLAY,
|
||||
itemModel
|
||||
);
|
||||
|
||||
matrixStack.pop();
|
||||
@@ -142,25 +163,25 @@ public class StorageMonitorTileRenderer extends TileEntityRenderer<StorageMonito
|
||||
final int colorAlpha = fluidColor >> 24 & 0xFF;
|
||||
|
||||
buffer.pos(matrixStack.getLast().getMatrix(), -0.5F, -0.5F, 0F)
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMinU(), sprite.getMinV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMinU(), sprite.getMinV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
buffer.pos(matrixStack.getLast().getMatrix(), 0.5F, -0.5F, 0F)
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMaxU(), sprite.getMinV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMaxU(), sprite.getMinV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
buffer.pos(matrixStack.getLast().getMatrix(), 0.5F, -1.5F, 0F)
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMaxU(), sprite.getMaxV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMaxU(), sprite.getMaxV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
buffer.pos(matrixStack.getLast().getMatrix(), -0.5F, -1.5F, 0F)
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMinU(), sprite.getMaxV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
.color(colorRed, colorGreen, colorBlue, colorAlpha)
|
||||
.tex(sprite.getMinU(), sprite.getMaxV())
|
||||
.lightmap(light)
|
||||
.endVertex();
|
||||
|
||||
matrixStack.pop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user