mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +00:00
Make the mod classes significantly less godlike.
Move Config variables into their own class, (in api because other stuff in API references config, may make sense to move it back to common later), and move Blocks and Items into final variables in their own classes. It looks a lot cleaner this way and my OCD can finally rest now.
This commit is contained in:
1 parent
6762f416d3
commit
725b7463f0
163 files changed
+1848
-1789
No files matched your search
@@ -3,6 +3,8 @@ package mekanism.api;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.util.BlockInfo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package mekanism.api;
|
||||
|
||||
import mekanism.api.util.EnergyUtil.EnergyType;
|
||||
|
||||
public class MekanismConfig
|
||||
{
|
||||
public static class general
|
||||
{
|
||||
public static boolean updateNotifications = true;
|
||||
public static boolean controlCircuitOreDict = true;
|
||||
public static boolean logPackets = false;
|
||||
public static boolean dynamicTankEasterEgg = false;
|
||||
public static boolean voiceServerEnabled = true;
|
||||
public static boolean cardboardSpawners = true;
|
||||
public static boolean machineEffects = true;
|
||||
public static boolean enableWorldRegeneration = true;
|
||||
public static boolean creativeOverrideElectricChest = true;
|
||||
public static boolean spawnBabySkeletons = true;
|
||||
public static int obsidianTNTBlastRadius = 12;
|
||||
public static int osmiumPerChunk = 12;
|
||||
public static int copperPerChunk = 16;
|
||||
public static int tinPerChunk = 14;
|
||||
public static int saltPerChunk = 2;
|
||||
public static int obsidianTNTDelay = 100;
|
||||
public static int UPDATE_DELAY = 10;
|
||||
public static int VOICE_PORT = 36123;
|
||||
public static int maxUpgradeMultiplier = 10;
|
||||
public static int userWorldGenVersion = 0;
|
||||
public static double ENERGY_PER_REDSTONE = 10000;
|
||||
public static EnergyType activeType = EnergyType.J;
|
||||
public static double TO_IC2;
|
||||
public static double TO_BC;
|
||||
public static double TO_TE;
|
||||
public static double TO_UE = .001;
|
||||
public static double FROM_UE = 1/TO_UE;
|
||||
public static double FROM_H2;
|
||||
public static double FROM_IC2;
|
||||
public static double FROM_BC;
|
||||
public static double FROM_TE;
|
||||
}
|
||||
|
||||
public static class usage
|
||||
{
|
||||
public static double enrichmentChamberUsage;
|
||||
public static double osmiumCompressorUsage;
|
||||
public static double combinerUsage;
|
||||
public static double crusherUsage;
|
||||
public static double factoryUsage;
|
||||
public static double metallurgicInfuserUsage;
|
||||
public static double purificationChamberUsage;
|
||||
public static double energizedSmelterUsage;
|
||||
public static double digitalMinerUsage;
|
||||
public static double electricPumpUsage;
|
||||
public static double rotaryCondensentratorUsage;
|
||||
public static double oxidationChamberUsage;
|
||||
public static double chemicalInfuserUsage;
|
||||
public static double chemicalInjectionChamberUsage;
|
||||
public static double precisionSawmillUsage;
|
||||
public static double chemicalDissolutionChamberUsage;
|
||||
public static double chemicalWasherUsage;
|
||||
public static double chemicalCrystallizerUsage;
|
||||
public static double seismicVibratorUsage;
|
||||
public static double pressurizedReactionBaseUsage;
|
||||
public static double fluidicPlenisherUsage;
|
||||
}
|
||||
|
||||
public static class generators
|
||||
{
|
||||
public static double advancedSolarGeneration;
|
||||
public static double bioGeneration;
|
||||
public static double heatGeneration;
|
||||
public static double solarGeneration;
|
||||
public static double windGeneration;
|
||||
}
|
||||
|
||||
public static class tools
|
||||
{
|
||||
public static double armorSpawnRate;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.ListUtils;
|
||||
import mekanism.api.util.ListUtils;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
import mekanism.api.transmitters.ITransmitterNetwork;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.api.gas.Gas;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ChanceOutput
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
public class PressurizedRecipe
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.recipe;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.util;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -0,0 +1,195 @@
|
||||
package mekanism.api.util;
|
||||
|
||||
/**
|
||||
* Code taken from UE and modified to fit Mekanism.
|
||||
*/
|
||||
public class EnergyUtil
|
||||
{
|
||||
public static enum ElectricUnit
|
||||
{
|
||||
JOULES("Joule", "J"),
|
||||
REDSTONE_FLUX("Redstone Flux", "RF"),
|
||||
MINECRAFT_JOULES("Minecraft Joule", "MJ"),
|
||||
ELECTRICAL_UNITS("Electrical Unit", "EU");
|
||||
|
||||
public String name;
|
||||
public String symbol;
|
||||
|
||||
private ElectricUnit(String s, String s1)
|
||||
{
|
||||
name = s;
|
||||
symbol = s1;
|
||||
}
|
||||
|
||||
public String getPlural()
|
||||
{
|
||||
return this == REDSTONE_FLUX ? name : name + "s";
|
||||
}
|
||||
}
|
||||
|
||||
/** Metric system of measurement. */
|
||||
public static enum MeasurementUnit
|
||||
{
|
||||
FEMTO("Femto", "f", 0.000000000000001D),
|
||||
PICO("Pico", "p", 0.000000000001D),
|
||||
NANO("Nano", "n", 0.000000001D),
|
||||
MICRO("Micro", "u", 0.000001D),
|
||||
MILLI("Milli", "m", 0.001D),
|
||||
BASE("", "", 1),
|
||||
KILO("Kilo", "k", 1000D),
|
||||
MEGA("Mega", "M", 1000000D),
|
||||
GIGA("Giga", "G", 1000000000D),
|
||||
TERA("Tera", "T", 1000000000000D),
|
||||
PETA("Peta", "P", 1000000000000000D),
|
||||
EXA("Exa", "E", 1000000000000000000D),
|
||||
ZETTA("Zetta", "Z", 1000000000000000000000D),
|
||||
YOTTA("Yotta", "Y", 1000000000000000000000000D);
|
||||
|
||||
/** long name for the unit */
|
||||
public String name;
|
||||
|
||||
/** short unit version of the unit */
|
||||
public String symbol;
|
||||
|
||||
/** Point by which a number is consider to be of this unit */
|
||||
public double value;
|
||||
|
||||
private MeasurementUnit(String s, String s1, double v)
|
||||
{
|
||||
name = s;
|
||||
symbol = s1;
|
||||
value = v;
|
||||
}
|
||||
|
||||
public String getName(boolean getShort)
|
||||
{
|
||||
if(getShort)
|
||||
{
|
||||
return symbol;
|
||||
}
|
||||
else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public double process(double d)
|
||||
{
|
||||
return d / value;
|
||||
}
|
||||
|
||||
public boolean above(double d)
|
||||
{
|
||||
return d > value;
|
||||
}
|
||||
|
||||
public boolean below(double d)
|
||||
{
|
||||
return d < value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the unit as text. Does handle negative numbers, and will place a negative sign in
|
||||
* front of the output string showing this. Use string.replace to remove the negative sign if
|
||||
* unwanted
|
||||
*/
|
||||
public static String getDisplay(double value, ElectricUnit unit, int decimalPlaces, boolean isShort)
|
||||
{
|
||||
String unitName = unit.name;
|
||||
String prefix = "";
|
||||
|
||||
if(value < 0)
|
||||
{
|
||||
value = Math.abs(value);
|
||||
prefix = "-";
|
||||
}
|
||||
|
||||
if(isShort)
|
||||
{
|
||||
unitName = unit.symbol;
|
||||
}
|
||||
else if(value > 1)
|
||||
{
|
||||
unitName = unit.getPlural();
|
||||
}
|
||||
|
||||
if(value == 0)
|
||||
{
|
||||
return value + " " + unitName;
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < MeasurementUnit.values().length; i++)
|
||||
{
|
||||
MeasurementUnit lowerMeasure = MeasurementUnit.values()[i];
|
||||
|
||||
if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
if(lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
|
||||
MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1];
|
||||
|
||||
if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value)
|
||||
{
|
||||
return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prefix + roundDecimals(value, decimalPlaces) + " " + unitName;
|
||||
}
|
||||
|
||||
public static String getDisplayShort(double value, ElectricUnit unit)
|
||||
{
|
||||
return getDisplay(value, unit, 2, true);
|
||||
}
|
||||
|
||||
public static String getDisplayShort(double value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
return getDisplay(value, unit, decimalPlaces, true);
|
||||
}
|
||||
|
||||
public static String getDisplaySimple(double value, ElectricUnit unit, int decimalPlaces)
|
||||
{
|
||||
if(value > 1)
|
||||
{
|
||||
if(decimalPlaces < 1)
|
||||
{
|
||||
return (int)value + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.getPlural();
|
||||
}
|
||||
|
||||
if(decimalPlaces < 1)
|
||||
{
|
||||
return (int)value + " " + unit.name;
|
||||
}
|
||||
|
||||
return roundDecimals(value, decimalPlaces) + " " + unit.name;
|
||||
}
|
||||
|
||||
public static double roundDecimals(double d, int decimalPlaces)
|
||||
{
|
||||
int j = (int)(d*Math.pow(10, decimalPlaces));
|
||||
return j/Math.pow(10, decimalPlaces);
|
||||
}
|
||||
|
||||
public static double roundDecimals(double d)
|
||||
{
|
||||
return roundDecimals(d, 2);
|
||||
}
|
||||
|
||||
public static enum EnergyType
|
||||
{
|
||||
J,
|
||||
RF,
|
||||
EU,
|
||||
MJ
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.util;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mekanism.api;
|
||||
package mekanism.api.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
Reference in new issue
Block a user