minecraft-source/src/net/minecraft/world/item/EmptyMapItem.java

33 lines
1.1 KiB
Java

package net.minecraft.world.item;
import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
public class EmptyMapItem extends ComplexItem {
public EmptyMapItem(final Properties a) {
super(a);
}
@Override
public InteractionResultHolder<ItemStack> use(final Level bjt, final Player ayg, final InteractionHand ajh) {
final ItemStack bek5 = MapItem.create(bjt, Mth.floor(ayg.getX()), Mth.floor(ayg.getZ()), (byte)0, true, false);
final ItemStack bek6 = ayg.getItemInHand(ajh);
if (!ayg.abilities.instabuild) {
bek6.shrink(1);
}
if (bek6.isEmpty()) {
return InteractionResultHolder.<ItemStack>success(bek5);
}
if (!ayg.inventory.add(bek5.copy())) {
ayg.drop(bek5, false);
}
ayg.awardStat(Stats.ITEM_USED.get(this));
return InteractionResultHolder.<ItemStack>success(bek6);
}
}