This commit is contained in:
quat1024 2023-06-30 03:00:49 -04:00
parent 24765be267
commit c671a68354
2 changed files with 20 additions and 6 deletions

View File

@ -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
## 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 >:).

View File

@ -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<SpriteIdentifier, Sprite> 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;
}