mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Preserving BakedModel and switching to ItemRenderer.render instead of ItemRenderer.renderStatic for performance
This commit is contained in:
parent
75d337ba8c
commit
9dfbe061de
7 changed files with 30 additions and 26 deletions
|
@ -10,6 +10,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -33,8 +34,8 @@ public class PlacardRenderer extends SafeBlockEntityRenderer<PlacardBlockEntity>
|
||||||
|
|
||||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
ItemRenderer itemRenderer = Minecraft.getInstance()
|
||||||
.getItemRenderer();
|
.getItemRenderer();
|
||||||
boolean blockItem = itemRenderer.getModel(heldItem, null, null, 0)
|
BakedModel bakedModel = itemRenderer.getModel(heldItem, null, null, 0);
|
||||||
.isGui3d();
|
boolean blockItem = bakedModel.isGui3d();
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
TransformStack.cast(ms)
|
TransformStack.cast(ms)
|
||||||
|
@ -46,7 +47,7 @@ public class PlacardRenderer extends SafeBlockEntityRenderer<PlacardBlockEntity>
|
||||||
.translate(0, 0, 4.5 / 16f)
|
.translate(0, 0, 4.5 / 16f)
|
||||||
.scale(blockItem ? .5f : .375f);
|
.scale(blockItem ? .5f : .375f);
|
||||||
|
|
||||||
itemRenderer.renderStatic(heldItem, TransformType.FIXED, light, overlay, ms, buffer, 0);
|
itemRenderer.render(heldItem, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -78,8 +79,8 @@ public class ItemDrainRenderer extends SmartBlockEntityRenderer<ItemDrainBlockEn
|
||||||
.getItemRenderer();
|
.getItemRenderer();
|
||||||
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
|
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
|
||||||
boolean renderUpright = BeltHelper.isItemUpright(itemStack);
|
boolean renderUpright = BeltHelper.isItemUpright(itemStack);
|
||||||
boolean blockItem = itemRenderer.getModel(itemStack, null, null, 0)
|
BakedModel bakedModel = itemRenderer.getModel(itemStack, null, null, 0);
|
||||||
.isGui3d();
|
boolean blockItem = bakedModel.isGui3d();
|
||||||
|
|
||||||
if (renderUpright)
|
if (renderUpright)
|
||||||
ms.translate(0, 3 / 32d, 0);
|
ms.translate(0, 3 / 32d, 0);
|
||||||
|
@ -117,7 +118,7 @@ public class ItemDrainRenderer extends SmartBlockEntityRenderer<ItemDrainBlockEn
|
||||||
ms.scale(.5f, .5f, .5f);
|
ms.scale(.5f, .5f, .5f);
|
||||||
if (!blockItem && !renderUpright)
|
if (!blockItem && !renderUpright)
|
||||||
msr.rotateX(90);
|
msr.rotateX(90);
|
||||||
itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer, 0);
|
itemRenderer.render(itemStack, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
|
|
||||||
if (!renderUpright) {
|
if (!renderUpright) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.core.Direction.AxisDirection;
|
import net.minecraft.core.Direction.AxisDirection;
|
||||||
|
@ -194,6 +195,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
||||||
boolean slopeAlongX = beltFacing
|
boolean slopeAlongX = beltFacing
|
||||||
.getAxis() == Axis.X;
|
.getAxis() == Axis.X;
|
||||||
|
|
||||||
|
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||||
boolean onContraption = be.getLevel() instanceof WrappedWorld;
|
boolean onContraption = be.getLevel() instanceof WrappedWorld;
|
||||||
|
|
||||||
for (TransportedItemStack transported : be.getInventory()
|
for (TransportedItemStack transported : be.getInventory()
|
||||||
|
@ -238,11 +240,10 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
||||||
ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset);
|
ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset);
|
||||||
|
|
||||||
int stackLight = onContraption ? light : getPackedLight(be, offset);
|
int stackLight = onContraption ? light : getPackedLight(be, offset);
|
||||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
|
||||||
.getItemRenderer();
|
|
||||||
boolean renderUpright = BeltHelper.isItemUpright(transported.stack);
|
boolean renderUpright = BeltHelper.isItemUpright(transported.stack);
|
||||||
boolean blockItem = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0)
|
BakedModel bakedModel = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0);
|
||||||
.isGui3d();
|
boolean blockItem = bakedModel.isGui3d();
|
||||||
int count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
|
int count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
|
||||||
Random r = new Random(transported.angle);
|
Random r = new Random(transported.angle);
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.scale(.5f, .5f, .5f);
|
ms.scale(.5f, .5f, .5f);
|
||||||
itemRenderer.renderStatic(null, transported.stack, TransformType.FIXED, false, ms, buffer, be.getLevel(), stackLight, overlay, 0);
|
itemRenderer.render(transported.stack, TransformType.FIXED, false, ms, buffer, stackLight, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
|
|
||||||
if (!renderUpright) {
|
if (!renderUpright) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
@ -89,9 +90,8 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
.getItemRenderer();
|
.getItemRenderer();
|
||||||
|
|
||||||
TransformType transform = TransformType.NONE;
|
TransformType transform = TransformType.NONE;
|
||||||
boolean isBlockItem = (be.heldItem.getItem() instanceof BlockItem)
|
BakedModel bakedModel = itemRenderer.getModel(be.heldItem, be.getLevel(), null, 0);
|
||||||
&& itemRenderer.getModel(be.heldItem, be.getLevel(), null, 0)
|
boolean isBlockItem = (be.heldItem.getItem() instanceof BlockItem) && bakedModel.isGui3d();
|
||||||
.isGui3d();
|
|
||||||
|
|
||||||
if (displayMode) {
|
if (displayMode) {
|
||||||
float scale = isBlockItem ? 1.25f : 1;
|
float scale = isBlockItem ? 1.25f : 1;
|
||||||
|
@ -106,7 +106,7 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
||||||
transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED;
|
transform = punching ? TransformType.THIRD_PERSON_RIGHT_HAND : TransformType.FIXED;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemRenderer.renderStatic(be.heldItem, transform, light, overlay, ms, buffer, 0);
|
itemRenderer.render(be.heldItem, transform, false, ms, buffer, light, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
@ -45,9 +46,8 @@ public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
|
||||||
ItemRenderer itemRenderer = Minecraft.getInstance()
|
ItemRenderer itemRenderer = Minecraft.getInstance()
|
||||||
.getItemRenderer();
|
.getItemRenderer();
|
||||||
|
|
||||||
boolean isBlockItem =
|
BakedModel bakedModel = itemRenderer.getModel(item, be.getLevel(), null, 0);
|
||||||
hasItem && (item.getItem() instanceof BlockItem) && itemRenderer.getModel(item, be.getLevel(), null, 0)
|
boolean isBlockItem = hasItem && (item.getItem() instanceof BlockItem) && bakedModel.isGui3d();
|
||||||
.isGui3d();
|
|
||||||
|
|
||||||
VertexConsumer builder = buffer.getBuffer(be.goggles ? RenderType.cutout() : RenderType.solid());
|
VertexConsumer builder = buffer.getBuffer(be.goggles ? RenderType.cutout() : RenderType.solid());
|
||||||
BlockState blockState = be.getBlockState();
|
BlockState blockState = be.getBlockState();
|
||||||
|
@ -102,7 +102,7 @@ public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
|
||||||
.multiply(msLocal.last()
|
.multiply(msLocal.last()
|
||||||
.pose());
|
.pose());
|
||||||
|
|
||||||
itemRenderer.renderStatic(item, TransformType.FIXED, light, overlay, ms, buffer, 0);
|
itemRenderer.render(item, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,13 +141,13 @@ public class ArmRenderer extends KineticBlockEntityRenderer<ArmBlockEntity> {
|
||||||
.renderInto(ms, builder);
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
transformHead(msr, headAngle);
|
transformHead(msr, headAngle);
|
||||||
|
|
||||||
if (inverted)
|
if (inverted)
|
||||||
msr.rotateZ(180);
|
msr.rotateZ(180);
|
||||||
|
|
||||||
claw.transform(msLocal)
|
claw.transform(msLocal)
|
||||||
.renderInto(ms, builder);
|
.renderInto(ms, builder);
|
||||||
|
|
||||||
if (inverted)
|
if (inverted)
|
||||||
msr.rotateZ(180);
|
msr.rotateZ(180);
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class SawRenderer extends SafeBlockEntityRenderer<SawBlockEntity> {
|
||||||
if (alongZ)
|
if (alongZ)
|
||||||
ms.mulPose(Vector3f.YP.rotationDegrees(90));
|
ms.mulPose(Vector3f.YP.rotationDegrees(90));
|
||||||
ms.mulPose(Vector3f.XP.rotationDegrees(90));
|
ms.mulPose(Vector3f.XP.rotationDegrees(90));
|
||||||
itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, light, overlay, ms, buffer, 0);
|
itemRenderer.render(stack, ItemTransforms.TransformType.FIXED, false, ms, buffer, light, overlay, modelWithOverrides);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||||
|
import net.minecraft.client.resources.model.BakedModel;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -104,8 +105,8 @@ public class DepotRenderer extends SafeBlockEntityRenderer<DepotBlockEntity> {
|
||||||
TransformStack msr = TransformStack.cast(ms);
|
TransformStack msr = TransformStack.cast(ms);
|
||||||
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
|
int count = (int) (Mth.log2((int) (itemStack.getCount()))) / 2;
|
||||||
boolean renderUpright = BeltHelper.isItemUpright(itemStack);
|
boolean renderUpright = BeltHelper.isItemUpright(itemStack);
|
||||||
boolean blockItem = itemRenderer.getModel(itemStack, null, null, 0)
|
BakedModel bakedModel = itemRenderer.getModel(itemStack, null, null, 0);
|
||||||
.isGui3d();
|
boolean blockItem = bakedModel.isGui3d();
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
msr.rotateY(angle);
|
msr.rotateY(angle);
|
||||||
|
@ -131,7 +132,7 @@ public class DepotRenderer extends SafeBlockEntityRenderer<DepotBlockEntity> {
|
||||||
ms.translate(0, -3 / 16f, 0);
|
ms.translate(0, -3 / 16f, 0);
|
||||||
msr.rotateX(90);
|
msr.rotateX(90);
|
||||||
}
|
}
|
||||||
itemRenderer.renderStatic(itemStack, TransformType.FIXED, light, overlay, ms, buffer, 0);
|
itemRenderer.render(itemStack, TransformType.FIXED, false, ms, buffer, light, overlay, bakedModel);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
|
|
||||||
if (!renderUpright) {
|
if (!renderUpright) {
|
||||||
|
|
Loading…
Reference in a new issue