2025-11-24 22:52:51 +03:00

44 lines
1.5 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.world.item;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.stats.Stats;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MapItem;
import net.minecraft.world.level.Level;
public class EmptyMapItem
extends Item {
public EmptyMapItem(Item.Properties properties) {
super(properties);
}
@Override
public InteractionResult use(Level level, Player player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
if (!(level instanceof ServerLevel)) {
return InteractionResult.SUCCESS;
}
ServerLevel serverLevel = (ServerLevel)level;
itemStack.consume(1, player);
player.awardStat(Stats.ITEM_USED.get(this));
serverLevel.playSound(null, player, SoundEvents.UI_CARTOGRAPHY_TABLE_TAKE_RESULT, player.getSoundSource(), 1.0f, 1.0f);
ItemStack map = MapItem.create(serverLevel, player.getBlockX(), player.getBlockZ(), (byte)0, true, false);
if (itemStack.isEmpty()) {
return InteractionResult.SUCCESS.heldItemTransformedTo(map);
}
if (!player.getInventory().add(map.copy())) {
player.drop(map, false);
}
return InteractionResult.SUCCESS;
}
}