diff --git a/src/main/java/io/github/cottonmc/templates/Templates.java b/src/main/java/io/github/cottonmc/templates/Templates.java index ee4c46d..933bd4a 100644 --- a/src/main/java/io/github/cottonmc/templates/Templates.java +++ b/src/main/java/io/github/cottonmc/templates/Templates.java @@ -13,6 +13,7 @@ import io.github.cottonmc.templates.block.TemplatePressurePlateBlock; import io.github.cottonmc.templates.block.TemplateSlabBlock; import io.github.cottonmc.templates.block.TemplateSlopeBlock; import io.github.cottonmc.templates.block.TemplateEntity; +import io.github.cottonmc.templates.block.TemplateStairsBlock; import io.github.cottonmc.templates.block.TemplateWallBlock; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; @@ -63,7 +64,7 @@ public class Templates implements ModInitializer { 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 SLAB = reg("slab", new TemplateSlabBlock(cp(Blocks.OAK_SLAB))); - //stair + public static final Block STAIRS = reg("stairs", new TemplateStairsBlock(cp(Blocks.OAK_STAIRS))); //trapdoor public static final Block WALL = reg("wall", new TemplateWallBlock(cp(Blocks.COBBLESTONE_WALL))); diff --git a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java index 608fc3e..9ddf320 100644 --- a/src/main/java/io/github/cottonmc/templates/TemplatesClient.java +++ b/src/main/java/io/github/cottonmc/templates/TemplatesClient.java @@ -77,6 +77,9 @@ public class TemplatesClient implements ClientModInitializer { 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_top_special"), new UnbakedAutoRetexturedModel(new Identifier("block/slab_top"))); + 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("outer_stairs_special"), new UnbakedAutoRetexturedModel(new Identifier("block/outer_stairs"))); 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_tall_special"), new UnbakedAutoRetexturedModel(new Identifier("block/template_wall_side_tall"))); @@ -106,6 +109,7 @@ public class TemplatesClient implements ClientModInitializer { 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("stairs_special"), Templates.STAIRS); provider.assignItemModel(Templates.id("wall_inventory_special"), Templates.WALL); } } diff --git a/src/main/java/io/github/cottonmc/templates/block/TemplateStairsBlock.java b/src/main/java/io/github/cottonmc/templates/block/TemplateStairsBlock.java new file mode 100644 index 0000000..91541c6 --- /dev/null +++ b/src/main/java/io/github/cottonmc/templates/block/TemplateStairsBlock.java @@ -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.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.StairsBlock; +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 TemplateStairsBlock extends StairsBlock implements BlockEntityProvider { + public TemplateStairsBlock(BlockState blockState, Settings settings) { + super(blockState, settings); + } + + public TemplateStairsBlock(Settings settings) { + this(Blocks.OAK_PLANKS.getDefaultState(), settings); + } + + @Nullable + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return Templates.TEMPLATE_BLOCK_ENTITY.instantiate(pos, state); + } + + @Override + protected void appendProperties(StateManager.Builder 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); + } +} diff --git a/src/main/resources/assets/templates/blockstates/stairs.json b/src/main/resources/assets/templates/blockstates/stairs.json new file mode 100644 index 0000000..75ccd35 --- /dev/null +++ b/src/main/resources/assets/templates/blockstates/stairs.json @@ -0,0 +1,209 @@ +{ + "variants": { + "facing=east,half=bottom,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=inner_right": { + "model": "templates:inner_stairs_special" + }, + "facing=east,half=bottom,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 270 + }, + "facing=east,half=bottom,shape=outer_right": { + "model": "templates:outer_stairs_special" + }, + "facing=east,half=bottom,shape=straight": { + "model": "templates:stairs_special" + }, + "facing=east,half=top,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180 + }, + "facing=east,half=top,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=east,half=top,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "x": 180 + }, + "facing=north,half=bottom,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 180 + }, + "facing=north,half=bottom,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 270 + }, + "facing=north,half=bottom,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "y": 270 + }, + "facing=north,half=top,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=north,half=top,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180 + }, + "facing=north,half=top,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=south,half=bottom,shape=inner_left": { + "model": "templates:inner_stairs_special" + }, + "facing=south,half=bottom,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=outer_left": { + "model": "templates:outer_stairs_special" + }, + "facing=south,half=bottom,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 90 + }, + "facing=south,half=bottom,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "y": 90 + }, + "facing=south,half=top,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=south,half=top,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=south,half=top,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "x": 180, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 90 + }, + "facing=west,half=bottom,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "y": 180 + }, + "facing=west,half=bottom,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "y": 180 + }, + "facing=west,half=top,shape=inner_left": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=inner_right": { + "model": "templates:inner_stairs_special", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=outer_left": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 180 + }, + "facing=west,half=top,shape=outer_right": { + "model": "templates:outer_stairs_special", + "uvlock": true, + "x": 180, + "y": 270 + }, + "facing=west,half=top,shape=straight": { + "model": "templates:stairs_special", + "uvlock": true, + "x": 180, + "y": 180 + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/templates/lang/en_us.json b/src/main/resources/assets/templates/lang/en_us.json index ff573a4..9c769ac 100644 --- a/src/main/resources/assets/templates/lang/en_us.json +++ b/src/main/resources/assets/templates/lang/en_us.json @@ -12,5 +12,6 @@ "block.templates.pressure_plate": "Pressure Plate Template", "block.templates.slope": "Slope Template", "block.templates.slab": "Slab Template", + "block.templates.stairs": "Stairs Template", "block.templates.wall": "Wall Template" } \ No newline at end of file diff --git a/src/main/resources/data/templates/advancements/recipes/decorations/templates.json b/src/main/resources/data/templates/advancements/recipes/decorations/templates.json index 98ac140..08e483f 100644 --- a/src/main/resources/data/templates/advancements/recipes/decorations/templates.json +++ b/src/main/resources/data/templates/advancements/recipes/decorations/templates.json @@ -11,6 +11,7 @@ "templates:post", "templates:slab", "templates:slope", + "templates:stairs", "templates:wall" ] }, diff --git a/src/main/resources/data/templates/loot_tables/blocks/stairs.json b/src/main/resources/data/templates/loot_tables/blocks/stairs.json new file mode 100644 index 0000000..7528455 --- /dev/null +++ b/src/main/resources/data/templates/loot_tables/blocks/stairs.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "templates:stairs" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/templates/recipes/stairs.json b/src/main/resources/data/templates/recipes/stairs.json new file mode 100644 index 0000000..4699084 --- /dev/null +++ b/src/main/resources/data/templates/recipes/stairs.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "I~ ", + "II~", + "III" + ], + "key": { + "I": { + "item": "minecraft:bamboo" + }, + "~": { + "item": "minecraft:string" + } + }, + "result": { + "item": "templates:stairs", + "count": 10 + }, + "group": "templates" +} \ No newline at end of file