Pane and trapdoor, with weird models

This commit is contained in:
quat1024 2023-07-09 23:27:49 -04:00
parent 8acb584fd2
commit b1ba8d2ebc
14 changed files with 434 additions and 2 deletions

View File

@ -8,12 +8,14 @@ import io.github.cottonmc.templates.block.TemplateCarpetBlock;
import io.github.cottonmc.templates.block.TemplateFenceBlock; import io.github.cottonmc.templates.block.TemplateFenceBlock;
import io.github.cottonmc.templates.block.TemplateFenceGateBlock; import io.github.cottonmc.templates.block.TemplateFenceGateBlock;
import io.github.cottonmc.templates.block.TemplateLeverBlock; import io.github.cottonmc.templates.block.TemplateLeverBlock;
import io.github.cottonmc.templates.block.TemplatePaneBlock;
import io.github.cottonmc.templates.block.TemplatePostBlock; import io.github.cottonmc.templates.block.TemplatePostBlock;
import io.github.cottonmc.templates.block.TemplatePressurePlateBlock; import io.github.cottonmc.templates.block.TemplatePressurePlateBlock;
import io.github.cottonmc.templates.block.TemplateSlabBlock; import io.github.cottonmc.templates.block.TemplateSlabBlock;
import io.github.cottonmc.templates.block.TemplateSlopeBlock; import io.github.cottonmc.templates.block.TemplateSlopeBlock;
import io.github.cottonmc.templates.block.TemplateEntity; import io.github.cottonmc.templates.block.TemplateEntity;
import io.github.cottonmc.templates.block.TemplateStairsBlock; import io.github.cottonmc.templates.block.TemplateStairsBlock;
import io.github.cottonmc.templates.block.TemplateTrapdoorBlock;
import io.github.cottonmc.templates.block.TemplateWallBlock; import io.github.cottonmc.templates.block.TemplateWallBlock;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
@ -60,12 +62,12 @@ public class Templates implements ModInitializer {
public static final Block FENCE = reg("fence", new TemplateFenceBlock(cp(Blocks.OAK_FENCE))); public static final Block FENCE = reg("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 = reg("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 = reg("lever", new TemplateLeverBlock(cp(Blocks.LEVER)));
//pane public static final Block PANE = reg("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 = reg("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 = reg("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 = reg("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 = reg("stairs", new TemplateStairsBlock(cp(Blocks.OAK_STAIRS)));
//trapdoor public static final Block TRAPDOOR = reg("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 = reg("wall", new TemplateWallBlock(cp(Blocks.COBBLESTONE_WALL)));
public static final Block SLOPE = reg("slope", new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings())); public static final Block SLOPE = reg("slope", new TemplateSlopeBlock(TemplateInteractionUtil.makeSettings()));

View File

@ -73,6 +73,11 @@ public class TemplatesClient implements ClientModInitializer {
provider.addTemplateModel(Templates.id("fence_gate_open_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_open"))); provider.addTemplateModel(Templates.id("fence_gate_open_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_open")));
provider.addTemplateModel(Templates.id("fence_gate_wall_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_wall"))); provider.addTemplateModel(Templates.id("fence_gate_wall_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_wall")));
provider.addTemplateModel(Templates.id("fence_gate_wall_open_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_wall_open"))); provider.addTemplateModel(Templates.id("fence_gate_wall_open_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_fence_gate_wall_open")));
provider.addTemplateModel(Templates.id("glass_pane_post_special"), new UnbakedAutoRetexturedModel(new Identifier("block/glass_pane_post")));
provider.addTemplateModel(Templates.id("glass_pane_side_special"), new UnbakedAutoRetexturedModel(new Identifier("block/glass_pane_side")));
provider.addTemplateModel(Templates.id("glass_pane_side_alt_special"), new UnbakedAutoRetexturedModel(new Identifier("block/glass_pane_side_alt")));
provider.addTemplateModel(Templates.id("glass_pane_noside_special"), new UnbakedAutoRetexturedModel(new Identifier("block/glass_pane_noside")));
provider.addTemplateModel(Templates.id("glass_pane_noside_alt_special"), new UnbakedAutoRetexturedModel(new Identifier("block/glass_pane_noside_alt")));
provider.addTemplateModel(Templates.id("pressure_plate_up_special"), new UnbakedAutoRetexturedModel(new Identifier("block/pressure_plate_up"))); provider.addTemplateModel(Templates.id("pressure_plate_up_special"), new UnbakedAutoRetexturedModel(new Identifier("block/pressure_plate_up")));
provider.addTemplateModel(Templates.id("pressure_plate_down_special"), new UnbakedAutoRetexturedModel(new Identifier("block/pressure_plate_down"))); provider.addTemplateModel(Templates.id("pressure_plate_down_special"), new UnbakedAutoRetexturedModel(new Identifier("block/pressure_plate_down")));
provider.addTemplateModel(Templates.id("slab_bottom_special"), new UnbakedAutoRetexturedModel(new Identifier("block/slab"))); provider.addTemplateModel(Templates.id("slab_bottom_special"), new UnbakedAutoRetexturedModel(new Identifier("block/slab")));
@ -80,6 +85,9 @@ public class TemplatesClient implements ClientModInitializer {
provider.addTemplateModel(Templates.id("stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/stairs"))); provider.addTemplateModel(Templates.id("stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/stairs")));
provider.addTemplateModel(Templates.id("inner_stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/inner_stairs"))); provider.addTemplateModel(Templates.id("inner_stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/inner_stairs")));
provider.addTemplateModel(Templates.id("outer_stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/outer_stairs"))); provider.addTemplateModel(Templates.id("outer_stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/outer_stairs")));
provider.addTemplateModel(Templates.id("trapdoor_bottom_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_trapdoor_bottom")));
provider.addTemplateModel(Templates.id("trapdoor_open_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_trapdoor_open")));
provider.addTemplateModel(Templates.id("trapdoor_top_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_trapdoor_top")));
provider.addTemplateModel(Templates.id("wall_post_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_post"))); provider.addTemplateModel(Templates.id("wall_post_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_post")));
provider.addTemplateModel(Templates.id("wall_side_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_side"))); provider.addTemplateModel(Templates.id("wall_side_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_side")));
provider.addTemplateModel(Templates.id("wall_side_tall_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_side_tall"))); provider.addTemplateModel(Templates.id("wall_side_tall_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_side_tall")));
@ -106,11 +114,13 @@ public class TemplatesClient implements ClientModInitializer {
provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE); provider.assignItemModel(Templates.id("fence_inventory_special"), Templates.FENCE);
provider.assignItemModel(Templates.id("fence_gate_special"), Templates.FENCE_GATE); provider.assignItemModel(Templates.id("fence_gate_special"), Templates.FENCE_GATE);
provider.assignItemModel(Templates.id("lever_special"), Templates.LEVER); //TODO vanilla uses its own item model provider.assignItemModel(Templates.id("lever_special"), Templates.LEVER); //TODO vanilla uses its own item model
//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("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("wall_inventory_special"), Templates.WALL); provider.assignItemModel(Templates.id("wall_inventory_special"), Templates.WALL);
} }
} }

