Final Flywheel Fixes

- Update Flywheel
- Resolve all remaining errors
This commit is contained in:
PepperCode1 2022-08-03 23:43:36 -07:00
parent 1797eddf0f
commit 4ea1f3e620
8 changed files with 28 additions and 35 deletions

View file

@ -21,7 +21,7 @@ parchment_version = 2022.07.10
# dependency versions # dependency versions
registrate_version = MC1.19-1.1.5 registrate_version = MC1.19-1.1.5
flywheel_minecraft_version = 1.19 flywheel_minecraft_version = 1.19
flywheel_version = 0.6.4-1 flywheel_version = 0.6.4-2
jei_minecraft_version = 1.19 jei_minecraft_version = 1.19
jei_version = 11.1.0.235 jei_version = 11.1.0.235
curios_minecraft_version = 1.19 curios_minecraft_version = 1.19

View file

@ -56,7 +56,6 @@ public class DeployerFakePlayer extends FakePlayer {
public DeployerFakePlayer(ServerLevel world) { public DeployerFakePlayer(ServerLevel world) {
super(world, DEPLOYER_PROFILE); super(world, DEPLOYER_PROFILE);
connection = new FakePlayNetHandler(world.getServer(), this); connection = new FakePlayNetHandler(world.getServer(), this);
this.playEquipSound(spawnedItemEffects);
} }
@Override @Override

View file

@ -15,7 +15,7 @@ import com.jozufozu.flywheel.event.ReloadRenderersEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent; import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.jozufozu.flywheel.util.WorldAttached; import com.jozufozu.flywheel.util.WorldAttached;
import com.jozufozu.flywheel.util.transform.TransformStack; import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
@ -171,11 +171,11 @@ public class ContraptionRenderDispatcher {
public static SuperByteBuffer buildStructureBuffer(VirtualRenderWorld renderWorld, Contraption c, public static SuperByteBuffer buildStructureBuffer(VirtualRenderWorld renderWorld, Contraption c,
RenderType layer) { RenderType layer) {
Collection<StructureTemplate.StructureBlockInfo> values = c.getRenderedBlocks(); Collection<StructureTemplate.StructureBlockInfo> values = c.getRenderedBlocks();
BufferBuilder builder = new WorldModelBuilder(layer).withRenderWorld(renderWorld) com.jozufozu.flywheel.util.Pair<RenderedBuffer, Integer> pair = new WorldModelBuilder(layer).withRenderWorld(renderWorld)
.withBlocks(values) .withBlocks(values)
.withModelData(c.modelData) .withModelData(c.modelData)
.build(); .build();
return new SuperByteBuffer(builder); return new SuperByteBuffer(pair.first(), pair.second());
} }
public static int getLight(Level world, float lx, float ly, float lz) { public static int getLight(Level world, float lx, float ly, float lz) {

View file

@ -29,7 +29,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper<BakedModel> {
@Override @Override
public ModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, ModelData tileData) { public ModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, ModelData tileData) {
if (isVirtual(tileData)) if (ModelUtil.isVirtual(tileData))
return tileData; return tileData;
BracketedModelData data = new BracketedModelData(); BracketedModelData data = new BracketedModelData();
BracketedTileEntityBehaviour attachmentBehaviour = BracketedTileEntityBehaviour attachmentBehaviour =
@ -42,7 +42,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper<BakedModel> {
@Override @Override
public List<BakedQuad> getQuads(BlockState state, Direction side, RandomSource rand, ModelData data, RenderType renderType) { public List<BakedQuad> getQuads(BlockState state, Direction side, RandomSource rand, ModelData data, RenderType renderType) {
if (!isVirtual(data)) { if (!ModelUtil.isVirtual(data)) {
if (data.has(BRACKET_PROPERTY)) { if (data.has(BRACKET_PROPERTY)) {
BracketedModelData pipeData = data.get(BRACKET_PROPERTY); BracketedModelData pipeData = data.get(BRACKET_PROPERTY);
BakedModel bracket = pipeData.getBracket(); BakedModel bracket = pipeData.getBracket();
@ -54,11 +54,6 @@ public class BracketedKineticBlockModel extends BakedModelWrapper<BakedModel> {
return super.getQuads(state, side, rand, data, renderType); return super.getQuads(state, side, rand, data, renderType);
} }
// TODO 1.19: move to Flywheel's ModelUtil
private static boolean isVirtual(ModelData data) {
return data.has(ModelUtil.VIRTUAL_PROPERTY) && data.get(ModelUtil.VIRTUAL_PROPERTY);
}
private static class BracketedModelData { private static class BracketedModelData {
private BakedModel bracket; private BakedModel bracket;

View file

@ -4,9 +4,10 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import com.jozufozu.flywheel.core.model.ModelUtil; import com.jozufozu.flywheel.core.model.ModelUtil;
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder;
import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer; import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer;
import com.jozufozu.flywheel.util.Pair;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.blaze3d.vertex.VertexFormat;
@ -100,7 +101,7 @@ public class SchematicRenderer {
BoundingBox bounds = renderWorld.getBounds(); BoundingBox bounds = renderWorld.getBounds();
ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper; ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
ShadeSeparatedBufferBuilder builder = new ShadeSeparatedBufferBuilder(512); BufferBuilder builder = new BufferBuilder(512);
BufferBuilder unshadedBuilder = objects.unshadedBuilder; BufferBuilder unshadedBuilder = objects.unshadedBuilder;
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
@ -132,13 +133,11 @@ public class SchematicRenderer {
ModelBlockRenderer.clearCache(); ModelBlockRenderer.clearCache();
shadeSeparatingWrapper.clear(); shadeSeparatingWrapper.clear();
unshadedBuilder.end(); Pair<RenderedBuffer, Integer> pair = ModelUtil.endShadeSeparated(builder, unshadedBuilder);
builder.appendUnshadedVertices(unshadedBuilder);
builder.end();
renderWorld.renderMode = false; renderWorld.renderMode = false;
return new SuperByteBuffer(builder); return new SuperByteBuffer(pair.first(), pair.second());
} }
private static int getLayerCount() { private static int getLayerCount() {

View file

@ -7,10 +7,10 @@ import java.util.Map.Entry;
import java.util.function.Consumer; import java.util.function.Consumer;
import com.jozufozu.flywheel.core.model.ModelUtil; import com.jozufozu.flywheel.core.model.ModelUtil;
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder;
import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer; import com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer;
import com.jozufozu.flywheel.util.transform.TransformStack; import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator; import com.mojang.blaze3d.vertex.SheetedDecalTextureGenerator;
@ -418,7 +418,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
PoseStack poseStack = objects.poseStack; PoseStack poseStack = objects.poseStack;
RandomSource random = objects.random; RandomSource random = objects.random;
ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper; ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
ShadeSeparatedBufferBuilder builder = new ShadeSeparatedBufferBuilder(512); BufferBuilder builder = new BufferBuilder(512);
BufferBuilder unshadedBuilder = objects.unshadedBuilder; BufferBuilder unshadedBuilder = objects.unshadedBuilder;
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
@ -455,11 +455,9 @@ public class WorldSectionElement extends AnimatedSceneElement {
world.clearMask(); world.clearMask();
shadeSeparatingWrapper.clear(); shadeSeparatingWrapper.clear();
unshadedBuilder.end(); com.jozufozu.flywheel.util.Pair<RenderedBuffer, Integer> pair = ModelUtil.endShadeSeparated(builder, unshadedBuilder);
builder.appendUnshadedVertices(unshadedBuilder);
builder.end();
return new SuperByteBuffer(builder); return new SuperByteBuffer(pair.first(), pair.second());
} }
private static class ThreadLocalObjects { private static class ThreadLocalObjects {

View file

@ -1,7 +1,8 @@
package com.simibubi.create.foundation.render; package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.core.model.ModelUtil; import com.jozufozu.flywheel.core.model.ModelUtil;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.jozufozu.flywheel.util.Pair;
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -22,8 +23,8 @@ public class BakedModelRenderHelper {
} }
public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) {
BufferBuilder builder = ModelUtil.getBufferBuilder(model, referenceState, ms); Pair<RenderedBuffer, Integer> pair = ModelUtil.getBufferBuilder(model, referenceState, ms);
return new SuperByteBuffer(builder); return new SuperByteBuffer(pair.first(), pair.second());
} }
} }

View file

@ -5,12 +5,12 @@ import java.util.function.IntPredicate;
import com.jozufozu.flywheel.api.vertex.ShadedVertexList; import com.jozufozu.flywheel.api.vertex.ShadedVertexList;
import com.jozufozu.flywheel.api.vertex.VertexList; import com.jozufozu.flywheel.api.vertex.VertexList;
import com.jozufozu.flywheel.backend.ShadersModHandler; import com.jozufozu.flywheel.backend.ShadersModHandler;
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder;
import com.jozufozu.flywheel.core.vertex.BlockVertexList; import com.jozufozu.flywheel.core.vertex.BlockVertexList;
import com.jozufozu.flywheel.util.DiffuseLightCalculator; import com.jozufozu.flywheel.util.DiffuseLightCalculator;
import com.jozufozu.flywheel.util.transform.TStack; import com.jozufozu.flywheel.util.transform.TStack;
import com.jozufozu.flywheel.util.transform.Transform; import com.jozufozu.flywheel.util.transform.Transform;
import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.BufferBuilder.DrawState;
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
@ -66,13 +66,14 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
// Temporary // Temporary
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
public SuperByteBuffer(BufferBuilder buf) { public SuperByteBuffer(RenderedBuffer buf, int unshadedStartVertex) {
if (buf instanceof ShadeSeparatedBufferBuilder separated) { if (buf != null) {
ShadedVertexList template = new BlockVertexList.Shaded(separated); DrawState drawState = buf.drawState();
shadedPredicate = template::isShaded; ShadedVertexList template = new BlockVertexList.Shaded(buf.vertexBuffer(), drawState.vertexCount(), drawState.format().getVertexSize(), unshadedStartVertex);
this.template = template; this.template = template;
shadedPredicate = template::isShaded;
} else { } else {
template = new BlockVertexList(buf); this.template = null;
shadedPredicate = index -> true; shadedPredicate = index -> true;
} }
transforms = new PoseStack(); transforms = new PoseStack();
@ -233,7 +234,7 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
} }
public boolean isEmpty() { public boolean isEmpty() {
return template.isEmpty(); return template == null || template.isEmpty();
} }
public PoseStack getTransforms() { public PoseStack getTransforms() {