Null checks and flap updates.

This commit is contained in:
JozsefA 2021-03-03 17:15:45 -08:00
parent fe492c5d75
commit 9062f1c8fa
3 changed files with 14 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials;
import com.simibubi.create.content.logistics.block.FlapData; 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.render.backend.instancing.*;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -72,8 +73,12 @@ public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity>
@Override @Override
public void tick() { public void tick() {
tunnelFlaps.forEach((direction, keys) -> { 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<FlapData> key : keys) { for (InstanceKey<FlapData> key : keys) {
key.modifyInstance(data -> data.setFlapness(flapness)); key.modifyInstance(data -> data.setFlapness(flapness));
} }

View File

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel;
import java.util.*; import java.util.*;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered; import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@ -113,6 +114,9 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe
super.read(compound, clientPacket); super.read(compound, clientPacket);
if (clientPacket)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this));
if (!clientPacket) if (!clientPacket)
return; return;
if (!compound.contains("TriggerFlaps")) if (!compound.contains("TriggerFlaps"))

View File

@ -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.config.AllConfigs;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.item.TooltipHelper; 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.render.backend.instancing.IInstanceRendered;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -331,6 +332,9 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
int direction = compound.getInt("Flap"); int direction = compound.getInt("Flap");
flap.set(direction); flap.set(direction);
} }
if (clientPacket)
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> FastRenderDispatcher.enqueueUpdate(this));
} }
@Override @Override