mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Formatting and code readability cleanup (#5467)
* First pass reformatting code to be more readable (common still not done) * Replace google common collect calls with Java calls where possible * Remove a bunch of unnecessary parenthesis leaving clarifying ones * Add some missing @Nonnull annotations * Fix checking wrong type * Remove unnecessary continue/return statements and simplify comparision check * Pass exception instead of directly printing stack trace * Work on cleaning up common, through config so far * Work on cleaning up common, through integration so far * Work on cleaning up common, through network so far * Work on cleaning up common, through tier so far * Remove empty constructors that get created by default anyways * Work on cleaning up common, through transmitters so far * Work on cleaning up common, through utils so far * Finish cleaning up spacing for common
This commit is contained in:
1 parent
91ef2a5c3d
commit
0d4b50908f
909 files changed
+6234
-15623
No files matched your search
@@ -21,16 +21,12 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends
|
||||
TileEntityUpgradeableMachine<ItemStackInput, ChanceOutput, RECIPE> {
|
||||
public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe<RECIPE>> extends TileEntityUpgradeableMachine<ItemStackInput, ChanceOutput, RECIPE> {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate",
|
||||
"getMaxEnergy", "getEnergyNeeded"};
|
||||
private static final String[] methods = new String[]{"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
|
||||
|
||||
public TileEntityChanceMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage,
|
||||
int ticksRequired, ResourceLocation location) {
|
||||
public TileEntityChanceMachine(String soundPath, String name, double baseMaxEnergy, double baseEnergyUsage, int ticksRequired, ResourceLocation location) {
|
||||
super(soundPath, name, baseMaxEnergy, baseEnergyUsage, 3, ticksRequired, location);
|
||||
|
||||
configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY);
|
||||
|
||||
configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
|
||||
@@ -61,34 +57,24 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (!world.isRemote) {
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
RECIPE recipe = getRecipe();
|
||||
|
||||
if (canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) {
|
||||
setActive(true);
|
||||
|
||||
electricityStored -= energyPerTick;
|
||||
|
||||
if ((operatingTicks + 1) < ticksRequired) {
|
||||
operatingTicks++;
|
||||
} else {
|
||||
operate(recipe);
|
||||
|
||||
operatingTicks = 0;
|
||||
}
|
||||
} else {
|
||||
if (prevEnergy >= getEnergy()) {
|
||||
setActive(false);
|
||||
}
|
||||
} else if (prevEnergy >= getEnergy()) {
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
if (!canOperate(recipe)) {
|
||||
operatingTicks = 0;
|
||||
}
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
@@ -96,14 +82,12 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotID, @Nonnull ItemStack itemstack) {
|
||||
if (slotID == 3) {
|
||||
return itemstack.getItem() == MekanismItems.SpeedUpgrade
|
||||
|| itemstack.getItem() == MekanismItems.EnergyUpgrade;
|
||||
return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade;
|
||||
} else if (slotID == 0) {
|
||||
return RecipeHandler.isInRecipe(itemstack, getRecipes());
|
||||
} else if (slotID == 1) {
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,7 +99,6 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
@Override
|
||||
public void operate(RECIPE recipe) {
|
||||
recipe.operate(inventory, 0, 2, 4);
|
||||
|
||||
markDirty();
|
||||
ejectorComponent.outputItems();
|
||||
}
|
||||
@@ -129,20 +112,16 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
public boolean canExtractItem(int slotID, @Nonnull ItemStack itemstack, @Nonnull EnumFacing side) {
|
||||
if (slotID == 1) {
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
} else {
|
||||
return slotID == 2 || slotID == 4;
|
||||
}
|
||||
|
||||
return slotID == 2 || slotID == 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECIPE getRecipe() {
|
||||
ItemStackInput input = getInput();
|
||||
|
||||
if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) {
|
||||
cachedRecipe = RecipeHandler.getChanceRecipe(input, getRecipes());
|
||||
}
|
||||
|
||||
return cachedRecipe;
|
||||
}
|
||||
|
||||
@@ -177,4 +156,4 @@ public abstract class TileEntityChanceMachine<RECIPE extends ChanceMachineRecipe
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user