mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 23:46:05 +00:00
Yeet custom config in favor of NHLib (#53)
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: Maya <[email protected]>
This commit is contained in:
63 files changed
+160
-992
No files matched your search
@@ -8,7 +8,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
@@ -33,7 +32,9 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public abstract boolean isActive();
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getChannel();
|
||||
@@ -47,10 +48,6 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
return new IBinnieGUID[0];
|
||||
}
|
||||
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[0];
|
||||
}
|
||||
|
||||
public abstract IProxyCore getProxy();
|
||||
|
||||
public abstract String getModID();
|
||||
@@ -67,12 +64,6 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getConfigs() != null) {
|
||||
for (Class<?> cls : getConfigs()) {
|
||||
Binnie.Configuration.registerConfiguration(cls, this);
|
||||
}
|
||||
}
|
||||
|
||||
getProxy().preInit();
|
||||
for (IInitializable module : modules) {
|
||||
module.preInit();
|
||||
|
||||
@@ -22,8 +22,6 @@ import binnie.core.liquid.FluidContainer;
|
||||
import binnie.core.liquid.ItemFluidContainer;
|
||||
import binnie.core.machines.MachineGroup;
|
||||
import binnie.core.machines.storage.ModuleStorage;
|
||||
import binnie.core.mod.config.ConfigurationMain;
|
||||
import binnie.core.mod.config.ConfigurationMods;
|
||||
import binnie.core.mod.parser.FieldParser;
|
||||
import binnie.core.mod.parser.ItemParser;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
@@ -49,13 +47,16 @@ import forestry.api.core.ForestryEvent;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
@Mod(
|
||||
modid = "BinnieCore",
|
||||
name = "Binnie Core",
|
||||
modid = BinnieCore.CORE_MODID,
|
||||
name = BinnieCore.CORE_MOD_NAME,
|
||||
version = Tags.VERSION,
|
||||
useMetadata = true,
|
||||
dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)")
|
||||
public class BinnieCore extends AbstractMod {
|
||||
|
||||
public static final String CORE_MODID = "BinnieCore";
|
||||
public static final String CORE_MOD_NAME = "Binnie Core";
|
||||
|
||||
@Mod.Instance("BinnieCore")
|
||||
public static BinnieCore instance;
|
||||
|
||||
@@ -70,7 +71,6 @@ public class BinnieCore extends AbstractMod {
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
Binnie.Configuration.registerConfiguration(ConfigurationMods.class, this);
|
||||
for (ManagerBase baseManager : Binnie.Managers) {
|
||||
addModule(baseManager);
|
||||
}
|
||||
@@ -134,20 +134,12 @@ public class BinnieCore extends AbstractMod {
|
||||
return PluginManager.Module.ARBORICULTURE.isEnabled();
|
||||
}
|
||||
|
||||
public static boolean isBotanyActive() {
|
||||
return ConfigurationMods.botany;
|
||||
}
|
||||
|
||||
public static boolean isGeneticsActive() {
|
||||
return ConfigurationMods.genetics;
|
||||
}
|
||||
|
||||
public static boolean isExtraBeesActive() {
|
||||
return ConfigurationMods.extraBees && isApicultureActive();
|
||||
return isApicultureActive();
|
||||
}
|
||||
|
||||
public static boolean isExtraTreesActive() {
|
||||
return ConfigurationMods.extraTrees && isArboricultureActive();
|
||||
return isArboricultureActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,11 +207,6 @@ public class BinnieCore extends AbstractMod {
|
||||
Binnie.Resource.registerIcons(event.map, event.map.getTextureType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getConfigs() {
|
||||
return new Class[] { ConfigurationMain.class };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BinniePacketHandler> getPacketHandler() {
|
||||
return PacketHandler.class;
|
||||
|
||||
@@ -14,6 +14,7 @@ public class Mods {
|
||||
public static final Mod botania = new Mod("Botania");
|
||||
public static final Mod extraBiomes = new Mod("ExtrabiomesXL");
|
||||
public static final Mod dreamcraft = new Mod("dreamcraft");
|
||||
public static final Mod buildcraftCore = new Mod("BuildCraft|Core");
|
||||
|
||||
private static Item findItem(String modId, String name) {
|
||||
Item stack = GameRegistry.findItem(modId, name);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package binnie.core.craftgui.minecraft.control;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
@@ -17,8 +15,6 @@ import binnie.core.craftgui.minecraft.MinecraftTooltip;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.power.IPoweredMachine;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
@@ -34,17 +30,6 @@ public class ControlEnergyBar extends Control implements ITooltip {
|
||||
addAttribute(WidgetAttribute.MOUSE_OVER);
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public IPoweredMachine getClientPower() {
|
||||
IInventory inventory = Window.get(this).getInventory();
|
||||
TileEntityMachine machine = (inventory instanceof TileEntityMachine) ? (TileEntityMachine) inventory : null;
|
||||
if (machine == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return machine.getMachine().getInterface(IPoweredMachine.class);
|
||||
}
|
||||
|
||||
public float getPercentage() {
|
||||
float percentage = 100.0f * getStoredEnergy() / getMaxEnergy();
|
||||
if (percentage > 100.0f) {
|
||||
|
||||
@@ -58,9 +58,8 @@ public class ManagerGenetics extends ManagerBase {
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
mothBreedingSystem = new MothBreedingSystem();
|
||||
}
|
||||
if (BinnieCore.isBotanyActive()) {
|
||||
flowerBreedingSystem = new FlowerBreedingSystem();
|
||||
}
|
||||
|
||||
flowerBreedingSystem = new FlowerBreedingSystem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ModuleItems implements IInitializable {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onUseFieldKit(PlayerInteractEvent event) {
|
||||
if (!BinnieCore.isBotanyActive() || event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,4 @@ import binnie.core.network.IOrdinaled;
|
||||
public interface IMachineType extends IOrdinaled {
|
||||
|
||||
Class<? extends MachinePackage> getPackageClass();
|
||||
|
||||
boolean isActive();
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class MachineGroup {
|
||||
this.blockName = blockName;
|
||||
|
||||
for (IMachineType type : types) {
|
||||
if (type.getPackageClass() != null && type.isActive()) {
|
||||
if (type.getPackageClass() != null) {
|
||||
try {
|
||||
MachinePackage pack = type.getPackageClass().newInstance();
|
||||
pack.assignMetadata(type.ordinal());
|
||||
pack.setActive(type.isActive());
|
||||
pack.setActive(true);
|
||||
addPackage(pack);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to create machine package " + type.toString(), e);
|
||||
throw new RuntimeException("Failed to create machine package " + type, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
|
||||
// TODO unused class?
|
||||
public class TransferHandler {
|
||||
|
||||
public static ItemStack transfer(ItemStack item, IInventory origin, IInventory destination, boolean doAdd) {
|
||||
ItemStack ret = transferItemToInventory(item, destination, doAdd);
|
||||
if (destination instanceof ITankMachine) {
|
||||
ret = transferContainerIntoTank(ret, origin, (ITankMachine) destination, doAdd);
|
||||
ret = transferTankIntoContainer(ret, origin, (ITankMachine) destination, doAdd);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack transferItemToInventory(ItemStack item, IInventory destination, boolean doAdd) {
|
||||
if (item == null || destination == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
ItemStack addition = item.copy();
|
||||
for (int i = 0; i < destination.getSizeInventory(); ++i) {
|
||||
addition = transferToInventory(addition, destination, new int[] { i }, doAdd, false);
|
||||
if (addition == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return addition;
|
||||
}
|
||||
|
||||
public static ItemStack transferToInventory(ItemStack item, IInventory destination, int[] targetSlots,
|
||||
boolean doAdd, boolean ignoreValidation) {
|
||||
for (int i : targetSlots) {
|
||||
if (destination.isItemValidForSlot(i, item) || ignoreValidation) {
|
||||
if (destination.getStackInSlot(i) == null) {
|
||||
if (doAdd) {
|
||||
destination.setInventorySlotContents(i, item.copy());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (item.isStackable()) {
|
||||
ItemStack merged = destination.getStackInSlot(i).copy();
|
||||
ItemStack[] newStacks = mergeStacks(item.copy(), merged.copy());
|
||||
item = newStacks[0];
|
||||
if (doAdd) {
|
||||
destination.setInventorySlotContents(i, newStacks[1]);
|
||||
}
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack[] mergeStacks(ItemStack itemstack, ItemStack merged) {
|
||||
if (ItemStack.areItemStackTagsEqual(itemstack, merged) && itemstack.isItemEqual(merged)) {
|
||||
int space = merged.getMaxStackSize() - merged.stackSize;
|
||||
if (space > 0) {
|
||||
if (itemstack.stackSize > space) {
|
||||
itemstack.stackSize -= space;
|
||||
merged.stackSize += space;
|
||||
} else {
|
||||
merged.stackSize += itemstack.stackSize;
|
||||
itemstack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStack[] { itemstack, merged };
|
||||
}
|
||||
|
||||
public static ItemStack transferContainerIntoTank(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
boolean doAdd) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IFluidTank[] tanks = destination.getTanks();
|
||||
ItemStack stack = item.copy();
|
||||
for (int i = 0; i < tanks.length; ++i) {
|
||||
stack = transferToTank(stack, origin, destination, i, doAdd);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack transferTankIntoContainer(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
boolean doAdd) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IFluidTank[] tanks = destination.getTanks();
|
||||
ItemStack stack = item.copy();
|
||||
for (int i = 0; i < tanks.length; ++i) {
|
||||
stack = transferFromTank(stack, origin, destination, i, doAdd);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack transferToTank(ItemStack item, IInventory origin, ITankMachine destination, int tankID,
|
||||
boolean doAdd) {
|
||||
if (item == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
FluidStack containerLiquid = null;
|
||||
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
|
||||
for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry
|
||||
.getRegisteredFluidContainerData()) {
|
||||
if (data.filledContainer.isItemEqual(item)) {
|
||||
containerLiquidData = data;
|
||||
containerLiquid = data.fluid.copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (containerLiquid == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
IFluidTank tank = destination.getTanks()[tankID];
|
||||
IValidatedTankContainer validated = Machine.getInterface(IValidatedTankContainer.class, destination);
|
||||
if (validated != null && !validated.isLiquidValidForTank(containerLiquid, tankID)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
FluidStack largeAmountOfLiquid = containerLiquid.copy();
|
||||
largeAmountOfLiquid.amount = tank.getCapacity();
|
||||
int amountAdded = tank.fill(largeAmountOfLiquid, false);
|
||||
int numberOfContainersToAdd = amountAdded / containerLiquid.amount;
|
||||
if (numberOfContainersToAdd > item.stackSize) {
|
||||
numberOfContainersToAdd = item.stackSize;
|
||||
}
|
||||
|
||||
ItemStack copy;
|
||||
ItemStack leftOverContainers = copy = item.copy();
|
||||
copy.stackSize -= numberOfContainersToAdd;
|
||||
if (leftOverContainers.stackSize <= 0) {
|
||||
leftOverContainers = null;
|
||||
}
|
||||
|
||||
ItemStack emptyContainers = containerLiquidData.emptyContainer.copy();
|
||||
emptyContainers.stackSize = 0;
|
||||
ItemStack itemStack = emptyContainers;
|
||||
itemStack.stackSize += numberOfContainersToAdd;
|
||||
if (emptyContainers.stackSize <= 0) {
|
||||
emptyContainers = null;
|
||||
}
|
||||
|
||||
ItemStack containersThatCantBeDumped = transferItemToInventory(emptyContainers, origin, false);
|
||||
if (containersThatCantBeDumped != null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (doAdd) {
|
||||
FluidStack copy2;
|
||||
FluidStack liquidToFillTank = copy2 = containerLiquid.copy();
|
||||
copy2.amount *= numberOfContainersToAdd;
|
||||
tank.fill(liquidToFillTank, true);
|
||||
transferItemToInventory(emptyContainers, origin, true);
|
||||
}
|
||||
return leftOverContainers;
|
||||
}
|
||||
|
||||
public static ItemStack transferFromTank(ItemStack item, IInventory origin, ITankMachine destination, int tankID,
|
||||
boolean doAdd) {
|
||||
if (item == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
IFluidTank tank = destination.getTanks()[tankID];
|
||||
FluidStack liquidInTank = tank.getFluid();
|
||||
if (liquidInTank == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
FluidContainerRegistry.FluidContainerData containerLiquidData = null;
|
||||
for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry
|
||||
.getRegisteredFluidContainerData()) {
|
||||
if (data.emptyContainer.isItemEqual(item) && liquidInTank.isFluidEqual(data.fluid)) {
|
||||
containerLiquidData = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (containerLiquidData == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
int maximumExtractedLiquid = item.stackSize * containerLiquidData.fluid.amount;
|
||||
FluidStack drainedLiquid = tank.drain(maximumExtractedLiquid, false);
|
||||
int amountInTank = (drainedLiquid == null) ? 0 : drainedLiquid.amount;
|
||||
int numberOfContainersToFill = amountInTank / containerLiquidData.fluid.amount;
|
||||
if (numberOfContainersToFill > item.stackSize) {
|
||||
numberOfContainersToFill = item.stackSize;
|
||||
}
|
||||
|
||||
ItemStack copy;
|
||||
ItemStack leftOverContainers = copy = item.copy();
|
||||
copy.stackSize -= numberOfContainersToFill;
|
||||
if (leftOverContainers.stackSize <= 0) {
|
||||
leftOverContainers = null;
|
||||
}
|
||||
|
||||
ItemStack filledContainers = containerLiquidData.filledContainer.copy();
|
||||
filledContainers.stackSize = 0;
|
||||
ItemStack itemStack = filledContainers;
|
||||
itemStack.stackSize += numberOfContainersToFill;
|
||||
if (filledContainers.stackSize <= 0) {
|
||||
filledContainers = null;
|
||||
}
|
||||
|
||||
ItemStack containersThatCantBeDumped = transferItemToInventory(filledContainers, origin, false);
|
||||
if (containersThatCantBeDumped != null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (doAdd) {
|
||||
tank.drain(maximumExtractedLiquid, true);
|
||||
transferItemToInventory(filledContainers, origin, true);
|
||||
}
|
||||
return leftOverContainers;
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,6 @@ enum Compartment implements IMachineType {
|
||||
return clss;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack get(int i) {
|
||||
return new ItemStack(BinnieCore.packageCompartment.getBlock(), i, ordinal());
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package binnie.core.machines.transfer;
|
||||
|
||||
// TODO unused class?
|
||||
public class TransferHandler {
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
|
||||
public class BinnieConfiguration extends Configuration {
|
||||
|
||||
public AbstractMod mod;
|
||||
private final String filename;
|
||||
|
||||
public BinnieConfiguration(String filename, AbstractMod mod) {
|
||||
super(new File(BinnieCore.proxy.getDirectory(), filename));
|
||||
this.mod = mod;
|
||||
this.filename = filename;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
// TODO Why do we need this class?
|
||||
class BinnieItemData {
|
||||
|
||||
private final int item;
|
||||
private final BinnieConfiguration configFile;
|
||||
private final String configKey;
|
||||
|
||||
public BinnieItemData(int item, BinnieConfiguration configFile, String configKey) {
|
||||
this.item = item;
|
||||
this.configFile = configFile;
|
||||
this.configKey = configKey;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ConfigFile {
|
||||
|
||||
String filename();
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.FIELD })
|
||||
public @interface ConfigProperty {
|
||||
|
||||
String key();
|
||||
|
||||
String category() default "";
|
||||
|
||||
String[] comment() default {};
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.ANNOTATION_TYPE })
|
||||
@interface Type {
|
||||
|
||||
Class<? extends PropertyBase> propertyClass();
|
||||
|
||||
String category() default "general";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
@ConfigFile(filename = "/config/forestry/binniecore/main.conf")
|
||||
public class ConfigurationMain {
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
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 = true;
|
||||
|
||||
@ConfigProperty(key = "extraTrees", comment = { "Enables the Extra Trees Mod." })
|
||||
@PropBoolean
|
||||
public static boolean extraTrees = true;
|
||||
|
||||
@ConfigProperty(key = "botany", comment = { "Enables the Botany Mod." })
|
||||
@PropBoolean
|
||||
public static boolean botany = true;
|
||||
|
||||
@ConfigProperty(key = "genetics", comment = { "Enables the Genetics Mod." })
|
||||
@PropBoolean
|
||||
public static boolean genetics = true;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.ManagerBase;
|
||||
|
||||
public class ManagerConfig extends ManagerBase {
|
||||
|
||||
private final Map<Class<?>, Configuration> configurations;
|
||||
private final Map<AbstractMod, List<BinnieItemData>> itemIDs;
|
||||
|
||||
public ManagerConfig() {
|
||||
configurations = new LinkedHashMap<>();
|
||||
itemIDs = new HashMap<>();
|
||||
}
|
||||
|
||||
public void registerConfiguration(Class<?> cls, AbstractMod mod) {
|
||||
if (cls.isAnnotationPresent(ConfigFile.class)) {
|
||||
loadConfiguration(cls, mod);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadConfiguration(Class<?> cls, AbstractMod mod) {
|
||||
try {
|
||||
String filename = cls.getAnnotation(ConfigFile.class).filename();
|
||||
BinnieConfiguration config = new BinnieConfiguration(filename, mod);
|
||||
config.load();
|
||||
for (Field field : cls.getFields()) {
|
||||
if (field.isAnnotationPresent(ConfigProperty.class)) {
|
||||
ConfigProperty propertyAnnot = field.getAnnotation(ConfigProperty.class);
|
||||
for (Annotation annotation : field.getAnnotations()) {
|
||||
if (annotation.annotationType().isAnnotationPresent(ConfigProperty.Type.class)) {
|
||||
Class<?> propertyClass = annotation.annotationType()
|
||||
.getAnnotation(ConfigProperty.Type.class).propertyClass();
|
||||
// TODO what for?
|
||||
PropertyBase property = (PropertyBase) propertyClass.getConstructor(
|
||||
Field.class,
|
||||
BinnieConfiguration.class,
|
||||
ConfigProperty.class,
|
||||
annotation.annotationType()).newInstance(
|
||||
field,
|
||||
config,
|
||||
propertyAnnot,
|
||||
annotation.annotationType().cast(annotation));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
configurations.put(cls, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemID(Integer configValue, String configKey, BinnieConfiguration configFile) {
|
||||
if (!itemIDs.containsKey(configFile.mod)) {
|
||||
itemIDs.put(configFile.mod, new ArrayList<>());
|
||||
}
|
||||
itemIDs.get(configFile.mod).add(new BinnieItemData(configValue + 256, configFile, configKey));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropBoolean.PropertyBoolean.class)
|
||||
public @interface PropBoolean {
|
||||
|
||||
class PropertyBoolean extends PropertyBase<Boolean, PropBoolean> {
|
||||
|
||||
public PropertyBoolean(Field field, BinnieConfiguration file, ConfigProperty configProperty,
|
||||
PropBoolean annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return file.get(getCategory(), getKey(), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getConfigValue() {
|
||||
return property.getBoolean(defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
addComment("Default value is " + defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropDouble.PropertyDouble.class)
|
||||
public @interface PropDouble {
|
||||
|
||||
class PropertyDouble extends PropertyBase<Double, PropDouble> {
|
||||
|
||||
public PropertyDouble(Field field, BinnieConfiguration file, ConfigProperty configProperty,
|
||||
PropDouble annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return file.get(getCategory(), getKey(), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Double getConfigValue() {
|
||||
return property.getDouble(defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
addComment("Default value is " + defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropInteger.PropertyInteger.class)
|
||||
public @interface PropInteger {
|
||||
|
||||
class PropertyInteger extends PropertyBase<Integer, PropInteger> {
|
||||
|
||||
public PropertyInteger(Field field, BinnieConfiguration file, ConfigProperty configProperty,
|
||||
PropInteger annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return file.get(getCategory(), getKey(), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getConfigValue() {
|
||||
return property.getInt(defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
addComment("Default value is " + defaultValue + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ConfigProperty.Type(propertyClass = PropPercentage.PropertyPercentage.class)
|
||||
public @interface PropPercentage {
|
||||
|
||||
int upper() default 100;
|
||||
|
||||
int lower() default 0;
|
||||
|
||||
class PropertyPercentage extends PropertyBase<Integer, PropPercentage> {
|
||||
|
||||
public PropertyPercentage(Field field, BinnieConfiguration file, ConfigProperty configProperty,
|
||||
PropPercentage annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
super(field, file, configProperty, annotedProperty);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getConfigValue() {
|
||||
return property.getInt(defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addComments() {
|
||||
addComment("Default value is " + defaultValue + "%.");
|
||||
addComment("Range is " + annotatedProperty.lower() + "-" + annotatedProperty.upper() + "%.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Property getProperty() {
|
||||
return file.get(getCategory(), getKey(), defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package binnie.core.mod.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
public abstract class PropertyBase<ValueType, AnnotationType extends Annotation> {
|
||||
|
||||
protected Configuration file;
|
||||
protected Property property;
|
||||
protected ValueType defaultValue;
|
||||
protected AnnotationType annotatedProperty;
|
||||
|
||||
private final ConfigProperty configProperty;
|
||||
private final List<String> comments;
|
||||
private final Field field;
|
||||
|
||||
protected PropertyBase(Field field, BinnieConfiguration file, ConfigProperty configProperty,
|
||||
AnnotationType annotedProperty) throws IllegalArgumentException, IllegalAccessException {
|
||||
comments = new ArrayList<>();
|
||||
this.field = field;
|
||||
this.file = file;
|
||||
this.configProperty = configProperty;
|
||||
annotatedProperty = annotedProperty;
|
||||
defaultValue = getDefaultValue(field);
|
||||
property = getProperty();
|
||||
|
||||
for (String comment : configProperty.comment()) {
|
||||
addComment(comment);
|
||||
}
|
||||
addComments();
|
||||
property.comment = getComment();
|
||||
field.set(null, getConfigValue());
|
||||
}
|
||||
|
||||
protected abstract Property getProperty();
|
||||
|
||||
protected abstract ValueType getConfigValue();
|
||||
|
||||
protected abstract void addComments();
|
||||
|
||||
protected String getCategory() {
|
||||
return configProperty.category().isEmpty()
|
||||
? annotatedProperty.annotationType().getAnnotation(ConfigProperty.Type.class).category()
|
||||
: configProperty.category();
|
||||
}
|
||||
|
||||
protected String getKey() {
|
||||
return configProperty.key();
|
||||
}
|
||||
|
||||
protected ValueType getDefaultValue(Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
return (ValueType) field.get(null);
|
||||
}
|
||||
|
||||
protected void addComment(String comment) {
|
||||
comments.add(comment);
|
||||
}
|
||||
|
||||
protected String getComment() {
|
||||
StringBuilder comment = new StringBuilder();
|
||||
for (String com : comments) {
|
||||
comment.append(com).append(" ");
|
||||
}
|
||||
return comment.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package binnie.core.network.packet;
|
||||
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
// TODO unused interface?
|
||||
public interface IPacket {
|
||||
|
||||
Packet getPacket();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package binnie.core.network.packet;
|
||||
|
||||
// TODO unused class?
|
||||
public class IndexInPayload {
|
||||
|
||||
public int intIndex;
|
||||
public int floatIndex;
|
||||
public int stringIndex;
|
||||
|
||||
public IndexInPayload(int intIndex, int floatIndex, int stringIndex) {
|
||||
this.intIndex = intIndex;
|
||||
this.floatIndex = floatIndex;
|
||||
this.stringIndex = stringIndex;
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,4 @@ public class MessageContainerUpdate extends MessageCraftGUI {
|
||||
super(nbt);
|
||||
}
|
||||
|
||||
// TODO unused constructor?
|
||||
public MessageContainerUpdate(MessageBinnie message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package binnie.core.network.packet;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -18,11 +17,6 @@ public class MessageCoordinates extends MessageBase {
|
||||
super(message);
|
||||
}
|
||||
|
||||
// TODO unused constructor?
|
||||
public MessageCoordinates(int id, ChunkCoordinates coordinates) {
|
||||
this(id, coordinates.posX, coordinates.posY, coordinates.posZ);
|
||||
}
|
||||
|
||||
public MessageCoordinates(int id, int posX, int posY, int posZ) {
|
||||
super(id);
|
||||
this.posX = posX;
|
||||
@@ -44,11 +38,6 @@ public class MessageCoordinates extends MessageBase {
|
||||
posZ = data.readInt();
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(posX, posY, posZ);
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(World world) {
|
||||
return world.getTileEntity(posX, posY, posZ);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import binnie.core.network.INetworkedEntity;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -75,8 +74,4 @@ public class MessageUpdate extends MessageCoordinates {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public TileEntity getTarget(World world) {
|
||||
return world.getTileEntity(posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package binnie.core.network.packet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.core.network.INetworkedEntity;
|
||||
|
||||
public class PacketPayload {
|
||||
|
||||
public List<Integer> intPayload;
|
||||
@@ -17,12 +15,6 @@ public class PacketPayload {
|
||||
stringPayload = new ArrayList<>();
|
||||
}
|
||||
|
||||
// TODO unused constructor?
|
||||
public PacketPayload(INetworkedEntity tile) {
|
||||
this();
|
||||
tile.writeToPacket(this);
|
||||
}
|
||||
|
||||
public void addInteger(int a) {
|
||||
intPayload.add(a);
|
||||
}
|
||||
@@ -47,16 +39,6 @@ public class PacketPayload {
|
||||
return stringPayload.remove(0);
|
||||
}
|
||||
|
||||
// TODO unused method
|
||||
public void append(PacketPayload other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
intPayload.addAll(other.intPayload);
|
||||
floatPayload.addAll(other.floatPayload);
|
||||
stringPayload.addAll(other.stringPayload);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return intPayload.isEmpty() && floatPayload.isEmpty() && stringPayload.isEmpty();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import binnie.core.network.INetworkedEntity;
|
||||
import binnie.core.network.packet.MessageUpdate;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
@@ -69,11 +68,6 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public void throwException(String message, Throwable e) {
|
||||
FMLCommonHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecraft getMinecraftInstance() {
|
||||
return null;
|
||||
@@ -129,16 +123,6 @@ public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public void handleTextureRefresh(IIconRegister register, int type) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public void handlePostTextureRefresh(IIconRegister register, int type) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public short getUniqueTextureUID() {
|
||||
uniqueTextureUID++;
|
||||
return uniqueTextureUID;
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
@@ -139,13 +138,6 @@ public class BinnieProxyClient extends BinnieProxy implements IBinnieProxy {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
// TODO unused method?
|
||||
public void handlePreTextureRefresh(IIconRegister register, int type) {
|
||||
if (type == 0) {
|
||||
Binnie.Liquid.reloadIcons(register);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
|
||||
|
||||
Reference in new issue
Block a user