From c671a6835424d6df84463a760464b6ade3722ff4 Mon Sep 17 00:00:00 2001 From: quat1024 Date: Fri, 30 Jun 2023 03:00:49 -0400 Subject: [PATCH] hmm --- README.md | 14 +++++++++++--- .../templates/model/SlopeMeshTransformer.java | 12 +++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 19d97ed..9bff74a 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,18 @@ Templates is an API for Carpenter's Blocks-like templated blocks. Currently, pla Template blocks can be placed in the world, then right-clicked with a full-size block to set the textures for the template. Template blocks will inherit light and redstone values from the blocks they're given, or they can have light or redstone output added to any given block by right-clicking the template with glowstone dust or a redstone torch, respectively. -# quat was here - TODO +# quat was here + +## Todo * Re-generalize the model system (I removed a layer of indirection while rewriting it, so it's just slopes now) * See what I can do about using the vanilla rotation system (`ModelBakeSettings.getRotation`) instead of manually rotating the `Mesh` - * A simplification of the mesh system would *definitely* reduce the friction of adding new meshes + * A simplification of the mesh system would *definitely* reduce the friction of adding new meshes (see all the `paintXxx` stuff in `SlopeMeshTransformer`, it's fairly ugly) * Upside-down slopes would be nice... -* (if i may): Packages-ish "retexturing" of json blockmodels \ No newline at end of file +* (if i may): Packages-ish "retexturing" of json blockmodels + +## Notes for addon developers + +To create your block, instantiate or extend `TemplateBlock`. Pass your `Block.Settings` through `TemplateBlock.configureSettings` to wire up the "click for glowstone" feature. Create an `ItemBlock` as normal, and create a `BlockEntityType` by instantiating or extending `TemplateEntity`. + +Next, wire up the custom model. im going to refactor this in like 5 seconds so im not documenting it >:). \ No newline at end of file diff --git a/src/main/java/io/github/cottonmc/templates/model/SlopeMeshTransformer.java b/src/main/java/io/github/cottonmc/templates/model/SlopeMeshTransformer.java index a056f27..b45010b 100644 --- a/src/main/java/io/github/cottonmc/templates/model/SlopeMeshTransformer.java +++ b/src/main/java/io/github/cottonmc/templates/model/SlopeMeshTransformer.java @@ -1,6 +1,7 @@ package io.github.cottonmc.templates.model; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; +import net.fabricmc.fabric.api.renderer.v1.Renderer; import net.fabricmc.fabric.api.renderer.v1.RendererAccess; import net.fabricmc.fabric.api.renderer.v1.material.BlendMode; import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder; @@ -30,11 +31,14 @@ import java.util.function.Supplier; public class SlopeMeshTransformer implements MeshTransformer { public SlopeMeshTransformer(Function spriteLookup) { this.sprites = new SpriteSet(spriteLookup); + + Renderer r = RendererAccess.INSTANCE.getRenderer(); + if(r == null) throw new IllegalStateException("A Fabric Rendering API implementation is required"); + this.finder = r.materialFinder(); } - private final MinecraftClient minecraft = MinecraftClient.getInstance(); private final SpriteSet sprites; - private final MaterialFinder finder = RendererAccess.INSTANCE.getRenderer().materialFinder(); + private final MaterialFinder finder; private int color; private Direction dir; @@ -59,11 +63,12 @@ public class SlopeMeshTransformer implements MeshTransformer { .blendMode(BlendMode.fromRenderLayer(RenderLayers.getBlockLayer(state))) .find(); - BakedModel model = minecraft.getBlockRenderManager().getModel(template); + BakedModel model = MinecraftClient.getInstance().getBlockRenderManager().getModel(template); sprites.inspect(model, randomSupplier.get()); BlockColorProvider blockColor = ColorProviderRegistry.BLOCK.get(block); if(blockColor != null) color = 0xff000000 | blockColor.getColor(template, blockView, pos, 1); } + return this; } @@ -73,6 +78,7 @@ public class SlopeMeshTransformer implements MeshTransformer { color = 0xffffff; sprites.clear(); material = finder.clear().find(); + return this; }