private void DigBlock(int x, int y, Player player, float digStrength, bool mining) { if (digHardness == null) resetDigHardness(); if (!(x > 0 && y > 0 && x < bot.room.Width && y < bot.room.Height)) return; if (digHardness[x, y] <= 0) return; Block block = bot.room.getBlock(0, x, y); int blockId = -1; if (mining) { if (DigBlockMap.blockTranslator.ContainsKey(block.blockId)) { blockId = 4; BlockItem temp = (BlockItem)DigBlockMap.blockTranslator[block.blockId]; if (player.digLevel + 5 >= temp.Hardness) { if (digHardness[x, y] <= digStrength) { BlockItem newsak = new BlockItem(temp); player.inventory.AddItem(newsak, 1); player.digXp += (int)Math.Round((float)temp.XPGain * (float)player.Pickaxe.XPModifier); } if (player.hasPickaxe()) { player.Pickaxe.onDamage(temp.Hardness); if (player.Pickaxe.Durability <= 0) { PickaxeItem bestPick = null; for (int slot = 0; slot < player.inventory.capacity; slot++) { InventoryItem item = player.inventory.GetItem(slot); if (item != null && item.ItemType == (int)ItemType.Pickaxe) { PickaxeItem pick = (PickaxeItem)item; if (bestPick == null || (pick.Hardness > bestPick.Hardness && pick.Hardness <= player.Pickaxe.Hardness && pick != player.Pickaxe)) { bestPick = pick; } } } if (bestPick != null) { player.Pickaxe = bestPick; bot.connection.Send("say", player.name + ": Pickaxe broke! You now use an other one in your inventory."); } else bot.connection.Send("say", player.name + ": Pickaxe broke! Get another one!"); player.inventory.RemoveItem(player.Pickaxe, 1); return; } } } else { return; } } } switch (block.blockId) { case 142: blockId = 4; break; case 197: blockId = 119; break; case 21: blockId = 369; break; default: if (blockId == -1) return; else break; } digHardness[x, y] -= digStrength; if (digHardness[x, y] <= 0) { bot.room.DrawBlock(Block.CreateBlock(0, x, y, blockId, -1)); lock (dugBlocksToPlaceQueueLock) dugBlocksToPlaceQueue.Enqueue(block); } }
public BlockItem(BlockItem item) { SetData(item.GetData()); }