View File

@ -0,0 +1,80 @@
package io.github.cottonmc.templates.block;
import com.google.common.base.MoreObjects;
import io.github.cottonmc.templates.Templates;
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.PaneBlock;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class TemplatePaneBlock extends PaneBlock implements BlockEntityProvider {
public TemplatePaneBlock(Settings settings) {
super(settings);
setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState()));
}
@Override
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(TemplateInteractionUtil.appendProperties(builder));
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved);
super.onStateReplaced(state, world, pos, newState, moved);
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack);
super.onPlaced(world, pos, state, placer, stack);
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state, view, pos, ctx), super.getCollisionShape(state, view, pos, ctx));
}
@Override
public boolean emitsRedstonePower(BlockState state) {
return TemplateInteractionUtil.emitsRedstonePower(state);
}
@Override
public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir);
}
@Override
public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir);
}
}

View File

@ -0,0 +1,85 @@
package io.github.cottonmc.templates.block;
import com.google.common.base.MoreObjects;
import io.github.cottonmc.templates.Templates;
import io.github.cottonmc.templates.api.TemplateInteractionUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockSetType;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class TemplateTrapdoorBlock extends TrapdoorBlock implements BlockEntityProvider {
public TemplateTrapdoorBlock(Settings settings, BlockSetType blah) {
super(settings, blah);
setDefaultState(TemplateInteractionUtil.setDefaultStates(getDefaultState()));
}
public TemplateTrapdoorBlock(Settings settings) {
this(settings, BlockSetType.OAK);
}
@Override
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(TemplateInteractionUtil.appendProperties(builder));
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ActionResult r = TemplateInteractionUtil.onUse(state, world, pos, player, hand, hit);
if(!r.isAccepted()) r = super.onUse(state, world, pos, player, hand, hit);
return r;
}
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
TemplateInteractionUtil.onStateReplaced(state, world, pos, newState, moved);
super.onStateReplaced(state, world, pos, newState, moved);
}
@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
TemplateInteractionUtil.onPlaced(world, pos, state, placer, stack);
super.onPlaced(world, pos, state, placer, stack);
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ctx) {
return MoreObjects.firstNonNull(TemplateInteractionUtil.getCollisionShape(state, view, pos, ctx), super.getCollisionShape(state, view, pos, ctx));
}
@Override
public boolean emitsRedstonePower(BlockState state) {
return TemplateInteractionUtil.emitsRedstonePower(state);
}
@Override
public int getWeakRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
return TemplateInteractionUtil.getWeakRedstonePower(state, view, pos, dir);
}
@Override
public int getStrongRedstonePower(BlockState state, BlockView view, BlockPos pos, Direction dir) {
return TemplateInteractionUtil.getStrongRedstonePower(state, view, pos, dir);
}
}

View File

