diff --git a/src/main/java/com/technovision/tutorial/blocks/Oven.java b/src/main/java/com/technovision/tutorial/blocks/Oven.java new file mode 100644 index 0000000..3b8ddb9 --- /dev/null +++ b/src/main/java/com/technovision/tutorial/blocks/Oven.java @@ -0,0 +1,118 @@ +package com.technovision.tutorial.blocks; + +import net.minecraft.block.*; +import net.minecraft.block.material.Material; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.DirectionProperty; +import net.minecraft.state.StateContainer; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.IBooleanFunction; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; +import net.minecraft.world.IBlockReader; +import net.minecraftforge.common.ToolType; + +import java.util.stream.Stream; + +public class Oven extends Block { + + private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; + + private static final VoxelShape SHAPE_N = Stream.of( + Block.makeCuboidShape(2, 1, 2, 14, 9, 14), Block.makeCuboidShape(1, 9, 1, 15, 10, 15), + Block.makeCuboidShape(3, 10, 3, 13, 11, 13), Block.makeCuboidShape(13, 2, 1, 16, 3, 2), + Block.makeCuboidShape(15, 0, 1, 16, 2, 2), Block.makeCuboidShape(13, 2, 14, 16, 3, 15), + Block.makeCuboidShape(15, 0, 14, 16, 2, 15), Block.makeCuboidShape(0, 2, 14, 3, 3, 15), + Block.makeCuboidShape(0, 0, 14, 1, 2, 15), Block.makeCuboidShape(0, 2, 1, 3, 3, 2), + Block.makeCuboidShape(0, 0, 1, 1, 2, 2), Block.makeCuboidShape(6, 11, 12, 10, 16, 13), + Block.makeCuboidShape(6, 3, 14, 10, 16, 15), Block.makeCuboidShape(6, 10, 13, 10, 16, 14), + Block.makeCuboidShape(6, 12, 15, 10, 16, 16)).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get(); + + private static final VoxelShape SHAPE_E = Stream.of( + Block.makeCuboidShape(2, 1, 2, 14, 9, 14), Block.makeCuboidShape(1, 9, 1, 15, 10, 15), + Block.makeCuboidShape(3, 10, 3, 13, 11, 13), Block.makeCuboidShape(14, 2, 13, 15, 3, 16), + Block.makeCuboidShape(14, 0, 15, 15, 2, 16), Block.makeCuboidShape(1, 2, 13, 2, 3, 16), + Block.makeCuboidShape(1, 0, 15, 2, 2, 16), Block.makeCuboidShape(1, 2, 0, 2, 3, 3), + Block.makeCuboidShape(1, 0, 0, 2, 2, 1), Block.makeCuboidShape(14, 2, 0, 15, 3, 3), + Block.makeCuboidShape(14, 0, 0, 15, 2, 1), Block.makeCuboidShape(3, 11, 6, 4, 16, 10), + Block.makeCuboidShape(1, 3, 6, 2, 16, 10), Block.makeCuboidShape(2, 10, 6, 3, 16, 10), + Block.makeCuboidShape(0, 12, 6, 1, 16, 10)).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get(); + + private static final VoxelShape SHAPE_S = Stream.of( + Block.makeCuboidShape(2, 1, 2, 14, 9, 14), Block.makeCuboidShape(1, 9, 1, 15, 10, 15), + Block.makeCuboidShape(3, 10, 3, 13, 11, 13), Block.makeCuboidShape(0, 2, 14, 3, 3, 15), + Block.makeCuboidShape(0, 0, 14, 1, 2, 15), Block.makeCuboidShape(0, 2, 1, 3, 3, 2), + Block.makeCuboidShape(0, 0, 1, 1, 2, 2), Block.makeCuboidShape(13, 2, 1, 16, 3, 2), + Block.makeCuboidShape(15, 0, 1, 16, 2, 2), Block.makeCuboidShape(13, 2, 14, 16, 3, 15), + Block.makeCuboidShape(15, 0, 14, 16, 2, 15), Block.makeCuboidShape(6, 11, 3, 10, 16, 4), + Block.makeCuboidShape(6, 3, 1, 10, 16, 2), Block.makeCuboidShape(6, 10, 2, 10, 16, 3), + Block.makeCuboidShape(6, 12, 0, 10, 16, 1)).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get(); + + private static final VoxelShape SHAPE_W = Stream.of( + Block.makeCuboidShape(2, 1, 2, 14, 9, 14), Block.makeCuboidShape(1, 9, 1, 15, 10, 15), + Block.makeCuboidShape(3, 10, 3, 13, 11, 13), Block.makeCuboidShape(1, 2, 0, 2, 3, 3), + Block.makeCuboidShape(1, 0, 0, 2, 2, 1), Block.makeCuboidShape(14, 2, 0, 15, 3, 3), + Block.makeCuboidShape(14, 0, 0, 15, 2, 1), Block.makeCuboidShape(14, 2, 13, 15, 3, 16), + Block.makeCuboidShape(14, 0, 15, 15, 2, 16), Block.makeCuboidShape(1, 2, 13, 2, 3, 16), + Block.makeCuboidShape(1, 0, 15, 2, 2, 16), Block.makeCuboidShape(12, 11, 6, 13, 16, 10), + Block.makeCuboidShape(14, 3, 6, 15, 16, 10), Block.makeCuboidShape(13, 10, 6, 14, 16, 10), + Block.makeCuboidShape(15, 12, 6, 16, 16, 10)).reduce((v1, v2) -> { + return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get(); + + public Oven() { + super(Block.Properties.create(Material.IRON) + .hardnessAndResistance(3.5F, 4.0F) + .sound(SoundType.ANVIL) + .harvestLevel(0) + .harvestTool(ToolType.PICKAXE) + .setRequiresTool()); + } + + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + switch (state.get(FACING)) { + case NORTH: + return SHAPE_N; + case SOUTH: + return SHAPE_S; + case EAST: + return SHAPE_E; + case WEST: + return SHAPE_W; + default: + return SHAPE_N; + } + } + + @Override + public BlockState rotate(BlockState state, Rotation rot) { + return state.with(FACING, rot.rotate(state.get(FACING))); + } + + @Override + public BlockState mirror(BlockState state, Mirror mirrorIn) { + return state.rotate(mirrorIn.toRotation(state.get(FACING))); + } + + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(FACING); + } + + /**Change the block shadow -- Lower return values = more shadow*/ + @Override + public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) { + return 0.6F; + } +} diff --git a/src/main/java/com/technovision/tutorial/blocks/RubyBlock.java b/src/main/java/com/technovision/tutorial/blocks/RubyBlock.java index d02ccd2..ee20e85 100644 --- a/src/main/java/com/technovision/tutorial/blocks/RubyBlock.java +++ b/src/main/java/com/technovision/tutorial/blocks/RubyBlock.java @@ -11,6 +11,7 @@ public class RubyBlock extends Block { .hardnessAndResistance(5.0f, 6.0f) .sound(SoundType.METAL) .harvestLevel(2) - .harvestTool(ToolType.PICKAXE)); + .harvestTool(ToolType.PICKAXE) + .setRequiresTool()); } } diff --git a/src/main/java/com/technovision/tutorial/blocks/RubyOre.java b/src/main/java/com/technovision/tutorial/blocks/RubyOre.java index 151745e..40c692b 100644 --- a/src/main/java/com/technovision/tutorial/blocks/RubyOre.java +++ b/src/main/java/com/technovision/tutorial/blocks/RubyOre.java @@ -16,7 +16,8 @@ public class RubyOre extends OreBlock { .hardnessAndResistance(3.0f, 4.0f) .sound(SoundType.STONE) .harvestLevel(2) - .harvestTool(ToolType.PICKAXE)); + .harvestTool(ToolType.PICKAXE) + .setRequiresTool()); } @Override diff --git a/src/main/java/com/technovision/tutorial/util/RegistryHandler.java b/src/main/java/com/technovision/tutorial/util/RegistryHandler.java index d2ea2d2..1925465 100644 --- a/src/main/java/com/technovision/tutorial/util/RegistryHandler.java +++ b/src/main/java/com/technovision/tutorial/util/RegistryHandler.java @@ -2,6 +2,7 @@ package com.technovision.tutorial.util; import com.technovision.tutorial.Tutorial; import com.technovision.tutorial.armor.ModArmorMaterial; +import com.technovision.tutorial.blocks.Oven; import com.technovision.tutorial.blocks.RubyBlock; import com.technovision.tutorial.blocks.RubyOre; import com.technovision.tutorial.items.PoisonApple; @@ -53,8 +54,10 @@ public class RegistryHandler { // Blocks public static final RegistryObject RUBY_BLOCK = BLOCKS.register("ruby_block", RubyBlock::new); public static final RegistryObject RUBY_ORE = BLOCKS.register("ruby_ore", RubyOre::new); + public static final RegistryObject OVEN = BLOCKS.register("oven", Oven::new); // Block Items public static final RegistryObject RUBY_BLOCK_ITEM = ITEMS.register("ruby_block", () -> new BlockItem(RUBY_BLOCK.get(), new Item.Properties().group(Tutorial.TAB))); public static final RegistryObject RUBY_ORE_ITEM = ITEMS.register("ruby_ore", () -> new BlockItem(RUBY_ORE.get(), new Item.Properties().group(Tutorial.TAB))); + public static final RegistryObject OVEN_ITEM = ITEMS.register("oven", () -> new BlockItem(OVEN.get(), new Item.Properties().group(Tutorial.TAB))); } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 9c724b0..a18da59 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -8,7 +8,7 @@ issueTrackerURL="http://my.issue.tracker/" #optional modId="tutorial" #mandatory -version="1.15.2-1.0.0" #mandatory +version="1.16.1-1.0.0" #mandatory displayName="Tutorial Mod" #mandatory @@ -16,7 +16,7 @@ updateJSONURL="http://myurl.me/" #optional displayURL="http://example.com/" #optional -logoFile="examplemod.png" #optional +logoFile="logo.png" #optional credits="Thanks to my incredible subscribers!" #optional diff --git a/src/main/resources/assets/tutorial/blockstates/oven.json b/src/main/resources/assets/tutorial/blockstates/oven.json new file mode 100644 index 0000000..5e1d07d --- /dev/null +++ b/src/main/resources/assets/tutorial/blockstates/oven.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "tutorial:block/oven" }, + "facing=south": { "model": "tutorial:block/oven", "y": 180}, + "facing=west": { "model": "tutorial:block/oven", "y": 270}, + "facing=east": { "model": "tutorial:block/oven", "y": 90} + } +} diff --git a/src/main/resources/assets/tutorial/lang/en_us.json b/src/main/resources/assets/tutorial/lang/en_us.json index e67ea43..5b68be7 100644 --- a/src/main/resources/assets/tutorial/lang/en_us.json +++ b/src/main/resources/assets/tutorial/lang/en_us.json @@ -3,6 +3,7 @@ "item.tutorial.poison_apple": "Poison Apple", "block.tutorial.ruby_block": "Block of Ruby", "block.tutorial.ruby_ore": "Ruby Ore", + "block.tutorial.oven": "Oven", "itemGroup.tutorialTab": "Tutorial", "item.tutorial.ruby_sword": "Ruby Sword", "item.tutorial.ruby_pickaxe": "Ruby Pickaxe", diff --git a/src/main/resources/assets/tutorial/models/block/oven.json b/src/main/resources/assets/tutorial/models/block/oven.json new file mode 100644 index 0000000..0b9cf48 --- /dev/null +++ b/src/main/resources/assets/tutorial/models/block/oven.json @@ -0,0 +1,255 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "tutorial:blocks/oven", + "particle": "tutorial:blocks/oven" + }, + "elements": [ + { + "from": [0, 2, 1], + "to": [3, 3, 2], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "texture": "#0"} + } + }, + { + "from": [0, 0, 1], + "to": [1, 2, 2], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "texture": "#0"} + } + }, + { + "from": [0, 2, 14], + "to": [3, 3, 15], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "texture": "#0"} + } + }, + { + "from": [0, 0, 14], + "to": [1, 2, 15], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "texture": "#0"} + } + }, + { + "from": [13, 2, 14], + "to": [16, 3, 15], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15, 0, 14], + "to": [16, 2, 15], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 2, 1], + "to": [16, 3, 2], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15, 0, 1], + "to": [16, 2, 2], + "faces": { + "north": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "east": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "south": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "west": {"uv": [9, 4, 12, 5], "texture": "#0"}, + "up": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [9, 4, 12, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "name": "Base", + "from": [2, 1, 2], + "to": [14, 9, 14], + "faces": { + "north": {"uv": [3, 3, 6, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + }, + { + "name": "semi-top", + "from": [1, 9, 1], + "to": [15, 10, 15], + "faces": { + "north": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + }, + { + "name": "top", + "from": [3, 10, 3], + "to": [13, 11, 13], + "faces": { + "north": {"uv": [0, 3, 2, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 2, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 2, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 2, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 2, 5], "texture": "#0"} + } + }, + { + "name": "fume pipe", + "from": [6, 11, 12], + "to": [10, 16, 13], + "faces": { + "north": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + }, + { + "name": "fume pipe", + "from": [6, 3, 14], + "to": [10, 16, 15], + "faces": { + "north": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + }, + { + "name": "fume pipe", + "from": [6, 10, 13], + "to": [10, 16, 14], + "faces": { + "north": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + }, + { + "name": "fume pipe", + "from": [6, 12, 15], + "to": [10, 16, 16], + "faces": { + "north": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "east": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "south": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "west": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "up": {"uv": [0, 3, 3, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 3, 5], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [41, 0, 0], + "translation": [0, 1, 0], + "scale": [0.3, 0.3, 0.3] + }, + "thirdperson_lefthand": { + "rotation": [41, 0, 0], + "translation": [0, 1, 0], + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_righthand": { + "scale": [0.3, 0.3, 0.3] + }, + "firstperson_lefthand": { + "scale": [0.3, 0.3, 0.3] + }, + "ground": { + "translation": [0, 2.5, 0], + "scale": [0.3, 0.3, 0.3] + }, + "gui": { + "rotation": [13, 19, 0], + "scale": [0.7, 0.7, 0.7] + }, + "head": { + "translation": [0, 12.75, 0] + }, + "fixed": { + "translation": [0, 1.75, 2.75] + } + }, + "groups": [ + { + "name": "Leg1", + "origin": [8, 8, 8], + "children": [0, 1] + }, + { + "name": "leg2", + "origin": [8, 8, 8], + "children": [2, 3] + }, + { + "name": "leg3", + "origin": [8, 8, 8], + "children": [4, 5] + }, + { + "name": "leg 4", + "origin": [8, 8, 8], + "children": [6, 7] + }, 8, 9, 10, + { + "name": "group", + "origin": [8, 8, 8], + "children": [11, 12, 13, 14] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/models/item/oven.json b/src/main/resources/assets/tutorial/models/item/oven.json new file mode 100644 index 0000000..5b69a98 --- /dev/null +++ b/src/main/resources/assets/tutorial/models/item/oven.json @@ -0,0 +1,3 @@ +{ + "parent": "tutorial:block/oven" +} \ No newline at end of file diff --git a/src/main/resources/assets/tutorial/textures/blocks/oven.png b/src/main/resources/assets/tutorial/textures/blocks/oven.png new file mode 100644 index 0000000..ee0c435 Binary files /dev/null and b/src/main/resources/assets/tutorial/textures/blocks/oven.png differ diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png new file mode 100644 index 0000000..e5b82a2 Binary files /dev/null and b/src/main/resources/logo.png differ