diff --git a/build.gradle b/build.gradle index 6d0dfe039..af3d0dfae 100644 --- a/build.gradle +++ b/build.gradle @@ -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. diff --git a/gradle.properties b/gradle.properties index dab5c2870..54ad980d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java index 8cb457cfd..304fe9cd1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillActorInstance.java @@ -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 material = materialManager.defaultSolid() diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java index b623d9200..738e868cf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillMovementBehaviour.java @@ -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); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index 76445939d..28140233b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -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); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java index 5ea50777e..de07acdd9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterActorInstance.java @@ -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 material = materialManager.defaultCutout() diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java index 3fcc935bc..f30b6f9c4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -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); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index 4dec68c49..0fbe0c3d8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -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 mat = materialManager.defaultSolid() diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java index e16e7bd9c..e32c2a01f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerHandler.java @@ -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; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index da606521b..92e302c8e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -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); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 00d3a0ee7..2c45c235c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -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 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; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 5896963ab..6da19d6a5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -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 { 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); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java index 291a8dd7c..21a3db6ee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/MovementBehaviour.java @@ -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; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java index 2de04743b..8860950ff 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingInstance.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 91735760f..feb82bd90 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -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); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java index 697aee777..6ce2d95a5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ActorInstance.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java index 927207f91..ce999d473 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java @@ -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 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; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index ea4b1d9ed..47486e234 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -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 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); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java index 13724e05b..edbd00dd3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderInfo.java @@ -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; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java index 9b68b06fe..9bef13bca 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java @@ -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(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java index f7a596670..8ad5929cc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraptionManager.java @@ -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 p_46451_, DimensionType p_46452_, + Supplier 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 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 getEntities() { + return null; + } + + @Override + public LevelTickAccess getBlockTicks() { + return BlackholeTickAccess.emptyLevelList(); + } + + @Override + public LevelTickAccess 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; + } + } +} diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index 9c662be2b..ec8cede76 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -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); diff --git a/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java index 461a5a2b5..51050fd69 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/element/GuiGameElement.java @@ -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; diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index a8628aa59..1f2863bd2 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -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, Translate, Translate 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 customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer, float pt) { Iterator 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); diff --git a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java index 7cf0d0724..cd6087707 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ghost/GhostBlockRenderer.java @@ -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; diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java deleted file mode 100644 index 9ef910057..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/PlacementSimulationWorld.java +++ /dev/null @@ -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 blocksAdded = new HashMap<>(); - public Map tesAdded = new HashMap<>(); - - public Set 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 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 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 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(); - } -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java deleted file mode 100644 index 8b4b48a6e..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedChunkProvider.java +++ /dev/null @@ -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 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 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; - } -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index 499fb619e..d6b4b418b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -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 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 diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java deleted file mode 100644 index a800298e9..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/EmptierChunk.java +++ /dev/null @@ -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 p_46451_, DimensionType p_46452_, - Supplier 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 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 getEntities() { - return null; - } - - @Override - public LevelTickAccess getBlockTicks() { - return BlackholeTickAccess.emptyLevelList(); - } - - @Override - public LevelTickAccess 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; - } -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java deleted file mode 100644 index fbca9d03b..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunk.java +++ /dev/null @@ -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 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 getBlockEntitiesPos() { - return null; - } - - @Override - public Collection> 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, 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, LongSet> arg0) {} - - @Override - public void setStartForFeature(StructureFeature arg0, StructureStart arg1) {} - - @Override - public void setAllStarts(Map, StructureStart> p_201612_1_) {} - - @Override - public Map, StructureStart> getAllStarts() { - return null; - } - - @Override - public int getHeight() { - return world.getHeight(); - } - - @Override - public int getMinBuildHeight() { - return world.getMinBuildHeight(); - } - - @Override - public TickContainerAccess getFluidTicks() { - return BlackholeTickAccess.emptyContainer(); - } - - @Override - public TicksToSave getTicksForSerialization() { - return null; - } - - @Override - public TickContainerAccess getBlockTicks() { - return BlackholeTickAccess.emptyContainer(); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java deleted file mode 100644 index 6478ba4ee..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/chunk/WrappedChunkSection.java +++ /dev/null @@ -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."); - } -} diff --git a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert index 2460a76fc..df222953e 100644 --- a/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert +++ b/src/main/resources/assets/create/flywheel/shaders/contraption_structure.vert @@ -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;