Skip to content

Commit

Permalink
fix: Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 15, 2024
1 parent 161f66e commit fcd4903
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.data.ReduxTags;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.item.TooltipUtils;
import net.zepalesque.redux.item.VeridiumItem;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down
23 changes: 20 additions & 3 deletions src/main/java/net/zepalesque/redux/item/tools/VeridiumHoeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.data.ReduxTags;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.item.TooltipUtils;
import net.zepalesque.redux.item.VeridiumItem;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -83,6 +83,23 @@ public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPo
return bool;
}

@Override
public InteractionResult useOn(UseOnContext context) {
InteractionResult result = super.useOn(context);
if (result == InteractionResult.sidedSuccess(context.getLevel().isClientSide()) && !context.getPlayer().level().isClientSide() && !context.getPlayer().isCreative()) {
ItemStack stack = context.getItemInHand();
Player player = context.getPlayer();
ItemStack transform = this.deplete(stack, player, 1);
if (!player.level().isClientSide() && transform != null && transform != stack) {
player.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (player instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
}
return result;
}

@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return super.damageItem(stack, amount, entity, onBroken) * VeridiumItem.DURABILITY_DMG_MULTIPLIER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.zepalesque.redux.item;
package net.zepalesque.redux.item.tools;

import net.minecraft.core.Holder;
import net.minecraft.nbt.ByteTag;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package net.zepalesque.redux.item.tools;

import com.aetherteam.aether.entity.monster.dungeon.boss.Slider;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
Expand All @@ -17,9 +15,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.data.ReduxTags;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.item.TooltipUtils;
import net.zepalesque.redux.item.VeridiumItem;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.zepalesque.redux.data.ReduxTags;
import net.zepalesque.redux.item.ReduxItems;
import net.zepalesque.redux.item.TooltipUtils;
import net.zepalesque.redux.item.VeridiumItem;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -83,6 +83,23 @@ public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPo
return bool;
}

@Override
public InteractionResult useOn(UseOnContext context) {
InteractionResult result = super.useOn(context);
if (result == InteractionResult.sidedSuccess(context.getLevel().isClientSide()) && !context.getPlayer().level().isClientSide() && !context.getPlayer().isCreative()) {
ItemStack stack = context.getItemInHand();
Player player = context.getPlayer();
ItemStack transform = this.deplete(stack, player, 1);
if (!player.level().isClientSide() && transform != null && transform != stack) {
player.setItemSlot(EquipmentSlot.MAINHAND, transform);
if (player instanceof ServerPlayer sp) {
this.sendSound(sp);
}
}
}
return result;
}

@Override
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
return super.damageItem(stack, amount, entity, onBroken) * VeridiumItem.DURABILITY_DMG_MULTIPLIER;
Expand Down

0 comments on commit fcd4903

Please sign in to comment.