From c421f98c18581290f70fc03a7e2a066841a96586 Mon Sep 17 00:00:00 2001 From: PepperCode1 <44146161+PepperCode1@users.noreply.github.com> Date: Tue, 2 Aug 2022 00:18:11 -0700 Subject: [PATCH] Schematic printing and rendering fixes - Fix printed funnels not having filters; remove funnel survival NBT processor - Fix printed tunnels not having filters - Fix printed deployers not keeping mode - Remove boolean argument from IPartialSafeNBT.writeSafe as it was always false - Fix filters not rendering in schematic renders - Fix incorrect lighting on funnels in schematic renders - Improve rendering of crumbling overlay in ponders - Further improve CameraMixin - Use computeIfAbsent in TorquePropagator - Organize imports --- .../contraptions/TorquePropagator.java | 4 +-- .../crafter/MechanicalCrafterTileEntity.java | 4 +-- .../deployer/DeployerTileEntity.java | 6 ++++ .../chassis/AbstractChassisBlock.java | 2 +- .../curiosities/armor/BackTankUtil.java | 1 - .../belts/tunnel/BeltTunnelTileEntity.java | 13 ++++++-- .../block/depot/EjectorTileEntity.java | 4 +-- .../block/display/DisplayLinkTileEntity.java | 10 +++---- .../block/mechanicalArm/ArmTileEntity.java | 4 +-- .../item/LecternControllerTileEntity.java | 4 +-- .../trains/track/TrackTileEntity.java | 4 +-- .../content/schematics/SchematicWorld.java | 2 +- .../block/SchematicannonTileEntity.java | 2 +- .../schematics/client/SchematicRenderer.java | 19 +++++++----- .../create/foundation/mixin/CameraMixin.java | 21 ++----------- .../create/foundation/ponder/PonderScene.java | 30 +++++++------------ .../ponder/element/WorldSectionElement.java | 18 ++++++----- .../create/foundation/ponder/ui/PonderUI.java | 2 +- .../tileEntity/SmartTileEntity.java | 4 +-- .../filtering/FilteringRenderer.java | 14 +++++---- .../foundation/utility/BlockHelper.java | 1 + .../foundation/utility/IPartialSafeNBT.java | 3 +- .../foundation/utility/NBTProcessors.java | 12 -------- 23 files changed, 86 insertions(+), 98 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java index a6bf425d5..4d7e336ce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/TorquePropagator.java @@ -26,9 +26,7 @@ public class TorquePropagator { public KineticNetwork getOrCreateNetworkFor(KineticTileEntity te) { Long id = te.network; KineticNetwork network; - if (!networks.containsKey(te.getLevel())) - networks.put(te.getLevel(), new HashMap<>()); - Map map = networks.get(te.getLevel()); + Map map = networks.computeIfAbsent(te.getLevel(), $ -> new HashMap<>()); if (id == null) return null; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java index 1028647db..bc6be652a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java @@ -145,8 +145,8 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } @Override - public void writeSafe(CompoundTag compound, boolean clientPacket) { - super.writeSafe(compound, clientPacket); + public void writeSafe(CompoundTag compound) { + super.writeSafe(compound); if (input == null) return; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java index 78a68da21..1a825f0eb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java @@ -403,6 +403,12 @@ public class DeployerTileEntity extends KineticTileEntity { } } + @Override + public void writeSafe(CompoundTag tag) { + NBTHelper.writeEnum(tag, "Mode", mode); + super.writeSafe(tag); + } + private IItemHandlerModifiable createHandler() { return new DeployerItemHandler(this); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java index 34f6e27fb..bffbbe404 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java @@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTileEntities; -import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Iterate; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java index 7d3041cba..4d1011879 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.curiosities.armor; import com.simibubi.create.AllEnchantments; -import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.AllTags; import com.simibubi.create.foundation.config.AllConfigs; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java index 3541b7c1d..b0f3f605a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntity.java @@ -61,8 +61,7 @@ public class BeltTunnelTileEntity extends SmartTileEntity { cap.invalidate(); } - @Override - public void write(CompoundTag compound, boolean clientPacket) { + protected void writeFlapsAndSides(CompoundTag compound) { ListTag flapsNBT = new ListTag(); for (Direction direction : flaps.keySet()) flapsNBT.add(IntTag.valueOf(direction.get3DDataValue())); @@ -72,7 +71,17 @@ public class BeltTunnelTileEntity extends SmartTileEntity { for (Direction direction : sides) sidesNBT.add(IntTag.valueOf(direction.get3DDataValue())); compound.put("Sides", sidesNBT); + } + @Override + public void writeSafe(CompoundTag tag) { + writeFlapsAndSides(tag); + super.writeSafe(tag); + } + + @Override + public void write(CompoundTag compound, boolean clientPacket) { + writeFlapsAndSides(compound); super.write(compound, clientPacket); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java index d9946340c..1ff2704f0 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/depot/EjectorTileEntity.java @@ -516,8 +516,8 @@ public class EjectorTileEntity extends KineticTileEntity { } @Override - public void writeSafe(CompoundTag compound, boolean clientPacket) { - super.writeSafe(compound, clientPacket); + public void writeSafe(CompoundTag compound) { + super.writeSafe(compound); compound.putInt("HorizontalDistance", launcher.getHorizontalDistance()); compound.putInt("VerticalDistance", launcher.getVerticalDistance()); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkTileEntity.java index c06ee51e9..9d9a5f606 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/DisplayLinkTileEntity.java @@ -124,15 +124,15 @@ public class DisplayLinkTileEntity extends SmartTileEntity { } @Override - public void writeSafe(CompoundTag tag, boolean clientPacket) { - super.writeSafe(tag, clientPacket); - writeGatheredData(tag, clientPacket); + public void writeSafe(CompoundTag tag) { + super.writeSafe(tag); + writeGatheredData(tag); } @Override protected void write(CompoundTag tag, boolean clientPacket) { super.write(tag, clientPacket); - writeGatheredData(tag, clientPacket); + writeGatheredData(tag); if (clientPacket && activeTarget != null) tag.putString("TargetType", activeTarget.id.toString()); if (clientPacket && sendPulse) { @@ -141,7 +141,7 @@ public class DisplayLinkTileEntity extends SmartTileEntity { } } - private void writeGatheredData(CompoundTag tag, boolean clientPacket) { + private void writeGatheredData(CompoundTag tag) { tag.put("TargetOffset", NbtUtils.writeBlockPos(targetOffset)); tag.putInt("TargetLine", targetLine); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index c50b791ee..77eefd030 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -508,8 +508,8 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE } @Override - public void writeSafe(CompoundTag compound, boolean clientPacket) { - super.writeSafe(compound, clientPacket); + public void writeSafe(CompoundTag compound) { + super.writeSafe(compound); writeInteractionPoints(compound); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java index 0be2f6bbd..d67868a23 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LecternControllerTileEntity.java @@ -49,8 +49,8 @@ public class LecternControllerTileEntity extends SmartTileEntity { } @Override - public void writeSafe(CompoundTag compound, boolean clientPacket) { - super.writeSafe(compound, clientPacket); + public void writeSafe(CompoundTag compound) { + super.writeSafe(compound); compound.put("Controller", controller.save(new CompoundTag())); } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackTileEntity.java index 80cae8969..9e164e5bb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackTileEntity.java @@ -159,8 +159,8 @@ public class TrackTileEntity extends SmartTileEntity implements ITransformableTE } @Override - public void writeSafe(CompoundTag tag, boolean clientPacket) { - super.writeSafe(tag, clientPacket); + public void writeSafe(CompoundTag tag) { + super.writeSafe(tag); writeTurns(tag); } diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index e503b539a..782378a47 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -109,7 +109,7 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor } return tileEntity; } catch (Exception e) { - Create.LOGGER.debug("Could not create TE of block " + blockState + ": " + e); + Create.LOGGER.debug("Could not create TE of block " + blockState, e); } } return null; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index d5065cd53..8c3da6d6c 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -738,7 +738,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro data = NBTProcessors.process(tile, data, true); } else if (tile instanceof IPartialSafeNBT) { data = new CompoundTag(); - ((IPartialSafeNBT) tile).writeSafe(data, false); + ((IPartialSafeNBT) tile).writeSafe(data); data = NBTProcessors.process(tile, data, true); } } diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java index 5eea3f169..62f0b9c44 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicRenderer.java @@ -95,6 +95,7 @@ public class SchematicRenderer { Random random = objects.random; BlockPos.MutableBlockPos mutableBlockPos = objects.mutableBlockPos; SchematicWorld renderWorld = schematic; + renderWorld.renderMode = true; BoundingBox bounds = renderWorld.getBounds(); ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper; @@ -111,16 +112,16 @@ public class SchematicRenderer { BlockPos pos = mutableBlockPos.setWithOffset(localPos, anchor); BlockState state = renderWorld.getBlockState(pos); - poseStack.pushPose(); - poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ()); - if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) { - BlockEntity tileEntity = renderWorld.getBlockEntity(localPos); - dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, true, random, - tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE); - } + poseStack.pushPose(); + poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ()); - poseStack.popPose(); + BlockEntity tileEntity = renderWorld.getBlockEntity(localPos); + dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, false, random, + tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE); + + poseStack.popPose(); + } } ModelBlockRenderer.clearCache(); ForgeHooksClient.setRenderType(null); @@ -130,6 +131,8 @@ public class SchematicRenderer { builder.appendUnshadedVertices(unshadedBuilder); builder.end(); + renderWorld.renderMode = false; + return new SuperByteBuffer(builder); } diff --git a/src/main/java/com/simibubi/create/foundation/mixin/CameraMixin.java b/src/main/java/com/simibubi/create/foundation/mixin/CameraMixin.java index c36f28309..b9e775431 100644 --- a/src/main/java/com/simibubi/create/foundation/mixin/CameraMixin.java +++ b/src/main/java/com/simibubi/create/foundation/mixin/CameraMixin.java @@ -1,39 +1,22 @@ package com.simibubi.create.foundation.mixin; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.simibubi.create.content.logistics.trains.CameraDistanceModifier; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Camera; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.BlockGetter; @Mixin(Camera.class) public abstract class CameraMixin { - - @Shadow - private double getMaxZoom(double pStartingDistance) { - throw new AssertionError(); - } - - @Shadow - protected void move(double pDistanceOffset, double pVerticalOffset, double pHorizontalOffset) { - throw new AssertionError(); - } - @ModifyArg( method = "Lnet/minecraft/client/Camera;setup(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;ZZF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;move(DDD)V", ordinal = 0), + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D"), index = 0 ) public double modifyCameraOffset(double originalValue) { - return -this.getMaxZoom(4.0D * CameraDistanceModifier.getMultiplier(AnimationTickHolder.getPartialTicks())); + return originalValue * CameraDistanceModifier.getMultiplier(AnimationTickHolder.getPartialTicks()); } - } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java index 061b59b5d..3598a9492 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -455,6 +455,10 @@ public class PonderScene { return basePlateSize; } + public float getScaleFactor() { + return scaleFactor; + } + public float getYOffset() { return yOffset; } @@ -498,10 +502,10 @@ public class PonderScene { } public PoseStack apply(PoseStack ms) { - return apply(ms, AnimationTickHolder.getPartialTicks(world), false); + return apply(ms, AnimationTickHolder.getPartialTicks(world)); } - public PoseStack apply(PoseStack ms, float pt, boolean overlayCompatible) { + public PoseStack apply(PoseStack ms, float pt) { ms.translate(width / 2, height / 2, 200 + offset); TransformStack.cast(ms) @@ -513,23 +517,11 @@ public class PonderScene { .rotateX(xRotation.getValue(pt)) .rotateY(yRotation.getValue(pt)); + UIRenderHelper.flipForGuiRender(ms); float f = 30 * scaleFactor; - - if (!overlayCompatible) { - UIRenderHelper.flipForGuiRender(ms); - ms.scale(f, f, f); - ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset, - (basePlateSize + basePlateOffsetZ) / -2f); - } else { - // For block breaking overlay; Don't ask - ms.scale(f, f, f); - if (f == 30) - ms.translate(0.525, .2975, .9); - ms.translate((basePlateSize + basePlateOffsetX) / -2f, -yOffset, - (basePlateSize + basePlateOffsetZ) / -2f); - float y = (float) (0.5065 * Math.pow(2.2975, Math.log(1 / scaleFactor) / Math.log(2))) / 30; - ms.scale(y, -y, -y); - } + ms.scale(f, f, f); + ms.translate((basePlateSize + basePlateOffsetX) / -2f, -1f + yOffset, + (basePlateSize + basePlateOffsetZ) / -2f); return ms; } @@ -572,7 +564,7 @@ public class PonderScene { protected void refreshMatrix(float pt) { if (cachedMat != null) return; - cachedMat = apply(new PoseStack(), pt, false).last() + cachedMat = apply(new PoseStack(), pt).last() .pose(); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java index ad2549630..f1afaeb47 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java @@ -327,23 +327,27 @@ public class WorldSectionElement extends AnimatedSceneElement { BlockPos pos = entry.getKey(); if (!section.test(pos)) continue; + if (overlayMS == null) { overlayMS = new PoseStack(); - world.scene.getTransform() - .apply(overlayMS, pt, true); - transformMS(overlayMS, pt); + overlayMS.last().pose().load(ms.last().pose()); + overlayMS.last().normal().load(ms.last().normal()); + + float scaleFactor = world.scene.getScaleFactor(); + float f = (float) Math.pow(30 * scaleFactor, -1.2); + overlayMS.scale(f, f, f); } - ms.pushPose(); - ms.translate(pos.getX(), pos.getY(), pos.getZ()); VertexConsumer builder = new SheetedDecalTextureGenerator( buffer.getBuffer(ModelBakery.DESTROY_TYPES.get(entry.getValue())), overlayMS.last() .pose(), overlayMS.last() .normal()); + + ms.pushPose(); + ms.translate(pos.getX(), pos.getY(), pos.getZ()); ModelUtil.VANILLA_RENDERER - .renderBatched(world.getBlockState(pos), pos, world, ms, builder, true, new Random(), - EmptyModelData.INSTANCE); + .renderBreakingTexture(world.getBlockState(pos), pos, world, ms, builder, EmptyModelData.INSTANCE); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderUI.java b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderUI.java index b0258e403..32554bf02 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderUI.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/ui/PonderUI.java @@ -453,7 +453,7 @@ public class PonderUI extends NavigatableSimiScreen { story.getTransform() .updateScreenParams(width, height, slide); story.getTransform() - .apply(ms, partialTicks, false); + .apply(ms, partialTicks); story.getTransform() .updateSceneRVE(partialTicks); story.renderScene(buffer, ms, partialTicks); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java index 1c91eeda8..817b785d7 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/SmartTileEntity.java @@ -90,11 +90,11 @@ public abstract class SmartTileEntity extends CachedRenderBBTileEntity implement } @Override - public void writeSafe(CompoundTag tag, boolean clientPacket) { + public void writeSafe(CompoundTag tag) { super.saveAdditional(tag); forEachBehaviour(tb -> { if (tb.isSafeNBT()) - tb.write(tag, clientPacket); + tb.write(tag, false); }); } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java index 9afef6ce7..934204a36 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringRenderer.java @@ -95,11 +95,15 @@ public class FilteringRenderer { if (te == null || te.isRemoved()) return; - Entity cameraEntity = Minecraft.getInstance().cameraEntity; - float max = AllConfigs.CLIENT.filterItemRenderDistance.getF(); - if (!te.isVirtual() && cameraEntity != null && cameraEntity.position() - .distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max)) - return; + if (!te.isVirtual()) { + Entity cameraEntity = Minecraft.getInstance().cameraEntity; + if (cameraEntity != null && te.getLevel() == cameraEntity.getLevel()) { + float max = AllConfigs.CLIENT.filterItemRenderDistance.getF(); + if (cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max)) { + return; + } + } + } FilteringBehaviour behaviour = te.getBehaviour(FilteringBehaviour.TYPE); if (behaviour == null) diff --git a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java index 4817470f3..9dfdf5614 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/BlockHelper.java @@ -272,6 +272,7 @@ public class BlockHelper { ((KineticTileEntity) tile).warnOfMovement(); tile.load(data); } + System.out.println(""); } try { diff --git a/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java index 3c4952c1e..c8854bb0b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java +++ b/src/main/java/com/simibubi/create/foundation/utility/IPartialSafeNBT.java @@ -3,5 +3,6 @@ package com.simibubi.create.foundation.utility; import net.minecraft.nbt.CompoundTag; public interface IPartialSafeNBT { - public void writeSafe(CompoundTag compound, boolean clientPacket); + /** This method always runs on the logical server. */ + public void writeSafe(CompoundTag compound); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java index acb3a6a46..54a447d63 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java @@ -6,14 +6,10 @@ import java.util.function.UnaryOperator; import javax.annotation.Nullable; -import com.simibubi.create.AllTileEntities; -import com.simibubi.create.content.logistics.item.filter.FilterItem; - import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.entity.SpawnerBlockEntity; @@ -58,14 +54,6 @@ public final class NBTProcessors { } return data; }); - addSurvivalProcessor(AllTileEntities.FUNNEL.get(), data -> { - if (data.contains("Filter")) { - ItemStack filter = ItemStack.of(data.getCompound("Filter")); - if (filter.getItem() instanceof FilterItem) - data.remove("Filter"); - } - return data; - }); } public static boolean textComponentHasClickEvent(String json) {