/// <summary> /// Handles a players right click /// </summary> public override bool OnPlayerRightClick(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7) { SyncCurrentPlayItem(); NetClientHandler.AddToSendQueue(new Packet15Place(par4, par5, par6, par7, par1EntityPlayer.Inventory.GetCurrentItem())); int i = par2World.GetBlockId(par4, par5, par6); if (i > 0 && Block.BlocksList[i].BlockActivated(par2World, par4, par5, par6, par1EntityPlayer)) { return(true); } if (par3ItemStack == null) { return(false); } if (CreativeMode) { int j = par3ItemStack.GetItemDamage(); int k = par3ItemStack.StackSize; bool flag = par3ItemStack.UseItem(par1EntityPlayer, par2World, par4, par5, par6, par7); par3ItemStack.SetItemDamage(j); par3ItemStack.StackSize = k; return(flag); } else { return(par3ItemStack.UseItem(par1EntityPlayer, par2World, par4, par5, par6, par7)); } }
///<summary> /// Called when item is crafted/smelted. Used only by maps so far. ///</summary> public new void OnCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par1ItemStack.SetItemDamage(par2World.GetUniqueDataId("map")); string s = (new StringBuilder()).Append("map_").Append(par1ItemStack.GetItemDamage()).ToString(); MapData mapdata = new MapData(s); par2World.SetItemData(s, mapdata); mapdata.XCenter = MathHelper2.Floor_double(par3EntityPlayer.PosX); mapdata.ZCenter = MathHelper2.Floor_double(par3EntityPlayer.PosZ); mapdata.Scale = 3; mapdata.Dimension = (byte)par2World.WorldProvider.TheWorldType; mapdata.MarkDirty(); }
public virtual MapData GetMapData(ItemStack par1ItemStack, World par2World) { string s = (new StringBuilder()).Append("map_").Append(par1ItemStack.GetItemDamage()).ToString(); MapData mapdata = (MapData)par2World.LoadItemData(typeof(net.minecraft.src.MapData), (new StringBuilder()).Append("map_").Append(par1ItemStack.GetItemDamage()).ToString()); if (mapdata == null) { par1ItemStack.SetItemDamage(par2World.GetUniqueDataId("map")); string s1 = (new StringBuilder()).Append("map_").Append(par1ItemStack.GetItemDamage()).ToString(); mapdata = new MapData(s1); mapdata.XCenter = par2World.GetWorldInfo().GetSpawnX(); mapdata.ZCenter = par2World.GetWorldInfo().GetSpawnZ(); mapdata.Scale = 3; mapdata.Dimension = (byte)par2World.WorldProvider.TheWorldType; mapdata.MarkDirty(); par2World.SetItemData(s1, mapdata); } return(mapdata); }
/// <summary> /// Handles a players right click /// </summary> public override bool OnPlayerRightClick(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7) { int i = par2World.GetBlockId(par4, par5, par6); if (i > 0 && Block.BlocksList[i].BlockActivated(par2World, par4, par5, par6, par1EntityPlayer)) { return(true); } if (par3ItemStack == null) { return(false); } else { int j = par3ItemStack.GetItemDamage(); int k = par3ItemStack.StackSize; bool flag = par3ItemStack.UseItem(par1EntityPlayer, par2World, par4, par5, par6, par7); par3ItemStack.SetItemDamage(j); par3ItemStack.StackSize = k; return(flag); } }