diff --git a/src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java b/src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java index 736dc4f..54e8a85 100644 --- a/src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java +++ b/src/main/java/net/kaupenjoe/tutorialmod/block/ModBlocks.java @@ -130,6 +130,10 @@ public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, () -> new ModSaplingBlock(ModTreeGrowers.BLOODWOOD, BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_SAPLING), () -> Blocks.NETHERRACK)); + public static final DeferredBlock CHAIR = registerBlock("chair", + () -> new ChairBlock(BlockBehaviour.Properties.of().noOcclusion())); + + private static DeferredBlock registerBlock(String name, Supplier block) { DeferredBlock toReturn = BLOCKS.register(name, block); registerBlockItem(name, toReturn); diff --git a/src/main/java/net/kaupenjoe/tutorialmod/block/custom/ChairBlock.java b/src/main/java/net/kaupenjoe/tutorialmod/block/custom/ChairBlock.java new file mode 100644 index 0000000..53c75ee --- /dev/null +++ b/src/main/java/net/kaupenjoe/tutorialmod/block/custom/ChairBlock.java @@ -0,0 +1,43 @@ +package net.kaupenjoe.tutorialmod.block.custom; + +import com.mojang.serialization.MapCodec; +import net.minecraft.core.BlockPos; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +public class ChairBlock extends HorizontalDirectionalBlock { + public static final MapCodec CODEC = simpleCodec(ChairBlock::new); + private static final VoxelShape SHAPE = Block.box(3.0, 0.0, 3.0, 13.0, 16.0, 13.0); + + public ChairBlock(Properties properties) { + super(properties); + } + + @Override + protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { + return SHAPE; + } + + @Override + protected MapCodec codec() { + return CODEC; + } + + @Nullable + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(FACING); + } +} diff --git a/src/main/java/net/kaupenjoe/tutorialmod/item/ModCreativeModeTabs.java b/src/main/java/net/kaupenjoe/tutorialmod/item/ModCreativeModeTabs.java index 0747a39..55a57ca 100644 --- a/src/main/java/net/kaupenjoe/tutorialmod/item/ModCreativeModeTabs.java +++ b/src/main/java/net/kaupenjoe/tutorialmod/item/ModCreativeModeTabs.java @@ -93,6 +93,8 @@ public class ModCreativeModeTabs { output.accept(ModBlocks.BLOODWOOD_LEAVES.get()); + output.accept(ModBlocks.CHAIR.get()); + }).build()); diff --git a/src/main/resources/assets/tutorialmod/blockstates/chair.json b/src/main/resources/assets/tutorialmod/blockstates/chair.json new file mode 100644 index 0000000..ad141fe --- /dev/null +++ b/src/main/resources/assets/tutorialmod/blockstates/chair.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=north": { + "model": "tutorialmod:block/chair" + }, + "facing=south": { + "model": "tutorialmod:block/chair", + "y": 180 + }, + "facing=east": { + "model": "tutorialmod:block/chair", + "y": 90 + }, + "facing=west": { + "model": "tutorialmod:block/chair", + "y": 270 + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorialmod/lang/en_us.json b/src/main/resources/assets/tutorialmod/lang/en_us.json index 38678da..9465008 100644 --- a/src/main/resources/assets/tutorialmod/lang/en_us.json +++ b/src/main/resources/assets/tutorialmod/lang/en_us.json @@ -75,6 +75,7 @@ "block.tutorialmod.bloodwood_leaves": "Bloodwood Leaves", "block.tutorialmod.bloodwood_sapling": "Bloodwood Sapling", + "block.tutorialmod.chair": "Chair", "creativetab.tutorialmod.bismuth_items": "Bismuth Items", diff --git a/src/main/resources/assets/tutorialmod/models/block/chair.json b/src/main/resources/assets/tutorialmod/models/block/chair.json new file mode 100644 index 0000000..8b91972 --- /dev/null +++ b/src/main/resources/assets/tutorialmod/models/block/chair.json @@ -0,0 +1,111 @@ +{ + "credit": "Made with Blockbench", + "texture_size": [64, 64], + "textures": { + "0": "tutorialmod:block/chair", + "particle": "tutorialmod:block/chair" + }, + "elements": [ + { + "from": [3, 0, 11], + "to": [5, 7, 13], + "faces": { + "north": {"uv": [5.5, 0.5, 6, 2.25], "texture": "#0"}, + "east": {"uv": [5.5, 2.25, 6, 4], "texture": "#0"}, + "south": {"uv": [2.5, 5.5, 3, 7.25], "texture": "#0"}, + "west": {"uv": [3, 5.5, 3.5, 7.25], "texture": "#0"}, + "up": {"uv": [6.5, 3.75, 6, 3.25], "texture": "#0"}, + "down": {"uv": [6.5, 3.75, 6, 4.25], "texture": "#0"} + } + }, + { + "from": [11, 0, 11], + "to": [13, 7, 13], + "faces": { + "north": {"uv": [3.5, 5.5, 4, 7.25], "texture": "#0"}, + "east": {"uv": [4, 5.5, 4.5, 7.25], "texture": "#0"}, + "south": {"uv": [5.5, 4, 6, 5.75], "texture": "#0"}, + "west": {"uv": [4.5, 5.5, 5, 7.25], "texture": "#0"}, + "up": {"uv": [6.5, 4.75, 6, 4.25], "texture": "#0"}, + "down": {"uv": [6.5, 4.75, 6, 5.25], "texture": "#0"} + } + }, + { + "from": [11, 0, 3], + "to": [13, 7, 5], + "faces": { + "north": {"uv": [5, 5.5, 5.5, 7.25], "texture": "#0"}, + "east": {"uv": [5.5, 5.75, 6, 7.5], "texture": "#0"}, + "south": {"uv": [0, 6, 0.5, 7.75], "texture": "#0"}, + "west": {"uv": [0.5, 6, 1, 7.75], "texture": "#0"}, + "up": {"uv": [6.5, 5.75, 6, 5.25], "texture": "#0"}, + "down": {"uv": [6.5, 5.75, 6, 6.25], "texture": "#0"} + } + }, + { + "from": [3, 0, 3], + "to": [5, 7, 5], + "faces": { + "north": {"uv": [6, 0.5, 6.5, 2.25], "texture": "#0"}, + "east": {"uv": [1, 6, 1.5, 7.75], "texture": "#0"}, + "south": {"uv": [1.5, 6, 2, 7.75], "texture": "#0"}, + "west": {"uv": [2, 6, 2.5, 7.75], "texture": "#0"}, + "up": {"uv": [6.5, 6.75, 6, 6.25], "texture": "#0"}, + "down": {"uv": [7, 0.5, 6.5, 1], "texture": "#0"} + } + }, + { + "from": [2.9, 7, 2.5], + "to": [13.1, 8, 13], + "faces": { + "north": {"uv": [6, 2.75, 8.5, 3], "texture": "#0"}, + "east": {"uv": [6, 2.25, 8.75, 2.5], "texture": "#0"}, + "south": {"uv": [6, 3, 8.5, 3.25], "texture": "#0"}, + "west": {"uv": [6, 2.5, 8.75, 2.75], "texture": "#0"}, + "up": {"uv": [2.5, 2.75, 0, 0], "texture": "#0"}, + "down": {"uv": [5, 0, 2.5, 2.75], "texture": "#0"} + } + }, + { + "from": [3, 8, 11.5], + "to": [13, 19, 13], + "faces": { + "north": {"uv": [0, 2.75, 2.5, 5.5], "texture": "#0"}, + "east": {"uv": [5, 0, 5.5, 2.75], "texture": "#0"}, + "south": {"uv": [2.5, 2.75, 5, 5.5], "texture": "#0"}, + "west": {"uv": [5, 2.75, 5.5, 5.5], "texture": "#0"}, + "up": {"uv": [2.5, 6, 0, 5.5], "texture": "#0"}, + "down": {"uv": [8, 0, 5.5, 0.5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "translation": [0, -0.75, 0], + "scale": [0.5, 0.5, 0.5] + }, + "thirdperson_lefthand": { + "translation": [0, -0.75, 0], + "scale": [0.5, 0.5, 0.5] + }, + "firstperson_righthand": { + "scale": [0.85, 0.85, 0.85] + }, + "firstperson_lefthand": { + "scale": [0.85, 0.85, 0.85] + }, + "ground": { + "scale": [0.85, 0.85, 0.85] + }, + "gui": { + "rotation": [-165, -50, -180], + "translation": [0.25, -1, 0], + "scale": [0.65, 0.65, 0.65] + }, + "fixed": { + "rotation": [-25.35, 59.42, 2.14], + "translation": [0, -1.25, 0.25], + "scale": [0.85, 0.85, 0.85] + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorialmod/models/item/chair.json b/src/main/resources/assets/tutorialmod/models/item/chair.json new file mode 100644 index 0000000..6455625 --- /dev/null +++ b/src/main/resources/assets/tutorialmod/models/item/chair.json @@ -0,0 +1,3 @@ +{ + "parent": "tutorialmod:block/chair" +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorialmod/textures/block/chair.png b/src/main/resources/assets/tutorialmod/textures/block/chair.png new file mode 100644 index 0000000..21a3c78 Binary files /dev/null and b/src/main/resources/assets/tutorialmod/textures/block/chair.png differ