From f7e75ee4913fd09128d87697f18bd1b38daa7e8c Mon Sep 17 00:00:00 2001 From: Sara Freimer Date: Wed, 12 Jun 2024 13:09:50 -0500 Subject: [PATCH] Port to 1.21 and make it so the normal check can't throw a NPE (#219) --- build.gradle | 8 ++ gradle.properties | 4 +- src/main/java/team/chisel/ctm/CTM.java | 2 +- .../client/model/AbstractCTMBakedModel.java | 2 +- .../chisel/ctm/client/model/ModelCTM.java | 18 ++--- .../chisel/ctm/client/model/ModelUtil.java | 2 +- .../client/texture/IMetadataSectionCTM.java | 4 +- .../util/BlockstatePredicateParser.java | 2 +- .../team/chisel/ctm/client/util/Quad.java | 75 ++++++++----------- .../client/util/TextureMetadataHandler.java | 32 +++++--- .../chisel/ctm/client/util/VertexData.java | 22 +++--- .../resources/META-INF/accesstransformer.cfg | 3 +- src/main/resources/ctm.mixins.json | 2 +- .../chisel/ctm/tests/NewCTMLogicTest.java | 13 ++-- 14 files changed, 100 insertions(+), 89 deletions(-) diff --git a/build.gradle b/build.gradle index 5004839..2c00b16 100644 --- a/build.gradle +++ b/build.gradle @@ -74,6 +74,14 @@ tasks.named('jar', Jar).configure { Jar jar -> repositories { mavenLocal() + maven { + name 'Maven for PR #1076' // https://github.com/neoforged/NeoForge/pull/1076 + url 'https://prmaven.neoforged.net/NeoForge/pr1076' + content { + includeModule('net.neoforged', 'testframework') + includeModule('net.neoforged', 'neoforge') + } + } } dependencies { diff --git a/gradle.properties b/gradle.properties index 515af5a..a72e80a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ mod_version=1.1.11 -minecraft_version=1.20.6 -forge_version=20.6.113-beta +minecraft_version=1.21 +forge_version=21.0.0-alpha.1.21-rc1.20240611.222608 curse_type=beta projectId=267602 diff --git a/src/main/java/team/chisel/ctm/CTM.java b/src/main/java/team/chisel/ctm/CTM.java index e85b606..cfc33f2 100644 --- a/src/main/java/team/chisel/ctm/CTM.java +++ b/src/main/java/team/chisel/ctm/CTM.java @@ -56,7 +56,7 @@ public CTM(ModContainer modContainer, IEventBus modBus) { } private void modelRegistry(ModelEvent.RegisterGeometryLoaders event) { - event.register(new ResourceLocation(MOD_ID, "ctm"), ModelLoaderCTM.INSTANCE); + event.register(ResourceLocation.fromNamespaceAndPath(MOD_ID, "ctm"), ModelLoaderCTM.INSTANCE); } private void imc(InterModEnqueueEvent event) { diff --git a/src/main/java/team/chisel/ctm/client/model/AbstractCTMBakedModel.java b/src/main/java/team/chisel/ctm/client/model/AbstractCTMBakedModel.java index 98d7009..af4491f 100644 --- a/src/main/java/team/chisel/ctm/client/model/AbstractCTMBakedModel.java +++ b/src/main/java/team/chisel/ctm/client/model/AbstractCTMBakedModel.java @@ -84,7 +84,7 @@ public Overrides() { @SneakyThrows public BakedModel resolve(BakedModel originalModel, ItemStack stack, ClientLevel world, LivingEntity entity, int unknown) { ModelResourceLocation mrl = ModelUtil.getMesh(stack); - if (mrl == ModelBakery.MISSING_MODEL_LOCATION) { + if (mrl == ModelBakery.MISSING_MODEL_VARIANT) { // this must be a missing/invalid model return Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getModelManager().getMissingModel(); } diff --git a/src/main/java/team/chisel/ctm/client/model/ModelCTM.java b/src/main/java/team/chisel/ctm/client/model/ModelCTM.java index 4d00ba8..e53a427 100644 --- a/src/main/java/team/chisel/ctm/client/model/ModelCTM.java +++ b/src/main/java/team/chisel/ctm/client/model/ModelCTM.java @@ -85,7 +85,7 @@ public ModelCTM(BlockModel modelinfo, Int2ObjectMap overrides) thro for (Int2ObjectMap.Entry e : this.overrides.int2ObjectEntrySet()) { IMetadataSectionCTM meta = null; if (e.getValue().isJsonPrimitive() && e.getValue().getAsJsonPrimitive().isString()) { - ResourceLocation rl = new ResourceLocation(e.getValue().getAsString()); + ResourceLocation rl = ResourceLocation.parse(e.getValue().getAsString()); meta = ResourceUtil.getMetadata(ResourceUtil.spriteToAbsolute(rl)).orElse(null); // TODO lazy null textureDependencies.add(rl); } else if (e.getValue().isJsonObject()) { @@ -106,20 +106,20 @@ public ModelCTM(BlockModel modelinfo, Int2ObjectMap overrides) thro } @Override - public BakedModel bake(IGeometryBakingContext context, ModelBaker bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) { - return bake(bakery, spriteGetter, modelState, modelLocation); + public BakedModel bake(IGeometryBakingContext context, ModelBaker bakery, Function spriteGetter, ModelState modelState, ItemOverrides overrides) { + return bake(bakery, spriteGetter, modelState); } private static final ItemModelGenerator ITEM_MODEL_GENERATOR = new ItemModelGenerator(); - public BakedModel bake(ModelBaker bakery, Function spriteGetter, ModelState modelTransform, ResourceLocation modelLocation) { + public BakedModel bake(ModelBaker bakery, Function spriteGetter, ModelState modelTransform) { BakedModel parent; if (modelinfo != null && modelinfo.getRootModel() == ModelBakery.GENERATION_MARKER) { // Apply same special case that ModelBakery does - return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, modelinfo).bake(bakery, modelinfo, spriteGetter, modelTransform, modelLocation, false); + return ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, modelinfo).bake(bakery, modelinfo, spriteGetter, modelTransform, false); } else { initializeOverrides(spriteGetter); this.textureDependencies.forEach(t -> initializeTexture(new Material(TextureAtlas.LOCATION_BLOCKS, t), spriteGetter)); - parent = vanillamodel.bake(bakery, mat -> initializeTexture(mat, spriteGetter), modelTransform, modelLocation); + parent = vanillamodel.bake(bakery, mat -> initializeTexture(mat, spriteGetter), modelTransform); if (!isInitialized()) { this.spriteOverrides = new Int2ObjectOpenHashMap<>(); this.textureOverrides = new HashMap<>(); @@ -157,7 +157,7 @@ private void initializeOverrides(Function spriteGe // Convert all primitive values into sprites for (Int2ObjectMap.Entry e : overrides.int2ObjectEntrySet()) { if (e.getValue().isJsonPrimitive() && e.getValue().getAsJsonPrimitive().isString()) { - TextureAtlasSprite override = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(e.getValue().getAsString()))); + TextureAtlasSprite override = spriteGetter.apply(new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(e.getValue().getAsString()))); spriteOverrides.put(e.getIntKey(), override); } } @@ -165,10 +165,10 @@ private void initializeOverrides(Function spriteGe if (textureOverrides == null) { textureOverrides = new HashMap<>(); for (Int2ObjectMap.Entry e : metaOverrides.int2ObjectEntrySet()) { - List matches = modelinfo.getElements().stream().flatMap(b -> b.faces.values().stream()).filter(b -> b.tintIndex == e.getIntKey()).toList(); + List matches = modelinfo.getElements().stream().flatMap(b -> b.faces.values().stream()).filter(b -> b.tintIndex() == e.getIntKey()).toList(); Multimap bySprite = HashMultimap.create(); // TODO 1.15 this isn't right - matches.forEach(part -> bySprite.put(modelinfo.textureMap.getOrDefault(part.texture.substring(1), Either.right(part.texture)).left().get(), part)); + matches.forEach(part -> bySprite.put(modelinfo.textureMap.getOrDefault(part.texture().substring(1), Either.right(part.texture())).left().get(), part)); for (var e2 : bySprite.asMap().entrySet()) { ResourceLocation texLoc = e2.getKey().sprite().contents().name(); TextureAtlasSprite override = getOverrideSprite(e.getIntKey()); diff --git a/src/main/java/team/chisel/ctm/client/model/ModelUtil.java b/src/main/java/team/chisel/ctm/client/model/ModelUtil.java index 1ada4fa..10bda56 100644 --- a/src/main/java/team/chisel/ctm/client/model/ModelUtil.java +++ b/src/main/java/team/chisel/ctm/client/model/ModelUtil.java @@ -26,7 +26,7 @@ public static ModelResourceLocation getMesh(ItemStack stack) { if (shaper instanceof RegistryAwareItemModelShaper registryAwareShaper) { return registryAwareShaper.getLocation(stack); } - return ModelBakery.MISSING_MODEL_LOCATION; + return ModelBakery.MISSING_MODEL_VARIANT; } } diff --git a/src/main/java/team/chisel/ctm/client/texture/IMetadataSectionCTM.java b/src/main/java/team/chisel/ctm/client/texture/IMetadataSectionCTM.java index 1650134..682610f 100644 --- a/src/main/java/team/chisel/ctm/client/texture/IMetadataSectionCTM.java +++ b/src/main/java/team/chisel/ctm/client/texture/IMetadataSectionCTM.java @@ -51,7 +51,7 @@ default ICTMTexture makeTexture(TextureAtlasSprite sprite, Function deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { if (json.isJsonObject()) { JsonObject obj = json.getAsJsonObject(); - Block block = BuiltInRegistries.BLOCK.get(new ResourceLocation(GsonHelper.getAsString(obj, "block"))); + Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(GsonHelper.getAsString(obj, "block"))); if (block == Blocks.AIR) { return EMPTY; } diff --git a/src/main/java/team/chisel/ctm/client/util/Quad.java b/src/main/java/team/chisel/ctm/client/util/Quad.java index d72dce3..abefd1e 100644 --- a/src/main/java/team/chisel/ctm/client/util/Quad.java +++ b/src/main/java/team/chisel/ctm/client/util/Quad.java @@ -23,7 +23,6 @@ import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; import net.minecraft.world.phys.Vec2; -import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.client.model.pipeline.QuadBakingVertexConsumer; import team.chisel.ctm.api.texture.ISubmap; @@ -297,7 +296,7 @@ public Quad subsect(ISubmap submap) { } } - Vec3[] positions = new Vec3[vertices.length]; + Vector3f[] positions = new Vector3f[vertices.length]; float[][] uvs = new float[vertices.length][]; for (int i = 0; i < vertices.length; i++) { int idx = (firstIndex + i) % vertices.length; @@ -307,14 +306,15 @@ public Quad subsect(ISubmap submap) { } var origin = positions[0]; - var n1 = positions[1].subtract(origin); - var n2 = positions[2].subtract(origin); - var normalVec = n1.cross(n2).normalize(); - Direction normal = Direction.fromDelta((int) normalVec.x, (int) normalVec.y, (int) normalVec.z); + var n1 = positions[1].sub(origin, new Vector3f()); + var n2 = positions[2].sub(origin, new Vector3f()); + var normalVec = n1.cross(n2, new Vector3f()).normalize(); + + Direction normal = Direction.getNearest(normalVec.x, normalVec.y, normalVec.z); TextureAtlasSprite sprite = getUvs().getSprite(); - var xy = new double[positions.length][2]; - var newXy = new double[positions.length][2]; + var xy = new float[positions.length][2]; + var newXy = new float[positions.length][2]; for (int i = 0; i < positions.length; i++) { switch (normal.getAxis()) { case Y -> { @@ -455,7 +455,7 @@ public Quad setLight(int blockLight, int skyLight) { @SuppressWarnings("null") public BakedQuad rebake() { - var builder = new QuadBakingVertexConsumer.Buffered(); + var builder = new QuadBakingVertexConsumer(); builder.setDirection(this.builder.quadOrientation); builder.setTintIndex(this.builder.quadTint); builder.setShade(this.builder.applyDiffuseLighting); @@ -465,7 +465,7 @@ public BakedQuad rebake() { vertex.write(builder); } - return builder.getQuad(); + return builder.bakeQuad(); } public Quad transformUVs(TextureAtlasSprite sprite) { @@ -533,7 +533,7 @@ public static class Builder implements VertexConsumer { private boolean applyAmbientOcclusion; private final VertexData[] vertices = new VertexData[4]; - private VertexData vertex = new VertexData(); + private boolean building = false; private int vertexIndex = 0; public void copyFrom(BakedQuad baked) { @@ -545,72 +545,63 @@ public void copyFrom(BakedQuad baked) { } public Quad build() { + if (!building || ++vertexIndex != 4) { + throw new IllegalStateException("Not enough vertices available. Vertices in buffer: " + vertexIndex); + } return new Quad(vertices, this, getSprite()); } @NotNull @Override - public VertexConsumer vertex(double x, double y, double z) { - vertex.pos(x, y, z); + public VertexConsumer addVertex(float x, float y, float z) { + if (building) { + if (++vertexIndex > 4) { + throw new IllegalStateException("Expected quad export after fourth vertex"); + } + } + building = true; + vertices[vertexIndex] = new VertexData().pos(x, y, z); return this; } @NotNull @Override - public VertexConsumer color(int red, int green, int blue, int alpha) { - vertex.color(red, green, blue, alpha); + public VertexConsumer setColor(int red, int green, int blue, int alpha) { + vertices[vertexIndex].color(red, green, blue, alpha); return this; } @NotNull @Override - public VertexConsumer uv(float u, float v) { - vertex.texRaw(u, v); + public VertexConsumer setUv(float u, float v) { + vertices[vertexIndex].texRaw(u, v); return this; } @NotNull @Override - public VertexConsumer overlayCoords(int u, int v) { - vertex.overlay(u, v); + public VertexConsumer setUv1(int u, int v) { + vertices[vertexIndex].overlay(u, v); return this; } @NotNull @Override - public VertexConsumer uv2(int u, int v) { - vertex.lightRaw(u, v); + public VertexConsumer setUv2(int u, int v) { + vertices[vertexIndex].lightRaw(u, v); return this; } @NotNull @Override - public VertexConsumer normal(float x, float y, float z) { - vertex.normal(x, y, z); + public VertexConsumer setNormal(float x, float y, float z) { + vertices[vertexIndex].normal(x, y, z); return this; } - @Override - public void endVertex() { - if (vertexIndex < vertices.length) { - vertices[vertexIndex++] = vertex; - vertex = new VertexData(); - } - } - - @Override - public void defaultColor(int red, int green, int blue, int alpha) { - //We don't support having a default color - } - - @Override - public void unsetDefaultColor() { - //We don't support having a default color - } - @Override public VertexConsumer misc(VertexFormatElement element, int... rawData) { - vertex.misc(element, Arrays.copyOf(rawData, rawData.length)); + vertices[vertexIndex].misc(element, Arrays.copyOf(rawData, rawData.length)); return this; } } diff --git a/src/main/java/team/chisel/ctm/client/util/TextureMetadataHandler.java b/src/main/java/team/chisel/ctm/client/util/TextureMetadataHandler.java index a1ba8c1..1b0f294 100644 --- a/src/main/java/team/chisel/ctm/client/util/TextureMetadataHandler.java +++ b/src/main/java/team/chisel/ctm/client/util/TextureMetadataHandler.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.Set; +import net.minecraft.client.resources.model.ModelResourceLocation; import org.apache.logging.log4j.message.ParameterizedMessage; import com.google.common.collect.HashMultimap; @@ -35,7 +36,7 @@ public enum TextureMetadataHandler { INSTANCE; - private final Object2BooleanMap wrappedModels = new Object2BooleanLinkedOpenHashMap<>(); + private final Object2BooleanMap wrappedModels = new Object2BooleanLinkedOpenHashMap<>(); private final Multimap scrapedTextures = HashMultimap.create(); public void textureScraped(ResourceLocation modelLocation, Material material) { @@ -108,11 +109,21 @@ public void textureScraped(ResourceLocation modelLocation, Material material) { @SubscribeEvent(priority = EventPriority.LOWEST) // low priority to capture all event-registered models @SneakyThrows public void onModelBake(ModelEvent.ModifyBakingResult event) { - Map stateModels = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.getModelBakery(), "unbakedCache"); - Map models = event.getModels(); - for (Map.Entry entry : models.entrySet()) { - ResourceLocation rl = entry.getKey(); - UnbakedModel rootModel = stateModels.get(rl); + ModelBakery modelBakery = event.getModelBakery(); + Map topLevelModels = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, modelBakery, "topLevelModels"); + Map unbakedCache = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, modelBakery, "unbakedCache"); + Map models = event.getModels(); + for (Map.Entry entry : models.entrySet()) { + ModelResourceLocation mrl = entry.getKey(); + ResourceLocation rl = mrl.id(); + UnbakedModel rootModel = topLevelModels.get(mrl); + if (rootModel == null) { + rootModel = unbakedCache.get(rl); + if (rootModel != null) { + //TODO - 1.21: Remove this after testing against more complex models to validate if we need to do this or not + CTM.logger.info("Modify baking unbaked cache has an element top level doesn't: {}, {}", rl, mrl); + } + } if (rootModel != null) { BakedModel baked = entry.getValue(); if (baked instanceof AbstractCTMBakedModel) { @@ -125,13 +136,14 @@ public void onModelBake(ModelEvent.ModifyBakingResult event) { Set seenModels = new HashSet<>(); dependencies.push(rl); seenModels.add(rl); - boolean shouldWrap = wrappedModels.getOrDefault(rl, false); + boolean shouldWrap = wrappedModels.getOrDefault(mrl, false); // Breadth-first loop through dependencies, exiting as soon as a CTM texture is found, and skipping duplicates/cycles while (!shouldWrap && !dependencies.isEmpty()) { ResourceLocation dep = dependencies.pop(); UnbakedModel model; try { - model = dep == rl ? rootModel : event.getModelBakery().getModel(dep); + //TODO - 1.21: Evaluate if this should be using getModel or something that will get the dep as a root model? + model = dep == rl ? rootModel : modelBakery.getModel(dep); } catch (Exception e) { continue; } @@ -159,7 +171,7 @@ public void onModelBake(ModelEvent.ModifyBakingResult event) { CTM.logger.error(new ParameterizedMessage("Error loading model dependency {} for model {}. Skipping...", dep, rl), e); } } - wrappedModels.put(rl, shouldWrap); + wrappedModels.put(mrl, shouldWrap); if (shouldWrap) { try { entry.setValue(wrap(rootModel, baked)); @@ -187,7 +199,7 @@ public void onModelBake(ModelEvent.BakingCompleted event) { baked.getModel() instanceof ModelCTM ctmModel && !ctmModel.isInitialized()) { var baker = event.getModelBakery().new ModelBakerImpl((rl, m) -> m.sprite(), e.getKey()); - ctmModel.bake(baker, Material::sprite, BlockModelRotation.X0_Y0, e.getKey()); + ctmModel.bake(baker, Material::sprite, BlockModelRotation.X0_Y0); //Note: We have to clear the cache after baking each model to ensure that we can initialize and capture any textures // that might be done by parent models cache.clear(); diff --git a/src/main/java/team/chisel/ctm/client/util/VertexData.java b/src/main/java/team/chisel/ctm/client/util/VertexData.java index 105083f..4a1fbe5 100644 --- a/src/main/java/team/chisel/ctm/client/util/VertexData.java +++ b/src/main/java/team/chisel/ctm/client/util/VertexData.java @@ -11,6 +11,7 @@ import lombok.ToString; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; @Getter @ToString @@ -18,7 +19,7 @@ @AllArgsConstructor public class VertexData { - private double posX, posY, posZ; + private float posX, posY, posZ; private float normalX, normalY, normalZ; //Store int representations of the colors so that we don't go between ints and doubles when unpacking and repacking a vertex @@ -33,8 +34,8 @@ public class VertexData { private Map miscData = new HashMap<>(); - public Vec3 getPos() { - return new Vec3(posX, posY, posZ); + public Vector3f getPos() { + return new Vector3f(posX, posY, posZ); } public Vec2 getUV() { @@ -57,7 +58,7 @@ public VertexData color(int red, int green, int blue, int alpha) { return this; } - public VertexData pos(double x, double y, double z) { + public VertexData pos(float x, float y, float z) { this.posX = x; this.posY = y; this.posZ = z; @@ -113,15 +114,14 @@ public VertexData copy(boolean deepCopy) { } public void write(VertexConsumer consumer) { - consumer.vertex(posX, posY, posZ); - consumer.color(red, green, blue, alpha); - consumer.uv(texU, texV); - consumer.overlayCoords(overlayU, overlayV); - consumer.uv2(lightU, lightV); - consumer.normal(normalX, normalY, normalZ); + consumer.addVertex(posX, posY, posZ); + consumer.setColor(red, green, blue, alpha); + consumer.setUv(texU, texV); + consumer.setUv1(overlayU, overlayV); + consumer.setUv2(lightU, lightV); + consumer.setNormal(normalX, normalY, normalZ); for (Map.Entry entry : miscData.entrySet()) { consumer.misc(entry.getKey(), entry.getValue()); } - consumer.endVertex(); } } \ No newline at end of file diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 3acee88..5dcd885 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -4,4 +4,5 @@ public net.minecraft.client.resources.model.WeightedBakedModel list # ModelBakery hacks public net.minecraft.client.resources.model.ModelBakery$ModelBakerImpl -public net.minecraft.client.resources.model.ModelBakery$ModelBakerImpl (Lnet/minecraft/client/resources/model/ModelBakery;Ljava/util/function/BiFunction;Lnet/minecraft/resources/ResourceLocation;)V \ No newline at end of file +public net.minecraft.client.resources.model.ModelBakery$ModelBakerImpl (Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/resources/model/ModelBakery$TextureGetter;Lnet/minecraft/client/resources/model/ModelResourceLocation;)V +public net.minecraft.client.resources.model.ModelBakery getModel(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/resources/model/UnbakedModel; \ No newline at end of file diff --git a/src/main/resources/ctm.mixins.json b/src/main/resources/ctm.mixins.json index 730de3f..4bdbd3c 100644 --- a/src/main/resources/ctm.mixins.json +++ b/src/main/resources/ctm.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "team.chisel.ctm.client.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [ "TextureScrapingMixin" ], diff --git a/src/test/java/team/chisel/ctm/tests/NewCTMLogicTest.java b/src/test/java/team/chisel/ctm/tests/NewCTMLogicTest.java index 30820ba..53a73bc 100644 --- a/src/test/java/team/chisel/ctm/tests/NewCTMLogicTest.java +++ b/src/test/java/team/chisel/ctm/tests/NewCTMLogicTest.java @@ -10,7 +10,6 @@ import java.util.Arrays; import net.neoforged.neoforge.client.model.pipeline.QuadBakingVertexConsumer; -import net.neoforged.neoforge.client.model.pipeline.QuadBakingVertexConsumer.Buffered; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -38,13 +37,13 @@ void submaps() { @Test void quad() { - QuadBakingVertexConsumer.Buffered builder = new Buffered(); - builder.vertex(0, 0, 0).uv(0, 0).normal(0, 1, 0).endVertex(); - builder.vertex(1, 0, 0).uv(1, 0).normal(0, 1, 0).endVertex(); - builder.vertex(1, 0, 1).uv(1, 1).normal(0, 1, 0).endVertex(); - builder.vertex(0, 0, 1).uv(0, 1).normal(0, 1, 0).endVertex(); + QuadBakingVertexConsumer builder = new QuadBakingVertexConsumer(); + builder.addVertex(0, 0, 0).setUv(0, 0).setNormal(0, 1, 0); + builder.addVertex(1, 0, 0).setUv(1, 0).setNormal(0, 1, 0); + builder.addVertex(1, 0, 1).setUv(1, 1).setNormal(0, 1, 0); + builder.addVertex(0, 0, 1).setUv(0, 1).setNormal(0, 1, 0); - Quad q = Quad.from(builder.getQuad()); + Quad q = Quad.from(builder.bakeQuad()); Quad quarter = q.subsect(Submap.fromPixelScale(8, 8, 0, 0)); Quad half = q.subsect(Submap.fromPixelScale(8, 16, 0, 0)); Quad center = q.subsect(Submap.fromPixelScale(8, 8, 4, 4));