mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 03:43:30 +01:00
added depth axe ability
This commit is contained in:
parent
336795421d
commit
43c8976298
11 changed files with 42 additions and 28 deletions
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:item/depth_axe"
|
||||
}
|
||||
}
|
|
@ -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<BlockState> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<ItemStack> 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());
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:item/depth_axe_enabled"
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
},
|
||||
{
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 497 B After Width: | Height: | Size: 495 B |
Binary file not shown.
After Width: | Height: | Size: 519 B |
Loading…
Reference in a new issue