public override void OnTick(Level world) { Random random = new Random(); int x = Coordinates.X; int y = Coordinates.Y; int z = Coordinates.Z; int currentDecay = GetFlowDecay(world, x, y, z); byte multiplier = 1; if (this is FlowingLava) { multiplier = 2; } bool flag = true; int tickRate = TickRate(); if (currentDecay > 0) { int smallestFlowDecay = -100; _adjacentSources = 0; smallestFlowDecay = GetSmallestFlowDecay(world, x - 1, y, z, smallestFlowDecay); smallestFlowDecay = GetSmallestFlowDecay(world, x + 1, y, z, smallestFlowDecay); smallestFlowDecay = GetSmallestFlowDecay(world, x, y, z - 1, smallestFlowDecay); smallestFlowDecay = GetSmallestFlowDecay(world, x, y, z + 1, smallestFlowDecay); int newDecay = smallestFlowDecay + multiplier; if (newDecay >= 8 || smallestFlowDecay < 0) { newDecay = -1; } if (GetFlowDecay(world, x, y + 1, z) >= 0) { int topFlowDecay = GetFlowDecay(world, x, y + 1, z); if (topFlowDecay >= 8) { newDecay = topFlowDecay; } else { newDecay = topFlowDecay + 8; } } if (_adjacentSources >= 2 && this is FlowingWater) { if (world.GetBlock(x, y - 1, z).IsSolid) { newDecay = 0; } else if (IsSameMaterial(world.GetBlock(x, y - 1, z)) && world.GetBlock(x, y - 1, z).Metadata == 0) { newDecay = 0; } } if (this is FlowingLava && currentDecay < 8 && newDecay < 8 && newDecay > currentDecay && random.Next(4) != 0) { //newDecay = currentDecay; //flag = false; tickRate *= 4; } if (newDecay == currentDecay) { if (flag) { SetToStill(world, x, y, z); } } else { currentDecay = newDecay; if (newDecay < 0) { world.SetAir(x, y, z); } else { world.SetData(x, y, z, (byte) newDecay); world.ApplyPhysics(x, y, z); world.ScheduleBlockTick(this, tickRate); // Schedule tick } } } else { SetToStill(world, x, y, z); } if (CanBeFlownInto(world, x, y - 1, z) /* || world.GetBlock(x, y - 1, z) is Flowing*/) { if (this is FlowingLava && (world.GetBlock(x, y - 1, z) is FlowingWater || world.GetBlock(x, y - 1, z) is StationaryWater)) { world.SetBlock(new Cobblestone {Coordinates = new BlockCoordinates(x, y - 1, z)}); return; } if (currentDecay >= 8) { Flow(world, x, y - 1, z, currentDecay); } else { Flow(world, x, y - 1, z, currentDecay + 8); } } else if (currentDecay >= 0 && (currentDecay == 0 || BlocksFluid(world, x, y - 1, z))) { bool[] optimalFlowDirections = GetOptimalFlowDirections(world, x, y, z); int newDecay = currentDecay + multiplier; if (currentDecay >= 8) { newDecay = 1; } if (newDecay >= 8) { return; } if (optimalFlowDirections[0]) { Flow(world, x - 1, y, z, newDecay); } if (optimalFlowDirections[1]) { Flow(world, x + 1, y, z, newDecay); } if (optimalFlowDirections[2]) { Flow(world, x, y, z - 1, newDecay); } if (optimalFlowDirections[3]) { Flow(world, x, y, z + 1, newDecay); } } }