mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-22 05:02:34 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.io.File;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.AbstractMod;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
class BinnieConfiguration extends Configuration
|
||||
{
|
||||
public AbstractMod mod;
|
||||
private String filename;
|
||||
|
||||
public BinnieConfiguration(final String filename, final AbstractMod mod) {
|
||||
super(new File(BinnieCore.proxy.getDirectory(), filename));
|
||||
this.mod = mod;
|
||||
this.filename = filename;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
class BinnieItemData
|
||||
{
|
||||
private int item;
|
||||
private BinnieConfiguration configFile;
|
||||
private String configKey;
|
||||
|
||||
public BinnieItemData(final int item, final BinnieConfiguration configFile, final String configKey) {
|
||||
this.item = item;
|
||||
this.configFile = configFile;
|
||||
this.configKey = configKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ConfigFile {
|
||||
String filename();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.FIELD })
|
||||
public @interface ConfigProperty {
|
||||
String key();
|
||||
|
||||
String category() default "";
|
||||
|
||||
String[] comment() default {};
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.ANNOTATION_TYPE })
|
||||
public @interface Type {
|
||||
Class<? extends PropertyBase> propertyClass();
|
||||
|
||||
String category() default "general";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
@ConfigFile(filename = "/config/forestry/binniecore/main.conf")
|
||||
public class ConfigurationMain
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
@ConfigFile(filename = "/config/forestry/binnie-mods.conf")
|
||||
public class ConfigurationMods
|
||||
{
|
||||
@ConfigProperty(key = "extraBees", comment = { "Enables the Extra Bees Mod." })
|
||||
@PropBoolean
|
||||
public static boolean extraBees;
|
||||
@ConfigProperty(key = "extraTrees", comment = { "Enables the Extra Trees Mod." })
|
||||
@PropBoolean
|
||||
public static boolean extraTrees;
|
||||
@ConfigProperty(key = "botany", comment = { "Enables the Botany Mod." })
|
||||
@PropBoolean
|
||||
public static boolean botany;
|
||||
@ConfigProperty(key = "genetics", comment = { "Enables the Genetics Mod." })
|
||||
@PropBoolean
|
||||
public static boolean genetics;
|
||||
|
||||
static {
|
||||
ConfigurationMods.extraBees = true;
|
||||
ConfigurationMods.extraTrees = true;
|
||||
ConfigurationMods.botany = true;
|
||||
ConfigurationMods.genetics = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import binnie.core.AbstractMod;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import java.util.Map;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerConfig extends ManagerBase
|
||||
{
|
||||
private Map<Class<?>, Configuration> configurations;
|
||||
private Map<AbstractMod, List<BinnieItemData>> itemIDs;
|
||||
|
||||
public ManagerConfig() {
|
||||
this.configurations = new LinkedHashMap<Class<?>, Configuration>();
|
||||
this.itemIDs = new HashMap<AbstractMod, List<BinnieItemData>>();
|
||||
}
|
||||
|
||||
public void registerConfiguration(final Class<?> cls, final AbstractMod mod) {
|
||||
if (cls.isAnnotationPresent(ConfigFile.class)) {
|
||||
this.loadConfiguration(cls, mod);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfiguration(final Class<?> cls, final AbstractMod mod) {
|
||||
try {
|
||||
final String filename = cls.getAnnotation(ConfigFile.class).filename();
|
||||
final BinnieConfiguration config = new BinnieConfiguration(filename, mod);
|
||||
config.load();
|
||||
for (final Field field : cls.getFields()) {
|
||||
if (field.isAnnotationPresent(ConfigProperty.class)) {
|
||||
final ConfigProperty propertyAnnot = field.getAnnotation(ConfigProperty.class);
|
||||
for (final Annotation annotation : field.getAnnotations()) {
|
||||
if (annotation.annotationType().isAnnotationPresent(ConfigProperty.Type.class)) {
|
||||
final Class<?> propertyClass = annotation.annotationType().getAnnotation(ConfigProperty.Type.class).propertyClass();
|
||||
final PropertyBase property = (PropertyBase) propertyClass.getConstructor(Field.class, BinnieConfiguration.class, ConfigProperty.class, annotation.annotationType()).newInstance(field, config, propertyAnnot, annotation.annotationType().cast(annotation));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
this.configurations.put(cls, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemID(final Integer configValue, final String configKey, final BinnieConfiguration configFile) {
|
||||
if (!this.itemIDs.containsKey(configFile.mod)) {
|
||||
this.itemIDs.put(configFile.mod, new ArrayList<BinnieItemData>());
|
||||
}
|
||||
this.itemIDs.get(configFile.mod).add(new BinnieItemData(configValue + 256, configFile, configKey));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropBoolean.PropertyBoolean.class)
|
||||
public @interface PropBoolean {
|
||||
public static class PropertyBoolean extends PropertyBase<Boolean, PropBoolean>
|
||||
{
|
||||
public PropertyBoolean(final Field field, final BinnieConfiguration file, final ConfigProperty configProperty, final PropBoolean annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return this.file.get(this.getCategory(), this.getKey(), this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getConfigValue() {
|
||||
return this.property.getBoolean(this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
this.addComment("Default value is " + this.defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropDouble.PropertyDouble.class)
|
||||
public @interface PropDouble {
|
||||
public static class PropertyDouble extends PropertyBase<Double, PropDouble>
|
||||
{
|
||||
public PropertyDouble(final Field field, final BinnieConfiguration file, final ConfigProperty configProperty, final PropDouble annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return this.file.get(this.getCategory(), this.getKey(), this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Double getConfigValue() {
|
||||
return this.property.getDouble(this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
this.addComment("Default value is " + this.defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropInteger.PropertyInteger.class)
|
||||
public @interface PropInteger {
|
||||
public static class PropertyInteger extends PropertyBase<Integer, PropInteger>
|
||||
{
|
||||
public PropertyInteger(final Field field, final BinnieConfiguration file, final ConfigProperty configProperty, final PropInteger annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return this.file.get(this.getCategory(), this.getKey(), this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getConfigValue() {
|
||||
return this.property.getInt(this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
this.addComment("Default value is " + this.defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropPercentage.PropertyPercentage.class)
|
||||
public @interface PropPercentage {
|
||||
int upper() default 100;
|
||||
|
||||
int lower() default 0;
|
||||
|
||||
public static class PropertyPercentage extends PropertyBase<Integer, PropPercentage>
|
||||
{
|
||||
public PropertyPercentage(final Field field, final BinnieConfiguration file, final ConfigProperty configProperty, final PropPercentage annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getConfigValue() {
|
||||
return this.property.getInt(this.defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
this.addComment("Default value is " + this.defaultValue + "%.");
|
||||
this.addComment("Range is " + this.annotatedProperty.lower() + "-" + this.annotatedProperty.upper() + "%.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return this.file.get(this.getCategory(), this.getKey(), this.defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
abstract class PropertyBase<ValueType, AnnotationType extends Annotation>
|
||||
{
|
||||
Configuration file;
|
||||
Property property;
|
||||
ValueType defaultValue;
|
||||
private ConfigProperty configProperty;
|
||||
AnnotationType annotatedProperty;
|
||||
private List<String> comments;
|
||||
private Field field;
|
||||
|
||||
protected PropertyBase(final Field field, final BinnieConfiguration file, final ConfigProperty configProperty, final AnnotationType annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
this.comments = new ArrayList<String>();
|
||||
this.field = field;
|
||||
this.file = file;
|
||||
this.configProperty = configProperty;
|
||||
this.annotatedProperty = annotedProperty;
|
||||
this.defaultValue = this.getDefaultValue(field);
|
||||
this.property = this.getProperty();
|
||||
for (final String comment : configProperty.comment()) {
|
||||
this.addComment(comment);
|
||||
}
|
||||
this.addComments();
|
||||
this.property.comment = this.getComment();
|
||||
field.set(null, this.getConfigValue());
|
||||
}
|
||||
|
||||
protected abstract Property getProperty();
|
||||
|
||||
protected abstract ValueType getConfigValue();
|
||||
|
||||
protected abstract void addComments();
|
||||
|
||||
protected String getCategory() {
|
||||
return this.configProperty.category().equals("") ? this.annotatedProperty.annotationType().getAnnotation(ConfigProperty.Type.class).category() : this.configProperty.category();
|
||||
}
|
||||
|
||||
protected String getKey() {
|
||||
return this.configProperty.key();
|
||||
}
|
||||
|
||||
protected ValueType getDefaultValue(final Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
return (ValueType) field.get(null);
|
||||
}
|
||||
|
||||
protected void addComment(final String comment) {
|
||||
this.comments.add(comment);
|
||||
}
|
||||
|
||||
protected String getComment() {
|
||||
String comment = "";
|
||||
for (final String com : this.comments) {
|
||||
comment = comment + com + " ";
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.parser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import binnie.core.AbstractMod;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class FieldParser
|
||||
{
|
||||
public static Collection<FieldParser> parsers;
|
||||
|
||||
public abstract boolean isHandled(final Field p0, final AbstractMod p1);
|
||||
|
||||
public void preInit(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
}
|
||||
|
||||
public void init(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
}
|
||||
|
||||
public void postInit(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
}
|
||||
|
||||
public static void preInitParse(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
for (final FieldParser parser : FieldParser.parsers) {
|
||||
if (parser.isHandled(field, mod)) {
|
||||
parser.preInit(field, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initParse(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
for (final FieldParser parser : FieldParser.parsers) {
|
||||
if (parser.isHandled(field, mod)) {
|
||||
parser.init(field, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void postInitParse(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
for (final FieldParser parser : FieldParser.parsers) {
|
||||
if (parser.isHandled(field, mod)) {
|
||||
parser.postInit(field, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
FieldParser.parsers = new ArrayList<FieldParser>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.core.mod.parser;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import binnie.core.AbstractMod;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ItemParser extends FieldParser
|
||||
{
|
||||
@Override
|
||||
public boolean isHandled(final Field field, final AbstractMod mod) {
|
||||
return Item.class.isAssignableFrom(field.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit(final Field field, final AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
|
||||
final Item item = (Item) field.get(null);
|
||||
if (item != null) {
|
||||
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user