mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-29 22:28:34 +01:00
Compare commits
No commits in common. "06a6b7f0fbd24bcd0d7c4d457269e44ef6bba9a8" and "336795421d328a2e4d0946592f85d21c5c10cc91" have entirely different histories.
06a6b7f0fb
...
336795421d
13 changed files with 29 additions and 69 deletions
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:item/depth_axe"
|
||||
}
|
||||
}
|
|
@ -340,24 +340,21 @@ 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 (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));
|
||||
}
|
||||
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;
|
||||
});
|
||||
Helper.mineRecursively(this.level, this.ritualPos, this.ritualPos, false, 6, 32, s -> s.is(BlockTags.LOGS) || s.getBlock() instanceof LeavesBlock);
|
||||
BlockEntityWoodStand.recurseTreeDestruction(this.level, this.ritualPos, this.ritualPos, true, false);
|
||||
|
||||
var item = new ItemEntity(this.level,
|
||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||
|
@ -122,6 +122,10 @@ 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,6 +2,7 @@ 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;
|
||||
|
@ -49,9 +50,8 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
|||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) {
|
||||
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));
|
||||
if (stack.getItem() == ModItems.SKY_AXE && Helper.isToolEnabled(stack) && player.level.getBlockState(pos).is(BlockTags.LOGS)) {
|
||||
BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true);
|
||||
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 || stack.getItem() == ModItems.DEPTH_AXE) && Helper.toggleToolEnabled(player, stack))
|
||||
if (stack.getItem() == ModItems.SKY_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 || this == ModItems.DEPTH_AXE)
|
||||
if (this == ModItems.SKY_AXE)
|
||||
return;
|
||||
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ 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);
|
||||
|
@ -90,7 +89,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel
|
|||
stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand()));
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return super.useOn(context);
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,21 +8,13 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
|||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -47,28 +39,10 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
|||
target.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 2));
|
||||
} else if (this == ModItems.SKY_SWORD) {
|
||||
target.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 60, 2));
|
||||
} else if (this == ModItems.DEPTH_SWORD && attacker instanceof Player player) {
|
||||
// this is just a modified copy of Player.attack's sweeping damage code
|
||||
var damage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * 0.75F;
|
||||
for (var other : player.level.getEntitiesOfClass(LivingEntity.class, stack.getSweepHitBox(player, target))) {
|
||||
if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker()) && player.canHit(other, 0)) {
|
||||
other.knockback(0.4F, Mth.sin(player.getYRot() * (Mth.PI / 180)), -Mth.cos(player.getYRot() * (Mth.PI / 180)));
|
||||
other.hurt(DamageSource.playerAttack(player), damage);
|
||||
}
|
||||
}
|
||||
// this just displays the particles
|
||||
player.sweepAttack();
|
||||
}
|
||||
return super.hurtEnemy(stack, target, attacker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AABB getSweepHitBox(@NotNull ItemStack stack, @NotNull Player player, @NotNull Entity target) {
|
||||
if (this == ModItems.DEPTH_SWORD)
|
||||
return target.getBoundingBox().inflate(2, 1, 2);
|
||||
return super.getSweepHitBox(stack, player, target);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
||||
|
|
|
@ -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, ModItems.DEPTH_AXE}) {
|
||||
for (var item : new Item[]{ModItems.SKY_AXE, ModItems.DEPTH_PICKAXE}) {
|
||||
ItemProperties.register(item, new ResourceLocation(NaturesAura.MOD_ID, "enabled"),
|
||||
(stack, level, entity, i) -> Helper.isToolEnabled(stack) ? 1 : 0);
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "naturesaura:item/depth_axe"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"naturesaura:enabled": 1
|
||||
},
|
||||
"model": "naturesaura:item/depth_axe_enabled"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"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)small trees$(), doing so in one fell swoop.",
|
||||
"text": "The $(item)Skyseeker's Handaxe$() is very efficient at chopping $(thing)trees$(), doing so in one fell swoop.",
|
||||
"recipe": "naturesaura:sky_axe"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"type": "spotlight",
|
||||
"item": "naturesaura:vacuum_bottle",
|
||||
"link_recipe": true,
|
||||
"text": "Lastly, some areas have a severe lack of $(aura), much lower than the $(l:items/eye)Environmental Eye$() can display, and whose air is subsequently nearly devoid of oxygen. Using a $(item)Bottle and Cork$() in areas like these allows bottling up this air and capturing a nearly perfect $(aura) vacuum in the bottle."
|
||||
"text": "Lastly, some areas have a severe lack of $(aura), much lower than the $(l:items/eye)Environmental Eye$() can display, and whose air is subsequently nearly devoid of oxygen. Using a $(item)Bottle and Cork$() in areas like these allows bottling up this air and capturing a nearly perfect vacuum in the bottle."
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 497 B |
Binary file not shown.
Before Width: | Height: | Size: 519 B |
Loading…
Reference in a new issue