Unbotch the batch
- Contraptions now render properly with batching - Belts can be placed sideways again
This commit is contained in:
parent
3517f04a70
commit
fa51b68709
12 changed files with 91 additions and 63 deletions
|
@ -9,6 +9,7 @@ import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
|
@ -38,7 +39,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
@OnlyIn(value = Dist.CLIENT)
|
@OnlyIn(value = Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
||||||
if (!Backend.isOn())
|
if (!FlwContraption.canInstance())
|
||||||
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
@ -58,7 +59,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
||||||
if (!Backend.isOn())
|
if (!FlwContraption.canInstance())
|
||||||
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption;
|
||||||
import com.simibubi.create.content.logistics.trains.entity.CarriageContraption;
|
import com.simibubi.create.content.logistics.trains.entity.CarriageContraption;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||||
|
@ -55,7 +56,7 @@ public class PortableStorageInterfaceMovement implements MovementBehaviour {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
||||||
if (!Backend.isOn())
|
if (!FlwContraption.canInstance())
|
||||||
PortableStorageInterfaceRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
PortableStorageInterfaceRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +71,9 @@ public class PortableStorageInterfaceMovement implements MovementBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(MovementContext context) {
|
public void tick(MovementContext context) {
|
||||||
if (context.world.isClientSide)
|
if (context.world.isClientSide)
|
||||||
getAnimation(context).tickChaser();
|
getAnimation(context).tickChaser();
|
||||||
|
|
||||||
boolean onCarriage = context.contraption instanceof CarriageContraption;
|
boolean onCarriage = context.contraption instanceof CarriageContraption;
|
||||||
if (onCarriage && context.motion.length() > 1 / 4f)
|
if (onCarriage && context.motion.length() > 1 / 4f)
|
||||||
return;
|
return;
|
||||||
|
@ -152,7 +153,7 @@ public class PortableStorageInterfaceMovement implements MovementBehaviour {
|
||||||
public void stopMoving(MovementContext context) {
|
public void stopMoving(MovementContext context) {
|
||||||
// reset(context);
|
// reset(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelStall(MovementContext context) {
|
public void cancelStall(MovementContext context) {
|
||||||
reset(context);
|
reset(context);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption;
|
||||||
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
||||||
import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity;
|
import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity;
|
||||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||||
|
@ -290,7 +291,7 @@ public class DeployerMovementBehaviour implements MovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
||||||
if (!Backend.isOn())
|
if (!FlwContraption.canInstance())
|
||||||
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -849,35 +849,35 @@ public abstract class Contraption {
|
||||||
|
|
||||||
this.blocks.put(info.pos, info);
|
this.blocks.put(info.pos, info);
|
||||||
|
|
||||||
if (world.isClientSide) {
|
if (!world.isClientSide)
|
||||||
Block block = info.state.getBlock();
|
return;
|
||||||
CompoundTag tag = info.nbt;
|
|
||||||
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block);
|
|
||||||
if (tag == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
tag.putInt("x", info.pos.getX());
|
Block block = info.state.getBlock();
|
||||||
tag.putInt("y", info.pos.getY());
|
CompoundTag tag = info.nbt;
|
||||||
tag.putInt("z", info.pos.getZ());
|
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(block);
|
||||||
|
if (tag == null)
|
||||||
|
return;
|
||||||
|
|
||||||
BlockEntity te = BlockEntity.loadStatic(info.pos, info.state, tag);
|
tag.putInt("x", info.pos.getX());
|
||||||
if (te == null)
|
tag.putInt("y", info.pos.getY());
|
||||||
return;
|
tag.putInt("z", info.pos.getZ());
|
||||||
te.setLevel(world);
|
|
||||||
if (te instanceof KineticTileEntity)
|
|
||||||
((KineticTileEntity) te).setSpeed(0);
|
|
||||||
te.getBlockState();
|
|
||||||
|
|
||||||
if (movementBehaviour == null || !movementBehaviour.hasSpecialInstancedRendering())
|
BlockEntity te = BlockEntity.loadStatic(info.pos, info.state, tag);
|
||||||
maybeInstancedTileEntities.add(te);
|
if (te == null)
|
||||||
|
return;
|
||||||
|
te.setLevel(world);
|
||||||
|
if (te instanceof KineticTileEntity)
|
||||||
|
((KineticTileEntity) te).setSpeed(0);
|
||||||
|
te.getBlockState();
|
||||||
|
|
||||||
if (movementBehaviour != null && !movementBehaviour.renderAsNormalTileEntity())
|
if (movementBehaviour == null || !movementBehaviour.hasSpecialInstancedRendering())
|
||||||
return;
|
maybeInstancedTileEntities.add(te);
|
||||||
|
|
||||||
presentTileEntities.put(info.pos, te);
|
if (movementBehaviour != null && !movementBehaviour.renderAsNormalTileEntity())
|
||||||
specialRenderedTileEntities.add(te);
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
|
presentTileEntities.put(info.pos, te);
|
||||||
|
specialRenderedTileEntities.add(te);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption;
|
||||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
@ -34,7 +35,7 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||||
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
ContraptionMatrices matrices, MultiBufferSource buffer) {
|
||||||
if (Backend.isOn())
|
if (FlwContraption.canInstance())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Direction facing = context.state.getValue(BlockStateProperties.FACING);
|
Direction facing = context.state.getValue(BlockStateProperties.FACING);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.error.GlError;
|
import com.jozufozu.flywheel.backend.gl.error.GlError;
|
||||||
|
import com.jozufozu.flywheel.config.BackendType;
|
||||||
import com.jozufozu.flywheel.core.model.ModelUtil;
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
|
@ -48,7 +49,7 @@ public class ContraptionRenderDispatcher {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset a contraption's renderer.
|
* Reset a contraption's renderer.
|
||||||
*
|
*
|
||||||
* @param contraption The contraption to invalidate.
|
* @param contraption The contraption to invalidate.
|
||||||
* @return true if there was a renderer associated with the given contraption.
|
* @return true if there was a renderer associated with the given contraption.
|
||||||
*/
|
*/
|
||||||
|
@ -119,7 +120,12 @@ public class ContraptionRenderDispatcher {
|
||||||
BlockPos origin = c.anchor;
|
BlockPos origin = c.anchor;
|
||||||
int height = contraptionWorld.getHeight();
|
int height = contraptionWorld.getHeight();
|
||||||
int minBuildHeight = contraptionWorld.getMinBuildHeight();
|
int minBuildHeight = contraptionWorld.getMinBuildHeight();
|
||||||
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, origin, height, minBuildHeight);
|
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, origin, height, minBuildHeight) {
|
||||||
|
@Override
|
||||||
|
public boolean supportsFlywheel() {
|
||||||
|
return Backend.getBackendType() == BackendType.INSTANCING;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderWorld.setBlockEntities(c.presentTileEntities.values());
|
renderWorld.setBlockEntities(c.presentTileEntities.values());
|
||||||
for (StructureTemplate.StructureBlockInfo info : c.getBlocks()
|
for (StructureTemplate.StructureBlockInfo info : c.getBlocks()
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine;
|
import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine;
|
||||||
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
||||||
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
|
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
|
||||||
|
import com.jozufozu.flywheel.config.BackendType;
|
||||||
import com.jozufozu.flywheel.core.model.Model;
|
import com.jozufozu.flywheel.core.model.Model;
|
||||||
import com.jozufozu.flywheel.core.model.WorldModel;
|
import com.jozufozu.flywheel.core.model.WorldModel;
|
||||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
|
@ -53,13 +54,17 @@ public class FlwContraption extends ContraptionRenderInfo {
|
||||||
|
|
||||||
var restoreState = GlStateTracker.getRestoreState();
|
var restoreState = GlStateTracker.getRestoreState();
|
||||||
buildLayers();
|
buildLayers();
|
||||||
if (Backend.isOn()) {
|
if (canInstance()) {
|
||||||
buildInstancedTiles();
|
buildInstancedTiles();
|
||||||
buildActors();
|
buildActors();
|
||||||
}
|
}
|
||||||
restoreState.restore();
|
restoreState.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canInstance() {
|
||||||
|
return Backend.getBackendType() == BackendType.INSTANCING;
|
||||||
|
}
|
||||||
|
|
||||||
public ContraptionLighter<?> getLighter() {
|
public ContraptionLighter<?> getLighter() {
|
||||||
return lighter;
|
return lighter;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +144,7 @@ public class FlwContraption extends ContraptionRenderInfo {
|
||||||
|
|
||||||
List<RenderType> blockLayers = RenderType.chunkBufferLayers();
|
List<RenderType> blockLayers = RenderType.chunkBufferLayers();
|
||||||
Collection<StructureBlockInfo> renderedBlocks = contraption.getRenderedBlocks();
|
Collection<StructureBlockInfo> renderedBlocks = contraption.getRenderedBlocks();
|
||||||
|
|
||||||
for (RenderType layer : blockLayers) {
|
for (RenderType layer : blockLayers) {
|
||||||
Model layerModel = new WorldModel(renderWorld, layer, renderedBlocks, layer + "_" + contraption.entity.getId());
|
Model layerModel = new WorldModel(renderWorld, layer, renderedBlocks, layer + "_" + contraption.entity.getId());
|
||||||
renderLayers.put(layer, new ArrayModelRenderer(layerModel));
|
renderLayers.put(layer, new ArrayModelRenderer(layerModel));
|
||||||
|
@ -147,16 +152,15 @@ public class FlwContraption extends ContraptionRenderInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildInstancedTiles() {
|
private void buildInstancedTiles() {
|
||||||
Collection<BlockEntity> tileEntities = contraption.maybeInstancedTileEntities;
|
for (BlockEntity te : contraption.maybeInstancedTileEntities) {
|
||||||
if (!tileEntities.isEmpty()) {
|
if (!InstancedRenderRegistry.canInstance(te.getType())) {
|
||||||
for (BlockEntity te : tileEntities) {
|
continue;
|
||||||
if (InstancedRenderRegistry.canInstance(te.getType())) {
|
|
||||||
Level world = te.getLevel();
|
|
||||||
te.setLevel(renderWorld);
|
|
||||||
instanceWorld.tileInstanceManager.add(te);
|
|
||||||
te.setLevel(world);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Level world = te.getLevel();
|
||||||
|
te.setLevel(renderWorld);
|
||||||
|
instanceWorld.tileInstanceManager.add(te);
|
||||||
|
te.setLevel(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,12 @@ public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContrapt
|
||||||
GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
|
GlStateTracker.State restoreState = GlStateTracker.getRestoreState();
|
||||||
GlTextureUnit active = GlTextureUnit.getActive();
|
GlTextureUnit active = GlTextureUnit.getActive();
|
||||||
|
|
||||||
if (Backend.getBackendType() != BackendType.BATCHING) {
|
var backendType = Backend.getBackendType();
|
||||||
|
if (backendType != BackendType.OFF) {
|
||||||
renderStructures(event);
|
renderStructures(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getLayer() != null) {
|
if (backendType != BackendType.BATCHING && event.getLayer() != null) {
|
||||||
for (FlwContraption renderer : visible) {
|
for (FlwContraption renderer : visible) {
|
||||||
renderer.renderInstanceLayer(event);
|
renderer.renderInstanceLayer(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,6 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
failed = true;
|
failed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existingBlock.getMaterial()
|
|
||||||
.isReplaceable())
|
|
||||||
world.destroyBlock(pos, false);
|
|
||||||
|
|
||||||
BeltPart part = pos.equals(start) ? BeltPart.START : pos.equals(end) ? BeltPart.END : BeltPart.MIDDLE;
|
BeltPart part = pos.equals(start) ? BeltPart.START : pos.equals(end) ? BeltPart.END : BeltPart.MIDDLE;
|
||||||
BlockState shaftState = world.getBlockState(pos);
|
BlockState shaftState = world.getBlockState(pos);
|
||||||
|
@ -154,15 +150,20 @@ public class BeltConnectorItem extends BlockItem {
|
||||||
part = BeltPart.PULLEY;
|
part = BeltPart.PULLEY;
|
||||||
if (pulley && shaftState.getValue(AbstractSimpleShaftBlock.AXIS) == Axis.Y)
|
if (pulley && shaftState.getValue(AbstractSimpleShaftBlock.AXIS) == Axis.Y)
|
||||||
slope = BeltSlope.SIDEWAYS;
|
slope = BeltSlope.SIDEWAYS;
|
||||||
|
|
||||||
|
if (!existingBlock.getMaterial()
|
||||||
|
.isReplaceable())
|
||||||
|
world.destroyBlock(pos, false);
|
||||||
|
|
||||||
KineticTileEntity.switchToBlockState(world, pos, beltBlock.setValue(BeltBlock.SLOPE, slope)
|
KineticTileEntity.switchToBlockState(world, pos, beltBlock.setValue(BeltBlock.SLOPE, slope)
|
||||||
.setValue(BeltBlock.PART, part)
|
.setValue(BeltBlock.PART, part)
|
||||||
.setValue(BeltBlock.HORIZONTAL_FACING, facing));
|
.setValue(BeltBlock.HORIZONTAL_FACING, facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!failed)
|
if (!failed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (BlockPos pos : beltsToCreate)
|
for (BlockPos pos : beltsToCreate)
|
||||||
if (AllBlocks.BELT.has(world.getBlockState(pos)))
|
if (AllBlocks.BELT.has(world.getBlockState(pos)))
|
||||||
world.destroyBlock(pos, false);
|
world.destroyBlock(pos, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class CarriageContraptionEntityRenderer extends ContraptionEntityRenderer
|
||||||
: BlockPos.ZERO.relative(entity.getInitialOrientation()
|
: BlockPos.ZERO.relative(entity.getInitialOrientation()
|
||||||
.getCounterClockWise(), bogeySpacing);
|
.getCounterClockWise(), bogeySpacing);
|
||||||
|
|
||||||
if (!Backend.isOn() && !entity.getContraption()
|
if (!Backend.canUseInstancing(entity.level) && !entity.getContraption()
|
||||||
.isHiddenInPortal(bogeyPos)) {
|
.isHiddenInPortal(bogeyPos)) {
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
|
import com.jozufozu.flywheel.config.BackendType;
|
||||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
@ -48,7 +49,7 @@ public class TileEntityRenderHelper {
|
||||||
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
|
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
BlockEntity tileEntity = iterator.next();
|
BlockEntity tileEntity = iterator.next();
|
||||||
if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.shouldSkipRender(tileEntity))
|
if (Backend.getBackendType() == BackendType.INSTANCING && Backend.isFlywheelWorld(renderWorld) && InstancedRenderRegistry.shouldSkipRender(tileEntity))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);
|
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);
|
||||||
|
@ -63,16 +64,16 @@ public class TileEntityRenderHelper {
|
||||||
.translate(pos);
|
.translate(pos);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BlockPos lightPos;
|
int worldLight = getCombinedLight(world, getLightPos(lightTransform, pos), renderWorld, pos);
|
||||||
if (lightTransform != null) {
|
|
||||||
Vector4f lightVec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
|
if (renderWorld != null) {
|
||||||
lightVec.transform(lightTransform);
|
// Swap the real world for the render world so that the renderer gets contraption-local information
|
||||||
lightPos = new BlockPos(lightVec.x(), lightVec.y(), lightVec.z());
|
tileEntity.setLevel(renderWorld);
|
||||||
|
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||||
|
tileEntity.setLevel(world);
|
||||||
} else {
|
} else {
|
||||||
lightPos = pos;
|
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||||
}
|
}
|
||||||
int worldLight = getCombinedLight(world, lightPos, renderWorld, pos);
|
|
||||||
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
@ -90,6 +91,16 @@ public class TileEntityRenderHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BlockPos getLightPos(@Nullable Matrix4f lightTransform, BlockPos contraptionPos) {
|
||||||
|
if (lightTransform != null) {
|
||||||
|
Vector4f lightVec = new Vector4f(contraptionPos.getX() + .5f, contraptionPos.getY() + .5f, contraptionPos.getZ() + .5f, 1);
|
||||||
|
lightVec.transform(lightTransform);
|
||||||
|
return new BlockPos(lightVec.x(), lightVec.y(), lightVec.z());
|
||||||
|
} else {
|
||||||
|
return contraptionPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable VirtualRenderWorld renderWorld,
|
public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable VirtualRenderWorld renderWorld,
|
||||||
BlockPos renderWorldPos) {
|
BlockPos renderWorldPos) {
|
||||||
int worldLight = LevelRenderer.getLightColor(world, worldPos);
|
int worldLight = LevelRenderer.getLightColor(world, worldPos);
|
||||||
|
|
Loading…
Reference in a new issue