Hardcode the particle

The default texture is hardcoded and making that settable per-block
would be a big pain. Just hardcode it.
This commit is contained in:
quat1024 2023-07-04 03:15:46 -04:00
parent e3dc78fa6a
commit a981cd28c2
9 changed files with 19 additions and 19 deletions

View File

@ -51,9 +51,7 @@ If possible, I don't recommend making a wholly *new* json model. If you have an
"north": "templates:templates_special/north",
"south": "templates:templates_special/south",
"west": "templates:templates_special/west",
"east": "templates:templates_special/east",
"particle": "minecraft:block/scaffolding_top"
"east": "templates:templates_special/east"
}
}
```
@ -70,7 +68,7 @@ If you have a shape in mind that can't be represented with a json model (like a
We will construct a `RetexturedMeshUnbakedModel`. You need two things - the ID of a parent model, and a `Supplier<>` of a `Mesh` to retexture.
Ideally, the parent model should have a parent of `block/block`, or at least define *some* non-default rotations (smokey the bear voice *Only You Can Prevent Weirdly Rotated First-Person Models*), set `"gui_light": "front"` (lest the item model look weird), and define a particle texture. You should use a json model for this, but keep in mind that no quads will be read from the json model - it's only used to source all the miscellaneous `BakedModel` options.
Ideally, the parent model should have a parent of `block/block`, or at least define *some* non-default rotations (smokey the bear voice *Only You Can Prevent Weirdly Rotated First-Person Models*) and set `"gui_light": "front"` (lest the item model look weird). You should use a json model for this, but keep in mind that no quads will be read from the json model - it's only used to source all the miscellaneous `BakedModel` options.
When building the `Mesh`, if you want a face to be dynamically retextured, `.tag()` it with the `.ordinal() + 1` of the `Direction` it corresponds to, and give the face UV coordinates ranging from 0 to 1. (For example, if you tag a face with `3` (`Direction.NORTH.ordinal() + 1`), it will be retextured to the north side of the template's theme.)

View File

@ -90,7 +90,7 @@ public class TemplateInteractionUtil {
.with(REDSTONE, be.hasSpentRedstoneTorch() || placementState.getWeakRedstonePower(world, pos, Direction.NORTH) != 0));
if(!player.isCreative()) held.decrement(1);
world.playSound(player, pos, state.getSoundGroup().getPlaceSound(), SoundCategory.BLOCKS, 1f, 1f);
world.playSound(player, pos, placementState.getSoundGroup().getPlaceSound(), SoundCategory.BLOCKS, 1f, 1.1f);
return ActionResult.SUCCESS;
}
}

View File

@ -83,6 +83,11 @@ public class RetexturedJsonModelBakedModel extends ForwardingBakedModel {
context.meshConsumer().accept(meshCache.computeIfAbsent(key, this::makeMesh));
}
@Override
public Sprite getParticleSprite() {
return tam.getDefaultAppearance().getParticleSprite();
}
protected Mesh makeMesh(CacheKey key) {
Renderer r = TemplatesClient.getFabricRenderer();
MeshBuilder builder = r.meshBuilder();

View File

@ -56,6 +56,11 @@ public final class RetexturedMeshBakedModel extends ForwardingBakedModel {
context.popTransform();
}
@Override
public Sprite getParticleSprite() {
return tam.getDefaultAppearance().getParticleSprite();
}
public @NotNull RenderContext.QuadTransform retexturingBlockTransformer(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier) {
BlockState theme = (((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos) instanceof BlockState s) ? s : null;
if(theme == null || theme.isAir()) return new RetexturingTransformer(tam.getDefaultAppearance(), 0xFFFFFFFF, facePermutation);

View File

@ -25,19 +25,17 @@ import java.util.function.Function;
public class TemplateAppearanceManager {
public TemplateAppearanceManager(Function<SpriteIdentifier, Sprite> spriteLookup) {
SpriteIdentifier defaultSpriteId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/scaffolding_top"));
Sprite defaultSprite = spriteLookup.apply(defaultSpriteId);
if(defaultSprite == null) throw new IllegalStateException("Couldn't locate " + defaultSpriteId + " !");
MaterialFinder finder = TemplatesClient.getFabricRenderer().materialFinder();
for(BlendMode blend : BlendMode.values()) {
blockMaterials.put(blend, finder.clear().disableDiffuse(false).ambientOcclusion(TriState.FALSE).blendMode(blend).find());
}
Sprite defaultSprite = spriteLookup.apply(DEFAULT_SPRITE_ID);
if(defaultSprite == null) throw new IllegalStateException("Couldn't locate " + DEFAULT_SPRITE_ID + " !");
this.defaultAppearance = new SingleSpriteAppearance(defaultSprite, blockMaterials.get(BlendMode.CUTOUT));
}
public static final SpriteIdentifier DEFAULT_SPRITE_ID = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/scaffolding_top"));
private final TemplateAppearance defaultAppearance;
//Mutable, append-only cache:

View File

@ -6,7 +6,6 @@
"north": "templates:templates_special/north",
"south": "templates:templates_special/south",
"west": "templates:templates_special/west",
"east": "templates:templates_special/east",
"particle": "minecraft:block/scaffolding_top"
"east": "templates:templates_special/east"
}
}

View File

@ -6,8 +6,7 @@
"north": "templates:templates_special/north",
"south": "templates:templates_special/south",
"west": "templates:templates_special/west",
"east": "templates:templates_special/east",
"particle": "minecraft:block/scaffolding_top"
"east": "templates:templates_special/east"
},
"elements": [
{

View File

@ -6,8 +6,7 @@
"north": "templates:templates_special/north",
"south": "templates:templates_special/south",
"west": "templates:templates_special/west",
"east": "templates:templates_special/east",
"particle": "minecraft:block/scaffolding_top"
"east": "templates:templates_special/east"
},
"elements": [
{

View File

@ -1,9 +1,6 @@
{
"parent": "minecraft:block/block",
"gui_light": "front",
"textures": {
"particle": "minecraft:block/scaffolding_top"
},
"display": {
"firstperson_righthand": {
"rotation": [ 0, 135, 0 ],