From 43c8976298583ae93a2d9142da26bcd02cb4f38d Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 28 Feb 2023 14:00:57 +0100 Subject: [PATCH] added depth axe ability --- .../naturesaura/models/item/depth_axe.json | 6 ----- .../java/de/ellpeck/naturesaura/Helper.java | 21 ++++++++++-------- .../blocks/tiles/BlockEntityWoodStand.java | 6 +---- .../naturesaura/items/tools/ItemAxe.java | 10 ++++----- .../naturesaura/items/tools/ItemShovel.java | 3 ++- .../naturesaura/proxy/ClientProxy.java | 2 +- .../naturesaura/models/item/depth_axe.json | 14 ++++++++++++ .../models/item/depth_axe_enabled.json | 6 +++++ .../book/en_us/entries/items/sky_tools.json | 2 +- .../naturesaura/textures/item/depth_axe.png | Bin 497 -> 495 bytes .../textures/item/depth_axe_enabled.png | Bin 0 -> 519 bytes 11 files changed, 42 insertions(+), 28 deletions(-) delete mode 100644 src/generated/resources/assets/naturesaura/models/item/depth_axe.json create mode 100644 src/main/resources/assets/naturesaura/models/item/depth_axe.json create mode 100644 src/main/resources/assets/naturesaura/models/item/depth_axe_enabled.json create mode 100644 src/main/resources/assets/naturesaura/textures/item/depth_axe_enabled.png diff --git a/src/generated/resources/assets/naturesaura/models/item/depth_axe.json b/src/generated/resources/assets/naturesaura/models/item/depth_axe.json deleted file mode 100644 index 3584b1c3..00000000 --- a/src/generated/resources/assets/naturesaura/models/item/depth_axe.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/handheld", - "textures": { - "layer0": "naturesaura:item/depth_axe" - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 0ea615a5..861a2421 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -340,21 +340,24 @@ public final class Helper { public static void mineRecursively(Level level, BlockPos pos, BlockPos start, boolean drop, int horizontalRange, int verticalRange, Predicate filter) { if (Math.abs(pos.getX() - start.getX()) >= horizontalRange || Math.abs(pos.getZ() - start.getZ()) >= horizontalRange || Math.abs(pos.getY() - start.getY()) >= verticalRange) return; + + if (drop) { + level.destroyBlock(pos, true); + } else { + // in this case we don't want the block breaking particles, so we can't use destroyBlock + level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); + PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), PacketParticles.Type.TR_DISAPPEAR)); + } + for (var x = -1; x <= 1; x++) { for (var y = -1; y <= 1; y++) { for (var z = -1; z <= 1; z++) { + if (x == 0 && y == 0 && z == 0) + continue; var offset = pos.offset(x, y, z); var state = level.getBlockState(offset); - if (filter.test(state)) { - if (drop) { - level.destroyBlock(offset, true); - } else { - // in this case we don't want the block breaking particles, so we can't use destroyBlock - level.setBlockAndUpdate(offset, Blocks.AIR.defaultBlockState()); - PacketHandler.sendToAllAround(level, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR)); - } + if (filter.test(state)) Helper.mineRecursively(level, offset, start, drop, horizontalRange, verticalRange, filter); - } } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java index 3a38d897..c0a462eb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java @@ -81,7 +81,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); return true; }); - BlockEntityWoodStand.recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false); + Helper.mineRecursively(this.level, this.ritualPos, this.ritualPos, false, 6, 32, s -> s.is(BlockTags.LOGS) || s.getBlock() instanceof LeavesBlock); var item = new ItemEntity(this.level, this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5, @@ -122,10 +122,6 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl } - public static void recurseTreeDestruction(Level level, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) { - Helper.mineRecursively(level, pos, start, drop, 6, 32, s -> s.is(BlockTags.LOGS) || includeLeaves && s.getBlock() instanceof LeavesBlock); - } - private boolean isRitualOkay() { if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) { return false; diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java index 838c5bf6..db166d30 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; @@ -50,8 +49,9 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) { - if (stack.getItem() == ModItems.SKY_AXE && Helper.isToolEnabled(stack) && player.level.getBlockState(pos).is(BlockTags.LOGS)) { - BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true); + if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.isToolEnabled(stack) && player.level.getBlockState(pos).is(BlockTags.LOGS)) { + var horRange = stack.getItem() == ModItems.DEPTH_AXE ? 6 : 1; + Helper.mineRecursively(player.level, pos, pos, true, horRange, 32, s -> s.is(BlockTags.LOGS)); return true; } return false; @@ -60,7 +60,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { var stack = player.getItemInHand(hand); - if (stack.getItem() == ModItems.SKY_AXE && Helper.toggleToolEnabled(player, stack)) + if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.toggleToolEnabled(player, stack)) return InteractionResultHolder.success(stack); return super.use(level, player, hand); } @@ -73,7 +73,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public void generateCustomItemModel(ItemModelGenerator generator) { - if (this == ModItems.SKY_AXE) + if (this == ModItems.SKY_AXE || this == ModItems.DEPTH_AXE) return; generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName()); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java index 7e4756fe..d8ec0712 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java @@ -74,6 +74,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel stack.hurtAndBreak(damage, player, p -> p.broadcastBreakEvent(context.getHand())); return InteractionResult.SUCCESS; } + return InteractionResult.PASS; } else if (this == ModItems.SKY_SHOVEL) { if (this.getDestroySpeed(stack, state) <= 1) return super.useOn(context); @@ -89,7 +90,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand())); return InteractionResult.SUCCESS; } - return InteractionResult.PASS; + return super.useOn(context); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java index 05b412a1..b89dea72 100644 --- a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java @@ -49,7 +49,7 @@ public class ClientProxy implements IProxy { (stack, level, entity, i) -> ItemColorChanger.isFillMode(stack) ? 1 : 0); ItemProperties.register(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "has_color"), (stack, level, entity, i) -> ItemColorChanger.getStoredColor(stack) != null ? 1 : 0); - for (var item : new Item[]{ModItems.SKY_AXE, ModItems.DEPTH_PICKAXE}) { + for (var item : new Item[]{ModItems.SKY_AXE, ModItems.DEPTH_PICKAXE, ModItems.DEPTH_AXE}) { ItemProperties.register(item, new ResourceLocation(NaturesAura.MOD_ID, "enabled"), (stack, level, entity, i) -> Helper.isToolEnabled(stack) ? 1 : 0); } diff --git a/src/main/resources/assets/naturesaura/models/item/depth_axe.json b/src/main/resources/assets/naturesaura/models/item/depth_axe.json new file mode 100644 index 00000000..46ee77a0 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/depth_axe.json @@ -0,0 +1,14 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "naturesaura:item/depth_axe" + }, + "overrides": [ + { + "predicate": { + "naturesaura:enabled": 1 + }, + "model": "naturesaura:item/depth_axe_enabled" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/depth_axe_enabled.json b/src/main/resources/assets/naturesaura/models/item/depth_axe_enabled.json new file mode 100644 index 00000000..39aeff31 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/depth_axe_enabled.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "naturesaura:item/depth_axe_enabled" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/sky_tools.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/sky_tools.json index 360bdc87..4b4d6c5b 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/sky_tools.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/sky_tools.json @@ -15,7 +15,7 @@ }, { "type": "crafting", - "text": "The $(item)Skyseeker's Handaxe$() is very efficient at chopping $(thing)trees$(), doing so in one fell swoop.", + "text": "The $(item)Skyseeker's Handaxe$() is very efficient at chopping $(thing)small trees$(), doing so in one fell swoop.", "recipe": "naturesaura:sky_axe" }, { diff --git a/src/main/resources/assets/naturesaura/textures/item/depth_axe.png b/src/main/resources/assets/naturesaura/textures/item/depth_axe.png index 6d5072744b29c0a21267e122189010a3379fb025..adfe90fc8791ed5d189c97947d69cc24792825b3 100644 GIT binary patch delta 453 zcmV;$0XqKi1MdTnG=HW^L_t(IjlGl2YZE~jho5)mT@p9OG_;|`ixez{9+Vb8D0uTy z@X|lkqjw`>ya>`nP-zG>L7OJDYS?U&84vA_ySirw7G{U}eLOD={I7L%cq4KpFb}c07OxQh~WKom~$?Om&;|i=bS5Vuzy%A@ZMvs#TdiU;jwSj zngFOO0Q330fFOmRoAfA(c>d^xZ`7KoYDiaAJ`Z}lJ9#YuGZU+7sJ_4RG$aG8+_GR) z+8}exOtOIitR`c&_a0-7qN-e6p7ZMMODQynq9}+}l}@)Uoo-te7w5#b%BK%+P*vt> z!sK!s8fZvat$(hWj0xYv){d{)Dv3`ynVw2K=y`xnxBaJio+plDX0sV0!olXQk8i~9 zhh0%soO2js3bU|zgfvY7c(8Hbx9UyKevbM0{Ywb(-UrOm1^@?JyS`DW)1MAGy&6h3 z;JnaU8<4{cw(s2an`;}a-Kx`{ju`yNj_4TSHYke*Qwbmy|b^3(uw3R vIp+$ZQUnp<-t8?9(El;|2QB~D@;JW%(%`rn&rC@m00000NkvXXu0mjfVdvj3 delta 455 zcmV;&0XY8e1MvfpG=Hc`L_t(Ijir;#YZE~jho5)mT@p9OG}zGMMGBTe4@!$46ufyU zc4}e_V$LN51UcWCs!9 z`q>y0z_%MM9`8Q&`S$_=KomuY2;N_cIp+d+xm<=h=Ulmi#eZUf_a194#uyF{j(nrm z1VB{*n9t{h2vWFQsYg-7vxm=pqt--KgSx8nY0%^C@hb^2Gq9=#>wDWzf-=C$Eek}Y z4l>4!Br6PHH5s$D`v_|kRptERjF)d-NWnoAMFFg;bh>Tnblb8xKO?qPKE8jAsxnU# zCKu!2K!eI^b$^-3n6MwTwtdZ3Nqoxj^hDx8&jWP2?LW@*dEz)`Hk%~HM&_zL`P z*cDa9IfpT((1p!MNYfO6`|J07tKQ`F=a>)QJ_ix+eTZ4=0APP}$2Tf<`qLpN--nVF zoCjKKL*&rG)~!2!V{M(a8+H2A5rbb}B?F2Gl}d#qNk9sH6$qMfotmxEJN?2aok)Jj xIadIcMi3G1-rV#6{U4*hqUAr^^&b9f{RWfzxEe(ywGaRR002ovPDHLkV1np(*y8{I diff --git a/src/main/resources/assets/naturesaura/textures/item/depth_axe_enabled.png b/src/main/resources/assets/naturesaura/textures/item/depth_axe_enabled.png new file mode 100644 index 0000000000000000000000000000000000000000..f2fdb495eb2f94d6b0fffce8bad92d75c8b560e7 GIT binary patch literal 519 zcmV+i0{H!jP)j~p${4blNOU$Tbf4i&Ji-Y0GgdB$0N3 z#1kl`c(~SDlSo^RT3t43o4nckKqR4Pt&0Qz&N-A)h%6dK$vY2@=-BMIfW6;i9zvDW(T)>^(?oYCoxajLI!3aqsr{C2P5 zI|C$XoFiJPU>RJN#1l-%Y`=Vs(H3hhlbb8vpY(C6ue<{1oDXl!eN~;_nA6@N(d3H2 zl<9XnSZlexn=`!`7Zn&|NRkAtwU_&9^MzDQnOh=GE>o7OPJ4$K)mDWNgCJlwo1v8A zpt&o7DKnQlJ`O)AYc2nx9RYlRIRfV#aU3He>^F9#S=-?J*AG5V&KGHG?JX|nf&zep ztzD^=stm4&eE&UE+3S617r?)c?WfPAx!z!Xt;*nf#KqsAY6(Oqx?DRXxDjnUmyWsA}@&4IEb_YR&v*%E-kpHabD_OoT}{0AY3&%sS8?C<~p002ov JPDHLkV1ngo?=b)X literal 0 HcmV?d00001