mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 07:27:15 +01:00
Merge branch 'pr/6677' into mc1.18/dev
This commit is contained in:
commit
4953dbb181
3 changed files with 44 additions and 7 deletions
|
@ -195,15 +195,12 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
|||
boolean slopeAlongX = beltFacing
|
||||
.getAxis() == Axis.X;
|
||||
|
||||
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemRenderer itemRenderer = mc.getItemRenderer();
|
||||
boolean onContraption = be.getLevel() instanceof WrappedWorld;
|
||||
|
||||
for (TransportedItemStack transported : be.getInventory()
|
||||
.getTransportedItems()) {
|
||||
ms.pushPose();
|
||||
TransformStack.cast(ms)
|
||||
.nudge(transported.angle);
|
||||
|
||||
float offset;
|
||||
float sideOffset;
|
||||
float verticalMovement;
|
||||
|
@ -230,6 +227,18 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
|||
.getAxis() == Axis.Z);
|
||||
float slopeAngle = onSlope ? tiltForward ? -45 : 45 : 0;
|
||||
|
||||
Vec3 itemPos = beltStartOffset.add(
|
||||
be.getBlockPos().getX(),
|
||||
be.getBlockPos().getY(),
|
||||
be.getBlockPos().getZ())
|
||||
.add(offsetVec);
|
||||
|
||||
if (this.shouldCullItem(itemPos)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ms.pushPose();
|
||||
TransformStack.cast(ms).nudge(transported.angle);
|
||||
ms.translate(offsetVec.x, offsetVec.y, offsetVec.z);
|
||||
|
||||
boolean alongX = beltFacing
|
||||
|
@ -244,7 +253,11 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
|||
boolean renderUpright = BeltHelper.isItemUpright(transported.stack);
|
||||
BakedModel bakedModel = itemRenderer.getModel(transported.stack, be.getLevel(), null, 0);
|
||||
boolean blockItem = bakedModel.isGui3d();
|
||||
int count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
|
||||
|
||||
int count = 0;
|
||||
if (mc.player.getEyePosition(1.0F).distanceTo(itemPos) < 16)
|
||||
count = (int) (Mth.log2((int) (transported.stack.getCount()))) / 2;
|
||||
|
||||
Random r = new Random(transported.angle);
|
||||
|
||||
boolean slopeShadowOnly = renderUpright && onSlope;
|
||||
|
@ -265,7 +278,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
|||
}
|
||||
|
||||
if (renderUpright) {
|
||||
Entity renderViewEntity = Minecraft.getInstance().cameraEntity;
|
||||
Entity renderViewEntity = mc.cameraEntity;
|
||||
if (renderViewEntity != null) {
|
||||
Vec3 positionVec = renderViewEntity.position();
|
||||
Vec3 vectorForOffset = BeltHelper.getVectorForOffset(be, offset);
|
||||
|
|
|
@ -2,10 +2,14 @@ package com.simibubi.create.foundation.blockEntity.renderer;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T> {
|
||||
@Override
|
||||
|
@ -23,4 +27,21 @@ public abstract class SafeBlockEntityRenderer<T extends BlockEntity> implements
|
|||
return !be.hasLevel() || be.getBlockState()
|
||||
.getBlock() == Blocks.AIR;
|
||||
}
|
||||
|
||||
public boolean shouldCullItem(Vec3 itemPos) {
|
||||
Frustum frustum = Minecraft.getInstance().levelRenderer.capturedFrustum != null ?
|
||||
Minecraft.getInstance().levelRenderer.capturedFrustum :
|
||||
Minecraft.getInstance().levelRenderer.cullingFrustum;
|
||||
|
||||
AABB itemBB = new AABB(
|
||||
itemPos.x - 0.25,
|
||||
itemPos.y - 0.25,
|
||||
itemPos.z - 0.25,
|
||||
itemPos.x + 0.25,
|
||||
itemPos.y + 0.25,
|
||||
itemPos.z + 0.25
|
||||
);
|
||||
|
||||
return !frustum.isVisible(itemBB);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,3 +42,6 @@ public net.minecraft.client.model.AgeableListModel f_102012_ # bodyYOffset
|
|||
|
||||
public net.minecraft.client.gui.components.CommandSuggestions f_93866_ # suggestions
|
||||
public net.minecraft.client.gui.components.CommandSuggestions$SuggestionsList <init>(Lnet/minecraft/client/gui/components/CommandSuggestions;IIILjava/util/List;Z)V # <init>
|
||||
|
||||
public net.minecraft.client.renderer.LevelRenderer f_172938_ # cullingFrustum
|
||||
public net.minecraft.client.renderer.LevelRenderer f_109442_ # capturedFrustum
|
||||
|
|
Loading…
Reference in a new issue