From ffd76ecad83a2b4325289730e4ded2fcf10b882c Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Fri, 2 Oct 2020 17:17:04 +0300 Subject: [PATCH] Path blocks --- .../java/ru/betterend/blocks/BlockPath.java | 50 +++++++++++++++ .../java/ru/betterend/blocks/BlockSounds.java | 13 ++++ .../ru/betterend/blocks/BlockTerrain.java | 57 +++++++++++++++--- .../ru/betterend/registry/BlockRegistry.java | 5 ++ .../betterend/blockstates/end_moss_path.json | 10 +++ .../blockstates/end_mycelium_path.json | 10 +++ .../assets/betterend/lang/en_us.json | 4 ++ .../assets/betterend/lang/ru_ru.json | 4 ++ .../betterend/models/block/end_moss_path.json | 7 +++ .../models/block/end_mycelium_path.json | 7 +++ .../assets/betterend/models/block/path.json | 18 ++++++ .../betterend/models/item/end_moss_path.json | 3 + .../models/item/end_mycelium_path.json | 3 + .../textures/block/end_moss_path_top.png | Bin 0 -> 2379 bytes .../textures/block/end_mycelium_path_top.png | Bin 0 -> 2056 bytes 15 files changed, 183 insertions(+), 8 deletions(-) create mode 100644 src/main/java/ru/betterend/blocks/BlockPath.java create mode 100644 src/main/java/ru/betterend/blocks/BlockSounds.java create mode 100644 src/main/resources/assets/betterend/blockstates/end_moss_path.json create mode 100644 src/main/resources/assets/betterend/blockstates/end_mycelium_path.json create mode 100644 src/main/resources/assets/betterend/models/block/end_moss_path.json create mode 100644 src/main/resources/assets/betterend/models/block/end_mycelium_path.json create mode 100644 src/main/resources/assets/betterend/models/block/path.json create mode 100644 src/main/resources/assets/betterend/models/item/end_moss_path.json create mode 100644 src/main/resources/assets/betterend/models/item/end_mycelium_path.json create mode 100644 src/main/resources/assets/betterend/textures/block/end_moss_path_top.png create mode 100644 src/main/resources/assets/betterend/textures/block/end_mycelium_path_top.png diff --git a/src/main/java/ru/betterend/blocks/BlockPath.java b/src/main/java/ru/betterend/blocks/BlockPath.java new file mode 100644 index 00000000..f6f99453 --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockPath.java @@ -0,0 +1,50 @@ +package ru.betterend.blocks; + +import java.util.Collections; +import java.util.List; + +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.ShapeContext; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.loot.context.LootContextParameters; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.shape.VoxelShape; +import net.minecraft.world.BlockView; +import ru.betterend.blocks.basis.BlockBaseNotFull; + +public class BlockPath extends BlockBaseNotFull { + private static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 15, 16); + + public BlockPath(Block source) { + super(FabricBlockSettings.copyOf(source).allowsSpawning((state, world, pos, type) -> { return false; })); + if (source instanceof BlockTerrain) { + BlockTerrain terrain = (BlockTerrain) source; + terrain.setPathBlock(this); + } + } + + @Override + public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.get(LootContextParameters.TOOL); + if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + return Collections.singletonList(new ItemStack(this)); + } + return Collections.singletonList(new ItemStack(Blocks.END_STONE)); + } + + @Override + public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + return SHAPE; + } + + @Override + public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) { + return SHAPE; + } +} diff --git a/src/main/java/ru/betterend/blocks/BlockSounds.java b/src/main/java/ru/betterend/blocks/BlockSounds.java new file mode 100644 index 00000000..cf39c972 --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockSounds.java @@ -0,0 +1,13 @@ +package ru.betterend.blocks; + +import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.sound.SoundEvents; + +public class BlockSounds { + public static final BlockSoundGroup TERRAIN_SOUND = new BlockSoundGroup(1.0F, 1.0F, + SoundEvents.BLOCK_STONE_BREAK, + SoundEvents.BLOCK_WART_BLOCK_STEP, + SoundEvents.BLOCK_STONE_PLACE, + SoundEvents.BLOCK_STONE_HIT, + SoundEvents.BLOCK_STONE_FALL); +} diff --git a/src/main/java/ru/betterend/blocks/BlockTerrain.java b/src/main/java/ru/betterend/blocks/BlockTerrain.java index 454b92a9..d8336784 100644 --- a/src/main/java/ru/betterend/blocks/BlockTerrain.java +++ b/src/main/java/ru/betterend/blocks/BlockTerrain.java @@ -1,21 +1,62 @@ package ru.betterend.blocks; +import java.util.Collections; +import java.util.List; + import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.MaterialColor; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.loot.context.LootContextParameters; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +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.world.World; import ru.betterend.blocks.basis.BlockBase; public class BlockTerrain extends BlockBase { - public static final BlockSoundGroup TERRAIN_SOUND = new BlockSoundGroup(1.0F, 1.0F, - SoundEvents.BLOCK_STONE_BREAK, - SoundEvents.BLOCK_WART_BLOCK_STEP, - SoundEvents.BLOCK_STONE_PLACE, - SoundEvents.BLOCK_STONE_HIT, - SoundEvents.BLOCK_STONE_FALL); + private Block pathBlock; public BlockTerrain(MaterialColor color) { - super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(TERRAIN_SOUND)); + super(FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color).sounds(BlockSounds.TERRAIN_SOUND)); + } + + public void setPathBlock(Block roadBlock) { + this.pathBlock = roadBlock; + } + + @Override + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (pathBlock != null && player.getMainHandStack().getItem().isIn(FabricToolTags.SHOVELS)) { + world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); + if (!world.isClient) { + world.setBlockState(pos, pathBlock.getDefaultState()); + if (player != null && !player.isCreative()) { + player.getMainHandStack().damage(1, world.random, (ServerPlayerEntity) player); + } + } + return ActionResult.SUCCESS; + } + return ActionResult.FAIL; + } + + @Override + public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + ItemStack tool = builder.get(LootContextParameters.TOOL); + if (tool != null && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) { + return Collections.singletonList(new ItemStack(this)); + } + return Collections.singletonList(new ItemStack(Blocks.END_STONE)); } } diff --git a/src/main/java/ru/betterend/registry/BlockRegistry.java b/src/main/java/ru/betterend/registry/BlockRegistry.java index d5a51e63..b1a8c362 100644 --- a/src/main/java/ru/betterend/registry/BlockRegistry.java +++ b/src/main/java/ru/betterend/registry/BlockRegistry.java @@ -14,6 +14,7 @@ import ru.betterend.blocks.BlockMossyGlowshroomFur; import ru.betterend.blocks.BlockMossyGlowshroomHymenophore; import ru.betterend.blocks.BlockMossyGlowshroomSapling; import ru.betterend.blocks.BlockOre; +import ru.betterend.blocks.BlockPath; import ru.betterend.blocks.BlockTerrain; import ru.betterend.blocks.BlockUmbrellaMoss; import ru.betterend.blocks.BlockUmbrellaMossTall; @@ -29,6 +30,10 @@ public class BlockRegistry { public static final Block END_MYCELIUM = registerBlock("end_mycelium", new BlockTerrain(MaterialColor.LIGHT_BLUE)); public static final Block END_MOSS = registerBlock("end_moss", new BlockTerrain(MaterialColor.CYAN)); + // Roads // + public static final Block END_MYCELIUM_PATH = registerBlock("end_mycelium_path", new BlockPath(END_MYCELIUM)); + public static final Block END_MOSS_PATH = registerBlock("end_moss_path", new BlockPath(END_MOSS)); + // Wooden Materials // public static final Block MOSSY_GLOWSHROOM_SAPLING = registerBlock("mossy_glowshroom_sapling", new BlockMossyGlowshroomSapling()); public static final Block MOSSY_GLOWSHROOM_CAP = registerBlock("mossy_glowshroom_cap", new BlockMossyGlowshroomCap()); diff --git a/src/main/resources/assets/betterend/blockstates/end_moss_path.json b/src/main/resources/assets/betterend/blockstates/end_moss_path.json new file mode 100644 index 00000000..336a778d --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/end_moss_path.json @@ -0,0 +1,10 @@ +{ + "variants": { + "": [ + { "model": "betterend:block/end_moss_path" }, + { "model": "betterend:block/end_moss_path", "y": 90 }, + { "model": "betterend:block/end_moss_path", "y": 180 }, + { "model": "betterend:block/end_moss_path", "y": 270 } + ] + } +} diff --git a/src/main/resources/assets/betterend/blockstates/end_mycelium_path.json b/src/main/resources/assets/betterend/blockstates/end_mycelium_path.json new file mode 100644 index 00000000..22db9d60 --- /dev/null +++ b/src/main/resources/assets/betterend/blockstates/end_mycelium_path.json @@ -0,0 +1,10 @@ +{ + "variants": { + "": [ + { "model": "betterend:block/end_mycelium_path" }, + { "model": "betterend:block/end_mycelium_path", "y": 90 }, + { "model": "betterend:block/end_mycelium_path", "y": 180 }, + { "model": "betterend:block/end_mycelium_path", "y": 270 } + ] + } +} diff --git a/src/main/resources/assets/betterend/lang/en_us.json b/src/main/resources/assets/betterend/lang/en_us.json index 3f3cd060..e31fe395 100644 --- a/src/main/resources/assets/betterend/lang/en_us.json +++ b/src/main/resources/assets/betterend/lang/en_us.json @@ -4,6 +4,10 @@ "block.betterend.end_mycelium": "End Mycelium", "block.betterend.end_moss": "End Moss", "block.betterend.endstone_dust": "End Stone Dust", + + "block.betterend.end_mycelium_path": "End Mycelium Path", + "block.betterend.end_moss_path": "End Moss Path", + "block.betterend.ender_ore": "Ender Ore", "block.betterend.terminite_block": "Terminite Block", "block.betterend.aeternium_block": "Aeternium Block", diff --git a/src/main/resources/assets/betterend/lang/ru_ru.json b/src/main/resources/assets/betterend/lang/ru_ru.json index 7e7eb115..87cd036a 100644 --- a/src/main/resources/assets/betterend/lang/ru_ru.json +++ b/src/main/resources/assets/betterend/lang/ru_ru.json @@ -4,6 +4,10 @@ "block.betterend.end_mycelium": "Мицелий края", "block.betterend.end_moss": "Мох края", "block.betterend.endstone_dust": "Эндерняковая пыль", + + "block.betterend.end_mycelium_path": "Дорога из мицелия края", + "block.betterend.end_moss_path": "Дорога из мха края", + "block.betterend.ender_ore": "Руда Края", "block.betterend.terminite_block": "Блок Терминита", "block.betterend.aeternium_block": "Блок Этерия", diff --git a/src/main/resources/assets/betterend/models/block/end_moss_path.json b/src/main/resources/assets/betterend/models/block/end_moss_path.json new file mode 100644 index 00000000..f449acb8 --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/end_moss_path.json @@ -0,0 +1,7 @@ +{ "parent": "betterend:block/path", + "textures": { + "top": "betterend:block/end_moss_path_top", + "side": "betterend:block/end_moss_side", + "bottom": "block/end_stone" + } +} diff --git a/src/main/resources/assets/betterend/models/block/end_mycelium_path.json b/src/main/resources/assets/betterend/models/block/end_mycelium_path.json new file mode 100644 index 00000000..68bc5ea4 --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/end_mycelium_path.json @@ -0,0 +1,7 @@ +{ "parent": "betterend:block/path", + "textures": { + "top": "betterend:block/end_mycelium_path_top", + "side": "betterend:block/end_mycelium_side", + "bottom": "block/end_stone" + } +} diff --git a/src/main/resources/assets/betterend/models/block/path.json b/src/main/resources/assets/betterend/models/block/path.json new file mode 100644 index 00000000..54cbb2a5 --- /dev/null +++ b/src/main/resources/assets/betterend/models/block/path.json @@ -0,0 +1,18 @@ +{ "parent": "block/block", + "textures": { + "particle": "#side" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 15, 16 ], + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" }, + "north": { "uv": [ 0, 1, 16, 16 ], "texture": "#side", "cullface": "north" }, + "south": { "uv": [ 0, 1, 16, 16 ], "texture": "#side", "cullface": "south" }, + "west": { "uv": [ 0, 1, 16, 16 ], "texture": "#side", "cullface": "west" }, + "east": { "uv": [ 0, 1, 16, 16 ], "texture": "#side", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/betterend/models/item/end_moss_path.json b/src/main/resources/assets/betterend/models/item/end_moss_path.json new file mode 100644 index 00000000..7d7de48a --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/end_moss_path.json @@ -0,0 +1,3 @@ +{ + "parent": "betterend:block/end_moss_path" +} diff --git a/src/main/resources/assets/betterend/models/item/end_mycelium_path.json b/src/main/resources/assets/betterend/models/item/end_mycelium_path.json new file mode 100644 index 00000000..44e814c3 --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/end_mycelium_path.json @@ -0,0 +1,3 @@ +{ + "parent": "betterend:block/end_mycelium_path" +} diff --git a/src/main/resources/assets/betterend/textures/block/end_moss_path_top.png b/src/main/resources/assets/betterend/textures/block/end_moss_path_top.png new file mode 100644 index 0000000000000000000000000000000000000000..a4bc588fad9e539522be16fa4f0103d0bf4c6db6 GIT binary patch literal 2379 zcmb_e3vdi)9KT@5QEIA;s>fQ7(%ReC?L9U*X)c#aa1n7v&|+`*y9al-XLplayk@8x zG2-3OU`*mM8Z#cvcuh)Fje1Olric))v<*5bEg6r{_S?(l8cG?{o7vmlZ-3wa|NH&_ zzx}?=OHUitv3-yB8jYr7YKkobo;#~YY%BP`Y`Mn(PugJ0cv++A&_z9BG==NBYcy?( zypBvI(>{{rMZb;{L?_UN{6UD;XyOw>L5`mW6vPSK-hc(YT~>}FUcrKnW9)=Im;^lD zlo=8jGb7Ex&zQ!W1vFtO5+7n=06$PTB;@x6WHw|$!*N-7tq$WT5{4+#ENG&d5XrQs zBT1qJ5JqRfcv4RxMzfAI5N1k01fdAhh!aMfq%neI2?I-;k;o5)*(AZmX4pQ8R zr-+h66n)K&N^ho&BqgbhF(HG-c>{u&BM)vd2iQ0TSWt?f2#hdeG~pmAmL^$>`GBBV zf@p%;MZxRJZ2=`AnsSgvmLyrd;VCF|jle0~OThxqxsW0Kf=>*c7h}yO$ez zMaF>Xkt?4U3EP6@c-8I}lvn!#9!vJU&5YY07n1~RSr>+%wOD6iJHtb8@m4RR zy9T_8?mHj=OC`Zwg&VlOzedw4J=K=z7__`=M!j?q={&!6jJ2Tl%`dZmNL#=6M)}w7 z-WB%xBYD{IuLgV=d*);?Va>Iw12q#L)is=DI%@kqX^{6#S~+Xz$GYWrZNC<6|F%BO z%$L4ldXJ;(=qX0wf-U9#{rn1P^0?*n=@~r^yniz9NbI4IbL}*wP2${5H>>uLZT4qA zC@DTPPtGo{o6vZ$UEdWyOP)es={q~l?<(1!u;Gi&(|bZ4zX{P0@o5(v?V0o@=di z`nMH!rY;3`W>%FP&W{;8b?3lhd7ZnWf}dGgR#TOAjBZ#ky72a#4yR^UE{tD#&gz*M zo49&F_4URjb-CqNYPV>R@jHI1-DvKu-Mo0$p9-q2TehWWDc4;Xy*SJA09Qs_-IsxC zw>o@#er#+!zk1HBHk%Li?DS2w*5fG@c3UUjsjB@wZXw(6RAI@jZNrDgUk$A+jmH)p z+|JkBd3b5JKcm~3@k+N(&BGJR#}vmFyxkouV)m{Xu=((lB}eNj;^aq1eC>E*N=$A2 jcMIDO;xaR;8=oYM9qX#sX7;?Se(t0ur`fh!r_B2s-~Urh literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/betterend/textures/block/end_mycelium_path_top.png b/src/main/resources/assets/betterend/textures/block/end_mycelium_path_top.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb7474bc94a1ad2087152910def0a91f784a4b5 GIT binary patch literal 2056 zcmbVN4Qvx-7(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