mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 05:43:42 +01:00
parent
1f0b428e58
commit
4909546457
1 changed files with 25 additions and 46 deletions
|
@ -26,6 +26,7 @@ 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;
|
||||||
|
@ -174,14 +175,11 @@ 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,
|
||||||
|
@ -211,8 +209,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,
|
blockRenderer.renderSingleBlock(blockState, ms, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
||||||
OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE);
|
VirtualEmptyModelData.INSTANCE);
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
Lighting.setupFor3DItems();
|
Lighting.setupFor3DItems();
|
||||||
return;
|
return;
|
||||||
|
@ -224,11 +222,9 @@ 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,54 +256,37 @@ 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()
|
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
||||||
.getItemRenderer();
|
|
||||||
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
||||||
|
|
||||||
renderer.textureManager.getTexture(InventoryMenu.BLOCK_ATLAS)
|
renderer.textureManager.getTexture(TextureAtlas.LOCATION_BLOCKS).setFilter(false, false);
|
||||||
.setFilter(false, false);
|
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS);
|
||||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
|
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_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();
|
||||||
MultiBufferSource.BufferSource buffer = Minecraft.getInstance()
|
matrixStack.translate(0, 0, 100.0F + renderer.blitOffset);
|
||||||
.renderBuffers()
|
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
||||||
.bufferSource();
|
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
||||||
|
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
boolean flatLighting = !bakedModel.usesBlockLight();
|
boolean flatLighting = !bakedModel.usesBlockLight();
|
||||||
if (useDefaultLighting && flatLighting)
|
if (useDefaultLighting) {
|
||||||
Lighting.setupForFlatItems();
|
if (flatLighting) {
|
||||||
|
Lighting.setupForFlatItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderer.render(stack, ItemTransforms.TransformType.GUI, false, new PoseStack(), buffer,
|
renderer.render(stack, ItemTransforms.TransformType.GUI, false, matrixStack, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
|
||||||
LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
|
|
||||||
buffer.endBatch();
|
buffer.endBatch();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
if (useDefaultLighting && flatLighting)
|
if (useDefaultLighting) {
|
||||||
Lighting.setupFor3DItems();
|
if (flatLighting) {
|
||||||
|
Lighting.setupFor3DItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matrixStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue