hmm
This commit is contained in:
parent
24765be267
commit
c671a68354
12
README.md
12
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.
|
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)
|
* 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`
|
* 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...
|
* Upside-down slopes would be nice...
|
||||||
* (if i may): Packages-ish "retexturing" of json blockmodels
|
* (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 >:).
|
@ -1,6 +1,7 @@
|
|||||||
package io.github.cottonmc.templates.model;
|
package io.github.cottonmc.templates.model;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
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.RendererAccess;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
|
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder;
|
import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder;
|
||||||
@ -30,11 +31,14 @@ import java.util.function.Supplier;
|
|||||||
public class SlopeMeshTransformer implements MeshTransformer {
|
public class SlopeMeshTransformer implements MeshTransformer {
|
||||||
public SlopeMeshTransformer(Function<SpriteIdentifier, Sprite> spriteLookup) {
|
public SlopeMeshTransformer(Function<SpriteIdentifier, Sprite> spriteLookup) {
|
||||||
this.sprites = new SpriteSet(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 SpriteSet sprites;
|
||||||
private final MaterialFinder finder = RendererAccess.INSTANCE.getRenderer().materialFinder();
|
private final MaterialFinder finder;
|
||||||
|
|
||||||
private int color;
|
private int color;
|
||||||
private Direction dir;
|
private Direction dir;
|
||||||
@ -59,11 +63,12 @@ public class SlopeMeshTransformer implements MeshTransformer {
|
|||||||
.blendMode(BlendMode.fromRenderLayer(RenderLayers.getBlockLayer(state)))
|
.blendMode(BlendMode.fromRenderLayer(RenderLayers.getBlockLayer(state)))
|
||||||
.find();
|
.find();
|
||||||
|
|
||||||
BakedModel model = minecraft.getBlockRenderManager().getModel(template);
|
BakedModel model = MinecraftClient.getInstance().getBlockRenderManager().getModel(template);
|
||||||
sprites.inspect(model, randomSupplier.get());
|
sprites.inspect(model, randomSupplier.get());
|
||||||
BlockColorProvider blockColor = ColorProviderRegistry.BLOCK.get(block);
|
BlockColorProvider blockColor = ColorProviderRegistry.BLOCK.get(block);
|
||||||
if(blockColor != null) color = 0xff000000 | blockColor.getColor(template, blockView, pos, 1);
|
if(blockColor != null) color = 0xff000000 | blockColor.getColor(template, blockView, pos, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +78,7 @@ public class SlopeMeshTransformer implements MeshTransformer {
|
|||||||
color = 0xffffff;
|
color = 0xffffff;
|
||||||
sprites.clear();
|
sprites.clear();
|
||||||
material = finder.clear().find();
|
material = finder.clear().find();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user