mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-25 22:34:26 +00:00
Chore: rename
- rename networkWrapper to network - move JECConfig and ItemCalculator to outer package and rename
This commit is contained in:
1 parent
4b5de3267e
commit
2989787c86
18 files changed
+746
-183
No files matched your search
@@ -4,26 +4,24 @@ import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkCheckHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import me.towdium.jecalculation.item.ItemCalculator;
|
||||
import me.towdium.jecalculation.network.IProxy;
|
||||
import me.towdium.jecalculation.network.packets.PacketCalculatorUpdate;
|
||||
import me.towdium.jecalculation.network.packets.PacketRecipeUpdate;
|
||||
import me.towdium.jecalculation.network.packets.PacketSyncRecord;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Towdium
|
||||
@@ -32,30 +30,36 @@ import java.util.ArrayList;
|
||||
@Mod(modid = JustEnoughCalculation.Reference.MODID,
|
||||
name = JustEnoughCalculation.Reference.MODNAME,
|
||||
version = JustEnoughCalculation.Reference.VERSION,
|
||||
dependencies = "after:NotEnoughItems")
|
||||
dependencies = "required-after:NotEnoughItems")
|
||||
public class JustEnoughCalculation {
|
||||
public static Item itemCalculator = new ItemCalculator().setUnlocalizedName("itemCalculator")
|
||||
.setTextureName(Reference.MODID + ":" + "itemCalculator");
|
||||
public static SimpleNetworkWrapper networkWrapper;
|
||||
public static Logger log = LogManager.getLogger(Reference.MODID);
|
||||
@Mod.Instance(Reference.MODID)
|
||||
public static JustEnoughCalculation instance;
|
||||
|
||||
@SidedProxy(clientSide = "me.towdium.jecalculation.network.ProxyClient",
|
||||
@SidedProxy(modId = Reference.MODID,
|
||||
clientSide = "me.towdium.jecalculation.network.ProxyClient",
|
||||
serverSide = "me.towdium.jecalculation.network.ProxyServer")
|
||||
public static IProxy proxy;
|
||||
|
||||
@Mod.Instance(JustEnoughCalculation.Reference.MODID)
|
||||
public static JustEnoughCalculation instance;
|
||||
public static SimpleNetworkWrapper network;
|
||||
public static Logger logger = LogManager.getLogger(Reference.MODID);
|
||||
|
||||
public static Item itemCalculator = new JecaItem().setUnlocalizedName("itemCalculator")
|
||||
.setTextureName(Reference.MODID + ":" + "itemCalculator");
|
||||
|
||||
@NetworkCheckHandler
|
||||
public static boolean networkCheck(Map<String, String> mods, Side s) {
|
||||
return s == Side.SERVER || mods.containsKey(Reference.MODID);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void preInit(FMLPreInitializationEvent event) {
|
||||
JECConfig.preInit(event);
|
||||
public static void initPre(FMLPreInitializationEvent event) {
|
||||
JecaConfig.preInit(event);
|
||||
GameRegistry.registerItem(itemCalculator, itemCalculator.getUnlocalizedName().substring(5));
|
||||
networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
|
||||
networkWrapper.registerMessage(PacketCalculatorUpdate.class, PacketCalculatorUpdate.class, 1, Side.SERVER);
|
||||
networkWrapper.registerMessage(PacketRecipeUpdate.class, PacketRecipeUpdate.class, 2, Side.SERVER);
|
||||
networkWrapper.registerMessage(PacketSyncRecord.class, PacketSyncRecord.class, 3, Side.CLIENT);
|
||||
networkWrapper.registerMessage(PacketSyncRecord.class, PacketSyncRecord.class, 4, Side.SERVER);
|
||||
network = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
|
||||
network.registerMessage(PacketCalculatorUpdate.class, PacketCalculatorUpdate.class, 1, Side.SERVER);
|
||||
network.registerMessage(PacketRecipeUpdate.class, PacketRecipeUpdate.class, 2, Side.SERVER);
|
||||
network.registerMessage(PacketSyncRecord.class, PacketSyncRecord.class, 3, Side.CLIENT);
|
||||
network.registerMessage(PacketSyncRecord.class, PacketSyncRecord.class, 4, Side.SERVER);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
@@ -89,140 +93,9 @@ public class JustEnoughCalculation {
|
||||
//DefaultOverlayHandler
|
||||
}
|
||||
|
||||
public static class JECConfig {
|
||||
public static boolean initialized = false;
|
||||
public static Configuration config;
|
||||
|
||||
public enum EnumItems {
|
||||
EnableInventoryCheck, ListRecipeBlackList, ListRecipeCategory;
|
||||
|
||||
public String getComment() {
|
||||
switch (this) {
|
||||
case EnableInventoryCheck:
|
||||
return "Set to false to disable auto inventory check";
|
||||
case ListRecipeBlackList:
|
||||
return "Add string identifier here to disable quick transfer of this type recipe\n" +
|
||||
"Names can be found in ListRecipeCategory";
|
||||
case ListRecipeCategory:
|
||||
return "List of categories, this is maintained by the mod automatically";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
switch (this) {
|
||||
case EnableInventoryCheck:
|
||||
return "EnableInventoryCheck";
|
||||
case ListRecipeBlackList:
|
||||
return "ListRecipeBlackList";
|
||||
case ListRecipeCategory:
|
||||
return "ListRecipeCategory";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
switch (this) {
|
||||
case EnableInventoryCheck:
|
||||
return EnumCategory.General.toString();
|
||||
case ListRecipeBlackList:
|
||||
return EnumCategory.General.toString();
|
||||
case ListRecipeCategory:
|
||||
return EnumCategory.General.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public EnumType getType() {
|
||||
switch (this) {
|
||||
case EnableInventoryCheck:
|
||||
return EnumType.Boolean;
|
||||
case ListRecipeBlackList:
|
||||
return EnumType.ListString;
|
||||
case ListRecipeCategory:
|
||||
return EnumType.ListString;
|
||||
}
|
||||
return EnumType.Error;
|
||||
}
|
||||
|
||||
public Object getDefault() {
|
||||
switch (this) {
|
||||
case EnableInventoryCheck:
|
||||
return true;
|
||||
case ListRecipeBlackList:
|
||||
return new String[0];
|
||||
case ListRecipeCategory:
|
||||
return new String[]{"crafting", "smelting"};
|
||||
}
|
||||
return JECConfig.empty;
|
||||
}
|
||||
|
||||
public Property init() {
|
||||
EnumType type = this.getType();
|
||||
if (type != null) {
|
||||
switch (this.getType()) {
|
||||
case Boolean:
|
||||
return config.get(this.getCategory(), this.getName(), (Boolean) this.getDefault(),
|
||||
this.getComment());
|
||||
case ListString:
|
||||
return config.get(this.getCategory(), this.getName(), (String[]) this.getDefault(),
|
||||
this.getComment());
|
||||
}
|
||||
config.getCategory(EnumCategory.General.toString()).get(this.getName());
|
||||
}
|
||||
return config.get(this.getCategory(), this.getName(), false, this.getComment());
|
||||
}
|
||||
|
||||
public Property getProperty() {
|
||||
return config.getCategory(EnumCategory.General.toString()).get(this.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public enum EnumCategory {
|
||||
General;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (this) {
|
||||
case General:
|
||||
return "general";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum EnumType {Boolean, ListString, Error}
|
||||
|
||||
public static Object empty;
|
||||
|
||||
public static void preInit(FMLPreInitializationEvent event) {
|
||||
config = new Configuration(new File(event.getModConfigurationDirectory(), "JustEnoughCalculation" + ".cfg"),
|
||||
Reference.VERSION);
|
||||
config.load();
|
||||
handleFormerVersion();
|
||||
handleInit();
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void handleFormerVersion() {
|
||||
config.getCategory("general").remove("RecipeTypeSupport");
|
||||
}
|
||||
|
||||
public static void handleInit() {
|
||||
for (EnumItems item : EnumItems.values()) {
|
||||
item.init();
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Reference {
|
||||
public static final String MODID = "jecalculation";
|
||||
public static final String MODNAME = "Just Enough Calculation";
|
||||
public static final String VERSION = "0.4.0";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user