Made Scrapboxinator functional to a extent

Fix progressbar flicker(Major one)
Opens the scrapbox now and has a vaild output
This commit is contained in:
Dimmerworld 2017-10-04 15:37:09 +11:00
parent e5e05d0afd
commit 4c1d011544

View file

@ -75,8 +75,11 @@ public class TileScrapboxinator extends TilePowerAcceptor
return this.progress * scale / runTime; return this.progress * scale / runTime;
} }
//todo Fix external interactions (Hopper etc) - Balance power - Fix progress bar flicker
@Override @Override
public void updateEntity() { public void update() {
final boolean burning = this.isBurning(); final boolean burning = this.isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (this.getEnergy() <= cost && this.canOpen()) { if (this.getEnergy() <= cost && this.canOpen()) {
@ -84,7 +87,7 @@ public class TileScrapboxinator extends TilePowerAcceptor
updateInventory = true; updateInventory = true;
} }
} }
if (this.isBurning() && this.canOpen()) { if (this.isBurning() && this.canOpen() && !this.isEmpty()) {
this.updateState(); this.updateState();
this.progress++; this.progress++;
@ -94,9 +97,12 @@ public class TileScrapboxinator extends TilePowerAcceptor
updateInventory = true; updateInventory = true;
} }
} else { } else {
this.progress = 0; if(this.isEmpty()) {
progress = 0;
}
this.updateState(); this.updateState();
} }
if (burning != this.isBurning()) { if (burning != this.isBurning()) {
updateInventory = true; updateInventory = true;
} }
@ -107,9 +113,9 @@ public class TileScrapboxinator extends TilePowerAcceptor
public void recycleItems() { public void recycleItems() {
if (this.canOpen() && !this.world.isRemote) { if (this.canOpen() && !this.world.isRemote) {
final int random = new Random().nextInt(ScrapboxList.stacks.size()); int random = world.rand.nextInt(ScrapboxList.stacks.size());
final ItemStack out = ScrapboxList.stacks.get(random).copy(); ItemStack out = ScrapboxList.stacks.get(random).copy();
if (this.getStackInSlot(this.output) == null) { if (this.getStackInSlot(this.output).isEmpty()) {
this.useEnergy(cost); this.useEnergy(cost);
this.setInventorySlotContents(this.output, out); this.setInventorySlotContents(this.output, out);
} }