From 9062f1c8fa3cf47ca9d25147d301cf902e13bbb2 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Wed, 3 Mar 2021 17:15:45 -0800 Subject: [PATCH] Null checks and flap updates. --- .../logistics/block/belts/tunnel/BeltTunnelInstance.java | 7 ++++++- .../logistics/block/belts/tunnel/BeltTunnelTileEntity.java | 4 ++++ .../content/logistics/block/funnel/FunnelTileEntity.java | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index 654bea79b..05671ba32 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.render.backend.instancing.*; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.tileentity.TileEntityType; @@ -72,8 +73,12 @@ public class BeltTunnelInstance extends TileEntityInstance @Override public void tick() { tunnelFlaps.forEach((direction, keys) -> { + InterpolatedChasingValue flapValue = tile.flaps.get(direction); + if (flapValue == null) { + return; + } - float flapness = tile.flaps.get(direction).get(AnimationTickHolder.getPartialTicks()); + float flapness = flapValue.get(AnimationTickHolder.getPartialTicks()); for (InstanceKey key : keys) { key.modifyInstance(data -> data.setFlapness(flapness)); } 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 bc5af6438..77938f65f 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 @@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; import java.util.*; import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.DistExecutor; @@ -113,6 +114,9 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe super.read(compound, clientPacket); + if (clientPacket) + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this)); + if (!clientPacket) return; if (!compound.contains("TriggerFlaps")) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java index c2d8f3893..665f49802 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelTileEntity.java @@ -15,6 +15,7 @@ import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock.Shape; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.item.TooltipHelper; +import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -331,6 +332,9 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn int direction = compound.getInt("Flap"); flap.set(direction); } + + if (clientPacket) + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this)); } @Override