mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-06 00:49:14 +07:00
Fixed conveyors/conduits not using items
This commit is contained in:
parent
7a4f56d943
commit
a683866397
@ -186,6 +186,7 @@ public class BuildBlock extends Block {
|
|||||||
public Recipe recipe;
|
public Recipe recipe;
|
||||||
|
|
||||||
public double progress = 0;
|
public double progress = 0;
|
||||||
|
public double lastProgress;
|
||||||
public Block previous;
|
public Block previous;
|
||||||
public Player lastBuilder;
|
public Player lastBuilder;
|
||||||
|
|
||||||
@ -193,6 +194,21 @@ public class BuildBlock extends Block {
|
|||||||
private boolean updated;
|
private boolean updated;
|
||||||
|
|
||||||
public void addProgress(InventoryModule inventory, double amount){
|
public void addProgress(InventoryModule inventory, double amount){
|
||||||
|
double maxProgress = checkRequired(inventory, amount);
|
||||||
|
|
||||||
|
for (int i = 0; i < recipe.requirements.length; i++) {
|
||||||
|
accumulator[i] += recipe.requirements[i].amount*maxProgress; //add min amount progressed to the accumulator
|
||||||
|
}
|
||||||
|
|
||||||
|
maxProgress = checkRequired(inventory, maxProgress);
|
||||||
|
|
||||||
|
progress += maxProgress;
|
||||||
|
|
||||||
|
lastProgress = maxProgress;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double checkRequired(InventoryModule inventory, double amount){
|
||||||
double maxProgress = amount;
|
double maxProgress = amount;
|
||||||
|
|
||||||
for(int i = 0; i < recipe.requirements.length; i ++){
|
for(int i = 0; i < recipe.requirements.length; i ++){
|
||||||
@ -204,8 +220,6 @@ public class BuildBlock extends Block {
|
|||||||
//get this as a fraction
|
//get this as a fraction
|
||||||
double fraction = maxUse / (double)required;
|
double fraction = maxUse / (double)required;
|
||||||
|
|
||||||
//accumulator[i] -= recipe.requirements[i].amount*amount*(1-fraction);
|
|
||||||
|
|
||||||
//move max progress down if this fraction is less than 1
|
//move max progress down if this fraction is less than 1
|
||||||
maxProgress = Math.min(maxProgress, maxProgress*fraction);
|
maxProgress = Math.min(maxProgress, maxProgress*fraction);
|
||||||
|
|
||||||
@ -216,12 +230,7 @@ public class BuildBlock extends Block {
|
|||||||
//else, no items are required yet, so just keep going
|
//else, no items are required yet, so just keep going
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < recipe.requirements.length; i++) {
|
return maxProgress;
|
||||||
accumulator[i] += recipe.requirements[i].amount*maxProgress; //add min amount progressed to the accumulator
|
|
||||||
}
|
|
||||||
|
|
||||||
progress += maxProgress;
|
|
||||||
updated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float progress(){
|
public float progress(){
|
||||||
|
Loading…
Reference in New Issue
Block a user