No more diffuse divide

- Move PlacementSimulationWorld to Flywheel as VirtualRenderWorld
 - Simplify ModelTransformer
 - Model doesn't need #configure
 - Bump Flywheel build
This commit is contained in:
Jozufozu 2021-12-25 01:01:48 -08:00
parent 714b926ee3
commit d98a07736c
40 changed files with 336 additions and 795 deletions

View file

@ -17,11 +17,10 @@ plugins {
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
boolean dev = System.getenv('RELEASE') == null || System.getenv('RELEASE').equals('false');
// jozu: I use a gradle workspace with both projects.

View file

@ -19,7 +19,7 @@ parchment_version = 2021.12.19
# dependency versions
registrate_version = MC1.18-1.0.21
flywheel_version = 1.18-0.5.0.28
flywheel_version = 1.18-0.5.0.30
jei_minecraft_version = 1.18
jei_version = 9.0.0.40

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.math.Quaternion;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.actors.flwdata.ActorData;
@ -10,7 +11,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren
import com.simibubi.create.foundation.render.AllMaterialSpecs;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
@ -20,7 +20,7 @@ public class DrillActorInstance extends ActorInstance {
ActorData drillHead;
private final Direction facing;
public DrillActorInstance(MaterialManager materialManager, PlacementSimulationWorld contraption, MovementContext context) {
public DrillActorInstance(MaterialManager materialManager, VirtualRenderWorld contraption, MovementContext context) {
super(materialManager, contraption, context);
Material<ActorData> material = materialManager.defaultSolid()

View file

@ -4,11 +4,11 @@ import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
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.ContraptionMatrices;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -35,7 +35,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
@OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (!Backend.isOn())
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
@ -48,7 +48,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@Nullable
@Override
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
return new DrillActorInstance(materialManager, simulationWorld, context);
}

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.actors;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
@ -11,7 +12,6 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -30,7 +30,7 @@ public class DrillRenderer extends KineticTileEntityRenderer {
return CachedBufferer.partialFacing(AllBlockPartials.DRILL_HEAD, state);
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
BlockState state = context.state;
SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.DRILL_HEAD, state);

View file

@ -4,13 +4,13 @@ import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
@ -31,7 +31,7 @@ public class HarvesterActorInstance extends ActorInstance {
private double rotation;
private double previousRotation;
public HarvesterActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public HarvesterActorInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
super(materialManager, simulationWorld, context);
Material<ModelData> material = materialManager.defaultCutout()

View file

@ -6,6 +6,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
@ -13,7 +14,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -50,13 +50,13 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
@Nullable
@Override
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld,
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld,
MovementContext context) {
return new HarvesterActorInstance(materialManager, simulationWorld, context);
}
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.isOn())
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
@ -13,7 +14,6 @@ import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -40,7 +40,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
.renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
BlockState blockState = context.state;
Direction facing = blockState.getValue(HORIZONTAL_FACING);

View file

@ -2,11 +2,11 @@ package com.simibubi.create.content.contraptions.components.actors;
import java.util.Optional;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -32,7 +32,7 @@ public class PortableStorageInterfaceMovement extends MovementBehaviour {
@Override
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
PortableStorageInterfaceRenderer.renderInContraption(context, renderWorld, matrices, buffer);
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import java.util.function.Consumer;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials;
@ -15,7 +16,6 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -41,7 +41,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
.renderInto(ms, vb));
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
BlockState blockState = context.state;
PortableStorageInterfaceTileEntity te = getTargetPSI(context);

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import java.util.Optional;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.content.contraptions.components.saw.SawBlock;
import com.simibubi.create.content.contraptions.components.saw.SawRenderer;
import com.simibubi.create.content.contraptions.components.saw.SawTileEntity;
@ -10,7 +11,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren
import com.simibubi.create.foundation.utility.AbstractBlockBreakQueue;
import com.simibubi.create.foundation.utility.TreeCutter;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -86,7 +86,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour {
@Override
@OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
SawRenderer.renderInContraption(context, renderWorld, matrices, buffer);
}

View file

@ -8,6 +8,7 @@ import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate;
@ -20,7 +21,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -42,7 +42,7 @@ public class DeployerActorInstance extends ActorInstance {
ModelData hand;
RotatingData shaft;
public DeployerActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public DeployerActorInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
super(materialManager, simulationWorld, context);
Material<ModelData> mat = materialManager.defaultSolid()

View file

@ -78,7 +78,7 @@ public class DeployerHandler {
boolean rayMode = false;
private ItemUseWorld(Level world, Direction face, BlockPos pos) {
super(world, world.getChunkSource());
super(world);
this.face = face;
this.pos = pos;
}

View file

@ -9,6 +9,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllTags.AllBlockTags;
@ -27,7 +28,6 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.NBTProcessors;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -255,7 +255,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
}
@Override
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffers) {
if (!Backend.isOn())
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
@ -268,7 +268,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
@Nullable
@Override
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
return new DeployerActorInstance(materialManager, simulationWorld, context);
}
}

View file

@ -5,6 +5,7 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
@ -26,7 +27,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
@ -155,7 +155,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
return buffer;
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = context.state;

View file

@ -4,6 +4,7 @@ import static net.minecraft.world.level.block.state.properties.BlockStatePropert
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
@ -18,7 +19,6 @@ import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRe
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
@ -157,7 +157,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
}
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
BlockState state = context.state;
Direction facing = state.getValue(SawBlock.FACING);

