diff --git a/gradle.properties b/gradle.properties index e6819087c..eb3694c76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,7 +23,7 @@ use_parchment = true # dependency versions registrate_version = MC1.20-1.3.3 flywheel_minecraft_version = 1.20.1 -flywheel_version = 1.0.0-alpha-14 +flywheel_version = 1.0.0-alpha-18 jei_minecraft_version = 1.20.1 jei_version = 15.2.0.22 curios_minecraft_version = 1.20.1 diff --git a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java index 7a5ee91a0..2f13b9502 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/actors/flwdata/ActorInstance.java @@ -39,15 +39,16 @@ public class ActorInstance extends AbstractInstance { return this; } - public ActorInstance setBlockLight(int blockLight) { - this.blockLight = (byte) ((blockLight & 0xF) << 4); - return this; - } - public ActorInstance setSkyLight(int skyLight) { - this.skyLight = (byte) ((skyLight & 0xF) << 4); - return this; - } + public ActorInstance setBlockLight(int blockLight) { + this.blockLight = (byte) blockLight; + return this; + } + + public ActorInstance setSkyLight(int skyLight) { + this.skyLight = (byte) skyLight; + return this; + } public ActorInstance setRotationOffset(float rotationOffset) { this.rotationOffset = rotationOffset; diff --git a/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java index 83de1c34c..a74e497f0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/pulley/RopePulleyInstance.java @@ -9,6 +9,7 @@ import com.jozufozu.flywheel.lib.instance.OrientedInstance; import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllPartialModels; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; public class RopePulleyInstance extends AbstractPulleyInstance { @@ -17,11 +18,11 @@ public class RopePulleyInstance extends AbstractPulleyInstance getRopeModel() { - return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.block(AllBlocks.ROPE.getDefaultState()), RenderStage.AFTER_BLOCK_ENTITIES); + return instancerProvider.instancer(InstanceTypes.ORIENTED, VirtualRenderHelper.blockModel(AllBlocks.ROPE.getDefaultState()), RenderStage.AFTER_BLOCK_ENTITIES); } protected Instancer getMagnetModel() { - return instancerProvider.instancer(InstanceTypes.ORIENTED, Models.block(AllBlocks.PULLEY_MAGNET.getDefaultState()), RenderStage.AFTER_BLOCK_ENTITIES); + return instancerProvider.instancer(InstanceTypes.ORIENTED, VirtualRenderHelper.blockModel(AllBlocks.PULLEY_MAGNET.getDefaultState()), RenderStage.AFTER_BLOCK_ENTITIES); } protected Instancer getHalfMagnetModel() { diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java index 8f38a4981..9bb1435b6 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/ShaftInstance.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.kinetics.base; +import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.visualization.VisualizationContext; - -import net.minecraft.world.level.block.state.BlockState; +import com.simibubi.create.foundation.render.VirtualRenderHelper; public class ShaftInstance extends SingleRotatingInstance { @@ -11,8 +11,7 @@ public class ShaftInstance extends SingleRotatingI } @Override - protected BlockState getRenderedBlockState() { - return shaft(); + protected Model model() { + return VirtualRenderHelper.blockModel(shaft()); } - } diff --git a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java index 8ef8ed139..db4b913ba 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/base/SingleRotatingInstance.java @@ -4,13 +4,10 @@ import java.util.function.Consumer; import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.instance.Instance; -import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.visualization.VisualizationContext; -import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.foundation.render.AllInstanceTypes; - -import net.minecraft.world.level.block.state.BlockState; +import com.simibubi.create.foundation.render.VirtualRenderHelper; public class SingleRotatingInstance extends KineticBlockEntityInstance { @@ -22,8 +19,9 @@ public class SingleRotatingInstance extends Kineti @Override public void init(float pt) { - var instance = getModel().createInstance(); - rotatingModel = setup(instance); + rotatingModel = instancerProvider.instancer(AllInstanceTypes.ROTATING, model(), RenderStage.AFTER_BLOCK_ENTITIES) + .createInstance(); + setup(rotatingModel); } @Override @@ -41,16 +39,8 @@ public class SingleRotatingInstance extends Kineti rotatingModel.delete(); } - protected BlockState getRenderedBlockState() { - return blockState; - } - - protected Instancer getModel() { - return instancerProvider.instancer(AllInstanceTypes.ROTATING, model(), RenderStage.AFTER_BLOCK_ENTITIES); - } - protected Model model() { - return Models.block(getRenderedBlockState()); + return VirtualRenderHelper.blockModel(blockState); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java index 464810bd9..f6cf78e42 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/belt/BeltInstance.java @@ -35,6 +35,7 @@ public class BeltInstance extends KineticInstance { } public BeltInstance setScrollTexture(SpriteShiftEntry spriteShift) { + // FIXME: these are null for some reason TextureAtlasSprite source = spriteShift.getOriginal(); TextureAtlasSprite target = spriteShift.getTarget(); diff --git a/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java index 5931ebfe0..50624e869 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crank/ValveHandleBlockEntity.java @@ -4,7 +4,6 @@ import java.util.List; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.api.model.Model; -import com.jozufozu.flywheel.lib.model.Models; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.kinetics.base.KineticBlockEntity; import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer; @@ -18,6 +17,7 @@ import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsFormatt import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.Components; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.VecHelper; @@ -149,7 +149,7 @@ public class ValveHandleBlockEntity extends HandCrankBlockEntity { @Override @OnlyIn(Dist.CLIENT) public Model getRenderedHandleInstance() { - return Models.block(getBlockState()); + return VirtualRenderHelper.blockModel(getBlockState()); } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java index 1eb3b5793..9340ac999 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerActorInstance.java @@ -18,6 +18,7 @@ import com.simibubi.create.content.kinetics.base.IRotate; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.NBTHelper; @@ -64,7 +65,7 @@ public class DeployerActorInstance extends ActorInstance { hand = instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(handPose), RenderStage.AFTER_BLOCK_ENTITIES).createInstance(); Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state); - shaft = instancerProvider.instancer(AllInstanceTypes.ROTATING, Models.block(KineticBlockEntityInstance.shaft(axis)), RenderStage.AFTER_BLOCK_ENTITIES) + shaft = instancerProvider.instancer(AllInstanceTypes.ROTATING, VirtualRenderHelper.blockModel(KineticBlockEntityInstance.shaft(axis)), RenderStage.AFTER_BLOCK_ENTITIES) .createInstance(); int blockLight = localBlockLight(); diff --git a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java index dc8c43806..37aece9c4 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/flywheel/FlywheelInstance.java @@ -9,12 +9,12 @@ import com.jozufozu.flywheel.api.visual.VisualFrameContext; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.instance.InstanceTypes; import com.jozufozu.flywheel.lib.instance.TransformedInstance; -import com.jozufozu.flywheel.lib.model.Models; import com.jozufozu.flywheel.lib.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.kinetics.base.KineticBlockEntityInstance; import com.simibubi.create.content.kinetics.base.RotatingInstance; import com.simibubi.create.foundation.render.AllInstanceTypes; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -29,9 +29,9 @@ public class FlywheelInstance extends KineticBlockEntityInstance { Direction facing = referenceState.getValue(BlockStateProperties.FACING); return Models.partial(AllPartialModels.SHAFT_HALF, facing); } else { - return Models.block(shaft()); + return VirtualRenderHelper.blockModel(shaft()); } } } diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java index f1790c2c2..0792ffd7e 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java +++ b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelInstance.java @@ -3,7 +3,6 @@ package com.simibubi.create.content.kinetics.waterwheel; import com.jozufozu.flywheel.api.model.Model; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.model.ModelCache; -import com.jozufozu.flywheel.lib.model.Models; import com.jozufozu.flywheel.lib.model.baked.BakedModelBuilder; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.content.kinetics.base.CutoutRotatingInstance; @@ -12,7 +11,6 @@ import com.simibubi.create.foundation.render.CachedBufferer; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.Direction; import net.minecraft.core.Direction.AxisDirection; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; public class WaterWheelInstance extends CutoutRotatingInstance { @@ -24,7 +22,7 @@ public class WaterWheelInstance extends CutoutR public WaterWheelInstance(VisualizationContext materialManager, T blockEntity, boolean large) { super(materialManager, blockEntity); this.large = large; - key = new WaterWheelModelKey(large, getRenderedBlockState(), blockEntity.material); + key = new WaterWheelModelKey(large, blockState, blockEntity.material); } public static WaterWheelInstance standard(VisualizationContext materialManager, T blockEntity) { diff --git a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java index 248ee272d..2a2e72230 100644 --- a/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java +++ b/src/main/java/com/simibubi/create/content/trains/bogey/BogeyRenderer.java @@ -12,7 +12,6 @@ import org.joml.Matrix4f; import org.joml.Quaternionf; import com.jozufozu.flywheel.api.event.RenderStage; -import com.jozufozu.flywheel.api.instance.Instancer; import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.lib.instance.InstanceTypes; import com.jozufozu.flywheel.lib.instance.TransformedInstance; @@ -24,13 +23,13 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.trains.entity.CarriageBogey; import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.VirtualRenderHelper; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.data.ModelData; /** * This is a port of the bogey api from Extended Bogeys, If you are looking to implement your own bogeys you can find some helpful resources below: @@ -214,7 +213,7 @@ public abstract class BogeyRenderer { */ public void createModelInstance(VisualizationContext materialManager, BlockState state, int count) { var instancer = materialManager.instancerProvider() - .instancer(InstanceTypes.TRANSFORMED, Models.block(state), RenderStage.AFTER_BLOCK_ENTITIES); + .instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(state), RenderStage.AFTER_BLOCK_ENTITIES); BogeyModelData[] modelData = IntStream.range(0, count) .mapToObj(i -> instancer.createInstance()) .map(BogeyModelData::new) diff --git a/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java index faa2a0018..8f337a039 100644 --- a/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java +++ b/src/main/java/com/simibubi/create/foundation/render/AllInstanceTypes.java @@ -10,8 +10,8 @@ import com.jozufozu.flywheel.api.layout.IntegerRepr; import com.jozufozu.flywheel.api.layout.LayoutBuilder; import com.jozufozu.flywheel.lib.instance.SimpleInstanceType; import com.simibubi.create.content.contraptions.actors.flwdata.ActorInstance; -import com.simibubi.create.content.kinetics.belt.BeltInstance; import com.simibubi.create.content.kinetics.base.RotatingInstance; +import com.simibubi.create.content.kinetics.belt.BeltInstance; import com.simibubi.create.content.logistics.flwdata.FlapData; import net.minecraftforge.api.distmarker.Dist; @@ -19,7 +19,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class AllInstanceTypes { - // FIXME: memory alignment issues and light being represented by bytes + // FIXME: optimize layouts/pack fields together if possible public static final InstanceType ROTATING = SimpleInstanceType.builder(RotatingInstance::new) .cullShader(asResource("instance/cull/rotating.glsl")) @@ -39,14 +39,14 @@ public class AllInstanceTypes { MemoryUtil.memPutByte(ptr + 5, instance.g); MemoryUtil.memPutByte(ptr + 6, instance.b); MemoryUtil.memPutByte(ptr + 7, instance.a); - MemoryUtil.memPutFloat(ptr + 6, instance.x); - MemoryUtil.memPutFloat(ptr + 10, instance.y); - MemoryUtil.memPutFloat(ptr + 14, instance.z); - MemoryUtil.memPutFloat(ptr + 18, instance.rotationalSpeed); - MemoryUtil.memPutFloat(ptr + 22, instance.rotationOffset); - MemoryUtil.memPutByte(ptr + 26, instance.rotationAxisX); - MemoryUtil.memPutByte(ptr + 27, instance.rotationAxisY); - MemoryUtil.memPutByte(ptr + 28, instance.rotationAxisZ); + MemoryUtil.memPutFloat(ptr + 8, instance.x); + MemoryUtil.memPutFloat(ptr + 12, instance.y); + MemoryUtil.memPutFloat(ptr + 16, instance.z); + MemoryUtil.memPutFloat(ptr + 20, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 24, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 28, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 29, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 30, instance.rotationAxisZ); }) .register(); public static final InstanceType BELTS = SimpleInstanceType.builder(BeltInstance::new) @@ -70,22 +70,22 @@ public class AllInstanceTypes { MemoryUtil.memPutByte(ptr + 5, instance.g); MemoryUtil.memPutByte(ptr + 6, instance.b); MemoryUtil.memPutByte(ptr + 7, instance.a); - MemoryUtil.memPutFloat(ptr + 6, instance.x); - MemoryUtil.memPutFloat(ptr + 10, instance.y); - MemoryUtil.memPutFloat(ptr + 14, instance.z); - MemoryUtil.memPutFloat(ptr + 18, instance.rotationalSpeed); - MemoryUtil.memPutFloat(ptr + 22, instance.rotationOffset); - MemoryUtil.memPutFloat(ptr + 26, instance.qX); - MemoryUtil.memPutFloat(ptr + 30, instance.qY); - MemoryUtil.memPutFloat(ptr + 34, instance.qZ); - MemoryUtil.memPutFloat(ptr + 38, instance.qW); - MemoryUtil.memPutFloat(ptr + 42, instance.sourceU); - MemoryUtil.memPutFloat(ptr + 46, instance.sourceV); - MemoryUtil.memPutFloat(ptr + 50, instance.minU); - MemoryUtil.memPutFloat(ptr + 54, instance.minV); - MemoryUtil.memPutFloat(ptr + 58, instance.maxU); - MemoryUtil.memPutFloat(ptr + 62, instance.maxV); - MemoryUtil.memPutByte(ptr + 66, instance.scrollMult); + MemoryUtil.memPutFloat(ptr + 8, instance.x); + MemoryUtil.memPutFloat(ptr + 12, instance.y); + MemoryUtil.memPutFloat(ptr + 16, instance.z); + MemoryUtil.memPutFloat(ptr + 20, instance.rotationalSpeed); + MemoryUtil.memPutFloat(ptr + 24, instance.rotationOffset); + MemoryUtil.memPutFloat(ptr + 28, instance.qX); + MemoryUtil.memPutFloat(ptr + 32, instance.qY); + MemoryUtil.memPutFloat(ptr + 36, instance.qZ); + MemoryUtil.memPutFloat(ptr + 40, instance.qW); + MemoryUtil.memPutFloat(ptr + 44, instance.sourceU); + MemoryUtil.memPutFloat(ptr + 48, instance.sourceV); + MemoryUtil.memPutFloat(ptr + 52, instance.minU); + MemoryUtil.memPutFloat(ptr + 56, instance.minV); + MemoryUtil.memPutFloat(ptr + 60, instance.maxU); + MemoryUtil.memPutFloat(ptr + 64, instance.maxV); + MemoryUtil.memPutByte(ptr + 68, instance.scrollMult); }) .register(); public static final InstanceType ACTORS = SimpleInstanceType.builder(ActorInstance::new) @@ -104,20 +104,20 @@ public class AllInstanceTypes { MemoryUtil.memPutFloat(ptr, instance.x); MemoryUtil.memPutFloat(ptr + 4, instance.y); MemoryUtil.memPutFloat(ptr + 8, instance.z); - MemoryUtil.memPutByte(ptr + 12, instance.blockLight); - MemoryUtil.memPutByte(ptr + 13, instance.skyLight); - MemoryUtil.memPutFloat(ptr + 14, instance.rotationOffset); - MemoryUtil.memPutByte(ptr + 18, instance.rotationAxisX); - MemoryUtil.memPutByte(ptr + 19, instance.rotationAxisY); - MemoryUtil.memPutByte(ptr + 20, instance.rotationAxisZ); - MemoryUtil.memPutFloat(ptr + 21, instance.qX); - MemoryUtil.memPutFloat(ptr + 25, instance.qY); - MemoryUtil.memPutFloat(ptr + 29, instance.qZ); - MemoryUtil.memPutFloat(ptr + 33, instance.qW); - MemoryUtil.memPutByte(ptr + 37, instance.rotationCenterX); - MemoryUtil.memPutByte(ptr + 38, instance.rotationCenterY); - MemoryUtil.memPutByte(ptr + 39, instance.rotationCenterZ); - MemoryUtil.memPutFloat(ptr + 40, instance.speed); + MemoryUtil.memPutShort(ptr + 12, instance.blockLight); + MemoryUtil.memPutShort(ptr + 14, instance.skyLight); + MemoryUtil.memPutFloat(ptr + 16, instance.rotationOffset); + MemoryUtil.memPutByte(ptr + 20, instance.rotationAxisX); + MemoryUtil.memPutByte(ptr + 21, instance.rotationAxisY); + MemoryUtil.memPutByte(ptr + 22, instance.rotationAxisZ); + MemoryUtil.memPutFloat(ptr + 24, instance.qX); + MemoryUtil.memPutFloat(ptr + 28, instance.qY); + MemoryUtil.memPutFloat(ptr + 32, instance.qZ); + MemoryUtil.memPutFloat(ptr + 34, instance.qW); + MemoryUtil.memPutByte(ptr + 38, instance.rotationCenterX); + MemoryUtil.memPutByte(ptr + 39, instance.rotationCenterY); + MemoryUtil.memPutByte(ptr + 40, instance.rotationCenterZ); + MemoryUtil.memPutFloat(ptr + 42, instance.speed); }) .register(); public static final InstanceType FLAPS = SimpleInstanceType.builder(FlapData::new) @@ -137,18 +137,18 @@ public class AllInstanceTypes { MemoryUtil.memPutFloat(ptr, instance.x); MemoryUtil.memPutFloat(ptr + 4, instance.y); MemoryUtil.memPutFloat(ptr + 8, instance.z); - MemoryUtil.memPutByte(ptr + 12, (byte) (instance.blockLight << 4)); - MemoryUtil.memPutByte(ptr + 13, (byte) (instance.skyLight << 4)); - MemoryUtil.memPutFloat(ptr + 14, instance.segmentOffsetX); - MemoryUtil.memPutFloat(ptr + 18, instance.segmentOffsetY); - MemoryUtil.memPutFloat(ptr + 22, instance.segmentOffsetZ); - MemoryUtil.memPutFloat(ptr + 26, instance.pivotX); - MemoryUtil.memPutFloat(ptr + 30, instance.pivotY); - MemoryUtil.memPutFloat(ptr + 34, instance.pivotZ); - MemoryUtil.memPutFloat(ptr + 38, instance.horizontalAngle); - MemoryUtil.memPutFloat(ptr + 42, instance.intensity); - MemoryUtil.memPutFloat(ptr + 46, instance.flapScale); - MemoryUtil.memPutFloat(ptr + 50, instance.flapness); + MemoryUtil.memPutShort(ptr + 12, instance.blockLight); + MemoryUtil.memPutShort(ptr + 14, instance.skyLight); + MemoryUtil.memPutFloat(ptr + 16, instance.segmentOffsetX); + MemoryUtil.memPutFloat(ptr + 20, instance.segmentOffsetY); + MemoryUtil.memPutFloat(ptr + 24, instance.segmentOffsetZ); + MemoryUtil.memPutFloat(ptr + 28, instance.pivotX); + MemoryUtil.memPutFloat(ptr + 32, instance.pivotY); + MemoryUtil.memPutFloat(ptr + 36, instance.pivotZ); + MemoryUtil.memPutFloat(ptr + 40, instance.horizontalAngle); + MemoryUtil.memPutFloat(ptr + 44, instance.intensity); + MemoryUtil.memPutFloat(ptr + 48, instance.flapScale); + MemoryUtil.memPutFloat(ptr + 52, instance.flapness); }) .register(); diff --git a/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java index b504cae4d..0009b0d8c 100644 --- a/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/VirtualRenderHelper.java @@ -7,9 +7,12 @@ import java.util.List; import org.apache.commons.lang3.mutable.MutableInt; import org.jetbrains.annotations.Nullable; +import com.jozufozu.flywheel.api.model.Model; +import com.jozufozu.flywheel.lib.model.ModelCache; import com.jozufozu.flywheel.lib.model.ModelUtil; import com.jozufozu.flywheel.lib.model.baked.BakedModelBufferer; import com.jozufozu.flywheel.lib.model.baked.BakedModelBufferer.ShadeSeparatedResultConsumer; +import com.jozufozu.flywheel.lib.model.baked.BlockModelBuilder; import com.jozufozu.flywheel.lib.model.baked.VirtualEmptyBlockGetter; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer; @@ -24,11 +27,21 @@ import net.minecraftforge.client.model.data.ModelProperty; public class VirtualRenderHelper { public static final ModelProperty VIRTUAL_PROPERTY = new ModelProperty<>(); public static final ModelData VIRTUAL_DATA = ModelData.builder().with(VIRTUAL_PROPERTY, true).build(); + public static final ModelCache VIRTUAL_BLOCKS = new ModelCache<>(state -> new BlockModelBuilder(state).modelData(VIRTUAL_DATA).build()); public static boolean isVirtual(ModelData data) { return data.has(VirtualRenderHelper.VIRTUAL_PROPERTY) && data.get(VirtualRenderHelper.VIRTUAL_PROPERTY); } + /** + * A copy of {@link com.jozufozu.flywheel.lib.model.Models#block(BlockState)}, but with virtual model data passed in. + * @param state The block state to get the model for. + * @return The model for the given block state. + */ + public static Model blockModel(BlockState state) { + return VIRTUAL_BLOCKS.get(state); + } + public static SuperByteBuffer bufferBlock(BlockState state) { return bufferModel(ModelUtil.VANILLA_RENDERER.getBlockModel(state), state); }