mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-29 22:28:34 +01:00
Compare commits
3 commits
336795421d
...
06a6b7f0fb
Author | SHA1 | Date | |
---|---|---|---|
06a6b7f0fb | |||
764e662c2d | |||
43c8976298 |
13 changed files with 69 additions and 29 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) {
|
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)
|
if (Math.abs(pos.getX() - start.getX()) >= horizontalRange || Math.abs(pos.getZ() - start.getZ()) >= horizontalRange || Math.abs(pos.getY() - start.getY()) >= verticalRange)
|
||||||
return;
|
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 x = -1; x <= 1; x++) {
|
||||||
for (var y = -1; y <= 1; y++) {
|
for (var y = -1; y <= 1; y++) {
|
||||||
for (var z = -1; z <= 1; z++) {
|
for (var z = -1; z <= 1; z++) {
|
||||||
|
if (x == 0 && y == 0 && z == 0)
|
||||||
|
continue;
|
||||||
var offset = pos.offset(x, y, z);
|
var offset = pos.offset(x, y, z);
|
||||||
var state = level.getBlockState(offset);
|
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);
|
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());
|
this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||||
return true;
|
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,
|
var item = new ItemEntity(this.level,
|
||||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
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() {
|
private boolean isRitualOkay() {
|
||||||
if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) {
|
if (!Multiblocks.TREE_RITUAL.isComplete(this.level, this.ritualPos)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.items.tools;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityWoodStand;
|
|
||||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
|
@ -50,8 +49,9 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) {
|
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)) {
|
if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.isToolEnabled(stack) && player.level.getBlockState(pos).is(BlockTags.LOGS)) {
|
||||||
BlockEntityWoodStand.recurseTreeDestruction(player.level, pos, pos, false, true);
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -60,7 +60,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
||||||
var stack = player.getItemInHand(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 InteractionResultHolder.success(stack);
|
||||||
return super.use(level, player, hand);
|
return super.use(level, player, hand);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
if (this == ModItems.SKY_AXE)
|
if (this == ModItems.SKY_AXE || this == ModItems.DEPTH_AXE)
|
||||||
return;
|
return;
|
||||||
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
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()));
|
stack.hurtAndBreak(damage, player, p -> p.broadcastBreakEvent(context.getHand()));
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
return InteractionResult.PASS;
|
||||||
} else if (this == ModItems.SKY_SHOVEL) {
|
} else if (this == ModItems.SKY_SHOVEL) {
|
||||||
if (this.getDestroySpeed(stack, state) <= 1)
|
if (this.getDestroySpeed(stack, state) <= 1)
|
||||||
return super.useOn(context);
|
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()));
|
stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand()));
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
return InteractionResult.PASS;
|
return super.useOn(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,13 +8,21 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
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.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
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.ItemStack;
|
||||||
import net.minecraft.world.item.SwordItem;
|
import net.minecraft.world.item.SwordItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -39,10 +47,28 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
||||||
target.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 2));
|
target.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 2));
|
||||||
} else if (this == ModItems.SKY_SWORD) {
|
} else if (this == ModItems.SKY_SWORD) {
|
||||||
target.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 60, 2));
|
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);
|
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
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
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);
|
(stack, level, entity, i) -> ItemColorChanger.isFillMode(stack) ? 1 : 0);
|
||||||
ItemProperties.register(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "has_color"),
|
ItemProperties.register(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "has_color"),
|
||||||
(stack, level, entity, i) -> ItemColorChanger.getStoredColor(stack) != null ? 1 : 0);
|
(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"),
|
ItemProperties.register(item, new ResourceLocation(NaturesAura.MOD_ID, "enabled"),
|
||||||
(stack, level, entity, i) -> Helper.isToolEnabled(stack) ? 1 : 0);
|
(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",
|
"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"
|
"recipe": "naturesaura:sky_axe"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"type": "spotlight",
|
"type": "spotlight",
|
||||||
"item": "naturesaura:vacuum_bottle",
|
"item": "naturesaura:vacuum_bottle",
|
||||||
"link_recipe": true,
|
"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 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 $(aura) vacuum in the bottle."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
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