mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Code cleanup (#5468)
* remove direct guava predicates from BlockStateMachine * cleanup blockstatebasic * fix a large number of e.printStacktrace calls, narrow ComputerIntegration exception signature * fix simple todos, remove invalid todos, unify some duplicate rendering code * use a generic method to get around unchecked warning * remove some redundant uses of hasCapability * experimental OptionalCapability class. not in use yet * nullable checks/annotations & remove duplicate field controlType in factory TE * Inline various redundant variables * Remove unused list * Cleanup BlockStateGenerator * Replace string constants with pointers to the proper mod id constant * As 9.7.5 breaks backwards compat API wise for the DynamicNetwork this is as good a time as any to remove this deprecated method * Use two argument constructor instead of appending a ':' inbetween * Convert other BlockState type classes to using suppliers for tile entity creation
This commit is contained in:
1 parent
40620ec23b
commit
80b07bc4b3
115 files changed
+583
-633
No files matched your search
@@ -2,6 +2,7 @@ package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
@@ -93,22 +94,22 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
/**
|
||||
* How much secondary energy each operation consumes per tick
|
||||
*/
|
||||
public double secondaryEnergyPerTick = 0;
|
||||
public int secondaryEnergyThisTick;
|
||||
private double secondaryEnergyPerTick = 0;
|
||||
private int secondaryEnergyThisTick;
|
||||
/**
|
||||
* How long it takes this factory to switch recipe types.
|
||||
*/
|
||||
public int RECIPE_TICKS_REQUIRED = 40;
|
||||
private static int RECIPE_TICKS_REQUIRED = 40;
|
||||
/**
|
||||
* How many recipe ticks have progressed.
|
||||
*/
|
||||
public int recipeTicks;
|
||||
private int recipeTicks;
|
||||
/**
|
||||
* The amount of infuse this machine has stored.
|
||||
*/
|
||||
public InfuseStorage infuseStored = new InfuseStorage();
|
||||
public final InfuseStorage infuseStored = new InfuseStorage();
|
||||
|
||||
public GasTank gasTank;
|
||||
public final GasTank gasTank;
|
||||
|
||||
public boolean sorting;
|
||||
|
||||
@@ -116,16 +117,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
|
||||
public double lastUsage;
|
||||
|
||||
/**
|
||||
* This machine's current RedstoneControl type.
|
||||
*/
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
/**
|
||||
* This machine's recipe type.
|
||||
*/
|
||||
@Nonnull
|
||||
private RecipeType recipeType = RecipeType.SMELTING;
|
||||
|
||||
public TileEntityFactory() {
|
||||
@@ -172,7 +169,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
world.setBlockToAir(getPos());
|
||||
world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5 + tier.ordinal() + 1), 3);
|
||||
|
||||
TileEntityFactory factory = (TileEntityFactory) world.getTileEntity(getPos());
|
||||
TileEntityFactory factory = Objects.requireNonNull((TileEntityFactory) world.getTileEntity(getPos()));
|
||||
|
||||
//Basic
|
||||
factory.facing = facing;
|
||||
@@ -193,7 +190,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
factory.prevEnergy = prevEnergy;
|
||||
factory.gasTank.setGas(gasTank.getGas());
|
||||
factory.sorting = sorting;
|
||||
factory.controlType = controlType;
|
||||
factory.setControlType(getControlType());
|
||||
factory.upgradeComponent.readFrom(upgradeComponent);
|
||||
factory.ejectorComponent.readFrom(ejectorComponent);
|
||||
factory.configComponent.readFrom(configComponent);
|
||||
@@ -201,7 +198,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
factory.setRecipeType(recipeType);
|
||||
factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
factory.securityComponent.readFrom(securityComponent);
|
||||
factory.infuseStored = infuseStored;
|
||||
factory.infuseStored.copyFrom(infuseStored);
|
||||
|
||||
for (int i = 0; i < tier.processes + 5; i++) {
|
||||
factory.inventory.set(i, inventory.get(i));
|
||||
@@ -316,12 +313,13 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public RecipeType getRecipeType() {
|
||||
return recipeType;
|
||||
}
|
||||
|
||||
public void setRecipeType(RecipeType type) {
|
||||
recipeType = type;
|
||||
public void setRecipeType(@Nonnull RecipeType type) {
|
||||
recipeType = Objects.requireNonNull(type);
|
||||
BASE_MAX_ENERGY = maxEnergy = tier.processes * Math.max(0.5D * recipeType.getEnergyStorage(), recipeType.getEnergyUsage());
|
||||
BASE_ENERGY_PER_TICK = energyPerTick = recipeType.getEnergyUsage();
|
||||
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
@@ -812,7 +810,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] invoke(int method, Object[] arguments) throws Exception {
|
||||
public Object[] invoke(int method, Object[] arguments) throws NoSuchMethodException {
|
||||
switch (method) {
|
||||
case 0:
|
||||
return new Object[]{electricityStored};
|
||||
|
||||
Reference in new issue
Block a user