@ -0,0 +1,77 @@
{
"multipart": [
{
"apply": {
"model": "templates:glass_pane_post_special"
}
},
{
"apply": {
"model": "templates:glass_pane_side_special"
},
"when": {
"north": "true"
}
},
{
"apply": {
"model": "templates:glass_pane_side_special",
"y": 90
},
"when": {
"east": "true"
}
},
{
"apply": {
"model": "templates:glass_pane_side_alt_special"
},
"when": {
"south": "true"
}
},
{
"apply": {
"model": "templates:glass_pane_side_alt_special",
"y": 90
},
"when": {
"west": "true"
}
},
{
"apply": {
"model": "templates:glass_pane_noside_special"
},
"when": {
"north": "false"
}
},
{
"apply": {
"model": "templates:glass_pane_noside_alt_special"
},
"when": {
"east": "false"
}
},
{
"apply": {
"model": "templates:glass_pane_noside_alt_special",
"y": 90
},
"when": {
"south": "false"
}
},
{
"apply": {
"model": "templates:glass_pane_noside_special",
"y": 270
},
"when": {
"west": "false"
}
}
]
}

View File

@ -0,0 +1,69 @@
{
"variants": {
"facing=east,half=bottom,open=false": {
"model": "templates:trapdoor_bottom_special",
"y": 90
},
"facing=east,half=bottom,open=true": {
"model": "templates:trapdoor_open_special",
"y": 90
},
"facing=east,half=top,open=false": {
"model": "templates:trapdoor_top_special",
"y": 90
},
"facing=east,half=top,open=true": {
"model": "templates:trapdoor_open_special",
"x": 180,
"y": 270
},
"facing=north,half=bottom,open=false": {
"model": "templates:trapdoor_bottom_special"
},
"facing=north,half=bottom,open=true": {
"model": "templates:trapdoor_open_special"
},
"facing=north,half=top,open=false": {
"model": "templates:trapdoor_top_special"
},
"facing=north,half=top,open=true": {
"model": "templates:trapdoor_open_special",
"x": 180,
"y": 180
},
"facing=south,half=bottom,open=false": {
"model": "templates:trapdoor_bottom_special",
"y": 180
},
"facing=south,half=bottom,open=true": {
"model": "templates:trapdoor_open_special",
"y": 180
},
"facing=south,half=top,open=false": {
"model": "templates:trapdoor_top_special",
"y": 180
},
"facing=south,half=top,open=true": {
"model": "templates:trapdoor_open_special",
"x": 180,
"y": 0
},
"facing=west,half=bottom,open=false": {
"model": "templates:trapdoor_bottom_special",
"y": 270
},
"facing=west,half=bottom,open=true": {
"model": "templates:trapdoor_open_special",
"y": 270
},
"facing=west,half=top,open=false": {
"model": "templates:trapdoor_top_special",
"y": 270
},
"facing=west,half=top,open=true": {
"model": "templates:trapdoor_open_special",
"x": 180,
"y": 90
}
}
}

View File

@ -8,10 +8,12 @@
"block.templates.fence": "Fence Template", "block.templates.fence": "Fence Template",
"block.templates.fence_gate": "Fence Gate Template", "block.templates.fence_gate": "Fence Gate Template",
"block.templates.lever": "Lever Template", "block.templates.lever": "Lever Template",
"block.templates.pane": "Pane Template",
"block.templates.post": "Post Template", "block.templates.post": "Post Template",
"block.templates.pressure_plate": "Pressure Plate Template", "block.templates.pressure_plate": "Pressure Plate Template",
"block.templates.slope": "Slope Template", "block.templates.slope": "Slope Template",
"block.templates.slab": "Slab Template", "block.templates.slab": "Slab Template",
"block.templates.stairs": "Stairs Template", "block.templates.stairs": "Stairs Template",
"block.templates.trapdoor": "Trapdoor Template",
"block.templates.wall": "Wall Template" "block.templates.wall": "Wall Template"
} }

View File

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "minecraft:block/scaffolding_top"
}
}

View File

@ -8,10 +8,12 @@
"templates:cube", "templates:cube",
"templates:fence", "templates:fence",
"templates:fence_gate", "templates:fence_gate",
"templates:pane",
"templates:post", "templates:post",
"templates:slab", "templates:slab",
"templates:slope", "templates:slope",
"templates:stairs", "templates:stairs",
"templates:trapdoor",
"templates:wall" "templates:wall"
] ]
}, },

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "templates:pane"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -6,6 +6,25 @@
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item",
"functions": [
{
"add": false,
"conditions": [
{
"block": "templates:slab",
"condition": "minecraft:block_state_property",
"properties": {
"type": "double"
}
}
],
"count": 2.0,
"function": "minecraft:set_count"
},
{
"function": "minecraft:explosion_decay"
}
],
"name": "templates:slab" "name": "templates:slab"
} }
], ],

View File

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "templates:trapdoor"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"~ ~",
"III",
"III"
],
"key": {
"I": {
"item": "minecraft:bamboo"
},
"~": {
"item": "minecraft:string"
}
},
"result": {
"item": "templates:pane",
"count": 16
},
"group": "templates"
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"III",
"III",
"~ ~"
],
"key": {
"I": {
"item": "minecraft:bamboo"
},
"~": {
"item": "minecraft:string"
}
},
"result": {
"item": "templates:trapdoor",
"count": 4
},
"group": "templates"
}