public override string GetItemDisplayName(ItemStack par1ItemStack) { if (par1ItemStack.GetItemDamage() == 0) { return(StatCollector.TranslateToLocal("item.emptyPotion.name").Trim()); } string s = ""; if (IsSplash(par1ItemStack.GetItemDamage())) { s = (new StringBuilder()).Append(StatCollector.TranslateToLocal("potion.prefix.grenade").Trim()).Append(" ").ToString(); } List <PotionEffect> list = Item.Potion.GetEffects(par1ItemStack); if (list != null && list.Count > 0) { string s1 = ((PotionEffect)list[0]).GetEffectName(); s1 = (new StringBuilder()).Append(s1).Append(".postfix").ToString(); return((new StringBuilder()).Append(s).Append(StatCollector.TranslateToLocal(s1).Trim()).ToString()); } else { string s2 = PotionHelper.Func_40359_b(par1ItemStack.GetItemDamage()); return((new StringBuilder()).Append(StatCollector.TranslateToLocal(s2).Trim()).Append(" ").Append(base.GetItemDisplayName(par1ItemStack)).ToString()); } }
/// <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> /// Callback for item usage. If the item does something special on right clicking, he will have one of those. Return /// True if something happen and false if it don't. This is for ITEMS, not BLOCKS ! /// </summary> public override bool OnItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) { if (par3World.IsRemote) { return(true); } int i = par3World.GetBlockId(par4, par5, par6); par4 += Facing.OffsetsXForSide[par7]; par5 += Facing.OffsetsYForSide[par7]; par6 += Facing.OffsetsZForSide[par7]; float d = 0.0F; if (par7 == 1 && i == Block.Fence.BlockID || i == Block.NetherFence.BlockID) { d = 0.5F; } if (Func_48440_a(par3World, par1ItemStack.GetItemDamage(), par4 + 0.5F, par5 + d, par6 + 0.5F) && !par2EntityPlayer.Capabilities.IsCreativeMode) { par1ItemStack.StackSize--; } return(true); }
public override string GetItemNameIS(ItemStack par1ItemStack) { int i = par1ItemStack.GetItemDamage(); if (i < 0 || i >= BlockStep.BlockStepTypes.Length) { i = 0; } return((new StringBuilder()).Append(base.GetItemName()).Append(".").Append(BlockStep.BlockStepTypes[i]).ToString()); }
/// <summary> /// Used to check if a recipe matches current crafting inventory /// </summary> public virtual bool Matches(InventoryCrafting par1InventoryCrafting) { List <ItemStack> arraylist = new List <ItemStack>(RecipeItems); int i = 0; do { if (i >= 3) { break; } for (int j = 0; j < 3; j++) { ItemStack itemstack = par1InventoryCrafting.GetStackInRowAndColumn(j, i); if (itemstack == null) { continue; } bool flag = false; IEnumerator <ItemStack> iterator = arraylist.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } ItemStack itemstack1 = iterator.Current; if (itemstack.ItemID != itemstack1.ItemID || itemstack1.GetItemDamage() != -1 && itemstack.GetItemDamage() != itemstack1.GetItemDamage()) { continue; } flag = true; arraylist.Remove(itemstack1); break; }while (true); if (!flag) { return(false); } } i++; }while (true); return(arraylist.Count == 0); }
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); }
public override string GetItemDisplayName(ItemStack par1ItemStack) { string s = (new StringBuilder()).Append("").Append(StatCollector.TranslateToLocal((new StringBuilder()).Append(GetItemName()).Append(".name").ToString())).ToString().Trim(); string s1 = EntityList.GetStringFromID(par1ItemStack.GetItemDamage()); if (s1 != null) { s = (new StringBuilder()).Append(s).Append(" ").Append(StatCollector.TranslateToLocal((new StringBuilder()).Append("entity.").Append(s1).Append(".name").ToString())).ToString(); } return(s); }
///<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(); }
private static bool Func_50087_b(ItemStack par0ItemStack, EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5, int par6) { if (par6 == 0) { par4--; } if (par6 == 1) { par4++; } if (par6 == 2) { par5--; } if (par6 == 3) { par5++; } if (par6 == 4) { par3--; } if (par6 == 5) { par3++; } int i = par2World.GetBlockId(par3, par4, par5); int j = par2World.GetBlockMetadata(par3, par4, par5); int k = j & 7; if (i == Block.StairSingle.BlockID && k == par0ItemStack.GetItemDamage()) { if (par2World.CheckIfAABBIsClear(Block.StairDouble.GetCollisionBoundingBoxFromPool(par2World, par3, par4, par5)) && par2World.SetBlockAndMetadataWithNotify(par3, par4, par5, Block.StairDouble.BlockID, k)) { par2World.PlaySoundEffect((float)par3 + 0.5F, (float)par4 + 0.5F, (float)par5 + 0.5F, Block.StairDouble.StepSound.GetStepSound(), (Block.StairDouble.StepSound.GetVolume() + 1.0F) / 2.0F, Block.StairDouble.StepSound.GetPitch() * 0.8F); par0ItemStack.StackSize--; } return(true); } else { return(false); } }
/// <summary> /// Called when a player right clicks a entity with a item. /// </summary> public override void UseItemOnEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving) { if (par2EntityLiving is EntitySheep) { EntitySheep entitysheep = (EntitySheep)par2EntityLiving; int i = BlockCloth.GetBlockFromDye(par1ItemStack.GetItemDamage()); if (!entitysheep.GetSheared() && entitysheep.GetFleeceColor() != i) { entitysheep.SetFleeceColor(i); par1ItemStack.StackSize--; } } }
/// <summary> /// Writes the ItemStack's ID (short), then size (byte), then damage. (short) /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected void writeItemStack(ItemStack par1ItemStack, DataOutputStream par2DataOutputStream) throws IOException protected virtual void WriteItemStack(ItemStack par1ItemStack, BinaryWriter par2DataOutputStream) { if (par1ItemStack == null) { par2DataOutputStream.Write((short)-1); } else { par2DataOutputStream.Write((short)par1ItemStack.ItemID); par2DataOutputStream.Write((byte)par1ItemStack.StackSize); par2DataOutputStream.Write((short)par1ItemStack.GetItemDamage()); if (par1ItemStack.GetItem().IsDamageable() || par1ItemStack.GetItem().Func_46056_k()) { WriteNBTTagCompound(par1ItemStack.StackTagCompound, par2DataOutputStream); } } }
public override string GetItemNameIS(ItemStack par1ItemStack) { if (BlockNames == null) { return(base.GetItemNameIS(par1ItemStack)); } int i = par1ItemStack.GetItemDamage(); if (i >= 0 && i < BlockNames.Length) { return((new StringBuilder()).Append(base.GetItemNameIS(par1ItemStack)).Append(".").Append(BlockNames[i]).ToString()); } else { return(base.GetItemNameIS(par1ItemStack)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static void writeWatchableObject(DataOutputStream par0DataOutputStream, WatchableObject par1WatchableObject) throws IOException private static void WriteWatchableObject(BinaryWriter par0DataOutputStream, WatchableObject par1WatchableObject) { int i = (par1WatchableObject.GetObjectType() << 5 | par1WatchableObject.GetDataValueId() & 0x1f) & 0xff; par0DataOutputStream.Write((byte)i); switch (par1WatchableObject.GetObjectType()) { case 0: par0DataOutputStream.Write((byte)par1WatchableObject.GetObject()); break; case 1: par0DataOutputStream.Write((short)par1WatchableObject.GetObject()); break; case 2: par0DataOutputStream.Write((int)par1WatchableObject.GetObject()); break; case 3: par0DataOutputStream.Write((float)par1WatchableObject.GetObject()); break; case 4: Packet.WriteString((string)par1WatchableObject.GetObject(), par0DataOutputStream); break; case 5: ItemStack itemstack = (ItemStack)par1WatchableObject.GetObject(); par0DataOutputStream.Write(itemstack.GetItem().ShiftedIndex); par0DataOutputStream.Write(itemstack.StackSize); par0DataOutputStream.Write(itemstack.GetItemDamage()); break; case 6: ChunkCoordinates chunkcoordinates = (ChunkCoordinates)par1WatchableObject.GetObject(); par0DataOutputStream.Write(chunkcoordinates.PosX); par0DataOutputStream.Write(chunkcoordinates.PosY); par0DataOutputStream.Write(chunkcoordinates.PosZ); break; } }
/// <summary> /// allows items to add custom lines of information to the mouseover description /// </summary> public virtual void AddInformation(ItemStack par1ItemStack, List <string> par2List) { if (par1ItemStack.GetItemDamage() == 0) { return; } List <PotionEffect> list = Item.Potion.GetEffects(par1ItemStack); if (list != null && list.Count > 0) { for (IEnumerator <PotionEffect> iterator = list.GetEnumerator(); iterator.MoveNext();) { PotionEffect potioneffect = iterator.Current; string s1 = StatCollector.TranslateToLocal(potioneffect.GetEffectName()).Trim(); if (potioneffect.GetAmplifier() > 0) { s1 = (new StringBuilder()).Append(s1).Append(" ").Append(StatCollector.TranslateToLocal((new StringBuilder()).Append("potion.potency.").Append(potioneffect.GetAmplifier()).ToString()).Trim()).ToString(); } if (potioneffect.GetDuration() > 20) { s1 = (new StringBuilder()).Append(s1).Append(" (").Append(net.minecraft.src.Potion.GetDurationString(potioneffect)).Append(")").ToString(); } if (net.minecraft.src.Potion.PotionTypes[potioneffect.GetPotionID()].IsBadEffect()) { par2List.Add((new StringBuilder()).Append((char)0xa7 + "c").Append(s1).ToString()); } else { par2List.Add((new StringBuilder()).Append((char)0xa7 + "7").Append(s1).ToString()); } } } else { string s = StatCollector.TranslateToLocal("potion.empty").Trim(); par2List.Add((new StringBuilder()).Append((char)0xa7).Append(s).ToString()); } }
/// <summary> /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer /// </summary> public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (IsSplash(par1ItemStack.GetItemDamage())) { par1ItemStack.StackSize--; par2World.PlaySoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / ((float)ItemRand.NextDouble() * 0.4F + 0.8F)); if (!par2World.IsRemote) { par2World.SpawnEntityInWorld(new EntityPotion(par2World, par3EntityPlayer, par1ItemStack.GetItemDamage())); } return(par1ItemStack); } else { par3EntityPlayer.SetItemInUse(par1ItemStack, GetMaxItemUseDuration(par1ItemStack)); return(par1ItemStack); } }
/// <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); } }
/// <summary> /// Called when the entity is attacked. /// </summary> public override bool AttackEntityFrom(DamageSource par1DamageSource, int par2) { if (WorldObj.IsRemote || IsDead) { return(true); } Func_41029_h(-Func_41030_m()); Func_41028_c(10); SetBeenAttacked(); Func_41024_b(Func_41025_i() + par2 * 10); if (Func_41025_i() > 40) { if (RiddenByEntity != null) { RiddenByEntity.MountEntity(this); } SetDead(); DropItemWithOffset(Item.MinecartEmpty.ShiftedIndex, 1, 0.0F); if (MinecartType == 1) { EntityMinecart entityminecart = this; label0: for (int i = 0; i < entityminecart.GetSizeInventory(); i++) { ItemStack itemstack = entityminecart.GetStackInSlot(i); if (itemstack == null) { continue; } float f = Rand.NextFloat() * 0.8F + 0.1F; float f1 = Rand.NextFloat() * 0.8F + 0.1F; float f2 = Rand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.StackSize <= 0) { goto label0; } int j = Rand.Next(21) + 10; if (j > itemstack.StackSize) { j = itemstack.StackSize; } itemstack.StackSize -= j; EntityItem entityitem = new EntityItem(WorldObj, PosX + f, PosY + f1, PosZ + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.MotionX = (float)Rand.NextGaussian() * f3; entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F; entityitem.MotionZ = (float)Rand.NextGaussian() * f3; WorldObj.SpawnEntityInWorld(entityitem); }while (true); } DropItemWithOffset(Block.Chest.BlockID, 1, 0.0F); } else if (MinecartType == 2) { DropItemWithOffset(Block.StoneOvenIdle.BlockID, 1, 0.0F); } } return(true); }
public override string GetItemNameIS(ItemStack par1ItemStack) { return((new StringBuilder()).Append(base.GetItemName()).Append(".").Append(ItemDye.DyeColorNames[BlockCloth.GetBlockFromDye(par1ItemStack.GetItemDamage())]).ToString()); }
/// <summary> /// Called whenever the block is removed. /// </summary> public override void OnBlockRemoval(World par1World, int par2, int par3, int par4) { TileEntity tileentity = par1World.GetBlockTileEntity(par2, par3, par4); if (tileentity != null && (tileentity is TileEntityBrewingStand)) { TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand)tileentity; label0: for (int i = 0; i < tileentitybrewingstand.GetSizeInventory(); i++) { ItemStack itemstack = tileentitybrewingstand.GetStackInSlot(i); if (itemstack == null) { continue; } float f = Rand.NextFloat() * 0.8F + 0.1F; float f1 = Rand.NextFloat() * 0.8F + 0.1F; float f2 = Rand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.StackSize <= 0) { goto label0; } int j = Rand.Next(21) + 10; if (j > itemstack.StackSize) { j = itemstack.StackSize; } itemstack.StackSize -= j; EntityItem entityitem = new EntityItem(par1World, (float)par2 + f, (float)par3 + f1, (float)par4 + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.MotionX = (float)Rand.NextGaussian() * f3; entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F; entityitem.MotionZ = (float)Rand.NextGaussian() * f3; par1World.SpawnEntityInWorld(entityitem); }while (true); } } base.OnBlockRemoval(par1World, par2, par3, par4); }
public virtual void UpdateEquippedItem() { PrevEquippedProgress = EquippedProgress; EntityPlayerSP entityplayersp = Mc.ThePlayer; ItemStack itemstack = ((EntityPlayer)(entityplayersp)).Inventory.GetCurrentItem(); ItemStack itemstack1 = itemstack; bool flag = EquippedItemSlot == ((EntityPlayer)(entityplayersp)).Inventory.CurrentItem && itemstack1 == ItemToRender; if (ItemToRender == null && itemstack1 == null) { flag = true; } if (itemstack1 != null && ItemToRender != null && itemstack1 != ItemToRender && itemstack1.ItemID == ItemToRender.ItemID && itemstack1.GetItemDamage() == ItemToRender.GetItemDamage()) { ItemToRender = itemstack1; flag = true; } float f = 0.4F; float f1 = flag ? 1.0F : 0.0F; float f2 = f1 - EquippedProgress; if (f2 < -f) { f2 = -f; } if (f2 > f) { f2 = f; } EquippedProgress += f2; if (EquippedProgress < 0.1F) { ItemToRender = itemstack1; EquippedItemSlot = ((EntityPlayer)(entityplayersp)).Inventory.CurrentItem; } }
/// <summary> /// Called whenever the block is removed. /// </summary> public override void OnBlockRemoval(World par1World, int par2, int par3, int par4) { if (!KeepFurnaceInventory) { TileEntityFurnace tileentityfurnace = (TileEntityFurnace)par1World.GetBlockTileEntity(par2, par3, par4); if (tileentityfurnace != null) { label0: for (int i = 0; i < tileentityfurnace.GetSizeInventory(); i++) { ItemStack itemstack = tileentityfurnace.GetStackInSlot(i); if (itemstack == null) { continue; } float f = FurnaceRand.NextFloat() * 0.8F + 0.1F; float f1 = FurnaceRand.NextFloat() * 0.8F + 0.1F; float f2 = FurnaceRand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.StackSize <= 0) { goto label0; } int j = FurnaceRand.Next(21) + 10; if (j > itemstack.StackSize) { j = itemstack.StackSize; } itemstack.StackSize -= j; EntityItem entityitem = new EntityItem(par1World, (float)par2 + f, (float)par3 + f1, (float)par4 + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage())); if (itemstack.HasTagCompound()) { entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy()); } float f3 = 0.05F; entityitem.MotionX = (float)FurnaceRand.NextGaussian() * f3; entityitem.MotionY = (float)FurnaceRand.NextGaussian() * f3 + 0.2F; entityitem.MotionZ = (float)FurnaceRand.NextGaussian() * f3; par1World.SpawnEntityInWorld(entityitem); }while (true); } } } base.OnBlockRemoval(par1World, par2, par3, par4); }
/// <summary> /// Renders the active item in the player's hand when in first person mode. Args: partialTickTime /// </summary> public virtual void RenderItemInFirstPerson(float par1) { float f = PrevEquippedProgress + (EquippedProgress - PrevEquippedProgress) * par1; EntityPlayerSP entityplayersp = Mc.ThePlayer; float f1 = ((EntityPlayer)(entityplayersp)).PrevRotationPitch + (((EntityPlayer)(entityplayersp)).RotationPitch - ((EntityPlayer)(entityplayersp)).PrevRotationPitch) * par1; //GL.PushMatrix(); //GL.Rotate(f1, 1.0F, 0.0F, 0.0F); //GL.Rotate(((EntityPlayer)(entityplayersp)).PrevRotationYaw + (((EntityPlayer)(entityplayersp)).RotationYaw - ((EntityPlayer)(entityplayersp)).PrevRotationYaw) * par1, 0.0F, 1.0F, 0.0F); RenderHelper.EnableStandardItemLighting(); //GL.PopMatrix(); if (entityplayersp is EntityPlayerSP) { EntityPlayerSP entityplayersp1 = (EntityPlayerSP)entityplayersp; float f2 = entityplayersp1.PrevRenderArmPitch + (entityplayersp1.RenderArmPitch - entityplayersp1.PrevRenderArmPitch) * par1; float f4 = entityplayersp1.PrevRenderArmYaw + (entityplayersp1.RenderArmYaw - entityplayersp1.PrevRenderArmYaw) * par1; //GL.Rotate((((EntityPlayer)(entityplayersp)).RotationPitch - f2) * 0.1F, 1.0F, 0.0F, 0.0F); //GL.Rotate((((EntityPlayer)(entityplayersp)).RotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); } ItemStack itemstack = ItemToRender; float f3 = Mc.TheWorld.GetLightBrightness(MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosX), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosY), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosZ)); f3 = 1.0F; int i = Mc.TheWorld.GetLightBrightnessForSkyBlocks(MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosX), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosY), MathHelper2.Floor_double(((EntityPlayer)(entityplayersp)).PosZ), 0); int k = i % 0x10000; int l = i / 0x10000; OpenGlHelper.SetLightmapTextureCoords(OpenGlHelper.LightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); if (itemstack != null) { int j = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), 0); float f8 = (float)(j >> 16 & 0xff) / 255F; float f13 = (float)(j >> 8 & 0xff) / 255F; float f19 = (float)(j & 0xff) / 255F; //GL.Color4(f3 * f8, f3 * f13, f3 * f19, 1.0F); } else { //GL.Color4(f3, f3, f3, 1.0F); } if (itemstack != null && itemstack.ItemID == Item.Map.ShiftedIndex) { //GL.PushMatrix(); // float f5 = 0.8F; float f9 = entityplayersp.GetSwingProgress(par1); float f14 = MathHelper2.Sin(f9 * (float)Math.PI); float f20 = MathHelper2.Sin(MathHelper2.Sqrt_float(f9) * (float)Math.PI); //GL.Translate(-f20 * 0.4F, MathHelper.Sin(MathHelper.Sqrt_float(f9) * (float)Math.PI * 2.0F) * 0.2F, -f14 * 0.2F); f9 = (1.0F - f1 / 45F) + 0.1F; if (f9 < 0.0F) { f9 = 0.0F; } if (f9 > 1.0F) { f9 = 1.0F; } f9 = -MathHelper2.Cos(f9 * (float)Math.PI) * 0.5F + 0.5F; //GL.Translate(0.0F, (0.0F * f5 - (1.0F - f) * 1.2F - f9 * 0.5F) + 0.04F, -0.9F * f5); //GL.Rotate(90F, 0.0F, 1.0F, 0.0F); //GL.Rotate(f9 * -85F, 0.0F, 0.0F, 1.0F); //GL.Enable(EnableCap.RescaleNormal); //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTextureForDownloadableImage(Mc.ThePlayer.SkinUrl, Mc.ThePlayer.GetTexture())); for (f14 = 0; f14 < 2; f14++) { f20 = f14 * 2 - 1; //GL.PushMatrix(); //GL.Translate(-0F, -0.6F, 1.1F * (float)f20); //GL.Rotate(-45 * f20, 1.0F, 0.0F, 0.0F); //GL.Rotate(-90F, 0.0F, 0.0F, 1.0F); //GL.Rotate(59F, 0.0F, 0.0F, 1.0F); //GL.Rotate(-65 * f20, 0.0F, 1.0F, 0.0F); Render render1 = RenderManager.Instance.GetEntityRenderObject(Mc.ThePlayer); RenderPlayer renderplayer1 = (RenderPlayer)render1; // float f34 = 1.0F; //GL.Scale(f34, f34, f34); renderplayer1.DrawFirstPersonHand(); //GL.PopMatrix(); } f14 = entityplayersp.GetSwingProgress(par1); f20 = MathHelper2.Sin(f14 * f14 * (float)Math.PI); float f27 = MathHelper2.Sin(MathHelper2.Sqrt_float(f14) * (float)Math.PI); //GL.Rotate(-f20 * 20F, 0.0F, 1.0F, 0.0F); //GL.Rotate(-f27 * 20F, 0.0F, 0.0F, 1.0F); //GL.Rotate(-f27 * 80F, 1.0F, 0.0F, 0.0F); f14 = 0.38F; //GL.Scale(f14, f14, f14); //GL.Rotate(90F, 0.0F, 1.0F, 0.0F); //GL.Rotate(180F, 0.0F, 0.0F, 1.0F); //GL.Translate(-1F, -1F, 0.0F); f20 = 0.015625F; //GL.Scale(f20, f20, f20); Mc.RenderEngineOld.BindTexture(Mc.RenderEngineOld.GetTexture("/misc/mapbg.png")); Tessellator tessellator = Tessellator.Instance; //GL.Normal3(0.0F, 0.0F, -1F); tessellator.StartDrawingQuads(); sbyte byte0 = 7; tessellator.AddVertexWithUV(0 - byte0, 128 + byte0, 0.0F, 0.0F, 1.0D); tessellator.AddVertexWithUV(128 + byte0, 128 + byte0, 0.0F, 1.0D, 1.0D); tessellator.AddVertexWithUV(128 + byte0, 0 - byte0, 0.0F, 1.0D, 0.0F); tessellator.AddVertexWithUV(0 - byte0, 0 - byte0, 0.0F, 0.0F, 0.0F); tessellator.Draw(); MapData mapdata = Item.Map.GetMapData(itemstack, Mc.TheWorld); MapItemRenderer.RenderMap(Mc.ThePlayer, Mc.RenderEngineOld, mapdata); //GL.PopMatrix(); } else if (itemstack != null) { //GL.PushMatrix(); // float f6 = 0.8F; if (entityplayersp.GetItemInUseCount() > 0) { EnumAction enumaction = itemstack.GetItemUseAction(); if (enumaction == EnumAction.Eat || enumaction == EnumAction.Drink) { float f15 = ((float)entityplayersp.GetItemInUseCount() - par1) + 1.0F; float f21 = 1.0F - f15 / (float)itemstack.GetMaxItemUseDuration(); float f28 = f21; float f31 = 1.0F - f28; f31 = f31 * f31 * f31; f31 = f31 * f31 * f31; f31 = f31 * f31 * f31; float f35 = 1.0F - f31; //GL.Translate(0.0F, MathHelper.Abs(MathHelper.Cos((f15 / 4F) * (float)Math.PI) * 0.1F) * (float)((double)f28 <= 0.20000000000000001D ? 0 : 1), 0.0F); //GL.Translate(f35 * 0.6F, -f35 * 0.5F, 0.0F); //GL.Rotate(f35 * 90F, 0.0F, 1.0F, 0.0F); //GL.Rotate(f35 * 10F, 1.0F, 0.0F, 0.0F); //GL.Rotate(f35 * 30F, 0.0F, 0.0F, 1.0F); } } else { float f10 = entityplayersp.GetSwingProgress(par1); float f16 = MathHelper2.Sin(f10 * (float)Math.PI); float f22 = MathHelper2.Sin(MathHelper2.Sqrt_float(f10) * (float)Math.PI); //GL.Translate(-f22 * 0.4F, MathHelper.Sin(MathHelper.Sqrt_float(f10) * (float)Math.PI * 2.0F) * 0.2F, -f16 * 0.2F); } //GL.Translate(0.7F * f6, -0.65F * f6 - (1.0F - f) * 0.6F, -0.9F * f6); //GL.Rotate(45F, 0.0F, 1.0F, 0.0F); //GL.Enable(EnableCap.RescaleNormal); float f11 = entityplayersp.GetSwingProgress(par1); float f17 = MathHelper2.Sin(f11 * f11 * (float)Math.PI); float f23 = MathHelper2.Sin(MathHelper2.Sqrt_float(f11) * (float)Math.PI); //GL.Rotate(-f17 * 20F, 0.0F, 1.0F, 0.0F); //GL.Rotate(-f23 * 20F, 0.0F, 0.0F, 1.0F); //GL.Rotate(-f23 * 80F, 1.0F, 0.0F, 0.0F); f11 = 0.4F; //GL.Scale(f11, f11, f11); if (entityplayersp.GetItemInUseCount() > 0) { EnumAction enumaction1 = itemstack.GetItemUseAction(); if (enumaction1 == EnumAction.Block) { //GL.Translate(-0.5F, 0.2F, 0.0F); //GL.Rotate(30F, 0.0F, 1.0F, 0.0F); //GL.Rotate(-80F, 1.0F, 0.0F, 0.0F); //GL.Rotate(60F, 0.0F, 1.0F, 0.0F); } else if (enumaction1 == EnumAction.Bow) { //GL.Rotate(-18F, 0.0F, 0.0F, 1.0F); //GL.Rotate(-12F, 0.0F, 1.0F, 0.0F); //GL.Rotate(-8F, 1.0F, 0.0F, 0.0F); //GL.Translate(-0.9F, 0.2F, 0.0F); float f24 = (float)itemstack.GetMaxItemUseDuration() - (((float)entityplayersp.GetItemInUseCount() - par1) + 1.0F); float f29 = f24 / 20F; f29 = (f29 * f29 + f29 * 2.0F) / 3F; if (f29 > 1.0F) { f29 = 1.0F; } if (f29 > 0.1F) { //GL.Translate(0.0F, MathHelper.Sin((f24 - 0.1F) * 1.3F) * 0.01F * (f29 - 0.1F), 0.0F); } //GL.Translate(0.0F, 0.0F, f29 * 0.1F); //GL.Rotate(-335F, 0.0F, 0.0F, 1.0F); //GL.Rotate(-50F, 0.0F, 1.0F, 0.0F); //GL.Translate(0.0F, 0.5F, 0.0F); float f32 = 1.0F + f29 * 0.2F; //GL.Scale(1.0F, 1.0F, f32); //GL.Translate(0.0F, -0.5F, 0.0F); //GL.Rotate(50F, 0.0F, 1.0F, 0.0F); //GL.Rotate(335F, 0.0F, 0.0F, 1.0F); } } if (itemstack.GetItem().ShouldRotateAroundWhenRendering()) { //GL.Rotate(180F, 0.0F, 1.0F, 0.0F); } if (itemstack.GetItem().Func_46058_c()) { RenderItem(entityplayersp, itemstack, 0); int i1 = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), 1); float f25 = (float)(i1 >> 16 & 0xff) / 255F; float f30 = (float)(i1 >> 8 & 0xff) / 255F; float f33 = (float)(i1 & 0xff) / 255F; //GL.Color4(f3 * f25, f3 * f30, f3 * f33, 1.0F); RenderItem(entityplayersp, itemstack, 1); } else { RenderItem(entityplayersp, itemstack, 0); } //GL.PopMatrix(); } else { //GL.PushMatrix(); // float f7 = 0.8F; float f12 = entityplayersp.GetSwingProgress(par1); float f18 = MathHelper2.Sin(f12 * (float)Math.PI); float f26 = MathHelper2.Sin(MathHelper2.Sqrt_float(f12) * (float)Math.PI); //GL.Translate(-f26 * 0.3F, MathHelper.Sin(MathHelper.Sqrt_float(f12) * (float)Math.PI * 2.0F) * 0.4F, -f18 * 0.4F); //GL.Translate(0.8F * f7, -0.75F * f7 - (1.0F - f) * 0.6F, -0.9F * f7); //GL.Rotate(45F, 0.0F, 1.0F, 0.0F); //GL.Enable(EnableCap.RescaleNormal); f12 = entityplayersp.GetSwingProgress(par1); f18 = MathHelper2.Sin(f12 * f12 * (float)Math.PI); f26 = MathHelper2.Sin(MathHelper2.Sqrt_float(f12) * (float)Math.PI); //GL.Rotate(f26 * 70F, 0.0F, 1.0F, 0.0F); //GL.Rotate(-f18 * 20F, 0.0F, 0.0F, 1.0F); //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTextureForDownloadableImage(Mc.ThePlayer.SkinUrl, Mc.ThePlayer.GetTexture())); //GL.Translate(-1F, 3.6F, 3.5F); //GL.Rotate(120F, 0.0F, 0.0F, 1.0F); //GL.Rotate(200F, 1.0F, 0.0F, 0.0F); //GL.Rotate(-135F, 0.0F, 1.0F, 0.0F); //GL.Scale(1.0F, 1.0F, 1.0F); //GL.Translate(5.6F, 0.0F, 0.0F); Render render = RenderManager.Instance.GetEntityRenderObject(Mc.ThePlayer); RenderPlayer renderplayer = (RenderPlayer)render; f26 = 1.0F; //GL.Scale(f26, f26, f26); renderplayer.DrawFirstPersonHand(); //GL.PopMatrix(); } //GL.Disable(EnableCap.RescaleNormal); RenderHelper.DisableStandardItemLighting(); }
/// <summary> /// Renders the item stack for being in an entity's hand Args: itemStack /// </summary> public virtual void RenderItem(EntityLiving par1EntityLiving, ItemStack par2ItemStack, int par3) { //GL.PushMatrix(); if (par2ItemStack.ItemID < 256 && RenderBlocks.RenderItemIn3d(Block.BlocksList[par2ItemStack.ItemID].GetRenderType())) { //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTexture("/terrain.png")); RenderBlocksInstance.RenderBlockAsItem(Block.BlocksList[par2ItemStack.ItemID], par2ItemStack.GetItemDamage(), 1.0F); } else { if (par2ItemStack.ItemID < 256) { //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTexture("/terrain.png")); } else { //GL.BindTexture(TextureTarget.Texture2D, Mc.RenderEngineOld.GetTexture("/gui/items.png")); } Tessellator tessellator = Tessellator.Instance; int i = par1EntityLiving.GetItemIcon(par2ItemStack, par3); float f = ((float)((i % 16) * 16) + 0.0F) / 256F; float f1 = ((float)((i % 16) * 16) + 15.99F) / 256F; float f2 = ((float)((i / 16) * 16) + 0.0F) / 256F; float f3 = ((float)((i / 16) * 16) + 15.99F) / 256F; // float f4 = 0.0F; // float f5 = 0.3F; //GL.Enable(EnableCap.RescaleNormal); //GL.Translate(-f4, -f5, 0.0F); // float f6 = 1.5F; //GL.Scale(f6, f6, f6); //GL.Rotate(50F, 0.0F, 1.0F, 0.0F); //GL.Rotate(335F, 0.0F, 0.0F, 1.0F); //GL.Translate(-0.9375F, -0.0625F, 0.0F); RenderItemIn2D(tessellator, f1, f2, f, f3); if (par2ItemStack != null && par2ItemStack.HasEffect() && par3 == 0) { //GL.DepthFunc(DepthFunction.Equal); //GL.Disable(EnableCap.Lighting); Mc.RenderEngineOld.BindTexture(Mc.RenderEngineOld.GetTexture("%blur%/misc/glint.png")); //GL.Enable(EnableCap.Blend); //GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); // float f7 = 0.76F; //GL.Color4(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); //GL.MatrixMode(MatrixMode.Texture); //GL.PushMatrix(); // float f8 = 0.125F; //GL.Scale(f8, f8, f8); float f9 = ((float)(JavaHelper.CurrentTimeMillis() % 3000L) / 3000F) * 8F; //GL.Translate(f9, 0.0F, 0.0F); //GL.Rotate(-50F, 0.0F, 0.0F, 1.0F); RenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F); //GL.PopMatrix(); //GL.PushMatrix(); //GL.Scale(f8, f8, f8); f9 = ((float)(JavaHelper.CurrentTimeMillis() % 4873L) / 4873F) * 8F; //GL.Translate(-f9, 0.0F, 0.0F); //GL.Rotate(10F, 0.0F, 0.0F, 1.0F); RenderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F); //GL.PopMatrix(); //GL.MatrixMode(MatrixMode.Modelview); //GL.Disable(EnableCap.Blend); //GL.Enable(EnableCap.Lighting); //GL.DepthFunc(DepthFunction.Lequal); } //GL.Disable(EnableCap.RescaleNormal); } //GL.PopMatrix(); }
/// <summary> /// Called whenever the block is removed. /// </summary> public override void OnBlockRemoval(World par1World, int par2, int par3, int par4) { TileEntityChest tileentitychest = (TileEntityChest)par1World.GetBlockTileEntity(par2, par3, par4); if (tileentitychest != null) { for (int i = 0; i < tileentitychest.GetSizeInventory(); i++) { ItemStack itemstack = tileentitychest.GetStackInSlot(i); if (itemstack == null) { continue; } float f = Random.NextFloat() * 0.8F + 0.1F; float f1 = Random.NextFloat() * 0.8F + 0.1F; float f2 = Random.NextFloat() * 0.8F + 0.1F; while (itemstack.StackSize > 0) { int j = Random.Next(21) + 10; if (j > itemstack.StackSize) { j = itemstack.StackSize; } itemstack.StackSize -= j; EntityItem entityitem = new EntityItem(par1World, (float)par2 + f, (float)par3 + f1, (float)par4 + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage())); float f3 = 0.05F; entityitem.MotionX = (float)Random.NextGaussian() * f3; entityitem.MotionY = (float)Random.NextGaussian() * f3 + 0.2F; entityitem.MotionZ = (float)Random.NextGaussian() * f3; if (itemstack.HasTagCompound()) { entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy()); } par1World.SpawnEntityInWorld(entityitem); } } } base.OnBlockRemoval(par1World, par2, par3, par4); }
/// <summary> /// Renders the item /// </summary> public virtual void DoRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) { Random.SetSeed(187); ItemStack itemstack = par1EntityItem.ItemStack; //GL.PushMatrix(); float f = MathHelper2.Sin(((float)par1EntityItem.Age + par9) / 10F + par1EntityItem.Field_804_d) * 0.1F + 0.1F; float f1 = (((float)par1EntityItem.Age + par9) / 20F + par1EntityItem.Field_804_d) * (180F / (float)Math.PI); sbyte byte0 = 1; if (par1EntityItem.ItemStack.StackSize > 1) { byte0 = 2; } if (par1EntityItem.ItemStack.StackSize > 5) { byte0 = 3; } if (par1EntityItem.ItemStack.StackSize > 20) { byte0 = 4; } //GL.Translate((float)par2, (float)par4 + f, (float)par6); //GL.Enable(EnableCap.RescaleNormal); if (itemstack.ItemID < 256 && RenderBlocks.RenderItemIn3d(Block.BlocksList[itemstack.ItemID].GetRenderType())) { //GL.Rotate(f1, 0.0F, 1.0F, 0.0F); LoadTexture("/terrain.png"); float f2 = 0.25F; int k = Block.BlocksList[itemstack.ItemID].GetRenderType(); if (k == 1 || k == 19 || k == 12 || k == 2) { f2 = 0.5F; } //GL.Scale(f2, f2, f2); for (int j1 = 0; j1 < byte0; j1++) { //GL.PushMatrix(); if (j1 > 0) { float f5 = ((Random.NextFloat() * 2.0F - 1.0F) * 0.2F) / f2; float f8 = ((Random.NextFloat() * 2.0F - 1.0F) * 0.2F) / f2; float f11 = ((Random.NextFloat() * 2.0F - 1.0F) * 0.2F) / f2; //GL.Translate(f5, f8, f11); } float f6 = 1.0F; RenderBlocks.RenderBlockAsItem(Block.BlocksList[itemstack.ItemID], itemstack.GetItemDamage(), f6); //GL.PopMatrix(); } } else if (itemstack.GetItem().Func_46058_c()) { //GL.Scale(0.5F, 0.5F, 0.5F); LoadTexture("/gui/items.png"); for (int i = 0; i <= 1; i++) { int l = itemstack.GetItem().Func_46057_a(itemstack.GetItemDamage(), i); float f3 = 1.0F; if (Field_27004_a) { int k1 = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), i); float f9 = (float)(k1 >> 16 & 0xff) / 255F; float f12 = (float)(k1 >> 8 & 0xff) / 255F; float f14 = (float)(k1 & 0xff) / 255F; //GL.Color4(f9 * f3, f12 * f3, f14 * f3, 1.0F); } Func_40267_a(l, byte0); } } else { //GL.Scale(0.5F, 0.5F, 0.5F); int j = itemstack.GetIconIndex(); if (itemstack.ItemID < 256) { LoadTexture("/terrain.png"); } else { LoadTexture("/gui/items.png"); } if (Field_27004_a) { int i1 = Item.ItemsList[itemstack.ItemID].GetColorFromDamage(itemstack.GetItemDamage(), 0); float f4 = (float)(i1 >> 16 & 0xff) / 255F; float f7 = (float)(i1 >> 8 & 0xff) / 255F; float f10 = (float)(i1 & 0xff) / 255F; float f13 = 1.0F; //GL.Color4(f4 * f13, f7 * f13, f10 * f13, 1.0F); } Func_40267_a(j, byte0); } //GL.Disable(EnableCap.RescaleNormal); //GL.PopMatrix(); }
/// <summary> /// Returns the icon index of the stack given as argument. /// </summary> public int GetIconIndex(ItemStack par1ItemStack) { return(GetIconFromDamage(par1ItemStack.GetItemDamage())); }
/// <summary> /// Returns a list of potion effects for the specified itemstack. /// </summary> public virtual List <PotionEffect> GetEffects(ItemStack par1ItemStack) { return(GetEffects(par1ItemStack.GetItemDamage())); }
/// <summary> /// merges provided ItemStack with the first avaliable one in the container/player inventory /// </summary> protected virtual bool MergeItemStack(ItemStack par1ItemStack, int par2, int par3, bool par4) { bool flag = false; int i = par2; if (par4) { i = par3 - 1; } if (par1ItemStack.IsStackable()) { while (par1ItemStack.StackSize > 0 && (!par4 && i < par3 || par4 && i >= par2)) { Slot slot = InventorySlots[i]; ItemStack itemstack = slot.GetStack(); if (itemstack != null && itemstack.ItemID == par1ItemStack.ItemID && (!par1ItemStack.GetHasSubtypes() || par1ItemStack.GetItemDamage() == itemstack.GetItemDamage()) && ItemStack.Func_46154_a(par1ItemStack, itemstack)) { int k = itemstack.StackSize + par1ItemStack.StackSize; if (k <= par1ItemStack.GetMaxStackSize()) { par1ItemStack.StackSize = 0; itemstack.StackSize = k; slot.OnSlotChanged(); flag = true; } else if (itemstack.StackSize < par1ItemStack.GetMaxStackSize()) { par1ItemStack.StackSize -= par1ItemStack.GetMaxStackSize() - itemstack.StackSize; itemstack.StackSize = par1ItemStack.GetMaxStackSize(); slot.OnSlotChanged(); flag = true; } } if (par4) { i--; } else { i++; } } } if (par1ItemStack.StackSize > 0) { int j; if (par4) { j = par3 - 1; } else { j = par2; } do { if ((par4 || j >= par3) && (!par4 || j < par2)) { break; } Slot slot1 = InventorySlots[j]; ItemStack itemstack1 = slot1.GetStack(); if (itemstack1 == null) { slot1.PutStack(par1ItemStack.Copy()); slot1.OnSlotChanged(); par1ItemStack.StackSize = 0; flag = true; break; } if (par4) { j--; } else { j++; } }while (true); } return(flag); }
public virtual ItemStack SlotClick(int par1, int par2, bool par3, EntityPlayer par4EntityPlayer) { ItemStack itemstack = null; if (par2 > 1) { return(null); } if (par2 == 0 || par2 == 1) { InventoryPlayer inventoryplayer = par4EntityPlayer.Inventory; if (par1 == -999) { if (inventoryplayer.GetItemStack() != null && par1 == -999) { if (par2 == 0) { par4EntityPlayer.DropPlayerItem(inventoryplayer.GetItemStack()); inventoryplayer.SetItemStack(null); } if (par2 == 1) { par4EntityPlayer.DropPlayerItem(inventoryplayer.GetItemStack().SplitStack(1)); if (inventoryplayer.GetItemStack().StackSize == 0) { inventoryplayer.SetItemStack(null); } } } } else if (par3) { ItemStack itemstack1 = TransferStackInSlot(par1); if (itemstack1 != null) { int i = itemstack1.ItemID; itemstack = itemstack1.Copy(); Slot slot1 = InventorySlots[par1]; if (slot1 != null && slot1.GetStack() != null && slot1.GetStack().ItemID == i) { RetrySlotClick(par1, par2, par3, par4EntityPlayer); } } } else { if (par1 < 0) { return(null); } Slot slot = InventorySlots[par1]; if (slot != null) { slot.OnSlotChanged(); ItemStack itemstack2 = slot.GetStack(); ItemStack itemstack4 = inventoryplayer.GetItemStack(); if (itemstack2 != null) { itemstack = itemstack2.Copy(); } if (itemstack2 == null) { if (itemstack4 != null && slot.IsItemValid(itemstack4)) { int j = par2 != 0 ? 1 : itemstack4.StackSize; if (j > slot.GetSlotStackLimit()) { j = slot.GetSlotStackLimit(); } slot.PutStack(itemstack4.SplitStack(j)); if (itemstack4.StackSize == 0) { inventoryplayer.SetItemStack(null); } } } else if (itemstack4 == null) { int k = par2 != 0 ? (itemstack2.StackSize + 1) / 2 : itemstack2.StackSize; ItemStack itemstack6 = slot.DecrStackSize(k); inventoryplayer.SetItemStack(itemstack6); if (itemstack2.StackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } else if (slot.IsItemValid(itemstack4)) { if (itemstack2.ItemID != itemstack4.ItemID || itemstack2.GetHasSubtypes() && itemstack2.GetItemDamage() != itemstack4.GetItemDamage() || !ItemStack.Func_46154_a(itemstack2, itemstack4)) { if (itemstack4.StackSize <= slot.GetSlotStackLimit()) { ItemStack itemstack5 = itemstack2; slot.PutStack(itemstack4); inventoryplayer.SetItemStack(itemstack5); } } else { int l = par2 != 0 ? 1 : itemstack4.StackSize; if (l > slot.GetSlotStackLimit() - itemstack2.StackSize) { l = slot.GetSlotStackLimit() - itemstack2.StackSize; } if (l > itemstack4.GetMaxStackSize() - itemstack2.StackSize) { l = itemstack4.GetMaxStackSize() - itemstack2.StackSize; } itemstack4.SplitStack(l); if (itemstack4.StackSize == 0) { inventoryplayer.SetItemStack(null); } itemstack2.StackSize += l; } } else if (itemstack2.ItemID == itemstack4.ItemID && itemstack4.GetMaxStackSize() > 1 && (!itemstack2.GetHasSubtypes() || itemstack2.GetItemDamage() == itemstack4.GetItemDamage()) && ItemStack.Func_46154_a(itemstack2, itemstack4)) { int i1 = itemstack2.StackSize; if (i1 > 0 && i1 + itemstack4.StackSize <= itemstack4.GetMaxStackSize()) { itemstack4.StackSize += i1; ItemStack itemstack3 = slot.DecrStackSize(i1); if (itemstack3.StackSize == 0) { slot.PutStack(null); } slot.OnPickupFromSlot(inventoryplayer.GetItemStack()); } } } } } return(itemstack); }
/// <summary> /// Will get destroyed next tick. /// </summary> public override void SetDead() { label0: for (int i = 0; i < GetSizeInventory(); i++) { ItemStack itemstack = GetStackInSlot(i); if (itemstack == null) { continue; } float f = Rand.NextFloat() * 0.8F + 0.1F; float f1 = Rand.NextFloat() * 0.8F + 0.1F; float f2 = Rand.NextFloat() * 0.8F + 0.1F; do { if (itemstack.StackSize <= 0) { goto label0; } int j = Rand.Next(21) + 10; if (j > itemstack.StackSize) { j = itemstack.StackSize; } itemstack.StackSize -= j; EntityItem entityitem = new EntityItem(WorldObj, PosX + f, PosY + f1, PosZ + f2, new ItemStack(itemstack.ItemID, j, itemstack.GetItemDamage())); if (itemstack.HasTagCompound()) { entityitem.ItemStack.SetTagCompound((NBTTagCompound)itemstack.GetTagCompound().Copy()); } float f3 = 0.05F; entityitem.MotionX = (float)Rand.NextGaussian() * f3; entityitem.MotionY = (float)Rand.NextGaussian() * f3 + 0.2F; entityitem.MotionZ = (float)Rand.NextGaussian() * f3; WorldObj.SpawnEntityInWorld(entityitem); }while (true); } base.SetDead(); }