Refactoring for Iron Furnace
This commit is contained in:
parent
2cd8183c12
commit
026dedd2e6
8 changed files with 167 additions and 197 deletions
|
@ -130,31 +130,23 @@ public class IronAlloyFurnaceBlockEntity extends MachineBaseBlockEntity
|
|||
private boolean canSmelt() {
|
||||
if (inventory.getInvStack(this.input1).isEmpty() || inventory.getInvStack(this.input2).isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
ItemStack itemstack = null;
|
||||
for (final RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) {
|
||||
if (this.hasAllInputs(recipeType)) {
|
||||
itemstack = recipeType.getOutputs().get(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (inventory.getInvStack(this.output).isEmpty())
|
||||
return true;
|
||||
if (!inventory.getInvStack(this.output).isItemEqualIgnoreDamage(itemstack))
|
||||
return false;
|
||||
final int result = inventory.getInvStack(this.output).getCount() + itemstack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getInvStack(this.output).getMaxCount(); // Forge
|
||||
// BugFix:
|
||||
// Make
|
||||
// it
|
||||
// respect
|
||||
// stack
|
||||
// sizes
|
||||
// properly.
|
||||
}
|
||||
ItemStack itemstack = null;
|
||||
for (final RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) {
|
||||
if (this.hasAllInputs(recipeType)) {
|
||||
itemstack = recipeType.getOutputs().get(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (inventory.getInvStack(this.output).isEmpty())
|
||||
return true;
|
||||
if (!inventory.getInvStack(this.output).isItemEqualIgnoreDamage(itemstack))
|
||||
return false;
|
||||
final int result = inventory.getInvStack(this.output).getCount() + itemstack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= inventory.getInvStack(this.output).getMaxCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,16 +224,11 @@ public class IronAlloyFurnaceBlockEntity extends MachineBaseBlockEntity
|
|||
return TRContent.Machine.IRON_ALLOY_FURNACE.getStack();
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RebornInventory<IronAlloyFurnaceBlockEntity> getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.burnTime;
|
||||
}
|
||||
|
|
|
@ -82,9 +82,9 @@ public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
|
|||
final boolean burning = this.isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (this.fuel > 0) {
|
||||
this.fuel--;
|
||||
this.updateState();
|
||||
fuel--;
|
||||
}
|
||||
updateState();
|
||||
if (this.fuel <= 0 && this.canSmelt()) {
|
||||
this.fuel = this.fuelGague = (int) (AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(inventory.getInvStack(this.fuelslot).getItem(), 0) * 1.25);
|
||||
if (this.fuel > 0) {
|
||||
|
@ -162,10 +162,10 @@ public class IronFurnaceBlockEntity extends MachineBaseBlockEntity
|
|||
}
|
||||
|
||||
public void updateState() {
|
||||
final BlockState BlockStateContainer = this.world.getBlockState(this.pos);
|
||||
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
|
||||
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
|
||||
if (BlockStateContainer.get(BlockMachineBase.ACTIVE) != this.fuel > 0)
|
||||
BlockState state = world.getBlockState(this.pos);
|
||||
if (state.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) state.getBlock();
|
||||
if (state.get(BlockMachineBase.ACTIVE) != this.fuel > 0)
|
||||
blockMachineBase.setActive(this.fuel > 0, this.world, this.pos);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue