001package net.minecraft.item;
002
003import net.minecraft.creativetab.CreativeTabs;
004import net.minecraft.entity.player.EntityPlayer;
005import net.minecraft.world.World;
006import net.minecraft.world.storage.MapData;
007
008public class ItemEmptyMap extends ItemMapBase
009{
010    protected ItemEmptyMap(int par1)
011    {
012        super(par1);
013        this.setCreativeTab(CreativeTabs.tabMisc);
014    }
015
016    /**
017     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
018     */
019    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
020    {
021        ItemStack itemstack1 = new ItemStack(Item.map, 1, par2World.getUniqueDataId("map"));
022        String s = "map_" + itemstack1.getItemDamage();
023        MapData mapdata = new MapData(s);
024        par2World.setItemData(s, mapdata);
025        mapdata.scale = 0;
026        int i = 128 * (1 << mapdata.scale);
027        mapdata.xCenter = (int)(Math.round(par3EntityPlayer.posX / (double)i) * (long)i);
028        mapdata.zCenter = (int)(Math.round(par3EntityPlayer.posZ / (double)i) * (long)i);
029        mapdata.dimension = (byte)par2World.provider.dimensionId;
030        mapdata.markDirty();
031        --par1ItemStack.stackSize;
032
033        if (par1ItemStack.stackSize <= 0)
034        {
035            return itemstack1;
036        }
037        else
038        {
039            if (!par3EntityPlayer.inventory.addItemStackToInventory(itemstack1.copy()))
040            {
041                par3EntityPlayer.dropPlayerItem(itemstack1);
042            }
043
044            return par1ItemStack;
045        }
046    }
047}