View file

@ -3,10 +3,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.core.BlockPos;
@ -66,12 +66,12 @@ public abstract class MovementBehaviour {
}
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {}
@OnlyIn(Dist.CLIENT)
@Nullable
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
return null;
}

View file

@ -3,13 +3,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
@ -23,7 +23,7 @@ public class StabilizedBearingInstance extends ActorInstance {
final Vector3f rotationAxis;
final Quaternion blockOrientation;
public StabilizedBearingInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public StabilizedBearingInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
super(materialManager, simulationWorld, context);
BlockState blockState = context.state;

View file

@ -5,6 +5,7 @@ import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.mojang.math.Quaternion;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
@ -18,7 +19,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -32,7 +32,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
@Override
@OnlyIn(Dist.CLIENT)
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
public void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) {
if (Backend.isOn()) return;
@ -70,7 +70,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
@Nullable
@Override
public ActorInstance createInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
public ActorInstance createInstance(MaterialManager materialManager, VirtualRenderWorld simulationWorld, MovementContext context) {
return new StabilizedBearingInstance(materialManager, simulationWorld, context);
}

View file

@ -1,17 +1,17 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.world.level.LightLayer;
public abstract class ActorInstance {
protected final MaterialManager materialManager;
protected final PlacementSimulationWorld simulationWorld;
protected final VirtualRenderWorld simulationWorld;
protected final MovementContext context;
public ActorInstance(MaterialManager materialManager, PlacementSimulationWorld world, MovementContext context) {
public ActorInstance(MaterialManager materialManager, VirtualRenderWorld world, MovementContext context) {
this.materialManager = materialManager;
this.simulationWorld = world;
this.context = context;

View file

@ -9,10 +9,10 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos;
@ -22,9 +22,9 @@ public class ContraptionInstanceManager extends TileInstanceManager {
protected ArrayList<ActorInstance> actors = new ArrayList<>();
private final PlacementSimulationWorld renderWorld;
private final VirtualRenderWorld renderWorld;
ContraptionInstanceManager(MaterialManager materialManager, PlacementSimulationWorld contraption) {
ContraptionInstanceManager(MaterialManager materialManager, VirtualRenderWorld contraption) {
super(materialManager);
this.renderWorld = contraption;
}

View file

@ -7,6 +7,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.gl.error.GlError;
import com.jozufozu.flywheel.core.model.ModelUtil;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.GatherContextEvent;
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
@ -22,7 +23,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.TileEntityRenderHelper;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer;
@ -93,7 +93,7 @@ public class ContraptionRenderDispatcher {
// something went wrong with the other rendering
if (!matrices.isReady()) return;
PlacementSimulationWorld renderWorld = renderInfo.renderWorld;
VirtualRenderWorld renderWorld = renderInfo.renderWorld;
renderTileEntities(world, renderWorld, contraption, matrices, buffers);
@ -103,8 +103,8 @@ public class ContraptionRenderDispatcher {
renderActors(world, renderWorld, contraption, matrices, buffers);
}
public static PlacementSimulationWorld setupRenderWorld(Level world, Contraption c) {
PlacementSimulationWorld renderWorld = new PlacementSimulationWorld(world);
public static VirtualRenderWorld setupRenderWorld(Level world, Contraption c) {
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world);
renderWorld.setTileEntities(c.presentTileEntities.values());
@ -118,13 +118,13 @@ public class ContraptionRenderDispatcher {
return renderWorld;
}
public static void renderTileEntities(Level world, PlacementSimulationWorld renderWorld, Contraption c,
public static void renderTileEntities(Level world, VirtualRenderWorld renderWorld, Contraption c,
ContraptionMatrices matrices, MultiBufferSource buffer) {
TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities,
matrices.getModelViewProjection(), matrices.getLight(), buffer);
}
protected static void renderActors(Level world, PlacementSimulationWorld renderWorld, Contraption c,
protected static void renderActors(Level world, VirtualRenderWorld renderWorld, Contraption c,
ContraptionMatrices matrices, MultiBufferSource buffer) {
PoseStack m = matrices.getModel();
@ -147,7 +147,7 @@ public class ContraptionRenderDispatcher {
}
}
public static SuperByteBuffer buildStructureBuffer(PlacementSimulationWorld renderWorld, Contraption c, RenderType layer) {
public static SuperByteBuffer buildStructureBuffer(VirtualRenderWorld renderWorld, Contraption c, RenderType layer) {
Collection<StructureTemplate.StructureBlockInfo> values = c.getBlocks()
.values();
BufferBuilder builder = ModelUtil.getBufferBuilderFromTemplate(renderWorld, layer, values);
@ -170,7 +170,7 @@ public class ContraptionRenderDispatcher {
return LightTexture.pack((int) block, (int) sky);
}
public static int getContraptionWorldLight(MovementContext context, PlacementSimulationWorld renderWorld) {
public static int getContraptionWorldLight(MovementContext context, VirtualRenderWorld renderWorld) {
return LevelRenderer.getLightColor(renderWorld, context.localPos);
}

View file

@ -1,23 +1,22 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.util.Mth;
public class ContraptionRenderInfo {
public final Contraption contraption;
public final PlacementSimulationWorld renderWorld;
public final VirtualRenderWorld renderWorld;
private final ContraptionMatrices matrices = new ContraptionMatrices();
private boolean visible;
public ContraptionRenderInfo(Contraption contraption, PlacementSimulationWorld renderWorld) {
public ContraptionRenderInfo(Contraption contraption, VirtualRenderWorld renderWorld) {
this.contraption = contraption;
this.renderWorld = renderWorld;
}

View file

@ -10,13 +10,13 @@ import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.instancing.Engine;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.backend.instancing.SerialTaskEngine;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
import com.jozufozu.flywheel.backend.model.ModelRenderer;
import com.jozufozu.flywheel.core.model.Model;
import com.jozufozu.flywheel.core.model.WorldModel;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.mojang.blaze3d.vertex.PoseStack;
@ -26,7 +26,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
import com.simibubi.create.foundation.render.CreateContexts;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.util.Mth;
@ -47,7 +46,7 @@ public class FlwContraption extends ContraptionRenderInfo {
// floats because we upload this to the gpu
private AABB lightBox;
public FlwContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
public FlwContraption(Contraption contraption, VirtualRenderWorld renderWorld) {
super(contraption, renderWorld);
this.lighter = contraption.makeLighter();

View file

@ -7,12 +7,12 @@ import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.RenderLayer;
import com.jozufozu.flywheel.backend.gl.GlTextureUnit;
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.jozufozu.flywheel.util.Textures;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.AllProgramSpecs;
import com.simibubi.create.foundation.render.CreateContexts;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.LevelAccessor;
@ -78,7 +78,7 @@ public class FlwContraptionManager extends ContraptionRenderingWorld<FlwContrapt
@Override
protected FlwContraption create(Contraption c) {
PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
VirtualRenderWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
return new FlwContraption(c, renderWorld);
}

View file

@ -1,12 +1,12 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.LevelAccessor;
@ -34,7 +34,7 @@ public class SBBContraptionManager extends ContraptionRenderingWorld<Contraption
@Override
protected ContraptionRenderInfo create(Contraption c) {
PlacementSimulationWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
VirtualRenderWorld renderWorld = ContraptionRenderDispatcher.setupRenderWorld(world, c);
return new ContraptionRenderInfo(c, renderWorld);
}

View file

@ -4,7 +4,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
import com.jozufozu.flywheel.core.virtual.VirtualEmptyModelData;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import net.minecraft.client.Minecraft;

View file

@ -0,0 +1,255 @@
package com.simibubi.create.content.schematics;
import java.util.List;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.TagContainer;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.entity.LevelEntityGetter;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.level.storage.WritableLevelData;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.ticks.BlackholeTickAccess;
import net.minecraft.world.ticks.LevelTickAccess;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
public class SchematicChunkSource extends ChunkSource {
private final Level fallbackWorld;
public SchematicChunkSource(Level world) {
fallbackWorld = world;
}
@Nullable
@Override
public BlockGetter getChunkForLighting(int x, int z) {
return getChunk(x, z);
}
@Override
public Level getLevel() {
return fallbackWorld;
}
@Nullable
@Override
public ChunkAccess getChunk(int x, int z, ChunkStatus status, boolean p_212849_4_) {
return getChunk(x, z);
}
public ChunkAccess getChunk(int x, int z) {
return new EmptierChunk(fallbackWorld.registryAccess());
}
@Override
public String gatherStats() {
return "WrappedChunkProvider";
}
@Override
public LevelLightEngine getLightEngine() {
return fallbackWorld.getLightEngine();
}
@Override
public void tick(BooleanSupplier pHasTimeLeft) {}
@Override
public int getLoadedChunksCount() {
return 0;
}
public static class EmptierChunk extends LevelChunk {
private static final class DummyLevel extends Level {
RegistryAccess access;
private DummyLevel(WritableLevelData p_46450_, ResourceKey<Level> p_46451_, DimensionType p_46452_,
Supplier<ProfilerFiller> p_46453_, boolean p_46454_, boolean p_46455_, long p_46456_) {
super(p_46450_, p_46451_, p_46452_, p_46453_, p_46454_, p_46455_, p_46456_);
}
public Level withAccess(RegistryAccess access) {
this.access = access;
return this;
}
@Override
public ChunkSource getChunkSource() {
return null;
}
@Override
public void levelEvent(Player pPlayer, int pType, BlockPos pPos, int pData) {}
@Override
public void gameEvent(Entity pEntity, GameEvent pEvent, BlockPos pPos) {}
@Override
public RegistryAccess registryAccess() {
return access;
}
@Override
public List<? extends Player> players() {
return null;
}
@Override
public Biome getUncachedNoiseBiome(int pX, int pY, int pZ) {
return null;
}
@Override
public float getShade(Direction pDirection, boolean pShade) {
return 0;
}
@Override
public void sendBlockUpdated(BlockPos pPos, BlockState pOldState, BlockState pNewState, int pFlags) {}
@Override
public void playSound(Player pPlayer, double pX, double pY, double pZ, SoundEvent pSound, SoundSource pCategory,
float pVolume, float pPitch) {}
@Override
public void playSound(Player pPlayer, Entity pEntity, SoundEvent pEvent, SoundSource pCategory, float pVolume,
float pPitch) {}
@Override
public String gatherChunkSourceStats() {
return null;
}
@Override
public Entity getEntity(int pId) {
return null;
}
@Override
public MapItemSavedData getMapData(String pMapName) {
return null;
}
@Override
public void setMapData(String pMapId, MapItemSavedData pData) {}
@Override
public int getFreeMapId() {
return 0;
}
@Override
public void destroyBlockProgress(int pBreakerId, BlockPos pPos, int pProgress) {}
@Override
public Scoreboard getScoreboard() {
return null;
}
@Override
public RecipeManager getRecipeManager() {
return null;
}
@Override
public TagContainer getTagManager() {
return null;
}
@Override
protected LevelEntityGetter<Entity> getEntities() {
return null;
}
@Override
public LevelTickAccess<Block> getBlockTicks() {
return BlackholeTickAccess.emptyLevelList();
}
@Override
public LevelTickAccess<Fluid> getFluidTicks() {
return BlackholeTickAccess.emptyLevelList();
}
}
private static final DummyLevel DUMMY_LEVEL = new DummyLevel(null, null,
ObfuscationReflectionHelper.getPrivateValue(DimensionType.class, null, "f_63848_"), null, false, false, 0);
public EmptierChunk(RegistryAccess registryAccess) {
super(DUMMY_LEVEL.withAccess(registryAccess), null);
}
public BlockState getBlockState(BlockPos p_180495_1_) {
return Blocks.VOID_AIR.defaultBlockState();
}
@Nullable
public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
return null;
}
public FluidState getFluidState(BlockPos p_204610_1_) {
return Fluids.EMPTY.defaultFluidState();
}
public int getLightEmission(BlockPos p_217298_1_) {
return 0;
}
@Nullable
public BlockEntity getBlockEntity(BlockPos p_177424_1_, EntityCreationType p_177424_2_) {
return null;
}
public void addAndRegisterBlockEntity(BlockEntity p_150813_1_) {}
public void setBlockEntity(BlockEntity p_177426_2_) {}
public void removeBlockEntity(BlockPos p_177425_1_) {}
public void markUnsaved() {}
public boolean isEmpty() {
return true;
}
public boolean isYSpaceEmpty(int p_76606_1_, int p_76606_2_) {
return true;
}
public ChunkHolder.FullChunkStatus getFullStatus() {
return ChunkHolder.FullChunkStatus.BORDER;
}
}
}

View file

@ -10,7 +10,6 @@ import java.util.function.Predicate;
import java.util.stream.Stream;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedChunkProvider;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.core.BlockPos;
@ -54,12 +53,8 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
}
public SchematicWorld(BlockPos anchor, Level original) {
this(anchor, original,new WrappedChunkProvider());
}
public SchematicWorld(BlockPos anchor, Level original, WrappedChunkProvider provider) {
super(original, provider);
provider.setFallbackWorld(this);
super(original);
setChunkSource(new SchematicChunkSource(this));
this.blocks = new HashMap<>();
this.tileEntities = new HashMap<>();
this.bounds = new BoundingBox(BlockPos.ZERO);

View file

@ -3,7 +3,7 @@ package com.simibubi.create.foundation.gui.element;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
import com.jozufozu.flywheel.core.virtual.VirtualEmptyModelData;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
import com.jozufozu.flywheel.api.vertex.VertexList;
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
import com.jozufozu.flywheel.util.transform.Rotate;
import com.jozufozu.flywheel.util.transform.Scale;
import com.jozufozu.flywheel.util.transform.TStack;
@ -127,7 +127,6 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
float ny = normal.y();
float nz = normal.z();
float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ);
float instanceDiffuse = LightUtil.diffuseLight(nx, ny, nz);
pos.set(x, y, z, 1F);
@ -152,9 +151,9 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
if (disableDiffuseDiv) {
diffuseMult = instanceDiffuse;
} else if (disableDiffuseMult) {
diffuseMult = 1 / staticDiffuse;
diffuseMult = 1;
} else {
diffuseMult = instanceDiffuse / staticDiffuse;
diffuseMult = instanceDiffuse;
}
int colorR = transformColor(r, diffuseMult);
int colorG = transformColor(g, diffuseMult);

View file

@ -6,6 +6,7 @@ import javax.annotation.Nullable;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
@ -13,7 +14,6 @@ import com.mojang.math.Vector4f;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LevelRenderer;
@ -36,13 +36,13 @@ public class TileEntityRenderHelper {
renderTileEntities(world, null, customRenderTEs, ms, null, buffer, pt);
}
public static void renderTileEntities(Level world, @Nullable PlacementSimulationWorld renderWorld,
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer) {
renderTileEntities(world, renderWorld, customRenderTEs, ms, lightTransform, buffer,
AnimationTickHolder.getPartialTicks());
}
public static void renderTileEntities(Level world, @Nullable PlacementSimulationWorld renderWorld,
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer,
float pt) {
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
@ -90,7 +90,7 @@ public class TileEntityRenderHelper {
}
}
public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable PlacementSimulationWorld renderWorld,
public static int getCombinedLight(Level world, BlockPos worldPos, @Nullable VirtualRenderWorld renderWorld,
BlockPos renderWorldPos) {
int worldLight = LevelRenderer.getLightColor(world, worldPos);

View file

@ -10,7 +10,7 @@ import javax.annotation.Nullable;
import org.lwjgl.system.MemoryStack;
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
import com.jozufozu.flywheel.core.virtual.VirtualEmptyModelData;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;

View file

@ -1,128 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.FlywheelWorld;
import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.lighting.LevelLightEngine;
public class PlacementSimulationWorld extends WrappedWorld implements FlywheelWorld {
public Map<BlockPos, BlockState> blocksAdded = new HashMap<>();
public Map<BlockPos, BlockEntity> tesAdded = new HashMap<>();
public Set<SectionPos> spannedSections = new HashSet<>();
public LevelLightEngine lighter;
public final WrappedChunkProvider chunkSource;
private final BlockPos.MutableBlockPos scratch = new BlockPos.MutableBlockPos();
public PlacementSimulationWorld(Level wrapped) {
this(wrapped, new WrappedChunkProvider());
}
public PlacementSimulationWorld(Level wrapped, WrappedChunkProvider chunkSource) {
super(wrapped, chunkSource);
// You can't leak this before the super ctor is called.
// You can't create inner classes before super ctor is called.
chunkSource.setPlacementWorld(this);
this.chunkSource = chunkSource;
lighter = new LevelLightEngine(chunkSource, true, false);
}
/**
* Run this after you're done using setBlock().
*/
public void runLightingEngine() {
for (Map.Entry<BlockPos, BlockState> entry : blocksAdded.entrySet()) {
BlockPos pos = entry.getKey();
BlockState state = entry.getValue();
int light = state.getLightEmission(this, pos);
if (light > 0) {
lighter.onBlockEmissionIncrease(pos, light);
}
}
lighter.runUpdates(Integer.MAX_VALUE, false, false);
}
@Override
public LevelLightEngine getLightEngine() {
return lighter;
}
public void setTileEntities(Collection<BlockEntity> tileEntities) {
tesAdded.clear();
tileEntities.forEach(te -> tesAdded.put(te.getBlockPos(), te));
}
public void clear() {
blocksAdded.clear();
}
@Override
public boolean setBlock(BlockPos pos, BlockState newState, int flags) {
blocksAdded.put(pos, newState);
SectionPos sectionPos = SectionPos.of(pos);
if (spannedSections.add(sectionPos)) {
lighter.updateSectionStatus(sectionPos, false);
}
if ((flags & Block.UPDATE_SUPPRESS_LIGHT) == 0) {
lighter.checkBlock(pos);
}
return true;
}
@Override
public boolean setBlockAndUpdate(BlockPos pos, BlockState state) {
return setBlock(pos, state, 0);
}
@Override
@Nullable
public BlockEntity getBlockEntity(BlockPos pos) {
return tesAdded.get(pos);
}
@Override
public boolean isStateAtPosition(BlockPos pos, Predicate<BlockState> condition) {
return condition.test(getBlockState(pos));
}
@Override
public boolean isLoaded(BlockPos pos) {
return true;
}
@Override
public boolean isAreaLoaded(BlockPos center, int range) {
return true;
}
public BlockState getBlockState(int x, int y, int z) {
return getBlockState(scratch.set(x, y, z));
}
@Override
public BlockState getBlockState(BlockPos pos) {
BlockState state = blocksAdded.get(pos);
if (state != null)
return state;
return Blocks.AIR.defaultBlockState();
}
}

View file

@ -1,90 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.EmptierChunk;
import com.simibubi.create.foundation.utility.worldWrappers.chunk.WrappedChunk;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.lighting.LevelLightEngine;
public class WrappedChunkProvider extends ChunkSource {
private PlacementSimulationWorld world;
private Level fallbackWorld;
public HashMap<Long, WrappedChunk> chunks;
public WrappedChunkProvider setFallbackWorld(Level world) {
fallbackWorld = world;
return this;
}
// VirtualChunkSource is created before VirtualRenderWorld, so we can't initialize it in the ctor.
public void setPlacementWorld(PlacementSimulationWorld world) {
fallbackWorld = this.world = world;
this.chunks = new HashMap<>();
}
public Stream<BlockPos> getLightSources() {
return world.blocksAdded.entrySet()
.stream()
.filter(it -> it.getValue()
.getLightEmission(world, it.getKey()) != 0)
.map(Map.Entry::getKey);
}
@Nullable
@Override
public BlockGetter getChunkForLighting(int x, int z) {
return getChunk(x, z);
}
@Override
public Level getLevel() {
return fallbackWorld;
}
@Nullable
@Override
public ChunkAccess getChunk(int x, int z, ChunkStatus status, boolean p_212849_4_) {
return getChunk(x, z);
}
public ChunkAccess getChunk(int x, int z) {
long pos = ChunkPos.asLong(x, z);
if (chunks == null)
return new EmptierChunk(fallbackWorld.registryAccess());
return chunks.computeIfAbsent(pos, $ -> new WrappedChunk(world, x, z));
}
@Override
public String gatherStats() {
return "WrappedChunkProvider";
}
@Override
public LevelLightEngine getLightEngine() {
return world.getLightEngine();
}
@Override
public void tick(BooleanSupplier pHasTimeLeft) {}
@Override
public int getLoadedChunksCount() {
return 0;
}
}

View file

@ -5,9 +5,7 @@ import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
@ -35,19 +33,18 @@ import net.minecraft.world.ticks.LevelTickAccess;
public class WrappedWorld extends Level {
protected Level world;
protected ChunkSource provider;
protected ChunkSource chunkSource;
protected LevelEntityGetter<Entity> entityGetter = new DummyLevelEntityGetter<>();
public WrappedWorld(Level world, ChunkSource provider) {
public WrappedWorld(Level world) {
super((WritableLevelData) world.getLevelData(), world.dimension(), world.dimensionType(), world::getProfiler,
world.isClientSide, world.isDebug(), 0);
this.world = world;
this.provider = provider;
}
public WrappedWorld(Level world) {
this(world, null);
public void setChunkSource(ChunkSource source) {
this.chunkSource = source;
}
public Level getLevel() {
@ -102,7 +99,7 @@ public class WrappedWorld extends Level {
@Override
public ChunkSource getChunkSource() {
return provider;
return chunkSource != null ? chunkSource : world.getChunkSource();
}
@Override

View file

@ -1,203 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
import java.util.List;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.TagContainer;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.entity.LevelEntityGetter;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.level.storage.WritableLevelData;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.ticks.BlackholeTickAccess;
import net.minecraft.world.ticks.LevelTickAccess;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
public class EmptierChunk extends LevelChunk {
private static final class DummyLevel extends Level {
RegistryAccess access;
private DummyLevel(WritableLevelData p_46450_, ResourceKey<Level> p_46451_, DimensionType p_46452_,
Supplier<ProfilerFiller> p_46453_, boolean p_46454_, boolean p_46455_, long p_46456_) {
super(p_46450_, p_46451_, p_46452_, p_46453_, p_46454_, p_46455_, p_46456_);
}
public Level withAccess(RegistryAccess access) {
this.access = access;
return this;
}
@Override
public ChunkSource getChunkSource() {
return null;
}
@Override
public void levelEvent(Player pPlayer, int pType, BlockPos pPos, int pData) {}
@Override
public void gameEvent(Entity pEntity, GameEvent pEvent, BlockPos pPos) {}
@Override
public RegistryAccess registryAccess() {
return access;
}
@Override
public List<? extends Player> players() {
return null;
}
@Override
public Biome getUncachedNoiseBiome(int pX, int pY, int pZ) {
return null;
}
@Override
public float getShade(Direction pDirection, boolean pShade) {
return 0;
}
@Override
public void sendBlockUpdated(BlockPos pPos, BlockState pOldState, BlockState pNewState, int pFlags) {}
@Override
public void playSound(Player pPlayer, double pX, double pY, double pZ, SoundEvent pSound, SoundSource pCategory,
float pVolume, float pPitch) {}
@Override
public void playSound(Player pPlayer, Entity pEntity, SoundEvent pEvent, SoundSource pCategory, float pVolume,
float pPitch) {}
@Override
public String gatherChunkSourceStats() {
return null;
}
@Override
public Entity getEntity(int pId) {
return null;
}
@Override
public MapItemSavedData getMapData(String pMapName) {
return null;
}
@Override
public void setMapData(String pMapId, MapItemSavedData pData) {}
@Override
public int getFreeMapId() {
return 0;
}
@Override
public void destroyBlockProgress(int pBreakerId, BlockPos pPos, int pProgress) {}
@Override
public Scoreboard getScoreboard() {
return null;
}
@Override
public RecipeManager getRecipeManager() {
return null;
}
@Override
public TagContainer getTagManager() {
return null;
}
@Override
protected LevelEntityGetter<Entity> getEntities() {
return null;
}
@Override
public LevelTickAccess<Block> getBlockTicks() {
return BlackholeTickAccess.emptyLevelList();
}
@Override
public LevelTickAccess<Fluid> getFluidTicks() {
return BlackholeTickAccess.emptyLevelList();
}
}
private static final DummyLevel DUMMY_LEVEL = new DummyLevel(null, null,
ObfuscationReflectionHelper.getPrivateValue(DimensionType.class, null, "f_63848_"), null, false, false, 0);
public EmptierChunk(RegistryAccess registryAccess) {
super(DUMMY_LEVEL.withAccess(registryAccess), null);
}
public BlockState getBlockState(BlockPos p_180495_1_) {
return Blocks.VOID_AIR.defaultBlockState();
}
@Nullable
public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
return null;
}
public FluidState getFluidState(BlockPos p_204610_1_) {
return Fluids.EMPTY.defaultFluidState();
}
public int getLightEmission(BlockPos p_217298_1_) {
return 0;
}
@Nullable
public BlockEntity getBlockEntity(BlockPos p_177424_1_, LevelChunk.EntityCreationType p_177424_2_) {
return null;
}
public void addAndRegisterBlockEntity(BlockEntity p_150813_1_) {}
public void setBlockEntity(BlockEntity p_177426_2_) {}
public void removeBlockEntity(BlockPos p_177425_1_) {}
public void markUnsaved() {}
public boolean isEmpty() {
return true;
}
public boolean isYSpaceEmpty(int p_76606_1_, int p_76606_2_) {
return true;
}
public ChunkHolder.FullChunkStatus getFullStatus() {
return ChunkHolder.FullChunkStatus.BORDER;
}
}

View file

@ -1,242 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.shorts.ShortList;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.ticks.BlackholeTickAccess;
import net.minecraft.world.ticks.TickContainerAccess;
public class WrappedChunk extends ChunkAccess {
final PlacementSimulationWorld world;
boolean needsLight;
final int x;
final int z;
private final LevelChunkSection[] sections;
public WrappedChunk(PlacementSimulationWorld world, int x, int z) {
super(new ChunkPos(x, z), UpgradeData.EMPTY, world, world.registryAccess()
.registry(Registry.BIOME_REGISTRY)
.orElseThrow(), 0L, null, null);
this.world = world;
this.needsLight = true;
this.x = x;
this.z = z;
this.sections = new LevelChunkSection[16];
for (int i = 0; i < 16; i++) {
sections[i] = new WrappedChunkSection(this, i << 4);
}
}
@Override
public Stream<BlockPos> getLights() {
return world.blocksAdded.entrySet()
.stream()
.filter(it -> {
BlockPos blockPos = it.getKey();
boolean chunkContains = blockPos.getX() >> 4 == x && blockPos.getZ() >> 4 == z;
return chunkContains && it.getValue()
.getLightEmission(world, blockPos) != 0;
})
.map(Map.Entry::getKey);
}
@Override
public LevelChunkSection[] getSections() {
return sections;
}
@Override
public ChunkStatus getStatus() {
return ChunkStatus.LIGHT;
}
@Nullable
@Override
public BlockState setBlockState(BlockPos p_177436_1_, BlockState p_177436_2_, boolean p_177436_3_) {
return null;
}
@Override
public void setBlockEntity(BlockEntity p_177426_2_) {}
@Override
public void addEntity(Entity p_76612_1_) {}
@Override
public Set<BlockPos> getBlockEntitiesPos() {
return null;
}
@Override
public Collection<Map.Entry<Heightmap.Types, Heightmap>> getHeightmaps() {
return null;
}
@Override
public void setHeightmap(Heightmap.Types p_201607_1_, long[] p_201607_2_) {}
@Override
public Heightmap getOrCreateHeightmapUnprimed(Heightmap.Types p_217303_1_) {
return null;
}
@Override
public int getHeight(Heightmap.Types p_201576_1_, int p_201576_2_, int p_201576_3_) {
return 0;
}
@Override
public void setUnsaved(boolean p_177427_1_) {}
@Override
public boolean isUnsaved() {
return false;
}
@Override
public void removeBlockEntity(BlockPos p_177425_1_) {}
@Override
public ShortList[] getPostProcessing() {
return new ShortList[0];
}
@Nullable
@Override
public CompoundTag getBlockEntityNbt(BlockPos p_201579_1_) {
return null;
}
@Nullable
@Override
public CompoundTag getBlockEntityNbtForSaving(BlockPos p_223134_1_) {
return null;
}
@Override
public UpgradeData getUpgradeData() {
return null;
}
@Override
public void setInhabitedTime(long p_177415_1_) {}
@Override
public long getInhabitedTime() {
return 0;
}
@Override
public boolean isLightCorrect() {
return needsLight;
}
@Override
public void setLightCorrect(boolean needsLight) {
this.needsLight = needsLight;
}
@Nullable
@Override
public BlockEntity getBlockEntity(BlockPos pos) {
return null;
}
@Override
public BlockState getBlockState(BlockPos pos) {
return world.getBlockState(pos);
}
@Override
public FluidState getFluidState(BlockPos p_204610_1_) {
return null;
}
@Override
public void addReferenceForFeature(StructureFeature<?> arg0, long arg1) {}
@Override
public Map<StructureFeature<?>, LongSet> getAllReferences() {
return null;
}
@Override
public LongSet getReferencesForFeature(StructureFeature<?> arg0) {
return null;
}
@Override
public StructureStart<?> getStartForFeature(StructureFeature<?> arg0) {
return null;
}
@Override
public void setAllReferences(Map<StructureFeature<?>, LongSet> arg0) {}
@Override
public void setStartForFeature(StructureFeature<?> arg0, StructureStart<?> arg1) {}
@Override
public void setAllStarts(Map<StructureFeature<?>, StructureStart<?>> p_201612_1_) {}
@Override
public Map<StructureFeature<?>, StructureStart<?>> getAllStarts() {
return null;
}
@Override
public int getHeight() {
return world.getHeight();
}
@Override
public int getMinBuildHeight() {
return world.getMinBuildHeight();
}
@Override
public TickContainerAccess<Fluid> getFluidTicks() {
return BlackholeTickAccess.emptyContainer();
}
@Override
public TicksToSave getTicksForSerialization() {
return null;
}
@Override
public TickContainerAccess<Block> getBlockTicks() {
return BlackholeTickAccess.emptyContainer();
}
}

View file

@ -1,39 +0,0 @@
package com.simibubi.create.foundation.utility.worldWrappers.chunk;
import net.minecraft.core.Registry;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunkSection;
public class WrappedChunkSection extends LevelChunkSection {
public WrappedChunk owner;
public final int xStart;
public final int yStart;
public final int zStart;
public WrappedChunkSection(WrappedChunk owner, int yBase) {
super(yBase, owner.world.registryAccess()
.registry(Registry.BIOME_REGISTRY)
.orElseThrow());
this.owner = owner;
this.xStart = owner.getPos()
.getMinBlockX();
this.yStart = yBase;
this.zStart = owner.getPos()
.getMinBlockZ();
}
@Override
public BlockState getBlockState(int x, int y, int z) {
// ChunkSection#getBlockState expects local chunk coordinates, so we add to get
// back into world coords.
return owner.world.getBlockState(x + xStart, y + yStart, z + zStart);
}
@Override
public BlockState setBlockState(int p_177484_1_, int p_177484_2_, int p_177484_3_, BlockState p_177484_4_,
boolean p_177484_5_) {
throw new IllegalStateException("Chunk sections should not be mutated in a fake world.");
}
}

View file

@ -29,7 +29,7 @@ BlockFrag vertex(Vertex v) {
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(v.color.rgb / diffuse(v.normal), v.color.a);
b.color = v.color;
#endif
return b;