mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 00:16:27 +01:00
Patch GuiGameElements
This commit is contained in:
parent
ab8f6a01ce
commit
55c95b347b
1 changed files with 47 additions and 26 deletions
|
@ -26,7 +26,6 @@ import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
||||||
import net.minecraft.client.resources.model.BakedModel;
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.inventory.InventoryMenu;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
|
@ -175,11 +174,14 @@ public class GuiGameElement {
|
||||||
VertexConsumer vb = buffer.getBuffer(renderType);
|
VertexConsumer vb = buffer.getBuffer(renderType);
|
||||||
|
|
||||||
transformMatrix(matrixStack);
|
transformMatrix(matrixStack);
|
||||||
|
if (customLighting == null)
|
||||||
|
Lighting.setupForEntityInInventory();
|
||||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
||||||
renderModel(blockRenderer, buffer, renderType, vb, matrixStack);
|
renderModel(blockRenderer, buffer, renderType, vb, matrixStack);
|
||||||
|
|
||||||
cleanUpMatrix(matrixStack);
|
cleanUpMatrix(matrixStack);
|
||||||
|
if (customLighting == null)
|
||||||
|
Lighting.setupFor3DItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
||||||
|
@ -209,8 +211,8 @@ public class GuiGameElement {
|
||||||
RenderType renderType, VertexConsumer vb, PoseStack ms) {
|
RenderType renderType, VertexConsumer vb, PoseStack ms) {
|
||||||
if (blockState.getBlock() instanceof FireBlock) {
|
if (blockState.getBlock() instanceof FireBlock) {
|
||||||
Lighting.setupForFlatItems();
|
Lighting.setupForFlatItems();
|
||||||
blockRenderer.renderSingleBlock(blockState, ms, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
blockRenderer.renderSingleBlock(blockState, ms, buffer, LightTexture.FULL_BRIGHT,
|
||||||
VirtualEmptyModelData.INSTANCE);
|
OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
Lighting.setupFor3DItems();
|
Lighting.setupFor3DItems();
|
||||||
return;
|
return;
|
||||||
|
@ -222,9 +224,11 @@ public class GuiGameElement {
|
||||||
.isEmpty())
|
.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Lighting.setupForFlatItems();
|
||||||
FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState()
|
FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState()
|
||||||
.getType(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, LightTexture.FULL_BRIGHT, false);
|
.getType(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, LightTexture.FULL_BRIGHT, false);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
|
Lighting.setupFor3DItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,37 +260,54 @@ public class GuiGameElement {
|
||||||
cleanUpMatrix(matrixStack);
|
cleanUpMatrix(matrixStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void transformMatrix(PoseStack matrixStack) {
|
||||||
|
super.transformMatrix(matrixStack);
|
||||||
|
PoseStack mvm = RenderSystem.getModelViewStack();
|
||||||
|
mvm.pushPose();
|
||||||
|
mvm.mulPoseMatrix(matrixStack.last()
|
||||||
|
.pose());
|
||||||
|
mvm.translate(8.0F, -8.0F, 8.0F);
|
||||||
|
mvm.scale(16.0F, 16.0F, 16.0F);
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void cleanUpMatrix(PoseStack matrixStack) {
|
||||||
|
super.cleanUpMatrix(matrixStack);
|
||||||
|
RenderSystem.getModelViewStack()
|
||||||
|
.popPose();
|
||||||
|
;
|
||||||
|
RenderSystem.applyModelViewMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
||||||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
ItemRenderer renderer = Minecraft.getInstance()
|
||||||
|
.getItemRenderer();
|
||||||
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
||||||
|
|
||||||
renderer.textureManager.getTexture(TextureAtlas.LOCATION_BLOCKS).setFilter(false, false);
|
renderer.textureManager.getTexture(InventoryMenu.BLOCK_ATLAS)
|
||||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
.setFilter(false, false);
|
||||||
|
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
|
||||||
|
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
matrixStack.pushPose();
|
|
||||||
matrixStack.translate(0, 0, 100.0F + renderer.blitOffset);
|
|
||||||
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
|
||||||
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
|
||||||
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
|
|
||||||
boolean flatLighting = !bakedModel.usesBlockLight();
|
|
||||||
if (useDefaultLighting) {
|
|
||||||
if (flatLighting) {
|
|
||||||
Lighting.setupForFlatItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer.render(stack, ItemTransforms.TransformType.GUI, false, matrixStack, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
|
MultiBufferSource.BufferSource buffer = Minecraft.getInstance()
|
||||||
|
.renderBuffers()
|
||||||
|
.bufferSource();
|
||||||
|
boolean flatLighting = !bakedModel.usesBlockLight();
|
||||||
|
if (useDefaultLighting && flatLighting)
|
||||||
|
Lighting.setupForFlatItems();
|
||||||
|
|
||||||
|
renderer.render(stack, ItemTransforms.TransformType.GUI, false, new PoseStack(), buffer,
|
||||||
|
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
if (useDefaultLighting) {
|
if (useDefaultLighting && flatLighting)
|
||||||
if (flatLighting) {
|
Lighting.setupFor3DItems();
|
||||||
Lighting.setupFor3DItems();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
matrixStack.popPose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue