Crash fix
This commit is contained in:
@@ -87,17 +87,6 @@ public abstract class ItemGenerator extends PowerGenerator{
|
|||||||
float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency;
|
float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency;
|
||||||
float mfract = maxPower / (powerOutput);
|
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){
|
if(entity.generateTime <= 0f && entity.items.total() > 0){
|
||||||
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
|
||||||
Item item = entity.items.take();
|
Item item = entity.items.take();
|
||||||
@@ -106,7 +95,19 @@ public abstract class ItemGenerator extends PowerGenerator{
|
|||||||
entity.generateTime = 1f;
|
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);
|
protected abstract float getItemEfficiency(Item item);
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ public abstract class ItemLiquidGenerator extends ItemGenerator{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
ItemGeneratorEntity entity = tile.entity();
|
ItemGeneratorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
entity.power.graph.update();
|
||||||
|
|
||||||
Liquid liquid = null;
|
Liquid liquid = null;
|
||||||
for(Liquid other : content.liquids()){
|
for(Liquid other : content.liquids()){
|
||||||
if(entity.liquids.get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){
|
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 maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * entity.delta()) * entity.efficiency;
|
||||||
float mfract = maxPower / (powerOutput);
|
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){
|
if(entity.generateTime > 0f){
|
||||||
entity.generateTime -= 1f / itemDuration * mfract * entity.delta();
|
entity.generateTime -= 1f / itemDuration * mfract * entity.delta();
|
||||||
entity.power.amount += maxPower;
|
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));
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user