Fix a few more issues with the fusion reactor
This commit is contained in:
parent
d7cfbcd443
commit
b01eb38863
1 changed files with 11 additions and 22 deletions
|
@ -56,7 +56,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
public int coilCount = 0;
|
public int coilCount = 0;
|
||||||
public int crafingTickTime = 0;
|
public int crafingTickTime = 0;
|
||||||
public int finalTickTime = 0;
|
|
||||||
public int neededPower = 0;
|
public int neededPower = 0;
|
||||||
public int size = 6;
|
public int size = 6;
|
||||||
public int state = -1;
|
public int state = -1;
|
||||||
|
@ -108,7 +107,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
private void resetCrafter() {
|
private void resetCrafter() {
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
crafingTickTime = 0;
|
crafingTickTime = 0;
|
||||||
finalTickTime = 0;
|
|
||||||
neededPower = 0;
|
neededPower = 0;
|
||||||
hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
}
|
}
|
||||||
|
@ -145,8 +143,9 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
* @return int Scale of progress
|
* @return int Scale of progress
|
||||||
*/
|
*/
|
||||||
public int getProgressScaled(int scale) {
|
public int getProgressScaled(int scale) {
|
||||||
if (crafingTickTime != 0 && finalTickTime != 0) {
|
FusionReactorRecipe reactorRecipe = getCurrentRecipeFromID();
|
||||||
return crafingTickTime * scale / finalTickTime;
|
if (crafingTickTime != 0 && reactorRecipe != null && reactorRecipe.getTime() != 0) {
|
||||||
|
return crafingTickTime * scale / reactorRecipe.getTime();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +158,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
if (validateRecipe((FusionReactorRecipe) recipe)) {
|
if (validateRecipe((FusionReactorRecipe) recipe)) {
|
||||||
currentRecipe = (FusionReactorRecipe) recipe;
|
currentRecipe = (FusionReactorRecipe) recipe;
|
||||||
crafingTickTime = 0;
|
crafingTickTime = 0;
|
||||||
finalTickTime = currentRecipe.getTime();
|
|
||||||
neededPower = currentRecipe.getStartEnergy();
|
neededPower = currentRecipe.getStartEnergy();
|
||||||
hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
break;
|
break;
|
||||||
|
@ -259,8 +257,9 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRecipe != null) {
|
if (currentRecipe != null) {
|
||||||
if (!validateRecipe(currentRecipe)) {
|
if (!hasStartedCrafting && !validateRecipe(currentRecipe)) {
|
||||||
resetCrafter();
|
resetCrafter();
|
||||||
|
inventory.resetChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,19 +272,20 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
useInput(bottomStackSlot);
|
useInput(bottomStackSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasStartedCrafting && crafingTickTime < finalTickTime) {
|
if (hasStartedCrafting && crafingTickTime < currentRecipe.getTime()) {
|
||||||
crafingTickTime++;
|
crafingTickTime++;
|
||||||
// Power gen
|
// Power gen
|
||||||
if (currentRecipe.getPower() > 0) {
|
if (currentRecipe.getPower() < 0) {
|
||||||
// Waste power if it has no where to go
|
// Waste power if it has no where to go
|
||||||
addEnergy(currentRecipe.getPower() * getPowerMultiplier());
|
double power = Math.abs(currentRecipe.getPower()) * getPowerMultiplier();
|
||||||
powerChange = currentRecipe.getPower() * getPowerMultiplier();
|
addEnergy(power);
|
||||||
|
powerChange = (power);
|
||||||
} else { // Power user
|
} else { // Power user
|
||||||
if (canUseEnergy(currentRecipe.getPower() * -1)) {
|
if (canUseEnergy(currentRecipe.getPower() * -1)) {
|
||||||
setEnergy(getEnergy() - currentRecipe.getPower() * -1);
|
setEnergy(getEnergy() - currentRecipe.getPower() * -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (crafingTickTime >= finalTickTime) {
|
} else if (crafingTickTime >= currentRecipe.getTime()) {
|
||||||
ItemStack result = currentRecipe.getOutputs().get(0);
|
ItemStack result = currentRecipe.getOutputs().get(0);
|
||||||
if (canFitStack(result, outputStackSlot, true)) {
|
if (canFitStack(result, outputStackSlot, true)) {
|
||||||
if (inventory.getInvStack(outputStackSlot).isEmpty()) {
|
if (inventory.getInvStack(outputStackSlot).isEmpty()) {
|
||||||
|
@ -350,7 +350,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public void fromTag(final CompoundTag tagCompound) {
|
public void fromTag(final CompoundTag tagCompound) {
|
||||||
super.fromTag(tagCompound);
|
super.fromTag(tagCompound);
|
||||||
this.crafingTickTime = tagCompound.getInt("crafingTickTime");
|
this.crafingTickTime = tagCompound.getInt("crafingTickTime");
|
||||||
this.finalTickTime = tagCompound.getInt("finalTickTime");
|
|
||||||
this.neededPower = tagCompound.getInt("neededPower");
|
this.neededPower = tagCompound.getInt("neededPower");
|
||||||
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
||||||
if(tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null){
|
if(tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null){
|
||||||
|
@ -366,7 +365,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public CompoundTag toTag(final CompoundTag tagCompound) {
|
public CompoundTag toTag(final CompoundTag tagCompound) {
|
||||||
super.toTag(tagCompound);
|
super.toTag(tagCompound);
|
||||||
tagCompound.putInt("crafingTickTime", this.crafingTickTime);
|
tagCompound.putInt("crafingTickTime", this.crafingTickTime);
|
||||||
tagCompound.putInt("finalTickTime", this.finalTickTime);
|
|
||||||
tagCompound.putInt("neededPower", this.neededPower);
|
tagCompound.putInt("neededPower", this.neededPower);
|
||||||
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
||||||
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
|
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
|
||||||
|
@ -405,7 +403,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
||||||
.sync(this::getCoilStatus, this::setCoilStatus)
|
.sync(this::getCoilStatus, this::setCoilStatus)
|
||||||
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
||||||
.sync(this::getFinalTickTime, this::setFinalTickTime)
|
|
||||||
.sync(this::getSize, this::setSize)
|
.sync(this::getSize, this::setSize)
|
||||||
.sync(this::getState, this::setState)
|
.sync(this::getState, this::setState)
|
||||||
.sync(this::getNeededPower, this::setNeededPower)
|
.sync(this::getNeededPower, this::setNeededPower)
|
||||||
|
@ -430,14 +427,6 @@ public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
this.crafingTickTime = crafingTickTime;
|
this.crafingTickTime = crafingTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFinalTickTime() {
|
|
||||||
return finalTickTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFinalTickTime(int finalTickTime) {
|
|
||||||
this.finalTickTime = finalTickTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNeededPower() {
|
public int getNeededPower() {
|
||||||
return neededPower;
|
return neededPower;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue