naming + texture change and cleanup
This commit is contained in:
@@ -49,14 +49,14 @@ import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* TODO handle random textures, handle grass side, multiple camos
|
||||
* TODO handle random textures wip, handle grass side, multiple camos
|
||||
*/
|
||||
public class Templates implements ModInitializer {
|
||||
public static final String MODID = "templates";
|
||||
public static final String MODID = "reframedtemplates";
|
||||
|
||||
//addon devs: *Don't* add your blocks to this collection, it's just for my registration convenience since Templates adds a lot of blocks...
|
||||
@ApiStatus.Internal static final ArrayList<Block> INTERNAL_TEMPLATES = new ArrayList<>();
|
||||
@ApiStatus.Internal static Block CUBE, STAIRS, SLAB, VERTICAL_SLAB, POST, FENCE, FENCE_GATE, DOOR, TRAPDOOR, IRON_DOOR, IRON_TRAPDOOR, PRESSURE_PLATE, BUTTON, LEVER, WALL, CARPET, PANE, CANDLE, SLOPE, TINY_SLOPE, COOL_RIVULET;
|
||||
@ApiStatus.Internal static Block CUBE, STAIRS, SLAB, VERTICAL_SLAB, POST, FENCE, FENCE_GATE, DOOR, TRAPDOOR, IRON_DOOR, IRON_TRAPDOOR, PRESSURE_PLATE, BUTTON, LEVER, WALL, CARPET, PANE, CANDLE, SLOPE, TINY_SLOPE;
|
||||
|
||||
//For addon devs: Please don't stuff more blocks into this BlockEntityType, and register your own.
|
||||
//You can even re-register the same TemplateEntity class under your own ID if you like. (It's an extensible block entity.)
|
||||
@@ -71,7 +71,7 @@ public class Templates implements ModInitializer {
|
||||
//the ordering is used in the creative tab, so they're roughly sorted by encounter order of the
|
||||
//corresponding vanilla block in the "search" creative tab... with the non-vanilla "post" and
|
||||
//"vertical slab" inserted where they fit ...and i moved the lever way up next to the pressureplate
|
||||
//and button, cause theyre redstoney... hopefully this ordering makes sense lol
|
||||
//and button, because they're redstoney... hopefully this ordering makes sense lol
|
||||
CUBE = registerTemplate("cube" , new TemplateBlock(TemplateInteractionUtil.makeSettings()));
|
||||
STAIRS = registerTemplate("stairs" , new TemplateStairsBlock(cp(Blocks.OAK_STAIRS)));
|
||||
SLAB = registerTemplate("slab" , new TemplateSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||
@@ -98,24 +98,11 @@ public class Templates implements ModInitializer {
|
||||
FabricBlockEntityTypeBuilder.create((pos, state) -> new TemplateEntity(TEMPLATE_BLOCK_ENTITY, pos, state), INTERNAL_TEMPLATES.toArray(new Block[0])).build(null)
|
||||
);
|
||||
|
||||
//hey guys rate my registration code
|
||||
Registry.register(Registries.ITEM, id("cool_rivulet"), new BlockItem(
|
||||
COOL_RIVULET = Registry.register(Registries.BLOCK, id("cool_rivulet"), new GlazedTerracottaBlock(
|
||||
AbstractBlock.Settings.create().hardness(0.2f)) {
|
||||
@Override
|
||||
public void appendTooltip(ItemStack stack, @Nullable BlockView world, List<Text> tooltip, TooltipContext eggbals) {
|
||||
tooltip.add(Text.translatable("block.templates.cool_rivulet").formatted(Formatting.GRAY));
|
||||
}
|
||||
}),
|
||||
new Item.Settings()
|
||||
));
|
||||
|
||||
Registry.register(Registries.ITEM_GROUP, id("tab"), FabricItemGroup.builder()
|
||||
.displayName(Text.translatable("itemGroup.templates.tab"))
|
||||
.displayName(Text.translatable("itemGroup.reframedtemplates.tab"))
|
||||
.icon(() -> new ItemStack(SLOPE))
|
||||
.entries((ctx, e) -> {
|
||||
e.addAll(INTERNAL_TEMPLATES.stream().map(ItemStack::new).collect(Collectors.toList()));
|
||||
e.add(COOL_RIVULET);
|
||||
}).build()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,16 +11,4 @@ public interface TemplateAppearance {
|
||||
@NotNull Sprite getSprite(Direction dir);
|
||||
int getBakeFlags(Direction dir);
|
||||
boolean hasColor(Direction dir);
|
||||
|
||||
//TODO ABI: Dates from before conditional model AO was added.
|
||||
@Deprecated(forRemoval = true)
|
||||
default @NotNull RenderMaterial getRenderMaterial() {
|
||||
return getRenderMaterial(false);
|
||||
}
|
||||
|
||||
//TODO ABI: Deprecated in 2.2. I never ended up implementing this, it's much easier to modify particles via the BlockState
|
||||
@Deprecated(forRemoval = true)
|
||||
default @NotNull Sprite getParticleSprite() {
|
||||
return getSprite(Direction.NORTH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TemplateAppearanceManager {
|
||||
|
||||
//TODO ABI: Shouldn't have been made public. Noticed this in 2.2.
|
||||
@ApiStatus.Internal
|
||||
public static final SpriteIdentifier DEFAULT_SPRITE_ID = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:block/scaffolding_top"));
|
||||
public static final SpriteIdentifier DEFAULT_SPRITE_ID = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("reframedtemplates:block/framed_block"));
|
||||
private static final SpriteIdentifier BARRIER_SPRITE_ID = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, new Identifier("minecraft:item/barrier"));
|
||||
|
||||
private final TemplateAppearance defaultAppearance;
|
||||
|
||||
@@ -100,11 +100,4 @@ public class UnbakedAutoRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//TODO ABI: (2.2) use TemplatesClientApi.getInstance.auto, and use the builder properties to set this field
|
||||
@Deprecated(forRemoval = true)
|
||||
public UnbakedAutoRetexturedModel(Identifier parent, BlockState itemModelState) {
|
||||
this(parent);
|
||||
itemModelState(itemModelState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ package fr.adrien1106.reframedtemplates.model;
|
||||
|
||||
import fr.adrien1106.reframedtemplates.Templates;
|
||||
import fr.adrien1106.reframedtemplates.api.TemplatesClientApi;
|
||||
import fr.adrien1106.reframedtemplates.mixin.model.WeightedBakedModelAccessor;
|
||||
import net.fabricmc.fabric.api.renderer.v1.Renderer;
|
||||
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder;
|
||||
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.render.model.Baker;
|
||||
import net.minecraft.client.render.model.ModelBakeSettings;
|
||||
import net.minecraft.client.render.model.UnbakedModel;
|
||||
import net.minecraft.client.render.model.*;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.screen.PlayerScreenHandler;
|
||||
@@ -73,9 +70,15 @@ public class UnbakedJsonRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
SpriteIdentifier id = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, Templates.id("templates_special/" + DIRECTIONS[i].getName()));
|
||||
specialSprites[i] = Objects.requireNonNull(spriteLookup.apply(id), () -> "Couldn't find sprite " + id + " !");
|
||||
}
|
||||
|
||||
|
||||
BakedModel model = baker.bake(parent, modelBakeSettings);
|
||||
if (model instanceof WeightedBakedModel weighted_model) {
|
||||
System.out.println("weighted model");
|
||||
((WeightedBakedModelAccessor) weighted_model).getModels();
|
||||
}
|
||||
|
||||
return new RetexturingBakedModel(
|
||||
baker.bake(parent, modelBakeSettings),
|
||||
model,
|
||||
TemplatesClientApi.getInstance().getOrCreateTemplateApperanceManager(spriteLookup),
|
||||
modelBakeSettings,
|
||||
itemModelState,
|
||||
@@ -85,7 +88,7 @@ public class UnbakedJsonRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
|
||||
@Override
|
||||
protected Mesh getBaseMesh(BlockState state) {
|
||||
//Convert models to retexturable Meshes lazily, the first time we encounter each blockstate
|
||||
//Convert models to re-texturable Meshes lazily, the first time we encounter each blockstate
|
||||
return jsonToMesh.computeIfAbsent(state, this::convertModel);
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ public class UnbakedJsonRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
RenderMaterial mat = tam.getCachedMaterial(state, false);
|
||||
|
||||
Random rand = Random.create(42);
|
||||
|
||||
|
||||
for(Direction cullFace : DIRECTIONS_AND_NULL) {
|
||||
for(BakedQuad quad : wrapped.getQuads(state, cullFace, rand)) {
|
||||
emitter.fromVanilla(quad, mat, cullFace);
|
||||
@@ -118,11 +121,4 @@ public class UnbakedJsonRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//TODO ABI: (2.2) use TemplatesClientApi.getInstance.json, and use the builder properties to set this field
|
||||
@Deprecated(forRemoval = true)
|
||||
public UnbakedJsonRetexturedModel(Identifier parent, BlockState itemModelState) {
|
||||
this(parent);
|
||||
itemModelState(itemModelState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,4 @@ public class UnbakedMeshRetexturedModel implements UnbakedModel, TemplatesClient
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//TODO ABI: (2.2) use TemplatesClientApi.getInstance.mesh
|
||||
@Deprecated(forRemoval = true)
|
||||
public UnbakedMeshRetexturedModel(Identifier parent, Supplier<Mesh> baseMeshFactory) {
|
||||
this(parent, __ -> baseMeshFactory.get());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user