succumb to the call of making a cute table
This commit is contained in:
parent
c44f8dc6e9
commit
7588087416
@ -36,41 +36,31 @@ import net.minecraft.util.Identifier;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class Templates implements ModInitializer {
|
public class Templates implements ModInitializer {
|
||||||
public static final String MODID = "templates";
|
public static final String MODID = "templates";
|
||||||
|
|
||||||
public static final List<Block> BLOCKS = new ArrayList<>();
|
|
||||||
private static <B extends Block> B reg(String id, B block) {
|
|
||||||
B b = Registry.register(Registries.BLOCK, id(id), block);
|
|
||||||
BLOCKS.add(b);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AbstractBlock.Settings cp(Block base) {
|
private static AbstractBlock.Settings cp(Block base) {
|
||||||
return TemplateInteractionUtil.configureSettings(AbstractBlock.Settings.copy(base));
|
return TemplateInteractionUtil.configureSettings(AbstractBlock.Settings.copy(base));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Block BUTTON = reg("button", new TemplateButtonBlock(cp(Blocks.OAK_BUTTON)));
|
public static final Block BUTTON = Registry.register(Registries.BLOCK, id("button") , new TemplateButtonBlock(cp(Blocks.OAK_BUTTON)));
|
||||||
public static final Block CANDLE = reg("candle", new TemplateCandleBlock(TemplateCandleBlock.configureSettings(cp(Blocks.CANDLE))));
|
public static final Block CANDLE = Registry.register(Registries.BLOCK, id("candle") , new TemplateCandleBlock(TemplateCandleBlock.configureSettings(cp(Blocks.CANDLE))));
|
||||||
public static final Block CARPET = reg("carpet", new TemplateCarpetBlock(cp(Blocks.WHITE_CARPET)));
|
public static final Block CARPET = Registry.register(Registries.BLOCK, id("carpet") , new TemplateCarpetBlock(cp(Blocks.WHITE_CARPET)));
|
||||||
public static final Block CUBE = reg("cube", new TemplateBlock(TemplateInteractionUtil.makeSettings()));
|
public static final Block CUBE = Registry.register(Registries.BLOCK, id("cube") , new TemplateBlock(TemplateInteractionUtil.makeSettings()));
|
||||||
//door? (hard cause its a multiblock)
|
//door? (hard cause its a multiblock)
|
||||||
public static final Block FENCE = reg("fence", new TemplateFenceBlock(cp(Blocks.OAK_FENCE)));
|
public static final Block FENCE = Registry.register(Registries.BLOCK, id("fence") , new TemplateFenceBlock(cp(Blocks.OAK_FENCE)));
|
||||||
public static final Block FENCE_GATE = reg("fence_gate", new TemplateFenceGateBlock(cp(Blocks.OAK_FENCE_GATE)));
|
public static final Block FENCE_GATE = Registry.register(Registries.BLOCK, id("fence_gate") , new TemplateFenceGateBlock(cp(Blocks.OAK_FENCE_GATE)));
|
||||||
public static final Block LEVER = reg("lever", new TemplateLeverBlock(cp(Blocks.LEVER)));
|
public static final Block LEVER = Registry.register(Registries.BLOCK, id("lever") , new TemplateLeverBlock(cp(Blocks.LEVER)));
|
||||||
public static final Block PANE = reg("pane", new TemplatePaneBlock(cp(Blocks.GLASS_PANE)));
|
public static final Block PANE = Registry.register(Registries.BLOCK, id("pane") , new TemplatePaneBlock(cp(Blocks.GLASS_PANE)));
|
||||||
public static final Block POST = reg("post", new TemplatePostBlock(cp(Blocks.OAK_FENCE)));
|
public static final Block POST = Registry.register(Registries.BLOCK, id("post") , new TemplatePostBlock(cp(Blocks.OAK_FENCE)));
|
||||||
public static final Block PRESSURE_PLATE = reg("pressure_plate", new TemplatePressurePlateBlock(cp(Blocks.OAK_PRESSURE_PLATE)));
|
public static final Block PRESSURE_PLATE = Registry.register(Registries.BLOCK, id("pressure_plate"), new TemplatePressurePlateBlock(cp(Blocks.OAK_PRESSURE_PLATE)));
|
||||||
public static final Block SLAB = reg("slab", new TemplateSlabBlock(cp(Blocks.OAK_SLAB)));
|
public static final Block SLAB = Registry.register(Registries.BLOCK, id("slab") , new TemplateSlabBlock(cp(Blocks.OAK_SLAB)));
|
||||||
public static final Block STAIRS = reg("stairs", new TemplateStairsBlock(cp(Blocks.OAK_STAIRS)));
|
public static final Block STAIRS = Registry.register(Registries.BLOCK, id("stairs") , new TemplateStairsBlock(cp(Blocks.OAK_STAIRS)));
|
||||||
public static final Block TRAPDOOR = reg("trapdoor", new TemplateTrapdoorBlock(cp(Blocks.OAK_TRAPDOOR)));
|
public static final Block TRAPDOOR = Registry.register(Registries.BLOCK, id("trapdoor") , new TemplateTrapdoorBlock(cp(Blocks.OAK_TRAPDOOR)));
|
||||||
public static final Block WALL = reg("wall", new TemplateWallBlock(cp(Blocks.COBBLESTONE_WALL)));
|
public static final Block WALL = Registry.register(Registries.BLOCK, id("wall") , new TemplateWallBlock(cp(Blocks.COBBLESTONE_WALL)));
|
||||||
|
public static final Block SLOPE = Registry.register(Registries.BLOCK, id("slope") , new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings()));
|
||||||
public static final Block SLOPE = reg("slope", new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings()));
|
|
||||||
//30 degree slope (shallow/deep)
|
//30 degree slope (shallow/deep)
|
||||||
//corner slopes
|
//corner slopes
|
||||||
//quarter slabs????
|
//quarter slabs????
|
||||||
@ -78,7 +68,23 @@ public class Templates implements ModInitializer {
|
|||||||
//for addon devs: it's fine to make your own block entity type instead of gluing additional blocks to this one
|
//for addon devs: it's fine to make your own block entity type instead of gluing additional blocks to this one
|
||||||
public static final BlockEntityType<TemplateEntity> TEMPLATE_BLOCK_ENTITY = Registry.register(
|
public static final BlockEntityType<TemplateEntity> TEMPLATE_BLOCK_ENTITY = Registry.register(
|
||||||
Registries.BLOCK_ENTITY_TYPE, id("slope"),
|
Registries.BLOCK_ENTITY_TYPE, id("slope"),
|
||||||
FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity, BLOCKS.toArray(new Block[0])).build(null)
|
FabricBlockEntityTypeBuilder.create(Templates::makeTemplateBlockEntity,
|
||||||
|
BUTTON,
|
||||||
|
CANDLE,
|
||||||
|
CARPET,
|
||||||
|
CUBE,
|
||||||
|
FENCE,
|
||||||
|
FENCE_GATE,
|
||||||
|
LEVER,
|
||||||
|
PANE,
|
||||||
|
POST,
|
||||||
|
PRESSURE_PLATE,
|
||||||
|
SLAB,
|
||||||
|
STAIRS,
|
||||||
|
TRAPDOOR,
|
||||||
|
WALL,
|
||||||
|
SLOPE
|
||||||
|
).build(null)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Overridden in TemplatesClient
|
//Overridden in TemplatesClient
|
||||||
@ -95,10 +101,21 @@ public class Templates implements ModInitializer {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
for(Block b : BLOCKS) {
|
Registry.register(Registries.ITEM, id("button") , new BlockItem(BUTTON, new Item.Settings()));
|
||||||
Identifier id = Registries.BLOCK.getId(b);
|
Registry.register(Registries.ITEM, id("candle") , new BlockItem(CANDLE, new Item.Settings()));
|
||||||
Registry.register(Registries.ITEM, id, new BlockItem(b, new Item.Settings()));
|
Registry.register(Registries.ITEM, id("carpet") , new BlockItem(CARPET, new Item.Settings()));
|
||||||
}
|
Registry.register(Registries.ITEM, id("cube") , new BlockItem(CUBE, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("fence") , new BlockItem(FENCE, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("fence_gate") , new BlockItem(FENCE_GATE, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("lever") , new BlockItem(LEVER, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("pane") , new BlockItem(PANE, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("post") , new BlockItem(POST, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("pressure_plate"), new BlockItem(PRESSURE_PLATE, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("slab") , new BlockItem(SLAB, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("stairs") , new BlockItem(STAIRS, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("trapdoor") , new BlockItem(TRAPDOOR, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("wall") , new BlockItem(WALL, new Item.Settings()));
|
||||||
|
Registry.register(Registries.ITEM, id("slope") , new BlockItem(SLOPE, new Item.Settings()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Identifier id(String path) {
|
public static Identifier id(String path) {
|
||||||
|
@ -11,7 +11,6 @@ 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.resource.ResourceManagerHelper;
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.resource.ResourceManager;
|
import net.minecraft.resource.ResourceManager;
|
||||||
@ -56,7 +55,23 @@ public class TemplatesClient implements ClientModInitializer {
|
|||||||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> provider); //block models
|
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> provider); //block models
|
||||||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> provider); //item models
|
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> provider); //item models
|
||||||
|
|
||||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), Templates.BLOCKS.toArray(new Block[0]));
|
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(),
|
||||||
|
Templates.BUTTON,
|
||||||
|
Templates.CANDLE,
|
||||||
|
Templates.CARPET,
|
||||||
|
Templates.CUBE,
|
||||||
|
Templates.FENCE,
|
||||||
|
Templates.FENCE_GATE,
|
||||||
|
Templates.LEVER,
|
||||||
|
Templates.PANE,
|
||||||
|
Templates.POST,
|
||||||
|
Templates.PRESSURE_PLATE,
|
||||||
|
Templates.SLAB,
|
||||||
|
Templates.STAIRS,
|
||||||
|
Templates.TRAPDOOR,
|
||||||
|
Templates.WALL,
|
||||||
|
Templates.SLOPE
|
||||||
|
);
|
||||||
|
|
||||||
//vanilla style models (using "auto" method)
|
//vanilla style models (using "auto" method)
|
||||||
provider.addTemplateModel(Templates.id("button_special") , new UnbakedAutoRetexturedModel(new Identifier("block/button")));
|
provider.addTemplateModel(Templates.id("button_special") , new UnbakedAutoRetexturedModel(new Identifier("block/button")));
|
||||||
@ -118,10 +133,10 @@ public class TemplatesClient implements ClientModInitializer {
|
|||||||
//provider.assignItemModel(Templates.id("glass_pane_side_special"), Templates.PANE); //Done with a regular json model actually
|
//provider.assignItemModel(Templates.id("glass_pane_side_special"), Templates.PANE); //Done with a regular json model actually
|
||||||
provider.assignItemModel(Templates.id("fence_post_inventory_special") , Templates.POST);
|
provider.assignItemModel(Templates.id("fence_post_inventory_special") , Templates.POST);
|
||||||
provider.assignItemModel(Templates.id("pressure_plate_up_special") , Templates.PRESSURE_PLATE);
|
provider.assignItemModel(Templates.id("pressure_plate_up_special") , Templates.PRESSURE_PLATE);
|
||||||
provider.assignItemModel(Templates.id("slope_special"), Templates.SLOPE);
|
|
||||||
provider.assignItemModel(Templates.id("slab_bottom_special") , Templates.SLAB);
|
provider.assignItemModel(Templates.id("slab_bottom_special") , Templates.SLAB);
|
||||||
provider.assignItemModel(Templates.id("stairs_special") , Templates.STAIRS);
|
provider.assignItemModel(Templates.id("stairs_special") , Templates.STAIRS);
|
||||||
provider.assignItemModel(Templates.id("trapdoor_bottom_special") , Templates.TRAPDOOR);
|
provider.assignItemModel(Templates.id("trapdoor_bottom_special") , Templates.TRAPDOOR);
|
||||||
provider.assignItemModel(Templates.id("wall_inventory_special") , Templates.WALL);
|
provider.assignItemModel(Templates.id("wall_inventory_special") , Templates.WALL);
|
||||||
|
provider.assignItemModel(Templates.id("slope_special") , Templates.SLOPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
|||||||
|
|
||||||
//The quad tag numbers were selected so this magic trick works:
|
//The quad tag numbers were selected so this magic trick works:
|
||||||
Direction dir = facePermutation.get(DIRECTIONS[quad.tag() - 1]);
|
Direction dir = facePermutation.get(DIRECTIONS[quad.tag() - 1]);
|
||||||
if(ta.hasColor(dir)) quad.color(tint, tint, tint, tint); //TODO: still doesn't cover stuff like grass blocks, leaf blocks, etc
|
if(ta.hasColor(dir)) quad.color(tint, tint, tint, tint);
|
||||||
|
|
||||||
quad.spriteBake(ta.getSprite(dir), MutableQuadView.BAKE_NORMALIZED | ta.getBakeFlags(dir) | (uvlock ? MutableQuadView.BAKE_LOCK_UV : 0));
|
quad.spriteBake(ta.getSprite(dir), MutableQuadView.BAKE_NORMALIZED | ta.getBakeFlags(dir) | (uvlock ? MutableQuadView.BAKE_LOCK_UV : 0));
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ public abstract class RetexturingBakedModel extends ForwardingBakedModel {
|
|||||||
if(tag == 0) return true;
|
if(tag == 0) return true;
|
||||||
|
|
||||||
Direction dir = facePermutation.get(DIRECTIONS[quad.tag() - 1]);
|
Direction dir = facePermutation.get(DIRECTIONS[quad.tag() - 1]);
|
||||||
if(ta.hasColor(dir)) quad.color(tint, tint, tint, tint); //TODO: still doesn't cover stuff like grass blocks, leaf blocks, etc
|
if(ta.hasColor(dir)) quad.color(tint, tint, tint, tint);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user