Skip to content

Commit

Permalink
fix Chest Label crash
Browse files Browse the repository at this point in the history
  • Loading branch information
luxtracon committed Nov 18, 2024
1 parent f358981 commit e139cbf
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -88,7 +90,12 @@ public String getNameByStyle(boolean pStyle) {
@OnlyIn(Dist.CLIENT)
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
var stack = pPlayer.getItemInHand(pUsedHand);
Minecraft.getInstance().setScreen(new ChestLabelScreen(stack));

if (pPlayer instanceof LocalPlayer localPlayer) {
Minecraft.getInstance().setScreen(new ChestLabelScreen(stack));
localPlayer.awardStat(Stats.ITEM_USED.get(this));
}

return InteractionResultHolder.sidedSuccess(stack, pLevel.isClientSide());
}
}

0 comments on commit e139cbf

Please sign in to comment.