public static void UpdateMiningSpeeds(string speedID, MiningSpeed measurements) { if (!MiningSpeeds.ContainsKey(speedID)) { MiningSpeeds[speedID] = new List <MiningSpeed>(); } if (MiningSpeeds[speedID].Count() == MaxHistory) { MiningSpeeds[speedID].RemoveAt(0); } MiningSpeeds[speedID].Add(measurements); }
public MinerRates(MiningSpeed miningSpeed) { try { speed = miningSpeed; WebClient webClient = new WebClient(); webClient.Proxy = null; string json = webClient.DownloadString(serviceAddress); var minerRates = GetMinerRates(json); FastestFee = minerRates.fastestFee; HalfHourFee = minerRates.halfHourFee; HourFee = minerRates.hourFee; } catch (Exception err) { Console.WriteLine($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}"); } }
//credit to stitch37 for this code public void destroyBlocks(IWorldAccessor world, BlockPos min, BlockPos max, IPlayer player, BlockPos centerBlockPos, ItemSlot slot) { int energy = slot.Itemstack.Attributes.GetInt("energy", 0); var centerBlock = world.BlockAccessor.GetBlock(centerBlockPos); var itemStack = new ItemStack(this); Block tempBlock; var miningTimeMainBlock = GetMiningSpeed(itemStack, centerBlock, player); float miningTime; var tempPos = new BlockPos(); for (int x = min.X; x <= max.X; x++) { for (int y = min.Y; y <= max.Y; y++) { for (int z = min.Z; z <= max.Z; z++) { tempPos.Set(x, y, z); tempBlock = world.BlockAccessor.GetBlock(tempPos); if (player.WorldData.CurrentGameMode == EnumGameMode.Creative) { world.BlockAccessor.SetBlock(0, tempPos); } else { if (energy >= consume) { miningTime = tempBlock.GetMiningSpeed(itemStack, tempBlock, player); if (this.ToolTier >= tempBlock.RequiredMiningTier && miningTimeMainBlock * 1.5f >= miningTime && MiningSpeed.ContainsKey(tempBlock.BlockMaterial)) { world.BlockAccessor.BreakBlock(tempPos, player); } } } } } } }
public void destroyBlocks(IWorldAccessor world, BlockPos min, BlockPos max, IPlayer player, BlockPos centerBlockPos) { var centerBlock = world.BlockAccessor.GetBlock(centerBlockPos); var itemStack = new ItemStack(this); Block tempBlock; var miningTimeMainBlock = GetMiningSpeed(itemStack, centerBlock, player); float miningTime; var tempPos = new BlockPos(); for (int x = min.X; x <= max.X; x++) { for (int y = min.Y; y <= max.Y; y++) { for (int z = min.Z; z <= max.Z; z++) { tempPos.Set(x, y, z); tempBlock = world.BlockAccessor.GetBlock(tempPos); if (player.WorldData.CurrentGameMode == EnumGameMode.Creative) { world.BlockAccessor.SetBlock(0, tempPos); } else { //Check if we can mine this block miningTime = tempBlock.GetMiningSpeed(itemStack, tempBlock, player); if (this.ToolTier >= tempBlock.RequiredMiningTier && //Нужный уровень инструмента miningTimeMainBlock * 1.5f >= miningTime && //Время добычи не сильно отличается MiningSpeed.ContainsKey(tempBlock.BlockMaterial)) //И материал металл или камень { world.BlockAccessor.BreakBlock(tempPos, player); } } } } } }
private void UpdateMinerText() { MiningSpeedText.text = "Mining speed: " + MiningSpeed.ToString("0.##") + " / s"; }