diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java index 6739fec89f..3619c33b6f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java @@ -87,17 +87,6 @@ public abstract class ItemGenerator extends PowerGenerator{ float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency; float mfract = maxPower / (powerOutput); - if(entity.generateTime > 0f){ - entity.generateTime -= 1f / itemDuration * mfract * entity.delta(); - entity.power.amount += maxPower; - entity.generateTime = Mathf.clamp(entity.generateTime); - - if(Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ - entity.damage(Mathf.random(8f)); - Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); - } - } - if(entity.generateTime <= 0f && entity.items.total() > 0){ Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f)); Item item = entity.items.take(); @@ -106,7 +95,19 @@ public abstract class ItemGenerator extends PowerGenerator{ entity.generateTime = 1f; } - tile.entity.power.graph.update(); + entity.power.graph.update(); + + if(entity.generateTime > 0f){ + entity.generateTime -= 1f / itemDuration * mfract * entity.delta(); + entity.power.amount += maxPower; + entity.generateTime = Mathf.clamp(entity.generateTime); + + if(Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.25f))){ + //this block is run last so that in the event of a block destruction, no code relies on the block type + entity.damage(Mathf.random(8f)); + Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); + } + } } protected abstract float getItemEfficiency(Item item); diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java index a4fd452e47..3e9d8dfaa7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -32,6 +32,8 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{ public void update(Tile tile){ ItemGeneratorEntity entity = tile.entity(); + entity.power.graph.update(); + Liquid liquid = null; for(Liquid other : content.liquids()){ if(entity.liquids.get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){ @@ -57,6 +59,14 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{ float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency; float mfract = maxPower / (powerOutput); + if(entity.generateTime <= 0f && entity.items.total() > 0){ + Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f)); + Item item = entity.items.take(); + entity.efficiency = getItemEfficiency(item); + entity.explosiveness = item.explosiveness; + entity.generateTime = 1f; + } + if(entity.generateTime > 0f){ entity.generateTime -= 1f / itemDuration * mfract * entity.delta(); entity.power.amount += maxPower; @@ -67,17 +77,7 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{ Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); } } - - if(entity.generateTime <= 0f && entity.items.total() > 0){ - Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f)); - Item item = entity.items.take(); - entity.efficiency = getItemEfficiency(item); - entity.explosiveness = item.explosiveness; - entity.generateTime = 1f; - } } - - tile.entity.power.graph.update(); } @Override