diff --git a/api/forestry b/api/forestry deleted file mode 160000 index 5e44fe9c6..000000000 --- a/api/forestry +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5e44fe9c6a9cfb4415b3e6f1d522f6ae057b9294 diff --git a/api/redstoneflux b/api/redstoneflux deleted file mode 160000 index 10e10af21..000000000 --- a/api/redstoneflux +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 10e10af21489e351624813120ed6474c44b09ff6 diff --git a/build.gradle b/build.gradle index 3252d89f1..11f6d5358 100755 --- a/build.gradle +++ b/build.gradle @@ -39,8 +39,8 @@ targetCompatibility = 1.7 minecraft { version = mcversion + "-" + forgeversion runDir = "run" - - mappings = "stable_20" + useDepAts = true + mappings = mcp_mappings replace '@VERSION@', project.version replace '@BUILD_NUMBER@', getBuildNumber() @@ -59,6 +59,13 @@ sourceSets { } repositories { + maven { + url "http://dvs1.progwml6.com/files/maven" + } +} + +dependencies { + deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}" } configurations { @@ -68,9 +75,6 @@ configurations { compile.extendsFrom shade } -dependencies { -} - processResources { // this will ensure that this task is redone when the versions change. diff --git a/gradle.properties b/gradle.properties index 871f3031a..c606f99cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,9 @@ mcversion=1.8.9 -forgeversion=11.15.0.1708 -version_major=4 -version_minor=3 +forgeversion=11.15.1.1755 +mcp_mappings=snapshot_20160219 + +jei_version=2.28.+ + +version_major=5 +version_minor=0 version_patch=0 diff --git a/src/main/java/cofh/LICENSE - LGPLv3.txt b/src/main/java/cofh/LICENSE - LGPLv3.txt new file mode 100644 index 000000000..65c5ca88a --- /dev/null +++ b/src/main/java/cofh/LICENSE - LGPLv3.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/main/java/cofh/README.md b/src/main/java/cofh/README.md new file mode 100644 index 000000000..3f855b753 --- /dev/null +++ b/src/main/java/cofh/README.md @@ -0,0 +1,11 @@ +Redstone Flux API +==================================== +This is the standalone CoFH Energy API - also known as the "Redstone Flux" API. + +Make great use of it. + +You are of course free to modify any/all of this code and even repackage it, but then it wouldn't be an awesome crossmod API anymore, now would it? + +Don't be a jerk. + +~Team CoFH \ No newline at end of file diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java new file mode 100644 index 000000000..eb2e05ade --- /dev/null +++ b/src/main/java/cofh/api/CoFHAPIProps.java @@ -0,0 +1,11 @@ +package cofh.api; + +public class CoFHAPIProps { + + private CoFHAPIProps() { + + } + + public static final String VERSION = "1.8.9R1.2.0B1"; + +} diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java new file mode 100644 index 000000000..dd7dd3e02 --- /dev/null +++ b/src/main/java/cofh/api/energy/EnergyStorage.java @@ -0,0 +1,162 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; + +/** + * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class EnergyStorage implements IEnergyStorage { + + protected int energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public EnergyStorage(int capacity) { + + this(capacity, capacity, capacity); + } + + public EnergyStorage(int capacity, int maxTransfer) { + + this(capacity, maxTransfer, maxTransfer); + } + + public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public EnergyStorage readFromNBT(NBTTagCompound nbt) { + + this.energy = nbt.getInteger("Energy"); + + if (energy > capacity) { + energy = capacity; + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + + if (energy < 0) { + energy = 0; + } + nbt.setInteger("Energy", energy); + return nbt; + } + + public EnergyStorage setCapacity(int capacity) { + + this.capacity = capacity; + + if (energy > capacity) { + energy = capacity; + } + return this; + } + + public EnergyStorage setMaxTransfer(int maxTransfer) { + + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + return this; + } + + public EnergyStorage setMaxReceive(int maxReceive) { + + this.maxReceive = maxReceive; + return this; + } + + public EnergyStorage setMaxExtract(int maxExtract) { + + this.maxExtract = maxExtract; + return this; + } + + public int getMaxReceive() { + + return maxReceive; + } + + public int getMaxExtract() { + + return maxExtract; + } + + /** + * This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers + * are guaranteed to have it. + * + * @param energy + */ + public void setEnergyStored(int energy) { + + this.energy = energy; + + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + /** + * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this + * externally, as not all IEnergyHandlers are guaranteed to have it. + * + * @param energy + */ + public void modifyEnergyStored(int energy) { + + this.energy += energy; + + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + /* IEnergyStorage */ + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + } + return energyReceived; + } + + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + } + return energyExtracted; + } + + @Override + public int getEnergyStored() { + + return energy; + } + + @Override + public int getMaxEnergyStored() { + + return capacity; + } + +} diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java new file mode 100644 index 000000000..29ef0a1ce --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyConnection.java @@ -0,0 +1,22 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + + +/** + * Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not + * accept it; otherwise just use IEnergyHandler. + *

+ * Note that {@link IEnergyHandler} is an extension of this. + * + * @author King Lemming + * + */ +public interface IEnergyConnection { + + /** + * Returns TRUE if the TileEntity can connect on a given side. + */ + boolean canConnectEnergy(EnumFacing from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java new file mode 100644 index 000000000..3ef725765 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyContainerItem.java @@ -0,0 +1,52 @@ +package cofh.api.energy; + +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on Item classes that support external manipulation of their internal energy storages. + *

+ * A reference implementation is provided {@link ItemEnergyContainer}. + * + * @author King Lemming + * + */ +public interface IEnergyContainerItem { + + /** + * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. + * + * @param container + * ItemStack to be charged. + * @param maxReceive + * Maximum amount of energy to be sent into the item. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received by the item. + */ + int receiveEnergy(ItemStack container, int maxReceive, boolean simulate); + + /** + * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally + * discharged. + * + * @param container + * ItemStack to be discharged. + * @param maxExtract + * Maximum amount of energy to be extracted from the item. + * @param simulate + * If TRUE, the discharge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted from the item. + */ + int extractEnergy(ItemStack container, int maxExtract, boolean simulate); + + /** + * Get the amount of energy currently stored in the container item. + */ + int getEnergyStored(ItemStack container); + + /** + * Get the max amount of energy that can be stored in the container item. + */ + int getMaxEnergyStored(ItemStack container); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java new file mode 100644 index 000000000..16b236e7a --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -0,0 +1,27 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + +/** + * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + *

+ * Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this. + * + * @author King Lemming + * + */ +public interface IEnergyHandler extends IEnergyConnection { + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(EnumFacing from); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(EnumFacing from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyProvider.java b/src/main/java/cofh/api/energy/IEnergyProvider.java new file mode 100644 index 000000000..ef0e09d06 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyProvider.java @@ -0,0 +1,29 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + + +/** + * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyProvider extends IEnergyHandler { + + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. + * + * @param from + * Orientation the energy is extracted from. + * @param maxExtract + * Maximum amount of energy to extract. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted. + */ + int extractEnergy(EnumFacing from, int maxExtract, boolean simulate); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyReceiver.java b/src/main/java/cofh/api/energy/IEnergyReceiver.java new file mode 100644 index 000000000..989e9baa5 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyReceiver.java @@ -0,0 +1,29 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + + +/** + * Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyReceiver extends IEnergyHandler { + + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. + * + * @param from + * Orientation the energy is received from. + * @param maxReceive + * Maximum amount of energy to receive. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received. + */ + int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java new file mode 100644 index 000000000..414b26566 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -0,0 +1,46 @@ +package cofh.api.energy; + +/** + * An energy storage is the unit of interaction with Energy inventories.
+ * This is not to be implemented on TileEntities. This is for internal use only. + *

+ * A reference implementation can be found at {@link EnergyStorage}. + * + * @author King Lemming + * + */ +public interface IEnergyStorage { + + /** + * Adds energy to the storage. Returns quantity of energy that was accepted. + * + * @param maxReceive + * Maximum amount of energy to be inserted. + * @param simulate + * If TRUE, the insertion will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) accepted by the storage. + */ + int receiveEnergy(int maxReceive, boolean simulate); + + /** + * Removes energy from the storage. Returns quantity of energy that was removed. + * + * @param maxExtract + * Maximum amount of energy to be extracted. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted from the storage. + */ + int extractEnergy(int maxExtract, boolean simulate); + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(); + +} diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java new file mode 100644 index 000000000..0fb36dab6 --- /dev/null +++ b/src/main/java/cofh/api/energy/ItemEnergyContainer.java @@ -0,0 +1,113 @@ +package cofh.api.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class ItemEnergyContainer extends Item implements IEnergyContainerItem { + + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public ItemEnergyContainer() { + + } + + public ItemEnergyContainer(int capacity) { + + this(capacity, capacity, capacity); + } + + public ItemEnergyContainer(int capacity, int maxTransfer) { + + this(capacity, maxTransfer, maxTransfer); + } + + public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { + + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public ItemEnergyContainer setCapacity(int capacity) { + + this.capacity = capacity; + return this; + } + + public ItemEnergyContainer setMaxTransfer(int maxTransfer) { + + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + return this; + } + + public ItemEnergyContainer setMaxReceive(int maxReceive) { + + this.maxReceive = maxReceive; + return this; + } + + public ItemEnergyContainer setMaxExtract(int maxExtract) { + + this.maxExtract = maxExtract; + return this; + } + + /* IEnergyContainerItem */ + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (!container.hasTagCompound()) { + container.setTagCompound(new NBTTagCompound()); + } + int energy = container.getTagCompound().getInteger("Energy"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.getTagCompound().setInteger("Energy", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) { + return 0; + } + int energy = container.getTagCompound().getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.getTagCompound().setInteger("Energy", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + + if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) { + return 0; + } + return container.getTagCompound().getInteger("Energy"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + + return capacity; + } + +} diff --git a/src/main/java/cofh/api/energy/TileEnergyHandler.java b/src/main/java/cofh/api/energy/TileEnergyHandler.java new file mode 100644 index 000000000..3ba60a664 --- /dev/null +++ b/src/main/java/cofh/api/energy/TileEnergyHandler.java @@ -0,0 +1,67 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +/** + * Reference implementation of {@link IEnergyReceiver} and {@link IEnergyProvider}. Use/extend this or implement your own. + * + * This class is really meant to summarize how each interface is properly used. + * + * @author King Lemming + * + */ +public class TileEnergyHandler extends TileEntity implements IEnergyReceiver, IEnergyProvider { + + protected EnergyStorage storage = new EnergyStorage(32000); + + @Override + public void readFromNBT(NBTTagCompound nbt) { + + super.readFromNBT(nbt); + storage.readFromNBT(nbt); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + + super.writeToNBT(nbt); + storage.writeToNBT(nbt); + } + + /* IEnergyConnection */ + @Override + public boolean canConnectEnergy(EnumFacing from) { + + return true; + } + + /* IEnergyReceiver */ + @Override + public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { + + return storage.receiveEnergy(maxReceive, simulate); + } + + /* IEnergyProvider */ + @Override + public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { + + return storage.extractEnergy(maxExtract, simulate); + } + + /* IEnergyHandler */ + @Override + public int getEnergyStored(EnumFacing from) { + + return storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(EnumFacing from) { + + return storage.getMaxEnergyStored(); + } + +} diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/main/java/cofh/api/energy/package-info.java new file mode 100644 index 000000000..da8566735 --- /dev/null +++ b/src/main/java/cofh/api/energy/package-info.java @@ -0,0 +1,10 @@ +/** + * (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy") +package cofh.api.energy; + +import net.minecraftforge.fml.common.API; +import cofh.api.CoFHAPIProps; + diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java new file mode 100644 index 000000000..e2847daad --- /dev/null +++ b/src/main/java/cofh/api/package-info.java @@ -0,0 +1,9 @@ +/** + * (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI") +package cofh.api; + +import net.minecraftforge.fml.common.API; + diff --git a/src/main/java/forestry/api/LICENSE.txt b/src/main/java/forestry/api/LICENSE.txt new file mode 100644 index 000000000..45bdcf0c8 --- /dev/null +++ b/src/main/java/forestry/api/LICENSE.txt @@ -0,0 +1,11 @@ +License („MIT“) + +Forestry API + +Copyright (c) 2011 - 2014 SirSengir. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/forestry/api/README.md b/src/main/java/forestry/api/README.md new file mode 100644 index 000000000..e080d790c --- /dev/null +++ b/src/main/java/forestry/api/README.md @@ -0,0 +1,26 @@ +Forestry API +==================================== + +### What is it? + +Forestry is a modification for the game Minecraft and known primarily for its farms and bees. This is the API for inter-mod operations. + +### Homepage + +[Wiki](http://forestry.sengir.net/) + +[Forums](http://forestry.sengir.net/forum/) + +[IRC #forestry on esper.net](http://webchat.esper.net/?nick=ForestryWiki...&channels=forestry&prompt=1) + +### Notes + +This is only the API. It is not intended to be used by itself, but rather for use either with Forestry itself or another mod which wants to use a functionality of Forestry. + +Package versioning follows the rules laid out by http://semver.org/ + +Bugfixes are generally welcome. If you want to contribute something which changes game mechanics, please talk to someone with commit privileges first. Nothing is more frustrating than putting a lot of work and effort into a new game mechanic and then having the PR rejected because it doesn’t fit gameplay-wise. + +### License & Copyright + +Forestry API is (c) 2011 - 2014 SirSengir and licensed under MIT. See the LICENSE.txt for more information. Note that the core Forestry source is licensed differently! The Forestry API may also contain code contributed by CovertJaguar, Player, MysteriousAges, Binnie and others. diff --git a/src/main/java/forestry/api/apiculture/BeeManager.java b/src/main/java/forestry/api/apiculture/BeeManager.java new file mode 100644 index 000000000..280ee751f --- /dev/null +++ b/src/main/java/forestry/api/apiculture/BeeManager.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; +/** + * + * Some miscellaneous lists and settings for bees. + * + * @author SirSengir + */ +public class BeeManager { + + /** + * 0 - Common Village Bees 1 - Uncommon Village Bees (20 % of spawns) + */ + public static ArrayList[] villageBees; + + /** + * List of items that can induce swarming. Integer denotes x in 1000 chance. + */ + public static HashMap inducers = new HashMap(); + + /** + * Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootBees") + */ + public static IBeeRoot beeRoot; + + /** + * Used to create new bees. + */ + public static IBeeFactory beeFactory; + + /** + * Used to create new bee mutations. + */ + public static IBeeMutationFactory beeMutationFactory; + + /** + * Used to get Forestry's jubilance implementations. + */ + public static IJubilanceFactory jubilanceFactory; + + /** + * Used to check whether a player is wearing Apiarist Armor. + */ + public static IArmorApiaristHelper armorApiaristHelper; +} diff --git a/src/main/java/forestry/api/apiculture/DefaultBeeListener.java b/src/main/java/forestry/api/apiculture/DefaultBeeListener.java new file mode 100644 index 000000000..8e76cf28d --- /dev/null +++ b/src/main/java/forestry/api/apiculture/DefaultBeeListener.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IIndividual; + +/** + * Easily extendable default IBeeListener. + * By itself, this IBeeListener does nothing. + * BeeListeners should inherit from this class unless they need to listen for everything. + */ +public class DefaultBeeListener implements IBeeListener { + @Override + public void wearOutEquipment(int amount) { + + } + + @Override + public void onQueenDeath() { + + } + + @Override + public boolean onPollenRetrieved(IIndividual pollen) { + return false; + } + +} diff --git a/src/main/java/forestry/api/apiculture/DefaultBeeModifier.java b/src/main/java/forestry/api/apiculture/DefaultBeeModifier.java new file mode 100644 index 000000000..69c7f7194 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/DefaultBeeModifier.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +/** + * Easily extendable default IBeeModifier. + * By itself, this IBeeModifier does nothing. + * BeeModifiers should inherit from this class unless they modify everything. + */ +public class DefaultBeeModifier implements IBeeModifier { + + @Override + public float getTerritoryModifier(IBeeGenome genome, float currentModifier) { + return 1.0f; + } + + @Override + public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return 1.0f; + } + + @Override + public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) { + return 1.0f; + } + + @Override + public float getProductionModifier(IBeeGenome genome, float currentModifier) { + return 1.0f; + } + + @Override + public float getFloweringModifier(IBeeGenome genome, float currentModifier) { + return 1.0f; + } + + @Override + public float getGeneticDecay(IBeeGenome genome, float currentModifier) { + return 1.0f; + } + + @Override + public boolean isSealed() { + return false; + } + + @Override + public boolean isSelfLighted() { + return false; + } + + @Override + public boolean isSunlightSimulated() { + return false; + } + + @Override + public boolean isHellish() { + return false; + } + +} diff --git a/src/main/java/forestry/api/apiculture/EnumBeeChromosome.java b/src/main/java/forestry/api/apiculture/EnumBeeChromosome.java new file mode 100644 index 000000000..d23b0f5d7 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/EnumBeeChromosome.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Locale; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleFlowers; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.ISpeciesRoot; + +/** + * Enum representing the order of chromosomes in a bee's genome and what they control. + * + * @author SirSengir + */ +public enum EnumBeeChromosome implements IChromosomeType { + /** + * Species of the bee. Alleles here must implement {@link IAlleleBeeSpecies}. + */ + SPECIES(IAlleleBeeSpecies.class), + /** + * (Production) Speed of the bee. + */ + SPEED(IAlleleFloat.class), + /** + * Lifespan of the bee. + */ + LIFESPAN(IAlleleInteger.class), + /** + * Fertility of the bee. Determines number of offspring. + */ + FERTILITY(IAlleleInteger.class), + /** + * Temperature difference to its native supported one the bee can tolerate. + */ + TEMPERATURE_TOLERANCE(IAlleleTolerance.class), + /** + * Slightly incorrectly named. If true, a naturally dirunal bee can work during the night. If true, a naturally nocturnal bee can work during the day. + */ + NOCTURNAL(IAlleleBoolean.class), + /** + * Not used / superseded by fixed values for the species. Probably going to be replaced with a boolean for FIRE_RESIST. + */ + @Deprecated + HUMIDITY(IAllele.class), + /** + * Humidity difference to its native supported one the bee can tolerate. + */ + HUMIDITY_TOLERANCE(IAlleleTolerance.class), + /** + * If true the bee can work during rain. + */ + TOLERANT_FLYER(IAlleleBoolean.class), + /** + * If true, the bee can work without a clear view of the sky. + */ + CAVE_DWELLING(IAlleleBoolean.class), + /** + * Contains the supported flower provider. + */ + FLOWER_PROVIDER(IAlleleFlowers.class), + /** + * Determines pollination speed. + */ + FLOWERING(IAlleleInteger.class), + /** + * Determines the size of the bee's territory. + */ + TERRITORY(IAlleleArea.class), + /** + * Determines the bee's effect. + */ + EFFECT(IAlleleBeeEffect.class); + + Class clss; + + EnumBeeChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(Locale.ENGLISH); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return BeeManager.beeRoot; + } +} diff --git a/src/main/java/forestry/api/apiculture/EnumBeeType.java b/src/main/java/forestry/api/apiculture/EnumBeeType.java new file mode 100644 index 000000000..c1b6244a1 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/EnumBeeType.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Locale; + +import forestry.api.genetics.ISpeciesType; + +public enum EnumBeeType implements ISpeciesType { + DRONE, PRINCESS, QUEEN, LARVAE, NONE; + + public static final EnumBeeType[] VALUES = values(); + + String name; + + EnumBeeType() { + this.name = this.toString().toLowerCase(Locale.ENGLISH); + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/forestry/api/apiculture/FlowerManager.java b/src/main/java/forestry/api/apiculture/FlowerManager.java new file mode 100644 index 000000000..2acaf61de --- /dev/null +++ b/src/main/java/forestry/api/apiculture/FlowerManager.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IFlowerRegistry; + +public class FlowerManager { + /** + *

e.g. FlowerManager.flowerRegister.registerPlantableFlower(new ItemStack(Blocks.red_flower), 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
+ */ + public static IFlowerRegistry flowerRegistry; + + public static final String FlowerTypeVanilla = "flowersVanilla"; + public static final String FlowerTypeNether = "flowersNether"; + public static final String FlowerTypeCacti = "flowersCacti"; + public static final String FlowerTypeMushrooms = "flowersMushrooms"; + public static final String FlowerTypeEnd = "flowersEnd"; + public static final String FlowerTypeJungle = "flowersJungle"; + public static final String FlowerTypeSnow = "flowersSnow"; + public static final String FlowerTypeWheat = "flowersWheat"; + public static final String FlowerTypeGourd = "flowersGourd"; + +} diff --git a/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java b/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java new file mode 100644 index 000000000..b2dddb319 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IAlleleBeeEffect.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +public interface IAlleleBeeEffect extends IAlleleEffect { + + /** + * Called by apiaries to cause an effect in the world. + * + * @param genome + * Genome of the bee queen causing this effect + * @param storedData + * Object containing the stored effect data for the apiary/hive the bee is in. + * @param housing {@link IBeeHousing} the bee currently resides in. + * @return storedData, may have been manipulated. + */ + IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); + + /** + * Is called to produce bee effects. + * + * @param genome + * @param storedData + * Object containing the stored effect data for the apiary/hive the bee is in. + * @param housing {@link IBeeHousing} the bee currently resides in. + * @return storedData, may have been manipulated. + */ + IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing); + +} diff --git a/src/main/java/forestry/api/apiculture/IAlleleBeeSpecies.java b/src/main/java/forestry/api/apiculture/IAlleleBeeSpecies.java new file mode 100644 index 000000000..b1d198421 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IAlleleBeeSpecies.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Map; + +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.genetics.IAlleleSpecies; + +public interface IAlleleBeeSpecies extends IAlleleSpecies { + + /** + * @return the IBeeRoot + */ + @Override + IBeeRoot getRoot(); + + /** + * @return true if this species is only active at night. + */ + boolean isNocturnal(); + + /** + * @return Map of possible products with the chance for drop each bee cycle. (0 - 1] + */ + Map getProductChances(); + + /** + * @return Map of possible specialities with the chance for drop each bee cycle. (0 - 1] + */ + Map getSpecialtyChances(); + + /** + * Only jubilant bees produce specialities. + * @return true if the bee is jubilant, false otherwise. + */ + boolean isJubilant(IBeeGenome genome, IBeeHousing housing); + + @SideOnly(Side.CLIENT) + ModelResourceLocation getModel(EnumBeeType type); + + /** + * @deprecated since Forestry 3.6. + * @return Path of the texture to use for entity rendering. + */ + @Deprecated + String getEntityTexture(); + +} diff --git a/src/main/java/forestry/api/apiculture/IAlleleBeeSpeciesCustom.java b/src/main/java/forestry/api/apiculture/IAlleleBeeSpeciesCustom.java new file mode 100644 index 000000000..9f7de5a51 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IAlleleBeeSpeciesCustom.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +import forestry.api.genetics.IAlleleSpeciesCustom; + +public interface IAlleleBeeSpeciesCustom extends IAlleleBeeSpecies, IAlleleSpeciesCustom { + + /** + * Add a product for this bee species. + * Chance is between 0 and 1. + */ + IAlleleBeeSpeciesCustom addProduct(ItemStack product, Float chance); + + /** + * Add a specialty product for this bee species. + * Bees only produce their specialty when they are Jubilant (see IJubilanceProvider) + * Chance is between 0 and 1. + */ + IAlleleBeeSpeciesCustom addSpecialty(ItemStack specialty, Float chance); + + /** + * Set the Jubilance Provider for this bee species. + * Bees only produce their specialty when they are Jubilant (see IJubilanceProvider) + */ + IAlleleBeeSpeciesCustom setJubilanceProvider(IJubilanceProvider provider); + + /** + * Make this species only active at night. + */ + IAlleleBeeSpeciesCustom setNocturnal(); + + /** Use this if you have custom icons for bees. */ + IAlleleBeeSpeciesCustom setCustomBeeModelProvider(IBeeModelProvider beeIconProvider); + + /** Use this if you have custom icon colours for bees (other than the default static primary + secondary colours). */ + IAlleleBeeSpeciesCustom setCustomBeeSpriteColourProvider(IBeeSpriteColourProvider beeIconColourProvider); +} diff --git a/src/main/java/forestry/api/apiculture/IApiaristTracker.java b/src/main/java/forestry/api/apiculture/IApiaristTracker.java new file mode 100644 index 000000000..0c65f56be --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IApiaristTracker.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IIndividual; + +/** + * Can be used to garner information on bee breeding. See {@link forestry.api.genetics.ISpeciesRoot} for retrieval functions. + * + * @author SirSengir + */ +public interface IApiaristTracker extends IBreedingTracker { + + /** + * Register the birth of a queen. Will mark species as discovered. + * + * @param queen + * Created queen. + */ + void registerQueen(IIndividual queen); + + /** + * @return Amount of queens bred with this tracker. + */ + int getQueenCount(); + + /** + * Register the birth of a princess. Will mark species as discovered. + * + * @param princess + * Created princess. + */ + void registerPrincess(IIndividual princess); + + /** + * @return Amount of princesses bred with this tracker. + */ + int getPrincessCount(); + + /** + * Register the birth of a drone. Will mark species as discovered. + * + * @param drone + * Created drone. + */ + void registerDrone(IIndividual drone); + + /** + * @return Amount of drones bred with this tracker. + */ + int getDroneCount(); + +} diff --git a/src/main/java/forestry/api/apiculture/IArmorApiarist.java b/src/main/java/forestry/api/apiculture/IArmorApiarist.java new file mode 100644 index 000000000..ef87163ef --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IArmorApiarist.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * When implemented by armor piece items, allows them to act as apiarist's armor. + */ +public interface IArmorApiarist { + /** + * Called when the apiarist's armor acts as protection against an attack. + * + * @param entity Entity being attacked + * @param armor Armor item + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return Whether or not the armor should protect the player from that attack + */ + boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect); + + /** + * Called when the apiarist's armor acts as protection against an attack. + * + * @param player Player being attacked + * @param armor Armor item + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return Whether or not the armor should protect the player from that attack + * @deprecated since Forestry 4.2. Use protectEntity + */ + @Deprecated + public boolean protectPlayer(EntityPlayer player, ItemStack armor, String cause, boolean doProtect); +} diff --git a/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java b/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java new file mode 100644 index 000000000..b0f652f0d --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Helper class for checking whether an entity is wearing Apiarist Armor + * + * @author Vexatos + */ +public interface IArmorApiaristHelper { + + /** + * Called when the apiarist's armor acts as protection against an attack. + * @param stack ItemStack to check + * @param entity Entity being attacked + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return Whether or not the item is valid Apiarist Armor and should protect the player from that attack + * @since Forestry 4.2 + */ + boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect); + + /** + * Called when the apiarist's armor acts as protection against an attack. + * @param entity Entity being attacked + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting + * @since Forestry 4.2 + */ + int wearsItems(EntityLivingBase entity, String cause, boolean doProtect); + + /** + * Called when the apiarist's armor acts as protection against an attack. + * @param stack ItemStack to check + * @param player Player being attacked + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return Whether or not the item is valid Apiarist Armor and should protect the player from that attack + * @deprecated since Forestry 4.2. use the EntityLivingBase version + */ + @Deprecated + boolean isArmorApiarist(ItemStack stack, EntityPlayer player, String cause, boolean doProtect); + + /** + * Called when the apiarist's armor acts as protection against an attack. + * @param player Player being attacked + * @param cause Optional cause of attack, such as a bee effect identifier + * @param doProtect Whether or not to actually do the side effects of protection + * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting + * @deprecated since Forestry 4.2. use the EntityLivingBase version + */ + @Deprecated + int wearsItems(EntityPlayer player, String cause, boolean doProtect); +} diff --git a/src/main/java/forestry/api/apiculture/IBee.java b/src/main/java/forestry/api/apiculture/IBee.java new file mode 100644 index 000000000..7b65a40bc --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBee.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.List; +import java.util.Set; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; + +import forestry.api.core.IErrorState; +import forestry.api.genetics.IEffectData; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IIndividualLiving; + +/** + * Other implementations than Forestry's default one are not supported. + * + * @author SirSengir + */ +public interface IBee extends IIndividualLiving { + + /** + * @return Bee's genetic information. + */ + @Override + IBeeGenome getGenome(); + + /** + * @return Genetic information of the bee's mate, null if unmated. + */ + @Override + IBeeGenome getMate(); + + /** + * @return true if the individual is originally of natural origin. + */ + boolean isNatural(); + + /** + * @return generation this individual is removed from the original individual. + */ + int getGeneration(); + + /** + * Set the natural flag on this bee. + * @param flag + */ + void setIsNatural(boolean flag); + + IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing); + + IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing); + + /** + * @return true if the bee may spawn offspring + */ + boolean canSpawn(); + + /** + * Determines whether the queen can work. + * @param housing the {@link IBeeHousing} the bee currently resides in. + * @return an empty set if the queen can work, a set of error states if the queen can not work + */ + Set getCanWork(IBeeHousing housing); + + List getSuitableBiomes(); + + ItemStack[] getProduceList(); + + ItemStack[] getSpecialtyList(); + + ItemStack[] produceStacks(IBeeHousing housing); + + IBee spawnPrincess(IBeeHousing housing); + + IBee[] spawnDrones(IBeeHousing housing); + + void plantFlowerRandom(IBeeHousing housing); + + IIndividual retrievePollen(IBeeHousing housing); + + boolean pollinateRandom(IBeeHousing housing, IIndividual pollen); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeFactory.java b/src/main/java/forestry/api/apiculture/IBeeFactory.java new file mode 100644 index 000000000..c164731ce --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeFactory.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IClassification; + +public interface IBeeFactory { + + /** + * Creates a new bee species. + * Automatically registered with AlleleManager.alleleRegistry.registerAllele() + * See IAlleleBeeSpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species. + * + * @param uid Unique Identifier for this species + * @param dominant Whether this species is genetically dominant (false means it is recessive) + * @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry. + * @param unlocalizedName Unlocalized name for this species + * @param unlocalizedDescription Unlocalized description for this species + * @param branch Classification of this species + * @param binomial Binomial name of the species sans genus ("Apis"). "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null. + * @param primaryColor The outline color of this species + * @param secondaryColor The body color of this species + * @return a new bee species allele. + */ + IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor); + + /** + * Creates a new bee branch. + * Must be registered with AlleleManager.alleleRegistry.getClassification("family.apidae").addMemberGroup(); + * + * @param uid Unique Identifier for this branch + * @param scientific approximates a "genus" in real life. Real life examples: "Micrapis", "Megapis" + * @return a new bee branch + */ + IClassification createBranch(String uid, String scientific); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeGenome.java b/src/main/java/forestry/api/apiculture/IBeeGenome.java new file mode 100644 index 000000000..f759fc72e --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeGenome.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IFlowerProvider; +import forestry.api.genetics.IGenome; + +/** + * Only the default implementation is supported. + * + * @author SirSengir + * + */ +public interface IBeeGenome extends IGenome { + + @Override + IAlleleBeeSpecies getPrimary(); + + @Override + IAlleleBeeSpecies getSecondary(); + + float getSpeed(); + + int getLifespan(); + + int getFertility(); + + EnumTolerance getToleranceTemp(); + + EnumTolerance getToleranceHumid(); + + boolean getNocturnal(); + + boolean getTolerantFlyer(); + + boolean getCaveDwelling(); + + IFlowerProvider getFlowerProvider(); + + int getFlowering(); + + int[] getTerritory(); + + IAlleleBeeEffect getEffect(); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeHousing.java b/src/main/java/forestry/api/apiculture/IBeeHousing.java new file mode 100644 index 000000000..520a57243 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeHousing.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import com.mojang.authlib.GameProfile; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.IErrorLogicSource; +import forestry.api.genetics.IHousing; + +public interface IBeeHousing extends IHousing, IErrorLogicSource { + + /** + * Used by BeeManager.beeRoot.createBeeHousingModifier(IBeeHousing housing) + * to combine bee modifiers from several sources that can change over time. + * @return IBeeModifiers from the housing, frames, etc. + */ + Iterable getBeeModifiers(); + + /** + * Used by BeeManager.beeRoot.createBeeHousingListener(IBeeHousing housing) + * to combine bee listeners from several sources that can change over time. + * @return IBeeListeners from the housing, multiblock parts, etc. + */ + Iterable getBeeListeners(); + + IBeeHousingInventory getBeeInventory(); + IBeekeepingLogic getBeekeepingLogic(); + + EnumTemperature getTemperature(); + EnumHumidity getHumidity(); + int getBlockLightValue(); + boolean canBlockSeeTheSky(); + + World getWorld(); + BiomeGenBase getBiome(); + GameProfile getOwner(); + + /** + * @since Forestry 4.2 + * @return exact coordinates where bee FX should spawn from + */ + Vec3 getBeeFXCoordinates(); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeHousingInventory.java b/src/main/java/forestry/api/apiculture/IBeeHousingInventory.java new file mode 100644 index 000000000..c579a19f7 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeHousingInventory.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +public interface IBeeHousingInventory { + + ItemStack getQueen(); + ItemStack getDrone(); + + void setQueen(ItemStack itemstack); + void setDrone(ItemStack itemstack); + + /** + * Adds products to the housing's inventory. + * + * @param product ItemStack with the product to add. + * @param all if true, success requires that all products are added + * @return boolean indicating success or failure. + */ + boolean addProduct(ItemStack product, boolean all); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeListener.java b/src/main/java/forestry/api/apiculture/IBeeListener.java new file mode 100644 index 000000000..eaab40af2 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeListener.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IIndividual; + +public interface IBeeListener { + + /** + * Called when the bees wear out the housing's equipment. + * @param amount Integer indicating the amount worn out. + */ + void wearOutEquipment(int amount); + + /** + * Called after the children have been spawned, and before the new princess is spawned. + */ + void onQueenDeath(); + + /** + * Called when the bees have retrieved some pollen. + * @return true if this bee listener handled the pollen. + */ + boolean onPollenRetrieved(IIndividual pollen); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeModelProvider.java b/src/main/java/forestry/api/apiculture/IBeeModelProvider.java new file mode 100644 index 000000000..1bab611ba --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeModelProvider.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.core.IModelManager; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; + +public interface IBeeModelProvider { + void registerModels(Item item, IModelManager manager); + ModelResourceLocation getModel(EnumBeeType type); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeModifier.java b/src/main/java/forestry/api/apiculture/IBeeModifier.java new file mode 100644 index 000000000..134f441d2 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeModifier.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +public interface IBeeModifier { + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float used to modify the base territory. + */ + float getTerritoryModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param mate Genome of the bee mate this modifier is called for. + * @param currentModifier Current modifier. + * @return Float used to modify the base mutation chance. + */ + float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float used to modify the life span of queens. + */ + float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @param currentModifier Current modifier. + * @return Float modifying the production speed of queens. + */ + float getProductionModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @return Float modifying the flowering of queens. + */ + float getFloweringModifier(IBeeGenome genome, float currentModifier); + + /** + * @param genome Genome of the bee this modifier is called for. + * @return Float modifying the chance for a swarmer queen to die off. + */ + float getGeneticDecay(IBeeGenome genome, float currentModifier); + + /** + * @return Boolean indicating if housing can ignore rain + */ + boolean isSealed(); + + /** + * @return Boolean indicating if housing can ignore darkness/night + */ + boolean isSelfLighted(); + + /** + * @return Boolean indicating if housing can ignore not seeing the sky + */ + boolean isSunlightSimulated(); + + /** + * @return Boolean indicating whether this housing simulates the nether + */ + boolean isHellish(); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeMutation.java b/src/main/java/forestry/api/apiculture/IBeeMutation.java new file mode 100644 index 000000000..ead92f84d --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeMutation.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IMutation; + +public interface IBeeMutation extends IMutation { + + @Override + IBeeRoot getRoot(); + + /** + * @return float representing the chance for mutation to occur. note that this is 0 - 100 based, since it was an integer previously! + */ + float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeMutationCustom.java b/src/main/java/forestry/api/apiculture/IBeeMutationCustom.java new file mode 100644 index 000000000..d97a839a1 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeMutationCustom.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IMutationCustom; + +public interface IBeeMutationCustom extends IBeeMutation, IMutationCustom { + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeMutationFactory.java b/src/main/java/forestry/api/apiculture/IBeeMutationFactory.java new file mode 100644 index 000000000..315a4c6f1 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeMutationFactory.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import forestry.api.genetics.IAllele; + +public interface IBeeMutationFactory { + /** + * Creates a new bee mutation. + * Automatically registered with BeeManager.beeRoot.registerMutation() + * See IBeeMutationCustom and IMutationCustom for adding additional properties to the returned mutation. + * + * @param parentBee0 A parent bee for this mutation + * @param parentBee1 A parent bee for this mutation + * @param result The resulting alleles for this mutation + * @param chance The chance that breeding the two parent bees will result in this mutation + * @return a new bee mutation. + */ + IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance); +} diff --git a/src/main/java/forestry/api/apiculture/IBeeRoot.java b/src/main/java/forestry/api/apiculture/IBeeRoot.java new file mode 100644 index 000000000..3621fb50c --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeRoot.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.ISpeciesRoot; + +public interface IBeeRoot extends ISpeciesRoot { + + /** + * @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE + */ + @Override + boolean isMember(ItemStack stack); + + /** + * @return {@link IBee} pattern parsed from the passed stack's nbt data. + */ + @Override + IBee getMember(ItemStack stack); + + @Override + IBee getMember(NBTTagCompound compound); + + /* GENOME CONVERSION */ + @Override + IBee templateAsIndividual(IAllele[] template); + + @Override + IBee templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + @Override + IBeeGenome templateAsGenome(IAllele[] template); + + @Override + IBeeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* BREEDING TRACKER */ + /** + * @param world + * @return {@link IApiaristTracker} associated with the passed world. + */ + @Override + IApiaristTracker getBreedingTracker(World world, GameProfile player); + + /* BEE SPECIFIC */ + /** + * @return type of bee encoded on the itemstack. EnumBeeType.NONE if it isn't a bee. + */ + @Override + EnumBeeType getType(ItemStack stack); + + /** + * @return true if passed item is a drone. Equal to getType(ItemStack stack) == EnumBeeType.DRONE + */ + boolean isDrone(ItemStack stack); + + /** + * @return true if passed item is mated (i.e. a queen) + */ + boolean isMated(ItemStack stack); + + /** + * @param genome + * Valid {@link IBeeGenome} + * @return {@link IBee} from the passed genome + */ + IBee getBee(World world, IBeeGenome genome); + + /** + * Creates an IBee suitable for a queen containing the necessary second genome for the mate. + * + * @param genome + * Valid {@link IBeeGenome} + * @param mate + * Valid {@link IBee} representing the mate. + * @return Mated {@link IBee} from the passed genomes. + */ + IBee getBee(World world, IBeeGenome genome, IBee mate); + + /* TEMPLATES */ + @Override + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + @Override + Collection getMutations(boolean shuffle); + + /* GAME MODE */ + void resetBeekeepingMode(); + + ArrayList getBeekeepingModes(); + + IBeekeepingMode getBeekeepingMode(World world); + + IBeekeepingMode getBeekeepingMode(String name); + + void registerBeekeepingMode(IBeekeepingMode mode); + + void setBeekeepingMode(World world, String name); + + /* MISC */ + /** + * Creates beekeepingLogic for a housing. + * Should be used when the housing is created, see IBeekeepingLogic + */ + IBeekeepingLogic createBeekeepingLogic(IBeeHousing housing); + + /** + * Combines multiple modifiers from an IBeeHousing into one. + * Stays up to date with changes to the housing's modifiers. + */ + IBeeModifier createBeeHousingModifier(IBeeHousing housing); + + /** + * Combines multiple listeners from an IBeeHousing into one. + * Stays up to date with changes to the housing's listeners. + */ + IBeeListener createBeeHousingListener(IBeeHousing housing); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java b/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java new file mode 100644 index 000000000..72f42ee72 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeeSpriteColourProvider.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +/** + * Custom colour provider for bees with complicated colors. + */ +public interface IBeeSpriteColourProvider { + int getSpriteColour(int renderPass); +} diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java new file mode 100644 index 000000000..d591c4b3c --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeekeepingLogic.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.entity.player.EntityPlayerMP; + +import forestry.api.core.INBTTagable; + +/** + * Stores beekeeping logic for bee housings. + * Get one with BeeManager.beeRoot.createBeekeepingLogic(IBeeHousing housing) + * Save and load it to NBT using the INBTTagable methods. + */ +public interface IBeekeepingLogic extends INBTTagable { + + /* SERVER */ + + /** + * Checks that the bees can work, setting error conditions on the housing where needed + * @return true if no errors are present and doWork should be called + */ + boolean canWork(); + + /** + * Performs actual work, breeding, production, etc. + */ + void doWork(); + + + /* CLIENT */ + + /** + * Call this when the housing comes into view of the client. + * (i.e. when tile.getDescriptionPacket() is called) + */ + void syncToClient(); + void syncToClient(EntityPlayerMP player); + + /** + * Get the progress bar for breeding and production. + * To avoid network spam, this is only available server-side, + * and must be synced manually to the client when a GUI is open. + */ + int getBeeProgressPercent(); + + /** + * Whether bee fx should be active. + * Internally, this is automatically synced to the client. + */ + boolean canDoBeeFX(); + + /** + * Display bee fx. Calls IBee.doFX(IEffectData[] storedData, IBeeHousing housing) on the queen. + * Internally, the queen is automatically synced to the client for the fx. + */ + void doBeeFX(); + +} diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingMode.java b/src/main/java/forestry/api/apiculture/IBeekeepingMode.java new file mode 100644 index 000000000..b3a469c44 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IBeekeepingMode.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.ArrayList; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IBeekeepingMode { + + /** + * @return Localized name of this beekeeping mode. + */ + String getName(); + + /** + * @return Localized list of strings outlining the behaviour of this beekeeping mode. + */ + ArrayList getDescription(); + + /** + * @return Float used to modify the wear on comb frames. + */ + float getWearModifier(); + + /** + * @param queen + * @return fertility taking into account the birthing queen and surroundings. + */ + int getFinalFertility(IBee queen, World world, BlockPos pos); + + /** + * @param queen + * @return true if the queen is genetically "fatigued" and should not be reproduced anymore. + */ + boolean isFatigued(IBee queen, IBeeHousing housing); + + /** + * @param queen + * @param housing + * @return true if the queen is being overworked in the bee housing (with chance). will trigger a negative effect. + */ + boolean isOverworked(IBee queen, IBeeHousing housing); + + /** + * + * @param queen + * @param offspring + * @param housing + * @return true if the genetic structure of the queen is breaking down during spawning of the offspring (with chance). will trigger a negative effect. + */ + boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing); + + /** + * @param queen + * @return true if an offspring of this queen is considered a natural + */ + boolean isNaturalOffspring(IBee queen); + + /** + * @param queen + * @return true if this mode allows the passed queen or princess to be multiplied + */ + boolean mayMultiplyPrincess(IBee queen); + + /** + * @return the bee modifier for this mode + */ + IBeeModifier getBeeModifier(); +} diff --git a/src/main/java/forestry/api/apiculture/IHiveDrop.java b/src/main/java/forestry/api/apiculture/IHiveDrop.java new file mode 100644 index 000000000..151be26d6 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IHiveDrop.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * Bees can be seeded either as hive drops or as mutation results. + * + * Add IHiveDrops with HiveManager.get___Hive.addDrop + * + * @author SirSengir + */ +public interface IHiveDrop { + + ItemStack getPrincess(World world, BlockPos pos, int fortune); + + Collection getDrones(World world, BlockPos pos, int fortune); + + Collection getAdditional(World world, BlockPos pos, int fortune); + + /** + * Chance to drop. Default drops have 80 (= 80 %). + * + * @param world Minecraft world this is called for. + * @param pos Coordinates of the broken hive. + * @return Chance for drop as an integer of 0 - 100. + */ + int getChance(World world, BlockPos pos); +} diff --git a/src/main/java/forestry/api/apiculture/IHiveFrame.java b/src/main/java/forestry/api/apiculture/IHiveFrame.java new file mode 100644 index 000000000..08259cae7 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IHiveFrame.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.item.ItemStack; + +public interface IHiveFrame { + + /** + * Wears out a frame. + * + * @param housing IBeeHousing the frame is contained in. + * @param frame ItemStack containing the actual frame. + * @param queen Current queen in the caller. + * @param wear Integer denoting the amount worn out. The wear modifier of the current beekeeping mode has already been taken into account. + * @return ItemStack containing the actual frame with adjusted damage, or null if it has been broken. + */ + ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear); + + IBeeModifier getBeeModifier(); +} diff --git a/src/main/java/forestry/api/apiculture/IJubilanceFactory.java b/src/main/java/forestry/api/apiculture/IJubilanceFactory.java new file mode 100644 index 000000000..1b81a9d06 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IJubilanceFactory.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +import net.minecraft.block.Block; + +public interface IJubilanceFactory { + /** The default Jubilance Provider is satisfied when the humidity and temperature are ideal for the bee. */ + IJubilanceProvider getDefault(); + + /** The Requires Resource Jubilance Provider is satisfied when a specific block is under the hive. */ + IJubilanceProvider getRequiresResource(Block block, int meta); +} diff --git a/src/main/java/forestry/api/apiculture/IJubilanceProvider.java b/src/main/java/forestry/api/apiculture/IJubilanceProvider.java new file mode 100644 index 000000000..faf34d05e --- /dev/null +++ b/src/main/java/forestry/api/apiculture/IJubilanceProvider.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture; + +public interface IJubilanceProvider { + + /** + * Returns true when conditions are right to make this species Jubilant. + * Jubilant bees can produce their Specialty products. + */ + boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing); +} diff --git a/src/main/java/forestry/api/apiculture/hives/HiveManager.java b/src/main/java/forestry/api/apiculture/hives/HiveManager.java new file mode 100644 index 000000000..17ca7d20e --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/HiveManager.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture.hives; + +public class HiveManager { + + public static IHiveRegistry hiveRegistry; + public static IHiveGenHelper genHelper; + +} diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveDescription.java b/src/main/java/forestry/api/apiculture/hives/IHiveDescription.java new file mode 100644 index 000000000..52e248b31 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/IHiveDescription.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture.hives; + +import net.minecraft.block.Block; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public interface IHiveDescription { + + /** + * The hive generator for this hive. + */ + IHiveGen getHiveGen(); + + /** + * The hive block to be placed in the world. + */ + Block getBlock(); + int getMeta(); + + /** + * returns true if the hive can be generated in these conditions. + * Used as a fast early-elimination check for hives that have no hope of spawning in the area. + */ + boolean isGoodBiome(BiomeGenBase biome); + boolean isGoodHumidity(EnumHumidity humidity); + boolean isGoodTemperature(EnumTemperature temperature); + + /** + * float representing the relative chance a hive will generate in a chunk. + * Default is 1.0, higher numbers result in more hives, smaller will result in fewer. + * Tree hives want around 3.0 to 4.0 since there are less locations to generate on. + */ + float getGenChance(); + + /** + * Called after successful hive generation. + * world, x, y, z give the location of the new hive. + **/ + void postGen(World world, BlockPos pos); +} diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveGen.java b/src/main/java/forestry/api/apiculture/hives/IHiveGen.java new file mode 100644 index 000000000..2021b71ae --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/IHiveGen.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture.hives; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IHiveGen { + + /** + * return a Y value that the hive should try to generate at. + * returns negative if the hive can't be placed anywhere. + */ + int getYForHive(World world, int x, int z); + + /** + * returns true if the hive can be generated at this location. + * Used for advanced conditions, like checking that the ground below the hive is a certain type. + */ + boolean isValidLocation(World world, BlockPos pos); + + /** + * returns true if the hive can safely replace the block at this location. + */ + boolean canReplace(World world, BlockPos pos); + +} diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveGenHelper.java b/src/main/java/forestry/api/apiculture/hives/IHiveGenHelper.java new file mode 100644 index 000000000..0eb6400cb --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/IHiveGenHelper.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture.hives; + +import net.minecraft.block.Block; + +public interface IHiveGenHelper { + + /** + * Returns a hiveGen for a hive that spawns on the ground. + * validGroundBlocks specifies which block materials it can spawn on. + */ + IHiveGen ground(Block... validGroundBlocks); + + /** + * Returns a hiveGen for a hive that spawns in trees. + */ + IHiveGen tree(); + +} diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java b/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java new file mode 100644 index 000000000..68bbea5f7 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.apiculture.hives; + +import java.util.List; + +import forestry.api.apiculture.IHiveDrop; +import net.minecraft.util.IStringSerializable; + +public interface IHiveRegistry { + + /* Forestry Hive Names */ + public static enum HiveType implements IStringSerializable{ + FOREST("Forestry:forest"), + MEADOWS("Forestry:meadows"), + DESERT("Forestry:desert"), + JUNGLE("Forestry:jungle"), + END("Forestry:end"), + SNOW("Forestry:snow"), + SWAMP("Forestry:swamp"); + + private HiveType(String name) { + this.name = name; + } + + public String name; + + public String getHiveName() + { + return name; + } + + @Override + public String getName() { + return name().toLowerCase(); + } + + } + + /** + * Adds a new hive to be generated in the world. + */ + void registerHive(String hiveName, IHiveDescription hiveDescription); + + /** + * Add drops to a registered hive. + */ + void addDrops(String hiveName, IHiveDrop... drops); + void addDrops(String hiveName, List drop); +} diff --git a/src/main/java/forestry/api/apiculture/hives/package-info.java b/src/main/java/forestry/api/apiculture/hives/package-info.java new file mode 100644 index 000000000..0750c5d17 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/hives/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="4.1.0", owner="ForestryAPI|apiculture", provides="ForestryAPI|hives") +package forestry.api.apiculture.hives; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/apiculture/package-info.java b/src/main/java/forestry/api/apiculture/package-info.java new file mode 100644 index 000000000..bde28aea1 --- /dev/null +++ b/src/main/java/forestry/api/apiculture/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="4.8.0", owner="ForestryAPI|core", provides="ForestryAPI|apiculture") +package forestry.api.apiculture; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java b/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java new file mode 100644 index 000000000..85a995d90 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.StatCollector; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IFruitFamily; + +public enum EnumFruitFamily implements IFruitFamily { + PRUNES("prunes", "Prunus domestica"), + POMES("pomes", "Pomum"), + JUNGLE("jungle", "Tropicus"), + NUX("nuts", "Nux"); + + private final String uid; + private final String scientific; + + EnumFruitFamily(String uid, String scientific) { + this.uid = uid; + this.scientific = scientific; + AlleleManager.alleleRegistry.registerFruitFamily(this); + } + + @Override + public String getUID() { + return "forestry." + uid; + } + + @Override + public String getScientific() { + return this.scientific; + } + + @Override + public String getName() { + return StatCollector.translateToLocal("for.family." + uid); + } + + @Override + public String getDescription() { + return StatCollector.translateToLocal("for.family." + uid + ".description"); + } + +} diff --git a/src/main/java/forestry/api/arboriculture/EnumGermlingType.java b/src/main/java/forestry/api/arboriculture/EnumGermlingType.java new file mode 100644 index 000000000..ead88b1d7 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumGermlingType.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.ISpeciesType; + +public enum EnumGermlingType implements ISpeciesType { + SAPLING("sapling"), BLOSSOM("blossom"), POLLEN("pollen"), GERMLING("germling"), NONE("none"); + + public static final EnumGermlingType[] VALUES = values(); + + private final String name; + + EnumGermlingType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/src/main/java/forestry/api/arboriculture/EnumGrowthConditions.java b/src/main/java/forestry/api/arboriculture/EnumGrowthConditions.java new file mode 100644 index 000000000..8b28601c1 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumGrowthConditions.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public enum EnumGrowthConditions { + HOSTILE, PALTRY, NORMAL, GOOD, EXCELLENT +} diff --git a/src/main/java/forestry/api/arboriculture/EnumLeafType.java b/src/main/java/forestry/api/arboriculture/EnumLeafType.java new file mode 100644 index 000000000..472b3555a --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumLeafType.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public enum EnumLeafType { + DECIDUOUS, CONIFERS, JUNGLE, WILLOW, MAPLE, PALM +} diff --git a/src/main/java/forestry/api/arboriculture/EnumTreeChromosome.java b/src/main/java/forestry/api/arboriculture/EnumTreeChromosome.java new file mode 100644 index 000000000..29fcebad3 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumTreeChromosome.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.Locale; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAllelePlantType; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IFruitFamily; +import forestry.api.genetics.ISpeciesRoot; + +public enum EnumTreeChromosome implements IChromosomeType { + + /** + * Determines the following: - WorldGen, including the used wood blocks - {@link IFruitFamily}s supported. Limits which {@link IFruitProvider} + * will actually yield fruit with this species. - Native {@link EnumPlantType} for this tree. Combines with the PLANT chromosome. + */ + SPECIES(IAlleleTreeSpecies.class), + /** + * {@link IGrowthProvider}, determines conditions required by the tree to grow. + */ + GROWTH(IAlleleGrowth.class), + /** + * A float modifying the height of the tree. Taken into account at worldgen. + */ + HEIGHT(IAlleleFloat.class), + /** + * Chance for saplings. + */ + FERTILITY(IAlleleFloat.class), + /** + * {@link IFruitProvider}, determines if and what fruits are grown on the tree. Limited by the {@link IFruitFamily}s the species supports. + */ + FRUITS(IAlleleFruit.class), + /** + * Chance for fruit leaves and/or drops. + */ + YIELD(IAlleleFloat.class), + /** + * May add additional tolerances for {@link EnumPlantTypes}. + */ + PLANT(IAllelePlantType.class), + /** + * Determines the speed at which fruit will ripen on this tree. + */ + SAPPINESS(IAlleleFloat.class), + /** + * Territory for leaf effects. Unused. + */ + TERRITORY(IAlleleArea.class), + /** + * Leaf effect. Unused. + */ + EFFECT(IAlleleLeafEffect.class), + /** + * Amount of random ticks which need to elapse before a sapling will grow into a tree. + */ + MATURATION(IAlleleInteger.class), + + GIRTH(IAlleleInteger.class), + /** + * Determines if the tree can burn. + */ + FIREPROOF(IAlleleBoolean.class), + ; + + Class clss; + + EnumTreeChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(Locale.ENGLISH); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return TreeManager.treeRoot; + } + +} diff --git a/src/main/java/forestry/api/arboriculture/EnumWoodType.java b/src/main/java/forestry/api/arboriculture/EnumWoodType.java new file mode 100644 index 000000000..57b291166 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/EnumWoodType.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.Locale; +import java.util.Random; + +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IStringSerializable; + +public enum EnumWoodType implements IStringSerializable { + LARCH, TEAK, ACACIA, LIME, CHESTNUT, + WENGE, BAOBAB, SEQUOIA(4.0f), KAPOK, EBONY, + MAHOGANY, BALSA(1.0f), WILLOW, WALNUT, GREENHEART(7.5f), + CHERRY, MAHOE, POPLAR, PALM, PAPAYA, + PINE(3.0f), PLUM, MAPLE, CITRUS, GIGANTEUM, + IPE, PADAUK, COCOBOLO, ZEBRAWOOD; + + public static final PropertyEnum WOODTYPE = PropertyEnum.create("woodtype", EnumWoodType.class); + + public static final float DEFAULT_HARDNESS = 2.0f; + public static final EnumWoodType[] VALUES = values(); + + private final float hardness; + + EnumWoodType() { + this.hardness = DEFAULT_HARDNESS; + } + + EnumWoodType(float hardness) { + this.hardness = hardness; + } + + public float getHardness() { + return hardness; + } + + public static EnumWoodType getRandom(Random random) { + return VALUES[random.nextInt(VALUES.length)]; + } + + @Override + public String toString() { + return super.toString().toLowerCase(Locale.ENGLISH); + } + + @Override + public String getName() { + return toString(); + } +} diff --git a/src/main/java/forestry/api/arboriculture/IAlleleFruit.java b/src/main/java/forestry/api/arboriculture/IAlleleFruit.java new file mode 100644 index 000000000..4fee1c62a --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IAlleleFruit.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAllele; + +/** + * Simple allele encapsulating an {@link IFruitProvider}. + */ +public interface IAlleleFruit extends IAllele, Comparable { + + IFruitProvider getProvider(); + + String getModelName(); + + String getModID(); + +} diff --git a/src/main/java/forestry/api/arboriculture/IAlleleGrowth.java b/src/main/java/forestry/api/arboriculture/IAlleleGrowth.java new file mode 100644 index 000000000..6cb4b4389 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IAlleleGrowth.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAllele; + +/** + * Simple allele encapsulating an {@link IGrowthProvider}. + */ +public interface IAlleleGrowth extends IAllele { + + IGrowthProvider getProvider(); + +} diff --git a/src/main/java/forestry/api/arboriculture/IAlleleLeafEffect.java b/src/main/java/forestry/api/arboriculture/IAlleleLeafEffect.java new file mode 100644 index 000000000..2fe4bd054 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IAlleleLeafEffect.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +/** + * Simple allele encapsulating a leaf effect. (Not implemented) + */ +public interface IAlleleLeafEffect extends IAlleleEffect { + + IEffectData doEffect(ITreeGenome genome, IEffectData storedData, World world, BlockPos pos); + +} diff --git a/src/main/java/forestry/api/arboriculture/IAlleleTreeSpecies.java b/src/main/java/forestry/api/arboriculture/IAlleleTreeSpecies.java new file mode 100644 index 000000000..daa8c8a84 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IAlleleTreeSpecies.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.Collection; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.core.IModelManager; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IFruitFamily; + +public interface IAlleleTreeSpecies extends IAlleleSpecies, Comparable { + + @Override + ITreeRoot getRoot(); + + /** + * @return Native plant type of this species. + */ + EnumPlantType getPlantType(); + + /** + * @return List of all {@link IFruitFamily}s which can grow on leaves generated by this species. + */ + Collection getSuitableFruit(); + + /** + * @return Tree generator for this species. + */ + ITreeGenerator getGenerator(); + + /** + * @return The ModID from the mod. + */ + String getModID(); + + /** + * @return The name of the model from the tree. + */ + String getModelName(); + + /* TEXTURES AND OVERRIDES */ + int getLeafColour(boolean pollinated); + + @SideOnly(Side.CLIENT) + TextureAtlasSprite getLeafSprite(boolean pollinated, boolean fancy); + + @SideOnly(Side.CLIENT) + ModelResourceLocation getGermlingModel(EnumGermlingType type); + + @SideOnly(Side.CLIENT) + void registerModels(IModelManager manager); + + @SideOnly(Side.CLIENT) + int getGermlingColour(EnumGermlingType type, int renderPass); + +} diff --git a/src/main/java/forestry/api/arboriculture/IAlleleTreeSpeciesCustom.java b/src/main/java/forestry/api/arboriculture/IAlleleTreeSpeciesCustom.java new file mode 100644 index 000000000..d5bf25b7e --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IAlleleTreeSpeciesCustom.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IAlleleSpeciesCustom; +import forestry.api.genetics.IFruitFamily; + +public interface IAlleleTreeSpeciesCustom extends IAlleleSpeciesCustom, IAlleleTreeSpecies { + + /** Add a fruit family for this tree. Trees can have multiple fruit families. */ + IAlleleTreeSpeciesCustom addFruitFamily(IFruitFamily family); + + /** Set the minecraft plant type for this tree. Default is Plains. */ + IAlleleTreeSpeciesCustom setPlantType(EnumPlantType type); + +} diff --git a/src/main/java/forestry/api/arboriculture/IArboristTracker.java b/src/main/java/forestry/api/arboriculture/IArboristTracker.java new file mode 100644 index 000000000..9777e8763 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IArboristTracker.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IBreedingTracker; + +public interface IArboristTracker extends IBreedingTracker { + +} diff --git a/src/main/java/forestry/api/arboriculture/IFruitProvider.java b/src/main/java/forestry/api/arboriculture/IFruitProvider.java new file mode 100644 index 000000000..ff5916c85 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IFruitProvider.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.core.ITextureManager; +import forestry.api.genetics.IFruitFamily; + +public interface IFruitProvider { + + IFruitFamily getFamily(); + + int getColour(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime); + + boolean markAsFruitLeaf(ITreeGenome genome, World world, BlockPos pos); + + int getRipeningPeriod(); + + // / Products, Chance + ItemStack[] getProducts(); + + // / Specialty, Chance + ItemStack[] getSpecialty(); + + ItemStack[] getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime); + + /** + * @return Short, human-readable identifier used in the treealyzer. + */ + String getDescription(); + + String getModelName(); + + String getModID(); + + /* TEXTURE OVERLAY */ + /** + * @param genome + * @param world + * @param pos + * @param ripeningTime + * Elapsed ripening time for the fruit. + * @param fancy + * @return IIcon index of the texture to overlay on the leaf block. + */ + short getSpriteIndex(ITreeGenome genome, IBlockAccess world, BlockPos pos, int ripeningTime, boolean fancy); + + /** + * @return true if this fruit provider requires fruit blocks to spawn, false otherwise. + */ + boolean requiresFruitBlocks(); + + /** + * Tries to spawn a fruit block at the potential position when the tree generates. + * + * @param genome + * @param world + * @param pos + * @return true if a fruit block was spawned, false otherwise. + */ + boolean trySpawnFruitBlock(ITreeGenome genome, World world, BlockPos pos); + + @SideOnly(Side.CLIENT) + void registerSprites(); +} diff --git a/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java b/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java new file mode 100644 index 000000000..47f47c685 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IGermlingModelProvider.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.core.IModelManager; +import net.minecraft.client.resources.model.ModelResourceLocation; + +/** + * Provides icons for saplings, pollen, etc. + * You must implement this yourself to use TreeManager.treeFactory.createSpecies() + * There is no default implementation because every sapling has a unique icon. + */ +public interface IGermlingModelProvider { + void registerModels(IModelManager manager); + ModelResourceLocation getModel(EnumGermlingType type); +} diff --git a/src/main/java/forestry/api/arboriculture/IGrowthProvider.java b/src/main/java/forestry/api/arboriculture/IGrowthProvider.java new file mode 100644 index 000000000..909762c4b --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IGrowthProvider.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IGrowthProvider { + + /** + * Check to see whether a sapling at the given location with the given genome can grow into a tree. + * + * @param genome Genome of the tree this is called for. + * @param world Minecraft world the tree will inhabit. + * @param pos Coordinates to attempt growth at. + * @param expectedGirth Trunk size of the tree to generate. + * @param expectedHeight Height of the tree to generate. + * @return true if the tree can grow at the given coordinates, false otherwise. + */ + boolean canGrow(ITreeGenome genome, World world, BlockPos pos, int expectedGirth, int expectedHeight); + + EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, BlockPos pos); + + /** + * @return Short, human-readable identifier used in the treealyzer. + */ + String getDescription(); + + /** + * @return Detailed description of growth behaviour used in the treealyzer. + */ + String[] getInfo(); + +} diff --git a/src/main/java/forestry/api/arboriculture/ILeafSpriteProvider.java b/src/main/java/forestry/api/arboriculture/ILeafSpriteProvider.java new file mode 100644 index 000000000..fefda5f0c --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ILeafSpriteProvider.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; + +/** + * Provides icons for leaves. Used by TreeManager.treeFactory.createSpecies() + * Get a default Forestry implementation from TreeManager.treeFactory.getLeafIconProvider() or implement your own. + * + * If you implement your own, be sure to register the icons. + * Icon registration is not done here because these icons are heavily reused. + */ +public interface ILeafSpriteProvider { + TextureAtlasSprite getSprite(boolean pollinated, boolean fancy); + int getColor(boolean pollinated); +} diff --git a/src/main/java/forestry/api/arboriculture/ILeafTickHandler.java b/src/main/java/forestry/api/arboriculture/ILeafTickHandler.java new file mode 100644 index 000000000..5a2112a42 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ILeafTickHandler.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface ILeafTickHandler { + boolean onRandomLeafTick(ITree tree, World world, BlockPos pos, boolean isDestroyed); +} diff --git a/src/main/java/forestry/api/arboriculture/IToolGrafter.java b/src/main/java/forestry/api/arboriculture/IToolGrafter.java new file mode 100644 index 000000000..7273947dc --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IToolGrafter.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IToolGrafter { + /** + * Called by leaves to determine the increase in sapling droprate. + * + * @param stack ItemStack containing the grafter. + * @param world Minecraft world the player and the target block inhabit. + * @param pos Coordinate of the broken leaf block. + * @return Float representing the factor the usual drop chance is to be multiplied by. + */ + float getSaplingModifier(ItemStack stack, World world, EntityPlayer player, BlockPos pos); +} diff --git a/src/main/java/forestry/api/arboriculture/ITree.java b/src/main/java/forestry/api/arboriculture/ITree.java new file mode 100644 index 000000000..864200a8f --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITree.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.EnumSet; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import com.mojang.authlib.GameProfile; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IEffectData; +import forestry.api.genetics.IIndividual; +import forestry.api.world.ITreeGenData; + +public interface ITree extends IIndividual, ITreeGenData { + + void mate(ITree other); + + IEffectData[] doEffect(IEffectData[] storedData, World world, BlockPos pos); + + IEffectData[] doFX(IEffectData[] storedData, World world, BlockPos pos); + + @Override + ITreeGenome getGenome(); + + ITreeGenome getMate(); + + EnumSet getPlantTypes(); + + /** + * @since Forestry 4.0 + */ + ITree[] getSaplings(World world, GameProfile playerProfile, BlockPos pos, float modifier); + + ItemStack[] getProduceList(); + + ItemStack[] getSpecialtyList(); + + ItemStack[] produceStacks(World world, BlockPos pos, int ripeningTime); + + /** + * @return Boolean indicating whether a sapling can stay planted at the given position. + */ + boolean canStay(IBlockAccess world, BlockPos pos); + + /** + * @return Boolean indicating whether a sapling at the given position can grow into a tree. + */ + @Override + boolean canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight); + + /** + * @return Integer denoting the maturity (block ticks) required for a sapling to attempt to grow into a tree. + */ + int getRequiredMaturity(); + + /** + * @return Integer denoting how resilient leaf blocks are against adverse influences (i.e. caterpillars). + */ + int getResilience(); + + /** + * @return Integer denoting the size of the tree trunk. + */ + @Override + int getGirth(World world, BlockPos pos); + + /** + * @return Growth conditions at the given position. + */ + EnumGrowthConditions getGrowthCondition(World world, BlockPos pos); + + WorldGenerator getTreeGenerator(World world, BlockPos pos, boolean wasBonemealed); + + @Override + ITree copy(); + + boolean isPureBred(EnumTreeChromosome chromosome); + + boolean canBearFruit(); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeFactory.java b/src/main/java/forestry/api/arboriculture/ITreeFactory.java new file mode 100644 index 000000000..2eb8b8b94 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeFactory.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.awt.Color; + +import forestry.api.genetics.IClassification; + +public interface ITreeFactory { + /** + * Creates a new tree species. + * Automatically registered with AlleleManager.alleleRegistry.registerAllele() + * See IAlleleTreeSpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species. + * + * @param uid Unique Identifier for this species + * @param unlocalizedName Unlocalized name for this species + * @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry. + * @param unlocalizedDescription Unlocalized description for this species + * @param dominant Whether this species is genetically dominant (false means it is recessive) + * @param branch Classification of this species + * @param binomial Binomial name of the species sans genus. "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null. + * @param mdoelName The name of the model name for this species + * @param leafSpriteProvider The leaf sprite provider for this species + * @param germlingModelProvider The germling model provider for this species + * @param generator The tree generator + * @return a new tree species allele. + */ + IAlleleTreeSpeciesCustom createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, String mdoelName, ILeafSpriteProvider leafSpriteProvider, IGermlingModelProvider germlingModelProvider, ITreeGenerator generator); + + /** Get one of the built-in Forestry leaf types. Default type is deciduous. */ + ILeafSpriteProvider getLeafIconProvider(EnumLeafType enumLeafType, Color color, Color colorPollinated); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeGenerator.java b/src/main/java/forestry/api/arboriculture/ITreeGenerator.java new file mode 100644 index 000000000..cfb14fc3d --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeGenerator.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +import com.mojang.authlib.GameProfile; + +import forestry.api.world.ITreeGenData; + +/** + * Implements the tree generation for a tree species. + */ +public interface ITreeGenerator { + WorldGenerator getWorldGenerator(ITreeGenData tree); + + void setLogBlock(ITreeGenome genome, World world, BlockPos pos, EnumFacing facing); + + void setLeaves(ITreeGenome genome, World world, GameProfile owner, BlockPos pos, boolean decorative); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeGenome.java b/src/main/java/forestry/api/arboriculture/ITreeGenome.java new file mode 100644 index 000000000..fae3e72a0 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeGenome.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +import forestry.api.genetics.IGenome; + +public interface ITreeGenome extends IGenome { + + @Override + IAlleleTreeSpecies getPrimary(); + + @Override + IAlleleTreeSpecies getSecondary(); + + IFruitProvider getFruitProvider(); + + IGrowthProvider getGrowthProvider(); + + float getHeight(); + + float getFertility(); + + /** + * @return Determines either a) how many fruit leaves there are or b) the chance for any fruit leave to drop a sapling. Exact usage determined by the + * IFruitProvider + */ + float getYield(); + + float getSappiness(); + + EnumSet getPlantTypes(); + + /** + * @return Amount of random block ticks required for a sapling to mature into a fully grown tree. + */ + int getMaturationTime(); + + int getGirth(); + + IAlleleLeafEffect getEffect(); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeModifier.java b/src/main/java/forestry/api/arboriculture/ITreeModifier.java new file mode 100644 index 000000000..775f91ebe --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeModifier.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public interface ITreeModifier { + + /** + * + * @param genome + * @return Float used to modify the height. + */ + float getHeightModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the yield. + */ + float getYieldModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the sappiness. + */ + float getSappinessModifier(ITreeGenome genome, float currentModifier); + + /** + * + * @param genome + * @return Float used to modify the maturation. + */ + float getMaturationModifier(ITreeGenome genome, float currentModifier); + + /** + * @param genome0 + * @param genome1 + * @return Float used to modify the base mutation chance. + */ + float getMutationModifier(ITreeGenome genome0, ITreeGenome genome1, float currentModifier); + +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeMutation.java b/src/main/java/forestry/api/arboriculture/ITreeMutation.java new file mode 100644 index 000000000..ad2960cf2 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeMutation.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; + +public interface ITreeMutation extends IMutation { + + /** + * @return {@link ISpeciesRoot} this mutation is associated with. + */ + @Override + ITreeRoot getRoot(); + + /** + * @return float representing the percent chance for mutation to occur, from 0.0 to 100.0. + * @since Forestry 4.0 + */ + float getChance(World world, BlockPos pos, IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, ITreeGenome genome0, ITreeGenome genome1); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeMutationCustom.java b/src/main/java/forestry/api/arboriculture/ITreeMutationCustom.java new file mode 100644 index 000000000..b4d2075ad --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeMutationCustom.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IMutationCustom; + +public interface ITreeMutationCustom extends ITreeMutation, IMutationCustom { + +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeMutationFactory.java b/src/main/java/forestry/api/arboriculture/ITreeMutationFactory.java new file mode 100644 index 000000000..a6cf802fc --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeMutationFactory.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import forestry.api.genetics.IAllele; + +public interface ITreeMutationFactory { + /** + * Creates a new tree mutation. + * Automatically registered with TreeManager.treeRoot.registerMutation() + * See ITreeMutationCustom and IMutationCustom for adding additional properties to the returned mutation. + * + * @param parentTree0 A parent tree for this mutation + * @param parentTree1 A parent tree for this mutation + * @param result The resulting alleles for this mutation + * @param chance The chance that breeding the two parent trees will result in this mutation + * @return a new tree mutation. + */ + ITreeMutationCustom createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance); +} diff --git a/src/main/java/forestry/api/arboriculture/ITreeRoot.java b/src/main/java/forestry/api/arboriculture/ITreeRoot.java new file mode 100644 index 000000000..85ad24410 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreeRoot.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.ISpeciesRoot; + +public interface ITreeRoot extends ISpeciesRoot { + + @Override + boolean isMember(ItemStack itemstack); + + @Override + ITree getMember(ItemStack itemstack); + + @Override + ITree getMember(NBTTagCompound compound); + + @Override + ITree templateAsIndividual(IAllele[] template); + + @Override + ITree templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + @Override + ITreeGenome templateAsGenome(IAllele[] template); + + @Override + ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /** + * @param world + * @return {@link IArboristTracker} associated with the passed world. + */ + @Override + IArboristTracker getBreedingTracker(World world, GameProfile player); + + /* TREE SPECIFIC */ + /** + * Register a leaf tick handler. + * @param handler the {@link ILeafTickHandler} to register. + */ + void registerLeafTickHandler(ILeafTickHandler handler); + + Collection getLeafTickHandlers(); + + /** + * @return type of tree encoded on the itemstack. EnumGermlingType.NONE if it isn't a tree. + */ + @Override + EnumGermlingType getType(ItemStack stack); + + ITree getTree(World world, BlockPos pos); + + ITree getTree(World world, ITreeGenome genome); + + boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos); + + @Override + IChromosome[] templateAsChromosomes(IAllele[] template); + + @Override + IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive); + + boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, short[] indices, BlockPos pos); + + /* GAME MODE */ + ArrayList getTreekeepingModes(); + + ITreekeepingMode getTreekeepingMode(World world); + + ITreekeepingMode getTreekeepingMode(String name); + + void registerTreekeepingMode(ITreekeepingMode mode); + + void setTreekeepingMode(World world, String name); + + /* TEMPLATES */ + @Override + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + @Override + Collection getMutations(boolean shuffle); + +} diff --git a/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java b/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java new file mode 100644 index 000000000..cc5224d8a --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import java.util.ArrayList; + +public interface ITreekeepingMode extends ITreeModifier { + + /** + * @return Localized name of this treekeeping mode. + */ + String getName(); + + /** + * @return Localized list of strings outlining the behaviour of this treekeeping mode. + */ + ArrayList getDescription(); + +} diff --git a/src/main/java/forestry/api/arboriculture/IWoodItemAccess.java b/src/main/java/forestry/api/arboriculture/IWoodItemAccess.java new file mode 100644 index 000000000..023fdbd23 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/IWoodItemAccess.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +import net.minecraft.item.ItemStack; + +public interface IWoodItemAccess { + ItemStack getLog(EnumWoodType woodType, boolean fireproof); + ItemStack getPlanks(EnumWoodType woodType, boolean fireproof); + ItemStack getSlab(EnumWoodType woodType, boolean fireproof); + ItemStack getFence(EnumWoodType woodType, boolean fireproof); + ItemStack getStairs(EnumWoodType woodType, boolean fireproof); +} diff --git a/src/main/java/forestry/api/arboriculture/TreeManager.java b/src/main/java/forestry/api/arboriculture/TreeManager.java new file mode 100644 index 000000000..e8e46c72e --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/TreeManager.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.arboriculture; + +public class TreeManager { + + /** + * Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootTrees") + */ + public static ITreeRoot treeRoot; + + /** + * Convenient access to wood items. + */ + public static IWoodItemAccess woodItemAccess; + + /** + * Used to create new trees. + */ + public static ITreeFactory treeFactory; + + /** + * Used to create new tree mutations. + */ + public static ITreeMutationFactory treeMutationFactory; +} diff --git a/src/main/java/forestry/api/arboriculture/package-info.java b/src/main/java/forestry/api/arboriculture/package-info.java new file mode 100644 index 000000000..a2548cc83 --- /dev/null +++ b/src/main/java/forestry/api/arboriculture/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "4.2.1", owner = "ForestryAPI|core", provides = "ForestryAPI|arboriculture") +package forestry.api.arboriculture; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/circuits/ChipsetManager.java b/src/main/java/forestry/api/circuits/ChipsetManager.java new file mode 100644 index 000000000..c5f0db5c3 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ChipsetManager.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public class ChipsetManager { + + public static ISolderManager solderManager; + public static ICircuitRegistry circuitRegistry; + +} diff --git a/src/main/java/forestry/api/circuits/CircuitSocketType.java b/src/main/java/forestry/api/circuits/CircuitSocketType.java new file mode 100644 index 000000000..f7f67091a --- /dev/null +++ b/src/main/java/forestry/api/circuits/CircuitSocketType.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public enum CircuitSocketType implements ICircuitSocketType { + NONE("none"), + FARM("forestry.farm"), + ELECTRIC_ENGINE("forestry.electric.engine"), + MACHINE("forestry.machine"); + + private final String uid; + + CircuitSocketType(String uid) { + this.uid = uid; + } + + @Override + public String getUid() { + return uid; + } + + @Override + public boolean equals(ICircuitSocketType socketType) { + return uid.equals(socketType.getUid()); + } +} diff --git a/src/main/java/forestry/api/circuits/ICircuit.java b/src/main/java/forestry/api/circuits/ICircuit.java new file mode 100644 index 000000000..62c35f358 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuit.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.List; + +public interface ICircuit { + String getUID(); + + boolean requiresDiscovery(); + + int getLimit(); + + String getName(); + + boolean isCircuitable(Object tile); + + void onInsertion(int slot, Object tile); + + void onLoad(int slot, Object tile); + + void onRemoval(int slot, Object tile); + + void onTick(int slot, Object tile); + + void addTooltip(List list); +} diff --git a/src/main/java/forestry/api/circuits/ICircuitBoard.java b/src/main/java/forestry/api/circuits/ICircuitBoard.java new file mode 100644 index 000000000..ef09575c2 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuitBoard.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.List; + +import forestry.api.core.INBTTagable; + +public interface ICircuitBoard extends INBTTagable { + + int getPrimaryColor(); + + int getSecondaryColor(); + + void addTooltip(List list); + + void onInsertion(Object tile); + + void onLoad(Object tile); + + void onRemoval(Object tile); + + void onTick(Object tile); + + ICircuit[] getCircuits(); + + /** + * Specifies where a circuit can be used. + * @since Forestry 4.0 + */ + ICircuitSocketType getSocketType(); + +} diff --git a/src/main/java/forestry/api/circuits/ICircuitLayout.java b/src/main/java/forestry/api/circuits/ICircuitLayout.java new file mode 100644 index 000000000..8c49ab120 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuitLayout.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public interface ICircuitLayout { + + /** unique ID for this circuit layout */ + String getUID(); + + /** localized name for this circuit layout */ + String getName(); + + /** localized string for how this circuit layout is used */ + String getUsage(); + + /** + * Specifies where a circuit layout is used. + * @since Forestry 4.0 + */ + ICircuitSocketType getSocketType(); + +} diff --git a/src/main/java/forestry/api/circuits/ICircuitLibrary.java b/src/main/java/forestry/api/circuits/ICircuitLibrary.java new file mode 100644 index 000000000..0d65ba458 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuitLibrary.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +public interface ICircuitLibrary { + +} diff --git a/src/main/java/forestry/api/circuits/ICircuitRegistry.java b/src/main/java/forestry/api/circuits/ICircuitRegistry.java new file mode 100644 index 000000000..9fb2b94d5 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuitRegistry.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ICircuitRegistry { + + /* CIRCUITS */ + Map getRegisteredCircuits(); + + void registerCircuit(ICircuit circuit); + + ICircuit getCircuit(String uid); + + ICircuitLibrary getCircuitLibrary(World world, String playername); + + /* LAYOUTS */ + Map getRegisteredLayouts(); + + void registerLayout(ICircuitLayout layout); + + ICircuitLayout getLayout(String uid); + + ICircuitLayout getDefaultLayout(); + + ICircuitBoard getCircuitboard(ItemStack itemstack); + + boolean isChipset(ItemStack itemstack); + +} diff --git a/src/main/java/forestry/api/circuits/ICircuitSocketType.java b/src/main/java/forestry/api/circuits/ICircuitSocketType.java new file mode 100644 index 000000000..60250f712 --- /dev/null +++ b/src/main/java/forestry/api/circuits/ICircuitSocketType.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +/** + * Specifies where a circuit layout can be used. (i.e. farm, machine, engine, etc) + * See CircuitSocketType for Forestry's uses. + */ +public interface ICircuitSocketType { + /** unique identifier for this socket type */ + String getUid(); + + /** comparison using uid */ + boolean equals(ICircuitSocketType socketType); +} diff --git a/src/main/java/forestry/api/circuits/ISolderManager.java b/src/main/java/forestry/api/circuits/ISolderManager.java new file mode 100644 index 000000000..af9b41f1b --- /dev/null +++ b/src/main/java/forestry/api/circuits/ISolderManager.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.circuits; + +import net.minecraft.item.ItemStack; + +public interface ISolderManager { + + void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit); + +} diff --git a/src/main/java/forestry/api/circuits/package-info.java b/src/main/java/forestry/api/circuits/package-info.java new file mode 100644 index 000000000..db28a65fa --- /dev/null +++ b/src/main/java/forestry/api/circuits/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "3.1.0", owner = "ForestryAPI|core", provides = "ForestryAPI|circuits") +package forestry.api.circuits; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/core/BiomeHelper.java b/src/main/java/forestry/api/core/BiomeHelper.java new file mode 100644 index 000000000..3b70ca63c --- /dev/null +++ b/src/main/java/forestry/api/core/BiomeHelper.java @@ -0,0 +1,36 @@ +package forestry.api.core; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.BiomeDictionary; + +public class BiomeHelper { + + private static final Map isBiomeHellishCache = new HashMap(); + + /** + * Determines if it can rain or snow in the given biome. + */ + public static boolean canRainOrSnow(BiomeGenBase biomeGenBase) { + return biomeGenBase.getEnableSnow() || biomeGenBase.canRain(); + } + + /** + * Determines if a given BiomeGenBase is of HELLISH temperature, since it is treated separately from actual temperature values. + * Uses the BiomeDictionary. + * @param biomeGen BiomeGenBase of the biome in question + * @return true, if the BiomeGenBase is a Nether-type biome; false otherwise. + */ + public static boolean isBiomeHellish(BiomeGenBase biomeGen) { + if (isBiomeHellishCache.containsKey(biomeGen)) { + return isBiomeHellishCache.get(biomeGen); + } + + boolean isBiomeHellish = BiomeDictionary.isBiomeOfType(biomeGen, BiomeDictionary.Type.NETHER); + isBiomeHellishCache.put(biomeGen, isBiomeHellish); + return isBiomeHellish; + } +} diff --git a/src/main/java/forestry/api/core/EnumHumidity.java b/src/main/java/forestry/api/core/EnumHumidity.java new file mode 100644 index 000000000..a87431691 --- /dev/null +++ b/src/main/java/forestry/api/core/EnumHumidity.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +/** + * Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location. + * + * This enum concerns humidity. + */ +public enum EnumHumidity { + ARID("Arid"), NORMAL("Normal"), DAMP("Damp"); + + public final String name; + + private EnumHumidity(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + /** + * Determines the EnumHumidity given a floating point representation of Minecraft Rainfall. + * To check if rainfall is possible in a biome, use BiomeHelper.canRainOrSnow(). + * @param rawHumidity raw rainfall value + * @return EnumHumidity corresponding to rainfall value + */ + public static EnumHumidity getFromValue(float rawHumidity) { + if (rawHumidity > 0.85f) { // matches BiomeGenBase.isHighHumidity() + return DAMP; + } + else if (rawHumidity >= 0.3f) { + return NORMAL; + } + else { + return ARID; + } + } +} diff --git a/src/main/java/forestry/api/core/EnumTemperature.java b/src/main/java/forestry/api/core/EnumTemperature.java new file mode 100644 index 000000000..f38024ac2 --- /dev/null +++ b/src/main/java/forestry/api/core/EnumTemperature.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.BlockPos; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Many things Forestry use temperature and humidity of a biome to determine whether they can or how they can work or spawn at a given location. + * + * This enum concerns temperature. + */ +public enum EnumTemperature { + NONE("None", "habitats/ocean"), ICY("Icy", "habitats/snow"), COLD("Cold", "habitats/taiga"), + NORMAL("Normal", "habitats/plains"), WARM("Warm", "habitats/jungle"), HOT("Hot", "habitats/desert"), HELLISH("Hellish", "habitats/nether"); + + public final String name; + public final String iconIndex; + + private EnumTemperature(String name, String iconIndex) { + this.name = name; + this.iconIndex = iconIndex; + } + + public String getName() { + return this.name; + } + + @SideOnly(Side.CLIENT) + public TextureAtlasSprite getIcon() { + return ForestryAPI.textureManager.getDefault(iconIndex); + } + + /** + * Determines the EnumTemperature given a floating point representation of + * Minecraft temperature. Hellish biomes are handled based on their biome + * type - check BiomeHelper.isBiomeHellish. + * @param rawTemp raw temperature value + * @return EnumTemperature corresponding to value of rawTemp + */ + public static EnumTemperature getFromValue(float rawTemp) { + if (rawTemp > 1.00f) { + return HOT; + } + else if (rawTemp > 0.85f) { + return WARM; + } + else if (rawTemp > 0.35f) { + return NORMAL; + } + else if (rawTemp > 0.0f) { + return COLD; + } + else { + return ICY; + } + } + + public static EnumTemperature getFromBiome(BiomeGenBase biomeGenBase) { + if (BiomeHelper.isBiomeHellish(biomeGenBase)) { + return HELLISH; + } + return getFromValue(biomeGenBase.temperature); + } + + public static EnumTemperature getFromBiome(BiomeGenBase biomeGenBase, BlockPos pos) { + if (BiomeHelper.isBiomeHellish(biomeGenBase)) { + return HELLISH; + } + float temperature = biomeGenBase.getFloatTemperature(pos); + return getFromValue(temperature); + } +} diff --git a/src/main/java/forestry/api/core/ForestryAPI.java b/src/main/java/forestry/api/core/ForestryAPI.java new file mode 100644 index 000000000..d8854c237 --- /dev/null +++ b/src/main/java/forestry/api/core/ForestryAPI.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.util.Set; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Forestry's API is divided into several subcategories to make it easier to understand. + * + * If you need to distribute API files, try to only include the parts you are actually + * using to minimize conflicts due to API changes. + * + * .core - Miscallenous base classes and interfaces as well as some basics for tools, armor, game modes and stuff needed by biome mods. + * .fuels - Managers and classes to facilitate adding fuels to various engines and machines. + * .recipes - Managers and helpers to facilitate adding new recipes to various machines. + * .storage - Managers, events and interfaces for defining new backpacks and handling backpack behaviour. + * .mail - Anything related to handling letters and adding new mail carrier systems. + * .genetics - Shared code for all genetic subclasses. + * \ .apiculture - Bees. + * \ .arboriculture - Trees. + * \ .lepidopterology - Butterflies. + * + * Note that if Forestry is not present, all these references will be null. + */ +public class ForestryAPI { + + /** + * The main mod instance for Forestry. + */ + public static Object instance; + + /** + * A {@link ITextureManager} needed for some things in the API. + */ + @SideOnly(Side.CLIENT) + public static ITextureManager textureManager; + + /** + * A {@link IModelManager} needed for some things in the API. + */ + @SideOnly(Side.CLIENT) + public static IModelManager modleManager; + + /** + * The currently active {@link IGameMode}. + */ + public static IGameMode activeMode; + + /** + * Provides information on certain Forestry constants (Villager IDs, Chest gen keys, etc) + */ + public static IForestryConstants forestryConstants; + + /** + * The currently enabled Forestry plugins. + * Can be used to check if certain features are available, for example: + * ForestryAPI.enabledPlugins.contains("APICULTURE") + */ + public static Set enabledPlugins; + + /** + * Instance of the errorStateRegistry for registering errors. + * Also creates new instances of IErrorLogic. + */ + public static IErrorStateRegistry errorStateRegistry; +} diff --git a/src/main/java/forestry/api/core/ForestryEvent.java b/src/main/java/forestry/api/core/ForestryEvent.java new file mode 100644 index 000000000..d5fa539bc --- /dev/null +++ b/src/main/java/forestry/api/core/ForestryEvent.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.common.eventhandler.Event; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IBreedingTracker; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesRoot; + +public abstract class ForestryEvent extends Event { + + private static abstract class BreedingEvent extends ForestryEvent { + public final ISpeciesRoot root; + public final IBreedingTracker tracker; + public final GameProfile username; + + private BreedingEvent(ISpeciesRoot root, GameProfile username, IBreedingTracker tracker) { + super(); + this.root = root; + this.username = username; + this.tracker = tracker; + } + } + + public static class SpeciesDiscovered extends BreedingEvent { + public final IAlleleSpecies species; + public SpeciesDiscovered(ISpeciesRoot root, GameProfile username, IAlleleSpecies species, IBreedingTracker tracker) { + super(root, username, tracker); + this.species = species; + } + } + + public static class MutationDiscovered extends BreedingEvent { + public final IMutation allele; + public MutationDiscovered(ISpeciesRoot root, GameProfile username, IMutation allele, IBreedingTracker tracker) { + super(root, username, tracker); + this.allele = allele; + } + } + + public static class SyncedBreedingTracker extends ForestryEvent { + public final IBreedingTracker tracker; + public final EntityPlayer player; + public SyncedBreedingTracker(IBreedingTracker tracker, EntityPlayer player) { + super(); + this.tracker = tracker; + this.player = player; + } + + } +} diff --git a/src/main/java/forestry/api/core/IArmorNaturalist.java b/src/main/java/forestry/api/core/IArmorNaturalist.java new file mode 100644 index 000000000..87400e271 --- /dev/null +++ b/src/main/java/forestry/api/core/IArmorNaturalist.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public interface IArmorNaturalist { + + /** + * Called when the naturalist's armor acts as spectacles for seeing pollinated tree leaves/flowers. + * + * @param player + * Player doing the viewing + * @param armor + * Armor item + * @param doSee + * Whether or not to actually do the side effects of viewing + * @return true if the armor actually allows the player to see pollination. + */ + public boolean canSeePollination(EntityPlayer player, ItemStack armor, boolean doSee); +} diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java b/src/main/java/forestry/api/core/IClimateControlled.java old mode 100755 new mode 100644 similarity index 58% rename from src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java rename to src/main/java/forestry/api/core/IClimateControlled.java index d44ebd816..01ae27638 --- a/src/main/java/forestry/energy/circuits/CircuitElectricEfficiency.java +++ b/src/main/java/forestry/api/core/IClimateControlled.java @@ -8,14 +8,16 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.energy.circuits; +package forestry.api.core; -public class CircuitElectricEfficiency extends CircuitElectricChange { - - public CircuitElectricEfficiency(String uid) { - super(uid, false); - this.setLimit(1); - this.configureChange(-1, 0); - } +public interface IClimateControlled { + /** + * Change the temperature, but not lower than boundaryDown or higher than boundaryUp. + */ + void addTemperatureChange(float change, float boundaryDown, float boundaryUp); + /** + * Change the humidity, but not lower than boundaryDown or higher than boundaryUp. + */ + void addHumidityChange(float change, float boundaryDown, float boundaryUp); } diff --git a/src/main/java/forestry/api/core/IErrorLogic.java b/src/main/java/forestry/api/core/IErrorLogic.java new file mode 100644 index 000000000..03a9eb54f --- /dev/null +++ b/src/main/java/forestry/api/core/IErrorLogic.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Keeps track of all the IErrorStates for an object. + * Create a new IErrorLogic instance for your object with ForestryAPI.errorStateRegistry.createErrorLogic(). + */ +public interface IErrorLogic extends IErrorSource { + + /** + * Sets the errorState when condition is true, and unsets it when condition is false. + * @return condition + */ + boolean setCondition(boolean condition, IErrorState errorState); + + /** + * @return true if the error state is active. + */ + boolean contains(IErrorState state); + + /** + * @return true if there are any active error states. + */ + boolean hasErrors(); + + /** + * Sets all active error states to false + */ + void clearErrors(); + + /** + * Network serialization for syncing errors to the client from the server. + */ + void writeData(DataOutputStream data) throws IOException; + void readData(DataInputStream data) throws IOException; +} diff --git a/src/main/java/forestry/api/core/IErrorLogicSource.java b/src/main/java/forestry/api/core/IErrorLogicSource.java new file mode 100644 index 000000000..5161ae0ec --- /dev/null +++ b/src/main/java/forestry/api/core/IErrorLogicSource.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +/** + * An IErrorLogicSource uses an instance of IErrorLogic to deal with its errors. + */ +public interface IErrorLogicSource { + IErrorLogic getErrorLogic(); +} diff --git a/src/main/java/forestry/api/core/IErrorSource.java b/src/main/java/forestry/api/core/IErrorSource.java new file mode 100644 index 000000000..a594c4b2b --- /dev/null +++ b/src/main/java/forestry/api/core/IErrorSource.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import com.google.common.collect.ImmutableSet; + +public interface IErrorSource { + /** + * @return the active error states. An empty Set indicates no errors. + */ + ImmutableSet getErrorStates(); +} diff --git a/src/main/java/forestry/api/core/IErrorState.java b/src/main/java/forestry/api/core/IErrorState.java new file mode 100644 index 000000000..e09fc2827 --- /dev/null +++ b/src/main/java/forestry/api/core/IErrorState.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * + * @author CovertJaguar + */ +public interface IErrorState { + + short getID(); + + String getUniqueName(); + + String getDescription(); + + String getHelp(); + + @SideOnly(Side.CLIENT) + void registerSprite(); + + @SideOnly(value = Side.CLIENT) + TextureAtlasSprite getSprite(); + +} diff --git a/src/main/java/forestry/api/core/IErrorStateRegistry.java b/src/main/java/forestry/api/core/IErrorStateRegistry.java new file mode 100644 index 000000000..fc67ae78a --- /dev/null +++ b/src/main/java/forestry/api/core/IErrorStateRegistry.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import java.util.Set; + +public interface IErrorStateRegistry { + void registerErrorState(IErrorState state); + void addAlias(IErrorState state, String name); + + IErrorState getErrorState(short id); + IErrorState getErrorState(String name); + Set getErrorStates(); + + IErrorLogic createErrorLogic(); +} diff --git a/src/main/java/forestry/api/core/IForestryConstants.java b/src/main/java/forestry/api/core/IForestryConstants.java new file mode 100644 index 000000000..4cf876f67 --- /dev/null +++ b/src/main/java/forestry/api/core/IForestryConstants.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +public interface IForestryConstants { + + /** + * @return The villager ID for the Apiarist Villager. + */ + public int getApicultureVillagerID(); + + /** + * @return The villager ID for the Arborist Villager. + */ + public int getArboricultureVillagerID(); + + /** + * @return The ChestGenHooks key for adding items to the Forestry Villager chest. + */ + public String getVillagerChestGenKey(); +} diff --git a/src/main/java/forestry/api/core/IGameMode.java b/src/main/java/forestry/api/core/IGameMode.java new file mode 100644 index 000000000..0b2b0c55d --- /dev/null +++ b/src/main/java/forestry/api/core/IGameMode.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.item.ItemStack; + +public interface IGameMode { + + /** + * @return Human-readable identifier for the game mode. (i.e. 'EASY', 'NORMAL', 'HARD') + */ + String getIdentifier(); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, false if unknown setting. + */ + boolean getBooleanSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, 0 if unknown setting. + */ + int getIntegerSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, 0 if unknown setting. + */ + float getFloatSetting(String ident); + + /** + * @param ident Identifier for the setting. (See the gamemode config.) + * @return Value of the requested setting, an itemstack containing an apple if unknown setting. + */ + ItemStack getStackSetting(String ident); + +} diff --git a/src/main/java/forestry/api/core/IItemModelRegister.java b/src/main/java/forestry/api/core/IItemModelRegister.java new file mode 100644 index 000000000..d2d57da26 --- /dev/null +++ b/src/main/java/forestry/api/core/IItemModelRegister.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.item.Item; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IItemModelRegister { + + @SideOnly(Side.CLIENT) + void registerModel(Item item, IModelManager manager); + +} diff --git a/src/main/java/forestry/api/core/IModelBaker.java b/src/main/java/forestry/api/core/IModelBaker.java new file mode 100644 index 000000000..285de8bfb --- /dev/null +++ b/src/main/java/forestry/api/core/IModelBaker.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.util.BlockPos; + +/** + * A model baker to make custom models in the mod + */ +public interface IModelBaker { + + void setRenderBoundsFromBlock(Block block); + + void setRenderBounds(double d, double e, double f, double g, double h, double i ); + + void setColorIndex(int color); + + boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite[] sprites, int colorIndex); + + boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite sprites, int colorIndex); + + void renderFaceXNeg(BlockPos pos, TextureAtlasSprite sprite); + + void renderFaceYNeg(BlockPos pos, TextureAtlasSprite sprite); + + void renderFaceZNeg(BlockPos pos, TextureAtlasSprite sprite); + + void renderFaceYPos(BlockPos pos, TextureAtlasSprite sprite); + + void renderFaceZPos(BlockPos pos, TextureAtlasSprite sprite); + + void renderFaceXPos(BlockPos pos, TextureAtlasSprite sprite); + + IBakedModel bakeModel(boolean flip); + +} diff --git a/src/main/java/forestry/api/core/IModelManager.java b/src/main/java/forestry/api/core/IModelManager.java new file mode 100644 index 000000000..c510b7f31 --- /dev/null +++ b/src/main/java/forestry/api/core/IModelManager.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.ItemMeshDefinition; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IModelManager { + + void registerItemModel(Item item, int meta, String modifier, String identifier); + + void registerItemModel(Item item, int meta, String identifier); + + void registerItemModel(Item item, int meta, boolean withMeta); + + ModelResourceLocation getModelLocation(String identifier); + + ModelResourceLocation getModelLocation(String modID, String identifier); + + ModelResourceLocation getModelLocation(Item item); + + ModelResourceLocation getModelLocation(Item item, String identifier); + + ModelResourceLocation getModelLocation(Item item, String modifier, String identifier); + + ModelResourceLocation getModelLocation(Item item, int meta); + + ModelResourceLocation getModelLocation(Item item, int meta, String identifier); + + ModelResourceLocation getModelLocation(Item item, int meta, String modifier, String identifier); + + void registerItemModel(Item item, ItemMeshDefinition definition); + + void registerVariant(Item item, ResourceLocation... resources); + + IModelBaker createNewRenderer(); + +} diff --git a/src/main/java/forestry/api/core/IModelProvider.java b/src/main/java/forestry/api/core/IModelProvider.java new file mode 100644 index 000000000..e6723f716 --- /dev/null +++ b/src/main/java/forestry/api/core/IModelProvider.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Provides modles, needed in some interfaces, most notably for bees and trees. + */ +public interface IModelProvider { + + @SideOnly(Side.CLIENT) + ModelResourceLocation getModel(); + + @SideOnly(Side.CLIENT) + void registerModels(Item item, IModelManager manager); + +} diff --git a/src/main/java/forestry/api/core/INBTTagable.java b/src/main/java/forestry/api/core/INBTTagable.java new file mode 100644 index 000000000..1d3f85808 --- /dev/null +++ b/src/main/java/forestry/api/core/INBTTagable.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.nbt.NBTTagCompound; + +public interface INBTTagable { + void readFromNBT(NBTTagCompound nbttagcompound); + + void writeToNBT(NBTTagCompound nbttagcompound); +} diff --git a/src/main/java/forestry/api/core/ISpriteProvider.java b/src/main/java/forestry/api/core/ISpriteProvider.java new file mode 100644 index 000000000..4d6288adc --- /dev/null +++ b/src/main/java/forestry/api/core/ISpriteProvider.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Provides icons, needed in some interfaces, most notably for bees and trees. + */ +public interface ISpriteProvider { + + @SideOnly(Side.CLIENT) + TextureAtlasSprite getSprite(short texUID); + + @SideOnly(Side.CLIENT) + void registerSprites(); + +} diff --git a/src/main/java/forestry/api/core/IStateMapperRegister.java b/src/main/java/forestry/api/core/IStateMapperRegister.java new file mode 100644 index 000000000..2be1168f5 --- /dev/null +++ b/src/main/java/forestry/api/core/IStateMapperRegister.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +public interface IStateMapperRegister { + + void registerStateMapper(); + +} diff --git a/src/main/java/forestry/api/core/ITextureManager.java b/src/main/java/forestry/api/core/ITextureManager.java new file mode 100644 index 000000000..6d0a061a4 --- /dev/null +++ b/src/main/java/forestry/api/core/ITextureManager.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; + +@SideOnly(Side.CLIENT) +public interface ITextureManager { + + void registerIconProvider(ISpriteProvider provider); + + TextureAtlasSprite getSprite(short texUID); + + TextureAtlasSprite getDefault(String ident); +} diff --git a/src/main/java/forestry/api/core/IToolPipette.java b/src/main/java/forestry/api/core/IToolPipette.java new file mode 100644 index 000000000..f5f1a6338 --- /dev/null +++ b/src/main/java/forestry/api/core/IToolPipette.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Taken from BuildCraft 5.0.x + */ +public interface IToolPipette { + + /** + * @param pipette + * ItemStack of the pipette. + * @return Capacity of the pipette. + */ + int getCapacity(ItemStack pipette); + + /** + * @param pipette + * @return true if the pipette can pipette. + */ + boolean canPipette(ItemStack pipette); + + /** + * Fills the pipette with the given liquid stack. + * + * @param pipette + * @param liquid + * @param doFill + * @return Amount of liquid used in filling the pipette. + */ + int fill(ItemStack pipette, FluidStack liquid, boolean doFill); + + /** + * Drains liquid from the pipette + * + * @param pipette + * @param maxDrain + * @param doDrain + * @return Fluid stack representing the liquid and amount drained from the pipette. + */ + FluidStack drain(ItemStack pipette, int maxDrain, boolean doDrain); +} diff --git a/src/main/java/forestry/api/core/IToolScoop.java b/src/main/java/forestry/api/core/IToolScoop.java new file mode 100644 index 000000000..583b6c7ed --- /dev/null +++ b/src/main/java/forestry/api/core/IToolScoop.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +/** + * Marks a tool as a scoop. + */ +public interface IToolScoop { + +} diff --git a/src/main/java/forestry/api/core/Tabs.java b/src/main/java/forestry/api/core/Tabs.java new file mode 100644 index 000000000..4ce85838d --- /dev/null +++ b/src/main/java/forestry/api/core/Tabs.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.core; + +import net.minecraft.creativetab.CreativeTabs; + +/** + * References to the specialised tabs added by Forestry to creative inventory. + */ +public class Tabs { + + public static CreativeTabs tabApiculture; + public static CreativeTabs tabArboriculture; + public static CreativeTabs tabLepidopterology; + +} diff --git a/src/main/java/forestry/api/core/package-info.java b/src/main/java/forestry/api/core/package-info.java new file mode 100644 index 000000000..be9abfd21 --- /dev/null +++ b/src/main/java/forestry/api/core/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "5.0.0", owner = "Forestry", provides = "ForestryAPI|core") +package forestry.api.core; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/farming/DefaultFarmListener.java b/src/main/java/forestry/api/farming/DefaultFarmListener.java new file mode 100644 index 000000000..79d041015 --- /dev/null +++ b/src/main/java/forestry/api/farming/DefaultFarmListener.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; + +/** + * Easily extendable default farmListener. + * By itself, this farmListener does nothing. + * FarmListeners should inherit from this class unless they need to listen for everything. + */ +public class DefaultFarmListener implements IFarmListener { + @Override + public boolean beforeCropHarvest(ICrop crop) { + return false; + } + + @Override + public void afterCropHarvest(Collection harvested, ICrop crop) { + + } + + @Override + public void hasCollected(Collection collected, IFarmLogic logic) { + + } + + @Override + public void hasCultivated(IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent) { + + } + + @Override + public void hasScheduledHarvest(Collection harvested, IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent) { + + } + + @Override + public boolean cancelTask(IFarmLogic logic, FarmDirection direction) { + return false; + } + +} diff --git a/src/main/java/forestry/api/farming/FarmDirection.java b/src/main/java/forestry/api/farming/FarmDirection.java new file mode 100644 index 000000000..b65f3da2d --- /dev/null +++ b/src/main/java/forestry/api/farming/FarmDirection.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.util.EnumFacing; + +public enum FarmDirection { + NORTH(EnumFacing.NORTH), + EAST(EnumFacing.EAST), + SOUTH(EnumFacing.SOUTH), + WEST(EnumFacing.WEST); + + private final EnumFacing forgeDirection; + + FarmDirection(EnumFacing forgeDirection) { + this.forgeDirection = forgeDirection; + } + + public EnumFacing getForgeDirection() { + return forgeDirection; + } + + public static FarmDirection getFarmDirection(EnumFacing forgeDirection) { + switch (forgeDirection) { + case NORTH: return NORTH; + case EAST: return EAST; + case SOUTH: return SOUTH; + case WEST: return WEST; + } + return null; + } +} diff --git a/src/main/java/forestry/api/farming/Farmables.java b/src/main/java/forestry/api/farming/Farmables.java new file mode 100644 index 000000000..9816e64ee --- /dev/null +++ b/src/main/java/forestry/api/farming/Farmables.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; +import java.util.HashMap; + +public class Farmables { + /** + * Can be used to add IFarmables to some of the vanilla farm logics. + * + * Identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom + */ + public static HashMap> farmables = new HashMap>(); + +} diff --git a/src/main/java/forestry/api/farming/ICrop.java b/src/main/java/forestry/api/farming/ICrop.java new file mode 100644 index 000000000..22575477d --- /dev/null +++ b/src/main/java/forestry/api/farming/ICrop.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +public interface ICrop { + + /** + * Harvests this crop. Performs the necessary manipulations to set the crop into a "harvested" state. + * + * @return Products harvested. + */ + Collection harvest(); + +} diff --git a/src/main/java/forestry/api/farming/IFarmHousing.java b/src/main/java/forestry/api/farming/IFarmHousing.java new file mode 100644 index 000000000..81c01b215 --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmHousing.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.core.IErrorLogicSource; + +public interface IFarmHousing extends IErrorLogicSource { + + int[] getCoords(); + int[] getArea(); + int[] getOffset(); + World getWorld(); + + /** + * @return true if any work was done, false otherwise. + */ + boolean doWork(); + + boolean hasLiquid(FluidStack liquid); + void removeLiquid(FluidStack liquid); + + /** + * Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem. + * Will remove the appropriate germling from the farm's inventory. + * It's up to the logic to only call this on a valid location. + * + * @return true if planting was successful, false otherwise. + */ + boolean plantGermling(IFarmable farmable, World world, BlockPos pos); + + /* INTERACTION WITH HATCHES */ + IFarmInventory getFarmInventory(); + + /* LOGIC */ + void setFarmLogic(FarmDirection direction, IFarmLogic logic); + void resetFarmLogic(FarmDirection direction); + IFarmLogic getFarmLogic(FarmDirection direction); + + /* GUI */ + int getStoredFertilizerScaled(int scale); +} diff --git a/src/main/java/forestry/api/farming/IFarmInventory.java b/src/main/java/forestry/api/farming/IFarmInventory.java new file mode 100644 index 000000000..36f45ea39 --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmInventory.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public interface IFarmInventory { + boolean hasResources(ItemStack[] resources); + void removeResources(ItemStack[] resources); + + boolean acceptsAsGermling(ItemStack itemstack); + boolean acceptsAsResource(ItemStack itemstack); + boolean acceptsAsFertilizer(ItemStack itemstack); + + IInventory getProductInventory(); + IInventory getGermlingsInventory(); + IInventory getResourcesInventory(); + IInventory getFertilizerInventory(); +} diff --git a/src/main/java/forestry/api/farming/IFarmListener.java b/src/main/java/forestry/api/farming/IFarmListener.java new file mode 100644 index 000000000..20a98cadd --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmListener.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; + +public interface IFarmListener { + + /** + * Called before a crop is harvested. + * + * @param crop ICrop about to be harvested. + * @return true to cancel further processing of this crop. + */ + boolean beforeCropHarvest(ICrop crop); + + /** + * Called after a crop has been harvested, but before harvested items are stowed in the farms inventory. + * + * @param harvested Collection of harvested stacks. May be manipulated. Ensure removal of stacks with 0 or less items! + * @param crop Harvested {@link ICrop} + */ + void afterCropHarvest(Collection harvested, ICrop crop); + + /** + * Called after the stack of collected items has been returned by the farm logic, but before it is added to the farm's pending queue. + * + * @param collected Collection of collected stacks. May be manipulated. Ensure removal of stacks with 0 or less items! + */ + void hasCollected(Collection collected, IFarmLogic logic); + + /** + * Called after farmland has successfully been cultivated by a farm logic. + */ + void hasCultivated(IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent); + + /** + * Called after the stack of harvested crops has been returned by the farm logic, but before it is added to the farm's pending queue. + */ + void hasScheduledHarvest(Collection harvested, IFarmLogic logic, BlockPos pos, FarmDirection direction, int extent); + + /** + * Can be used to cancel farm task on a per side/{@link IFarmLogic} basis. + * + * @return true to skip any work action on the given logic and direction for this work cycle. + */ + boolean cancelTask(IFarmLogic logic, FarmDirection direction); +} diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java new file mode 100644 index 000000000..a6b426ee8 --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IFarmLogic { + + int getFertilizerConsumption(); + + int getWaterConsumption(float hydrationModifier); + + boolean isAcceptedResource(ItemStack itemstack); + + boolean isAcceptedGermling(ItemStack itemstack); + + Collection collect(); + + boolean cultivate(BlockPos pos, FarmDirection direction, int extent); + + Collection harvest(BlockPos pos, FarmDirection direction, int extent); + + IFarmLogic setManual(boolean manual); + + @SideOnly(Side.CLIENT) + ResourceLocation getTextureMap(); + + String getName(); + + @SideOnly(Side.CLIENT) + ItemStack getStack(); +} diff --git a/src/main/java/forestry/api/farming/IFarmable.java b/src/main/java/forestry/api/farming/IFarmable.java new file mode 100644 index 000000000..e1438715d --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmable.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.farming; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * IFarmable describes a crop or other harvestable object and can be used to inspect item stacks and blocks for matches. + */ +public interface IFarmable { + + /** + * @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop. + */ + boolean isSaplingAt(World world, BlockPos pos); + + /** + * @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise. + */ + ICrop getCropAt(World world, BlockPos pos); + + /** + * @return true if the item is a valid germling (plantable sapling, seed, etc.) for this type. + */ + boolean isGermling(ItemStack itemstack); + + /** + * @return true if the item is something that can drop from this type without actually being harvested as a crop. (Apples or sapling from decaying leaves.) + */ + boolean isWindfall(ItemStack itemstack); + + /** + * Plants a sapling by manipulating the world. The {@link IFarmLogic} should have verified the given location as valid. Called by the {@link IFarmHousing} + * which handles resources. + * + * @return true on success, false otherwise. + */ + boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos); + +} diff --git a/src/main/java/forestry/api/farming/package-info.java b/src/main/java/forestry/api/farming/package-info.java new file mode 100644 index 000000000..d916d01bd --- /dev/null +++ b/src/main/java/forestry/api/farming/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="2.1.0", owner="ForestryAPI|core", provides="ForestryAPI|farming") +package forestry.api.farming; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/food/BeverageManager.java b/src/main/java/forestry/api/food/BeverageManager.java new file mode 100644 index 000000000..2b0143ab1 --- /dev/null +++ b/src/main/java/forestry/api/food/BeverageManager.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +public class BeverageManager { + public static IBeverageEffect[] effectList = new IBeverageEffect[128]; + + public static IInfuserManager infuserManager; + public static IIngredientManager ingredientManager; +} diff --git a/src/main/java/forestry/api/food/IBeverageEffect.java b/src/main/java/forestry/api/food/IBeverageEffect.java new file mode 100644 index 000000000..6a787411d --- /dev/null +++ b/src/main/java/forestry/api/food/IBeverageEffect.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface IBeverageEffect { + int getId(); + + void doEffect(World world, EntityPlayer player); + + String getDescription(); +} diff --git a/src/main/java/forestry/api/food/IInfuserManager.java b/src/main/java/forestry/api/food/IInfuserManager.java new file mode 100644 index 000000000..d778ffa41 --- /dev/null +++ b/src/main/java/forestry/api/food/IInfuserManager.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.item.ItemStack; + +public interface IInfuserManager { + + void addMixture(int meta, ItemStack ingredient, IBeverageEffect effect); + + void addMixture(int meta, ItemStack[] ingredients, IBeverageEffect effect); + + ItemStack getSeasoned(ItemStack base, ItemStack[] ingredients); + + boolean hasMixtures(ItemStack[] ingredients); + + boolean isIngredient(ItemStack itemstack); + + ItemStack[] getRequired(ItemStack[] ingredients); + +} diff --git a/src/main/java/forestry/api/food/IIngredientManager.java b/src/main/java/forestry/api/food/IIngredientManager.java new file mode 100644 index 000000000..fab0e0129 --- /dev/null +++ b/src/main/java/forestry/api/food/IIngredientManager.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.food; + +import net.minecraft.item.ItemStack; + +public interface IIngredientManager { + + String getDescription(ItemStack itemstack); + + void addIngredient(ItemStack ingredient, String description); + +} diff --git a/src/main/java/forestry/api/food/package-info.java b/src/main/java/forestry/api/food/package-info.java new file mode 100644 index 000000000..c7dbfd01f --- /dev/null +++ b/src/main/java/forestry/api/food/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.1.0", owner="ForestryAPI|core", provides="ForestryAPI|food") +package forestry.api.food; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/fuels/EngineBronzeFuel.java b/src/main/java/forestry/api/fuels/EngineBronzeFuel.java new file mode 100644 index 000000000..cbab0cafc --- /dev/null +++ b/src/main/java/forestry/api/fuels/EngineBronzeFuel.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraftforge.fluids.Fluid; + +public class EngineBronzeFuel { + /** + * Item that is valid fuel for a biogas engine. + */ + public final Fluid liquid; + /** + * Power produced by this fuel per work cycle of the engine. + */ + public final int powerPerCycle; + /** + * How many work cycles a single "stack" of this type lasts. + */ + public final int burnDuration; + /** + * By how much the normal heat dissipation rate of 1 is multiplied when using this fuel type. + */ + public final int dissipationMultiplier; + + public EngineBronzeFuel(Fluid liquid, int powerPerCycle, int burnDuration, int dissipationMultiplier) { + this.liquid = liquid; + this.powerPerCycle = powerPerCycle; + this.burnDuration = burnDuration; + this.dissipationMultiplier = dissipationMultiplier; + } +} diff --git a/src/main/java/forestry/api/fuels/EngineCopperFuel.java b/src/main/java/forestry/api/fuels/EngineCopperFuel.java new file mode 100644 index 000000000..af568dd41 --- /dev/null +++ b/src/main/java/forestry/api/fuels/EngineCopperFuel.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class EngineCopperFuel { + + /** + * Item that is valid fuel for a peat-fired engine. + */ + public final ItemStack fuel; + /** + * Power produced by this fuel per work cycle. + */ + public final int powerPerCycle; + /** + * Amount of work cycles this item lasts before being consumed. + */ + public final int burnDuration; + + public EngineCopperFuel(ItemStack fuel, int powerPerCycle, int burnDuration) { + this.fuel = fuel; + this.powerPerCycle = powerPerCycle; + this.burnDuration = burnDuration; + } + +} diff --git a/src/main/java/forestry/api/fuels/FermenterFuel.java b/src/main/java/forestry/api/fuels/FermenterFuel.java new file mode 100644 index 000000000..32989a803 --- /dev/null +++ b/src/main/java/forestry/api/fuels/FermenterFuel.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class FermenterFuel { + /** + * Item that is a valid fuel for the fermenter (i.e. fertilizer). + */ + public final ItemStack item; + /** + * How much is fermeted per work cycle, i.e. how much biomass is produced per cycle. + */ + public final int fermentPerCycle; + /** + * Amount of work cycles a single item of this fuel lasts before expiring. + */ + public final int burnDuration; + + public FermenterFuel(ItemStack item, int fermentPerCycle, int burnDuration) { + this.item = item; + this.fermentPerCycle = fermentPerCycle; + this.burnDuration = burnDuration; + } +} diff --git a/src/main/java/forestry/api/fuels/FuelManager.java b/src/main/java/forestry/api/fuels/FuelManager.java new file mode 100644 index 000000000..f53d6fb71 --- /dev/null +++ b/src/main/java/forestry/api/fuels/FuelManager.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +import java.util.HashMap; + + +public class FuelManager { + /** + * Add new fuels for the fermenter here (i.e. fertilizer). + */ + public static HashMap fermenterFuel; + /** + * Add new resources for the moistener here (i.e. wheat) + */ + public static HashMap moistenerResource; + /** + * Add new substrates for the rainmaker here + */ + public static HashMap rainSubstrate; + /** + * Add new fuels for EngineBronze (= biogas engine) here + */ + public static HashMap bronzeEngineFuel; + /** + * Add new fuels for EngineCopper (= peat-fired engine) here + */ + public static HashMap copperEngineFuel; + /** + * Add new fuels for Generator here + */ + public static HashMap generatorFuel; + +} diff --git a/src/main/java/forestry/api/fuels/GeneratorFuel.java b/src/main/java/forestry/api/fuels/GeneratorFuel.java new file mode 100644 index 000000000..16e2ee4d3 --- /dev/null +++ b/src/main/java/forestry/api/fuels/GeneratorFuel.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraftforge.fluids.FluidStack; + +public class GeneratorFuel { + + /** + * LiquidStack representing the fuel type and amount consumed per triggered cycle. + */ + public final FluidStack fuelConsumed; + /** + * EU emitted per tick while this fuel is being consumed in the generator (i.e. biofuel = 32, biomass = 8). + */ + public final int eu; + /** + * Rate at which the fuel is consumed. 1 - Every tick 2 - Every second tick 3 - Every third tick etc. + */ + public final int rate; + + public GeneratorFuel(FluidStack fuelConsumed, int eu, int rate) { + this.fuelConsumed = fuelConsumed; + this.eu = eu; + this.rate = rate; + } + +} diff --git a/src/main/java/forestry/api/fuels/MoistenerFuel.java b/src/main/java/forestry/api/fuels/MoistenerFuel.java new file mode 100644 index 000000000..4c4c7a0b6 --- /dev/null +++ b/src/main/java/forestry/api/fuels/MoistenerFuel.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class MoistenerFuel { + /** + * The item to use + */ + public final ItemStack item; + /** + * The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch) + */ + public final ItemStack product; + /** + * How much this item contributes to the final product of the moistener (i.e. mycelium) + */ + public final int moistenerValue; + /** + * What stage this product represents. Resources with lower stage value will be consumed first. + */ + public final int stage; + + public MoistenerFuel(ItemStack item, ItemStack product, int stage, int moistenerValue) { + this.item = item; + this.product = product; + this.stage = stage; + this.moistenerValue = moistenerValue; + } +} diff --git a/src/main/java/forestry/api/fuels/RainSubstrate.java b/src/main/java/forestry/api/fuels/RainSubstrate.java new file mode 100644 index 000000000..ab0deb5a3 --- /dev/null +++ b/src/main/java/forestry/api/fuels/RainSubstrate.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.fuels; + +import net.minecraft.item.ItemStack; + +public class RainSubstrate { + /** + * Rain substrate capable of activating the rainmaker. + */ + public ItemStack item; + /** + * Duration of the rain shower triggered by this substrate in Minecraft ticks. + */ + public int duration; + /** + * Speed of activation sequence triggered. + */ + public float speed; + + public boolean reverse; + + public RainSubstrate(ItemStack item, int duration, float speed) { + this(item, duration, speed, false); + } + + public RainSubstrate(ItemStack item, float speed) { + this(item, 0, speed, true); + } + + public RainSubstrate(ItemStack item, int duration, float speed, boolean reverse) { + this.item = item; + this.duration = duration; + this.speed = speed; + this.reverse = reverse; + } +} diff --git a/src/main/java/forestry/api/fuels/package-info.java b/src/main/java/forestry/api/fuels/package-info.java new file mode 100644 index 000000000..c6bf9e745 --- /dev/null +++ b/src/main/java/forestry/api/fuels/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="2.0.1", owner="ForestryAPI|core", provides="ForestryAPI|fuels") +package forestry.api.fuels; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/genetics/AlleleManager.java b/src/main/java/forestry/api/genetics/AlleleManager.java new file mode 100644 index 000000000..6e3511621 --- /dev/null +++ b/src/main/java/forestry/api/genetics/AlleleManager.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +/** + * Holds a static reference to the {@link IAlleleRegistry}. + */ +public class AlleleManager { + /** + * Main access point for all things related to genetics. See {@link IAlleleRegistry} for details. + */ + public static IAlleleRegistry alleleRegistry; + /** + * Translates plain leaf blocks into genetic data. Used by bees and butterflies to convert and pollinate foreign leaf blocks. + */ + public static HashMap ersatzSpecimen = new HashMap(); + /** + * Translates plain saplings into genetic data. Used by the treealyzer and the farm to convert foreign saplings. + */ + public static HashMap ersatzSaplings = new HashMap(); + /** + * Queryable instance of an {@link IClimateHelper} for easier implementation. + */ + public static IClimateHelper climateHelper; + /** + * Creates Forestry alleles. + */ + public static IAlleleFactory alleleFactory; +} diff --git a/src/main/java/forestry/api/genetics/EnumTolerance.java b/src/main/java/forestry/api/genetics/EnumTolerance.java new file mode 100644 index 000000000..6ff0085eb --- /dev/null +++ b/src/main/java/forestry/api/genetics/EnumTolerance.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +public enum EnumTolerance { + NONE, + + BOTH_1, BOTH_2, BOTH_3, BOTH_4, BOTH_5, + + UP_1, UP_2, UP_3, UP_4, UP_5, + + DOWN_1, DOWN_2, DOWN_3, DOWN_4, DOWN_5 +} diff --git a/src/main/java/forestry/api/genetics/IAllele.java b/src/main/java/forestry/api/genetics/IAllele.java new file mode 100644 index 000000000..527474102 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAllele.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * An {@link IIndividual}'s {@link IGenome} is composed of {@link IChromosome}s consisting each of a primary and secondary {@link IAllele}. + * + * {@link IAllele}s hold all information regarding an {@link IIndividual}'s traits, from species to size, temperature tolerances, etc. + * + * Should be extended for different types of alleles. ISpeciesAllele, IBiomeAllele, etc. + * + * @author SirSengir + */ +public interface IAllele { + + /** + * @return A unique string identifier for this allele. + */ + String getUID(); + + /** + * @return true if the allele is dominant, false otherwise. + */ + boolean isDominant(); + + /** + * @return Localized short, human-readable identifier used in tooltips and beealyzer. + */ + String getName(); + + /** + * @return The unlocalized identifier + */ + String getUnlocalizedName(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleArea.java b/src/main/java/forestry/api/genetics/IAlleleArea.java new file mode 100644 index 000000000..7277ff0a1 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleArea.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleArea extends IAllele { + + int[] getValue(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleBoolean.java b/src/main/java/forestry/api/genetics/IAlleleBoolean.java new file mode 100644 index 000000000..887da3b90 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleBoolean.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleBoolean extends IAllele { + + boolean getValue(); + + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleEffect.java b/src/main/java/forestry/api/genetics/IAlleleEffect.java new file mode 100644 index 000000000..7b94e6b16 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleEffect.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Basic effect allele. + */ +public interface IAlleleEffect extends IAllele { + /** + * @return true if this effect can combine with the effect on other allele (i.e. run before or after). combination can only occur if both effects are + * combinable. + */ + boolean isCombinable(); + + /** + * Returns the passed data storage if it is valid for this effect or a new one if the passed storage object was invalid for this effect. + * + * @param storedData + * @return {@link IEffectData} for the next cycle. + */ + IEffectData validateStorage(IEffectData storedData); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleFactory.java b/src/main/java/forestry/api/genetics/IAlleleFactory.java new file mode 100644 index 000000000..573408007 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleFactory.java @@ -0,0 +1,153 @@ +package forestry.api.genetics; + +/** + * Creates new alleles with smart localization. + * + * + * UID is created like this: + * modId + '.' + category + WordUtils.capitalize(valueName); + * For Example: + * modId:forestry, category:height, valueName:smallest => forestry.heightSmallest + * This is mainly for legacy compatibility and may change in future major versions. + * + * + * The default localization uses: + * [modId].allele.[valueName] + * + * Languages that need category-specific names can override it by defining: + * [modId].allele.[category].[valueName] + * + * For example: + * en_US + * forestry.allele.smallest=Smallest + * ru_RU + * forestry.allele.smallest=????? ????????? + * forestry.allele.height.smallest=????? ?????? + */ +public interface IAlleleFactory { + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "height") + * @param valueName allele value name for uid and localization (i.e. "smallest") + * @param value allele float value + * @param isDominant allele dominance + * @param types allele chromosome type for registration (i.e. EnumTreeChromosome.HEIGHT) + * @return a new IAlleleFloat, registered with the allele registry. + * @since Forestry 4.2 + */ + IAlleleFloat createFloat(String modId, String category, String valueName, float value, boolean isDominant, IChromosomeType... types); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "territory") + * @param valueName allele value name for uid and localization (i.e. "large") + * @param xDimValue allele area X Size + * @param yDimValue allele area Y Size + * @param zDimValue allele area Z Size + * @param isDominant allele dominance + * @param types allele chromosome type for registration (i.e. EnumBeeChromosome.TERRITORY) + * @return a new IAlleleArea, registered with the allele registry. + * @since Forestry 4.2 + */ + IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant, IChromosomeType... types); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "fertility") + * @param valueName allele value name for uid and localization (i.e. "low") + * @param value allele int value + * @param isDominant allele dominance + * @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FERTILITY) + * @return a new IAlleleInteger, registered with the allele registry. + * @since Forestry 4.2 + */ + IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant, IChromosomeType... types); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "fireproof") + * @param value allele boolean value + * @param isDominant allele dominance + * @param types allele chromosome type for registration (i.e. EnumTreeChromosome.FIREPROOF) + * @return a new IAlleleBoolean, registered with the allele registry. + * Note that valueName will always be "true" or "false" + * @since Forestry 4.2 + */ + IAlleleBoolean createBoolean(String modId, String category, boolean value, boolean isDominant, IChromosomeType... types); + + /** + * @param modId mod prefix for uid (i.e. "forestry") + * @param category allele category for uid (i.e. "flowers") + * @param valueName allele value name for uid (i.e. "vanilla") + * @param value allele IFlowerProvider value + * @param isDominant allele dominance + * @param types allele chromosome type for registration (i.e. EnumBeeChromosome.FLOWER_PROVIDER) + * @return a new IAlleleFlowers, registered with the allele registry. + * IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles. + * @since Forestry 4.2 + */ + IAlleleFlowers createFlowers(String modId, String category, String valueName, IFlowerProvider value, boolean isDominant, IChromosomeType... types); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "height") + * @param valueName allele value name for uid and localization (i.e. "smallest") + * @param value allele float value + * @param isDominant allele dominance + * @return a new IAlleleFloat, registered with the allele registry. + * @deprecated since Forestry 4.2. Use the IChromosomeType version. + */ + @Deprecated + IAlleleFloat createFloat(String modId, String category, String valueName, float value, boolean isDominant); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "territory") + * @param valueName allele value name for uid and localization (i.e. "large") + * @param xDimValue allele area X Size + * @param yDimValue allele area Y Size + * @param zDimValue allele area Z Size + * @param isDominant allele dominance + * @return a new IAlleleArea, registered with the allele registry. + * @deprecated since Forestry 4.2. Use the IChromosomeType version. + */ + @Deprecated + IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "fertility") + * @param valueName allele value name for uid and localization (i.e. "low") + * @param value allele int value + * @param isDominant allele dominance + * @return a new IAlleleInteger, registered with the allele registry. + * @deprecated since Forestry 4.2. Use the IChromosomeType version. + */ + @Deprecated + IAlleleInteger createInteger(String modId, String category, String valueName, int value, boolean isDominant); + + /** + * @param modId mod prefix for uid and localization (i.e. "forestry") + * @param category allele category for uid and localization (i.e. "fireproof") + * @param value allele boolean value + * @param isDominant allele dominance + * @return a new IAlleleBoolean, registered with the allele registry. + * Note that valueName will always be "true" or "false" + * @deprecated since Forestry 4.2. Use the IChromosomeType version. + */ + @Deprecated + IAlleleBoolean createBoolean(String modId, String category, boolean value, boolean isDominant); + + /** + * @param modId mod prefix for uid (i.e. "forestry") + * @param category allele category for uid (i.e. "flowers") + * @param valueName allele value name for uid (i.e. "vanilla") + * @param value allele IFlowerProvider value + * @param isDominant allele dominance + * @return a new IAlleleFlowers, registered with the allele registry. + * IAlleleFlowers localization is handled by the IFlowerProvider.getDescription(), unlike the other alleles. + * @deprecated since Forestry 4.2. Use the IChromosomeType version. + */ + @Deprecated + IAlleleFlowers createFlowers(String modId, String category, String valueName, IFlowerProvider value, boolean isDominant); +} diff --git a/src/main/java/forestry/api/genetics/IAlleleFloat.java b/src/main/java/forestry/api/genetics/IAlleleFloat.java new file mode 100644 index 000000000..6ca28776a --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleFloat.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleFloat extends IAllele { + + float getValue(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleFlowers.java b/src/main/java/forestry/api/genetics/IAlleleFlowers.java new file mode 100644 index 000000000..0368ca41c --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleFlowers.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + + +public interface IAlleleFlowers extends IAllele { + + /** + * @return FlowerProvider + */ + IFlowerProvider getProvider(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleHandler.java b/src/main/java/forestry/api/genetics/IAlleleHandler.java new file mode 100644 index 000000000..3d052afe4 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleHandler.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * @author Alex Binnie + * + * Handler for events that occur in IAlleleRegistry, such as registering alleles, branches etc. Useful for handling plugin specific behavior (i.e. + * creating a list of all bee species etc.) + * + */ +public interface IAlleleHandler { + + /** + * Called when an allele is registered with {@link IAlleleRegistry}. + * + * @param allele + * Allele which was registered. + */ + public void onRegisterAllele(IAllele allele); + + /** + * Called when a classification is registered with {@link IAlleleRegistry}. + * + * @param classification + * Classification which was registered. + */ + public void onRegisterClassification(IClassification classification); + + /** + * Called when a fruit family is registered with {@link IAlleleRegistry}. + * + * @param family + * Fruit family which was registered. + */ + public void onRegisterFruitFamily(IFruitFamily family); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleInteger.java b/src/main/java/forestry/api/genetics/IAlleleInteger.java new file mode 100644 index 000000000..6991efe5f --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleInteger.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing integer values. + */ +public interface IAlleleInteger extends IAllele { + + int getValue(); + +} diff --git a/src/main/java/forestry/api/genetics/IAllelePlantType.java b/src/main/java/forestry/api/genetics/IAllelePlantType.java new file mode 100644 index 000000000..211237f20 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAllelePlantType.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +public interface IAllelePlantType extends IAllele { + + public EnumSet getPlantTypes(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleRegistry.java b/src/main/java/forestry/api/genetics/IAlleleRegistry.java new file mode 100644 index 000000000..90f89940e --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleRegistry.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IClassification.EnumClassLevel; + +/** + * Manages {@link ISpeciesRoot}, {@link IAllele}s, {@link IFruitFamily}s, {@link IClassification}, the blacklist and allows creation of research notes. + * + * @author SirSengir + */ +public interface IAlleleRegistry { + + /* SPECIES ROOT CLASSES */ + /** + * Register a {@link ISpeciesRoot}. + * @param root {@link ISpeciesRoot} to register. + */ + void registerSpeciesRoot(ISpeciesRoot root); + + /** + * @return Map of all registered {@link ISpeciesRoot}. + */ + Map getSpeciesRoot(); + + /** + * Retrieve the {@link ISpeciesRoot} with the given uid. + * @param uid Unique id for the species class, i.e. "rootBees", "rootTrees", "rootButterflies". + * @return {@link ISpeciesRoot} if it exists, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(String uid); + + /** + * Retrieve a matching {@link ISpeciesRoot} for the given itemstack. + * @param stack An itemstack possibly containing NBT data which can be converted by a species root. + * @return {@link ISpeciesRoot} if found, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(ItemStack stack); + + /** + * Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class. + * @param clz Class extending {@link IIndividual}. + * @return {@link ISpeciesRoot} if found, null otherwise. + */ + ISpeciesRoot getSpeciesRoot(Class clz); + + /* INDIVIDUAL */ + /** + * Tests the itemstack for genetic information. + * + * @param stack + * @return true if the itemstack is an individual. + */ + boolean isIndividual(ItemStack stack); + + /** + * Retrieve genetic information from an itemstack. + * + * @param stack + * Stack to retrieve genetic information for. + * @return IIndividual containing genetic information, null if none could be extracted. + */ + IIndividual getIndividual(ItemStack stack); + + /* ALLELES */ + + /** + * @return HashMap of all currently registered alleles. + */ + Map getRegisteredAlleles(); + + /** + * Registers an allele. + * + * @param allele IAllele to register. + * @deprecated since Forestry 4.2. Use the IChromosomeType-specific version. + */ + @Deprecated + void registerAllele(IAllele allele); + + /** + * Registers an allele. + * + * NOTE: Where possible, it is recommended to use IAlleleFactory instead + * because it has built-in advanced localization support. + * + * @param allele IAllele to register. + * @param chromosomeTypes valid chromosomeTypes for this allele. + * @since Forestry 4.2 + */ + void registerAllele(IAllele allele, IChromosomeType... chromosomeTypes); + + /** + * @return HashMap of all registered deprecated alleles and their corresponding replacements + */ + Map getDeprecatedAlleleReplacements(); + + /** + * Registers an old allele UID and the new IAllele to replace instances of it with. + * + * @param deprecatedAlleleUID + * the old allele's UID + * @param replacement + * the IAllele that the deprecated Allele will be replaced with. + */ + void registerDeprecatedAlleleReplacement(String deprecatedAlleleUID, IAllele replacement); + + /** + * Gets an allele + * + * @param uid + * String based unique identifier of the allele to retrieve. + * @return IAllele if found or a replacement is found in the Deprecated Allele map, null otherwise. + */ + IAllele getAllele(String uid); + + /** + * @return unmodifiable collection of all the known allele variations for the given chromosome type. + * @since Forestry 4.2 + */ + Collection getRegisteredAlleles(IChromosomeType type); + + /* CLASSIFICATIONS */ + /** + * @return HashMap of all currently registered classifications. + */ + Map getRegisteredClassifications(); + + /** + * Registers a classification. + * + * @param classification + * IClassification to register. + */ + void registerClassification(IClassification classification); + + /** + * Creates and returns a classification. + * + * @param level + * EnumClassLevel of the classification to create. + * @param uid + * String based unique identifier. Implementation will throw an exception if the key is already taken. + * @param scientific + * Binomial for the given classification. + * @return Created {@link IClassification} for easier chaining. + */ + IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific); + IClassification createAndRegisterClassification(EnumClassLevel level, String uid, String scientific, IClassification... members); + + /** + * Gets a classification. + * + * @param uid + * String based unique identifier of the classification to retrieve. + * @return {@link IClassification} if found, null otherwise. + */ + IClassification getClassification(String uid); + + /* FRUIT FAMILIES */ + /** + * Get all registered fruit families. + * + * @return A map of registered fruit families and their UIDs. + */ + Map getRegisteredFruitFamilies(); + + /** + * Registers a new fruit family. + * + * @param family + */ + void registerFruitFamily(IFruitFamily family); + + /** + * Retrieves a fruit family identified by uid. + * + * @param uid + * @return {IFruitFamily} if found, false otherwise. + */ + IFruitFamily getFruitFamily(String uid); + + /* ALLELE HANDLERS */ + /** + * Registers a new IAlleleHandler + * + * @param handler + * IAlleleHandler to register. + */ + void registerAlleleHandler(IAlleleHandler handler); + + /* BLACKLIST */ + /** + * Blacklist an allele identified by its UID from mutation. + * + * @param uid + * UID of the allele to blacklist. + */ + void blacklistAllele(String uid); + + /** + * @return Current blacklisted alleles. + */ + Collection getAlleleBlacklist(); + + /** + * @param uid + * UID of the species to vet. + * @return true if the allele is blacklisted. + */ + boolean isBlacklisted(String uid); + + /* RESEARCH */ + /** + * @param researcher Username of the player who researched this note. + * @param species {@link IAlleleSpecies} to encode on the research note. + * @return An itemstack containing a research note with the given species encoded onto it. + */ + ItemStack getSpeciesNoteStack(GameProfile researcher, IAlleleSpecies species); + + /** + * @param researcher Username of the player who researched this note. + * @param mutation {@link IMutation} to encode on the research note. + * @return An itemstack containing a research note with the given mutation encoded onto it. + */ + ItemStack getMutationNoteStack(GameProfile researcher, IMutation mutation); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleSpecies.java b/src/main/java/forestry/api/genetics/IAlleleSpecies.java new file mode 100644 index 000000000..d3a355267 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleSpecies.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import com.mojang.authlib.GameProfile; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.IModelProvider; + +/** + * Basic species allele. + */ +public interface IAlleleSpecies extends IAllele { + + /** + * @return the {@link ISpeciesRoot} associated with this species. + */ + ISpeciesRoot getRoot(); + + /** + * @return Localized short description of this species. (May be null.) + */ + String getDescription(); + + /** + * Binomial name of the species sans genus ("Apis"). Returning "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun + * names or return null. + * + * @return flavour text (may be null) + */ + String getBinomial(); + + /** + * Authority for the binomial name, e.g. "Sengir" on species of base Forestry. + * + * @return flavour text (may be null) + */ + String getAuthority(); + + /** + * @return Branch this species is associated with. + */ + IClassification getBranch(); + + /* RESEARCH */ + /** + * Complexity determines the difficulty researching a species. The values of primary and secondary are + * added together (and rounded) to determine the amount of pairs needed for successful research. + * @return Values between 3 - 11 are useful. + */ + int getComplexity(); + + /** + * @param itemstack + * @return A float signifying the chance for the passed itemstack to yield a research success. + */ + float getResearchSuitability(ItemStack itemstack); + + /** + * @param world + * @param gameProfile + * @param individual + * @param bountyLevel + * @return Array of itemstacks representing the bounty for this research success. + */ + ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel); + + /* CLIMATE */ + /** + * @return Preferred temperature + */ + EnumTemperature getTemperature(); + + /** + * @return Preferred humidity + */ + EnumHumidity getHumidity(); + + /* MISC */ + /** + * @return true if the species icon should have a glowing effect. + */ + boolean hasEffect(); + + /** + * @return true if the species should not be displayed in NEI or creative inventory. + */ + boolean isSecret(); + + /** + * @return true to have the species count against the species total. + */ + boolean isCounted(); + + /* APPEARANCE */ + /** + * @param renderPass Render pass to get the colour for. + * @return Colour to use for the render pass. + */ + int getSpriteColour(int renderPass); + + @SideOnly(Side.CLIENT) + IModelProvider getModelProvider(); + +} diff --git a/src/main/java/forestry/api/genetics/IAlleleSpeciesCustom.java b/src/main/java/forestry/api/genetics/IAlleleSpeciesCustom.java new file mode 100644 index 000000000..ff1381628 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleSpeciesCustom.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public interface IAlleleSpeciesCustom extends IAlleleSpecies { + + IAlleleSpeciesCustom setTemperature(EnumTemperature temperature); + IAlleleSpeciesCustom setHumidity(EnumHumidity humidity); + + IAlleleSpeciesCustom setHasEffect(); + + /** Secret species are not shown in creative mode. */ + IAlleleSpeciesCustom setIsSecret(); + + /** Uncounted species do not count toward total species discovered. */ + IAlleleSpeciesCustom setIsNotCounted(); +} diff --git a/src/main/java/forestry/api/genetics/IAlleleTolerance.java b/src/main/java/forestry/api/genetics/IAlleleTolerance.java new file mode 100644 index 000000000..f5ba9e670 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IAlleleTolerance.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Simple interface to allow adding additional alleles containing float values. + */ +public interface IAlleleTolerance extends IAllele { + + EnumTolerance getValue(); + +} diff --git a/src/main/java/forestry/api/genetics/IBreedingTracker.java b/src/main/java/forestry/api/genetics/IBreedingTracker.java new file mode 100644 index 000000000..7533a59a6 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IBreedingTracker.java @@ -0,0 +1,106 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +import forestry.api.apiculture.IBeekeepingMode; + +/** + * Keeps track of who bred, discovered, and researched which species in a world. + * + * @author SirSengir + */ +public interface IBreedingTracker { + + /** + * @return Name of the current {@link IBeekeepingMode}. + */ + String getModeName(); + + /** + * Set the current {@link IBeekeepingMode}. + */ + void setModeName(String name); + + /** + * @return Amount of species discovered. + */ + int getSpeciesBred(); + + /** + * Register the birth of an individual. Will mark it as discovered. + * + * @param individual + */ + void registerBirth(IIndividual individual); + + /** + * Register the pickup of an individual. + * + * @param individual + */ + void registerPickup(IIndividual individual); + + /** + * Marks a species as discovered. Should only be called from registerIndividual normally. + * + * @param species + */ + void registerSpecies(IAlleleSpecies species); + + /** + * Register a successful mutation. Will mark it as discovered. + * + * @param mutation + */ + void registerMutation(IMutation mutation); + + /** + * Queries the tracker for discovered species. + * + * @param mutation + * Mutation to query for. + * @return true if the mutation has been discovered. + */ + boolean isDiscovered(IMutation mutation); + + /** + * Queries the tracker for discovered species. + * + * @param species + * Species to check. + * @return true if the species has been bred. + */ + boolean isDiscovered(IAlleleSpecies species); + + /** + * Register a successfully researched mutation. + * Mutations are normally researched in the Escritoire. + * Researched mutations may have bonuses such as occurring at a higher rate. + * Researched mutations count as discovered. + */ + void researchMutation(IMutation mutation); + + /** + * @return true if the mutation has been researched. + */ + boolean isResearched(IMutation mutation); + + /** + * Synchronizes the tracker to the client side. + * Before Forestry 4.2.1: Should be called before opening any gui needing that information. + * Since Forestry 4.2.1: Breeding tracker should be automatically synced, only Forestry should need to call this. + */ + void synchToPlayer(EntityPlayer player); + + /* LOADING & SAVING */ + void decodeFromNBT(NBTTagCompound nbttagcompound); + + void encodeToNBT(NBTTagCompound nbttagcompound); + +} diff --git a/src/main/java/forestry/api/genetics/IChromosome.java b/src/main/java/forestry/api/genetics/IChromosome.java new file mode 100644 index 000000000..d501efbac --- /dev/null +++ b/src/main/java/forestry/api/genetics/IChromosome.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Implementations other than Forestry's default one are not supported! + * + * @author SirSengir + */ +public interface IChromosome extends INBTTagable { + + IAllele getPrimaryAllele(); + + IAllele getSecondaryAllele(); + + IAllele getInactiveAllele(); + + IAllele getActiveAllele(); + +} diff --git a/src/main/java/forestry/api/genetics/IChromosomeType.java b/src/main/java/forestry/api/genetics/IChromosomeType.java new file mode 100644 index 000000000..a3b1f8e0c --- /dev/null +++ b/src/main/java/forestry/api/genetics/IChromosomeType.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/* + * Interface to be implemented by the enums representing the various chromosomes + */ +public interface IChromosomeType { + + /* + * Get class which all alleles on this chromosome must interface + */ + Class getAlleleClass(); + + String getName(); + + ISpeciesRoot getSpeciesRoot(); + + int ordinal(); + +} diff --git a/src/main/java/forestry/api/genetics/IClassification.java b/src/main/java/forestry/api/genetics/IClassification.java new file mode 100644 index 000000000..f365b915c --- /dev/null +++ b/src/main/java/forestry/api/genetics/IClassification.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** + * Biological classifications from domain down to genus. + * + * Used by the *alyzers to display hierarchies. + */ +public interface IClassification { + + public enum EnumClassLevel { + + DOMAIN(0x777fff, true), KINGDOM(0x77c3ff), PHYLUM(0x77ffb6, true), DIVISION(0x77ffb6, true), CLASS(0x7bff77), ORDER(0xbeff77), FAMILY(0xfffd77), + SUBFAMILY(0xfffd77), TRIBE(0xfffd77), GENUS(0xffba77); + + private int colour; + private boolean isDroppable; + + private EnumClassLevel(int colour) { + this(colour, false); + } + + private EnumClassLevel(int colour, boolean isDroppable) { + this.colour = colour; + this.isDroppable = isDroppable; + } + + /** + * @return Colour to use for displaying this classification. + */ + public int getColour() { + return colour; + } + + /** + * @return Indicates whether display of this classification level can be ommitted in case of space constraints. + */ + public boolean isDroppable() { + return isDroppable; + } + } + + /** + * @return Level inside the full hierarchy this particular classification is located at. + */ + EnumClassLevel getLevel(); + + /** + * @return Unique String identifier. + */ + String getUID(); + + /** + * @return Localized branch name for user display. + */ + String getName(); + + /** + * A branch approximates a "genus" in real life. Real life examples: "Micrapis", "Megapis" + * + * @return flavour text (may be null) + */ + String getScientific(); + + /** + * @return Localized description of this branch. (May be null.) + */ + String getDescription(); + + /** + * @return Member groups of this one. + */ + IClassification[] getMemberGroups(); + + /** + * Adds subgroups to this group. + */ + void addMemberGroup(IClassification group); + + /** + * @return Member species of this group. + */ + IAlleleSpecies[] getMemberSpecies(); + + /** + * Used by the allele registry to populate internal collection of branch members on the fly. + * + * @param species + */ + void addMemberSpecies(IAlleleSpecies species); + + /** + * @return Parent classification, null if this is root. + */ + IClassification getParent(); + + /** + * Only used internally by the AlleleRegistry if this classification has been added to another one. + * + * @param parent + */ + void setParent(IClassification parent); +} diff --git a/src/main/java/forestry/api/genetics/IClimateHelper.java b/src/main/java/forestry/api/genetics/IClimateHelper.java new file mode 100644 index 000000000..481460427 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IClimateHelper.java @@ -0,0 +1,53 @@ +package forestry.api.genetics; + +import java.util.Collection; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +public interface IClimateHelper { + /** + * Determines whether the given temperature and humidity are within the given constraints. + * @param temperature The temperature to test. + * @param humidity The humidity to test. + * @param baseTemp Base temperature for the test. + * @param tolTemp Temperature tolerance to apply. + * @param baseHumid Base humidity for the test. + * @param tolHumid Humidity tolerance to apply. + * @return true if both temperature and humidity fit the given constraints. + */ + boolean isWithinLimits(EnumTemperature temperature, EnumHumidity humidity, + EnumTemperature baseTemp, EnumTolerance tolTemp, + EnumHumidity baseHumid, EnumTolerance tolHumid); + + boolean isWithinLimits(EnumTemperature temperature, EnumTemperature baseTemp, EnumTolerance tolTemp); + boolean isWithinLimits(EnumHumidity humidity, EnumHumidity baseHumid, EnumTolerance tolHumid); + + /** + * Gets a collection of humidities which fit the given parameters. + * @param prefered Base humidity from which to measure. + * @param tolerance Tolerance to apply to the base humidity. + * @return A collection of humidities which fall within the given parameters. + */ + Collection getToleratedHumidity(EnumHumidity prefered, EnumTolerance tolerance); + /** + * Gets a collection of temperatures which fit the given parameters. + * @param prefered Base temperature from which to measure. + * @param tolerance Tolerance to apply to the base temperatures. + * @return A collection of temperatures which fall within the given parameters. + */ + Collection getToleratedTemperature(EnumTemperature prefered, EnumTolerance tolerance); + + /** + * Gets a localized, human readable string for the given temperature. + * @param temperature Temperature to generate the string for. + * @return A localized, human readable string for the given temperature. + */ + String toDisplay(EnumTemperature temperature); + /** + * Gets a localized, human readable string for the given humidity. + * @param humidity Humidity to generate the string for. + * @return A localized, human readable string for the given humidity. + */ + String toDisplay(EnumHumidity humidity); +} \ No newline at end of file diff --git a/src/main/java/forestry/api/genetics/IEffectData.java b/src/main/java/forestry/api/genetics/IEffectData.java new file mode 100644 index 000000000..909ab78df --- /dev/null +++ b/src/main/java/forestry/api/genetics/IEffectData.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Container to hold some temporary data for bee, tree and butterfly effects. + * + * @author SirSengir + */ +public interface IEffectData extends INBTTagable { + void setInteger(int index, int val); + + void setFloat(int index, float val); + + void setBoolean(int index, boolean val); + + int getInteger(int index); + + float getFloat(int index); + + boolean getBoolean(int index); +} diff --git a/src/main/java/forestry/api/genetics/IFlower.java b/src/main/java/forestry/api/genetics/IFlower.java new file mode 100644 index 000000000..e37c16eaa --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlower.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.block.Block; + +/** + * @deprecated since Forestry 4.0. Use alternative methods in IFlowerRegistry. + */ +@Deprecated +public interface IFlower extends Comparable { + + Block getBlock(); + int getMeta(); + + double getWeight(); + void setWeight(double weight); + + boolean isPlantable(); + +} diff --git a/src/main/java/forestry/api/genetics/IFlowerAcceptableRule.java b/src/main/java/forestry/api/genetics/IFlowerAcceptableRule.java new file mode 100644 index 000000000..c2fedf8b6 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlowerAcceptableRule.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IFlowerAcceptableRule { + /** + * Checks if the flower at this position is accepted by this rule. + * flowerType is passed in case this rule is registered for multiple flower types. + */ + boolean isAcceptableFlower(String flowerType, World world, BlockPos pos); +} diff --git a/src/main/java/forestry/api/genetics/IFlowerGrowthHelper.java b/src/main/java/forestry/api/genetics/IFlowerGrowthHelper.java new file mode 100644 index 000000000..fd3b6bc6b --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlowerGrowthHelper.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IFlowerGrowthHelper { + /** + * Plants a random flower from flowerType at the specified position. + * @return true if successful, false if it could not be planted. + */ + boolean plantRandomFlower(String flowerType, World world, BlockPos pos); +} diff --git a/src/main/java/forestry/api/genetics/IFlowerGrowthRule.java b/src/main/java/forestry/api/genetics/IFlowerGrowthRule.java new file mode 100644 index 000000000..1cef316fb --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlowerGrowthRule.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * Basic condition for flower growing, such as checking that the soil is the correct type. + */ +public interface IFlowerGrowthRule { + /** + * Checks a position for suitability, and then plants a flower there. + * Returns true on success. + * For implementers, you can plant a random flower using IFlowerGrowthHelper.plantRandomFlower + * @since Forestry 4.0.8 + */ + boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos); +} diff --git a/src/main/java/forestry/api/genetics/IFlowerProvider.java b/src/main/java/forestry/api/genetics/IFlowerProvider.java new file mode 100644 index 000000000..d7a8967b0 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlowerProvider.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Set; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IFlowerProvider { + + boolean isAcceptedPollinatable(World world, IPollinatable pollinatable); + + /** + * @return The unique type used for the IFlowerRegistry + * @since Forestry 4.0.0 + */ + String getFlowerType(); + + /** + * @return Short, human-readable identifier used in the beealyzer. + */ + String getDescription(); + + /** + * Allows the flower provider to affect the produce at the given location. + * If this flowerProvider does not affect the products, it should return the products unchanged. + * @return Array of itemstacks being the (modified or unmodified) produce. + */ + ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products); +} diff --git a/src/main/java/forestry/api/genetics/IFlowerRegistry.java b/src/main/java/forestry/api/genetics/IFlowerRegistry.java new file mode 100644 index 000000000..44a3b9991 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFlowerRegistry.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +import forestry.api.apiculture.IBee; +import forestry.api.apiculture.IBeeHousing; + +// See {@link forestry.api.apiculture.FlowerManager}.FlowerType___ for basic Forestry flower types. +// Each IFlowerProvider has one flower type, and multiple IFlowerProviders may share one type. +// "Acceptable flowers" allow nearby bees to do work. +// "Plantable flowers" are "Acceptable flowers" and are also planted randomly by bees. +public interface IFlowerRegistry { + + /** + * Register a new flower growth rule. + * This defines the flower planting logic for the specified flower types. + * Without a flower growth rule, no flowers of that type can be planted. + */ + void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes); + + /** + * Registers an accepted flower with any meta value. + */ + void registerAcceptableFlower(Block flowerBlock, String... flowerTypes); + /** + * Registers an accepted flower with a specific meta value. + */ + void registerAcceptableFlower(Block flowerBlock, int flowerMeta, String... flowerTypes); + + /** + * Registers custom logic for accepted flowers. + * These rules are inefficient compared to ones made with registerAcceptableFlower, but may be necessary for tile entity flowers. + * The flower types built into Forestry can not be used here. + * @since Forestry 4.0.8 + */ + void registerAcceptableFlowerRule(IFlowerAcceptableRule flowerAcceptableRule, String... flowerTypes); + + /** + * Registers a plantable flower. + * The distribution is based on its own weight and the total number of plants for this flowerType. + * + * @param weight Weight for the Flower (Vanilla = 1.0, Modded flowers < 1.0) + * @param flowerTypes See {@link forestry.api.apiculture.FlowerManager}.FlowerTypeXXX + */ + void registerPlantableFlower(Block flowerBlock, int flowerMeta, double weight, String... flowerTypes); + + /** + * Calls the appropriate IFlowerGrowthRule to grow a flower at a specified position. + */ + boolean growFlower(String flowerType, World world, IIndividual individual, BlockPos pos); + + /** + * @return the coordinates of a nearby accepted flower or null if there is none. + */ + BlockPos getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType); + + /** + * Checks a single coordinate to see if it is an accepted flower. + */ + boolean isAcceptedFlower(String flowerType, World world, BlockPos pos); + + /** + * For use by IFlowerGrowthRule implementations + * @deprecated since Forestry 4.0.8 This will be accessible to IFlowerGrowthRule via IFlowerGrowthHelper + */ + @Deprecated + IFlower getRandomPlantableFlower(String flowerType, Random rand); + + /** + * Returns all known flower types. + * @deprecated since Forestry 4.0.8 This should only be used internally. + */ + @Deprecated + Collection getFlowerTypes(); + + /** + * @deprecated since Forestry 4.0.8 This should only be used internally. + */ + @Deprecated + Set getAcceptableFlowers(String flowerType); +} diff --git a/src/main/java/forestry/api/genetics/IFruitBearer.java b/src/main/java/forestry/api/genetics/IFruitBearer.java new file mode 100644 index 000000000..5316f9ebc --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFruitBearer.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +/** + * Can be implemented by tile entities which can bear fruit. + * + * @author SirSengir + */ +public interface IFruitBearer { + + /** + * @return true if the actual tile can bear fruits. + */ + boolean hasFruit(); + + /** + * @return Family of the potential fruits on this tile. + */ + IFruitFamily getFruitFamily(); + + /** + * Picks the fruits of this tile, resetting it to unripe fruits. + * + * @param tool + * Tool used in picking the fruits. May be null. + * @return Picked fruits. + */ + Collection pickFruit(ItemStack tool); + + /** + * @return float indicating the ripeness of the fruit with >= 1.0f indicating full ripeness. + */ + float getRipeness(); + + /** + * Increases the ripeness of the fruit. + * + * @param add + * Float to add to the ripeness. Will truncate to valid values. + */ + void addRipeness(float add); +} diff --git a/src/main/java/forestry/api/genetics/IFruitFamily.java b/src/main/java/forestry/api/genetics/IFruitFamily.java new file mode 100644 index 000000000..d48a4d8a1 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IFruitFamily.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +public interface IFruitFamily { + + /** + * @return Unique String identifier. + */ + String getUID(); + + /** + * @return Localized family name for user display. + */ + String getName(); + + /** + * A scientific-y name for this fruit family + * + * @return flavour text (may be null) + */ + String getScientific(); + + /** + * @return Localized description of this fruit family. (May be null.) + */ + String getDescription(); + +} diff --git a/src/main/java/forestry/api/genetics/IGenome.java b/src/main/java/forestry/api/genetics/IGenome.java new file mode 100644 index 000000000..0d3ad2319 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IGenome.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import forestry.api.core.INBTTagable; + +/** + * Holds the {@link IChromosome}s which comprise the traits of a given individual. + * + * Only the default implementation is supported. + */ +public interface IGenome extends INBTTagable { + + IAlleleSpecies getPrimary(); + + IAlleleSpecies getSecondary(); + + IChromosome[] getChromosomes(); + + IAllele getActiveAllele(IChromosomeType chromosomeType); + + IAllele getInactiveAllele(IChromosomeType chromosomeType); + + boolean isGeneticEqual(IGenome other); + + ISpeciesRoot getSpeciesRoot(); +} diff --git a/src/main/java/forestry/api/genetics/IHousing.java b/src/main/java/forestry/api/genetics/IHousing.java new file mode 100644 index 000000000..e9ac7af1b --- /dev/null +++ b/src/main/java/forestry/api/genetics/IHousing.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.util.BlockPos; + +/** + * Any housing, hatchery or nest with a location in the world. + */ +public interface IHousing { + + BlockPos getCoordinates(); + +} diff --git a/src/main/java/forestry/api/genetics/IIndividual.java b/src/main/java/forestry/api/genetics/IIndividual.java new file mode 100644 index 000000000..f86aa5829 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IIndividual.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.List; + +import forestry.api.core.INBTTagable; + +/** + * An actual individual with genetic information. + * + * Only the default implementation is supported. + */ +public interface IIndividual extends INBTTagable { + + String getIdent(); + + String getDisplayName(); + + void addTooltip(List list); + + /** + * Call to mark the IIndividual as analyzed. + * @return true if the IIndividual has not been analyzed previously. + */ + boolean analyze(); + + boolean isAnalyzed(); + + boolean hasEffect(); + + boolean isSecret(); + + IGenome getGenome(); + + /** + * Check whether the genetic makeup of two IIndividuals is identical. Ignores additional data like generations, irregular mating, etc.. + * @param other + * @return true if the given other IIndividual has the amount of chromosomes and their alleles are identical. + */ + boolean isGeneticEqual(IIndividual other); + + /** + * @return A deep copy of this individual. + */ + IIndividual copy(); + + boolean isPureBred(IChromosomeType chromosomeType); + +} diff --git a/src/main/java/forestry/api/genetics/IIndividualLiving.java b/src/main/java/forestry/api/genetics/IIndividualLiving.java new file mode 100644 index 000000000..67ce0a975 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IIndividualLiving.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.world.World; + +public interface IIndividualLiving extends IIndividual { + + /** + * @return Genetic information of the mate, null if unmated. + */ + IGenome getMate(); + + /** + * @return Current health of the individual. + */ + int getHealth(); + + /** + * @return Maximum health of the individual. + */ + int getMaxHealth(); + + /** + * Age the individual. + * @param world + * @param ageModifier + */ + void age(World world, float ageModifier); + + /** + * Mate with the given individual. + * @param individual the {@link IIndividual} to mate this one with. + */ + void mate(IIndividual individual); + + /** + * @return true if the individual is among the living. + */ + boolean isAlive(); + +} diff --git a/src/main/java/forestry/api/genetics/IMutation.java b/src/main/java/forestry/api/genetics/IMutation.java new file mode 100644 index 000000000..bf7ae62f1 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IMutation.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.Collection; + +/** + * Individuals can be seeded either as hive drops or as mutation results. + * + * {@link IAlleleRegistry} manages these. + * + * @author SirSengir + */ +public interface IMutation { + + /** + * @return {@link ISpeciesRoot} this mutation is associated with. + */ + ISpeciesRoot getRoot(); + + /** + * @return first of the alleles implementing IAlleleSpecies required for this mutation. + */ + IAlleleSpecies getAllele0(); + + /** + * @return second of the alleles implementing IAlleleSpecies required for this mutation. + */ + IAlleleSpecies getAllele1(); + + /** + * @return Array of {@link IAllele} representing the full default genome of the mutated side. + * + * Make sure to return a proper array for the species class. Returning an allele of the wrong type will cause cast errors on runtime. + */ + IAllele[] getTemplate(); + + /** + * @return Unmodified base chance for mutation to fire. + */ + float getBaseChance(); + + /** + * @return Collection of localized, human-readable strings describing special mutation conditions, if any. + */ + Collection getSpecialConditions(); + + /** + * @param allele + * @return true if the passed allele is one of the alleles participating in this mutation. + */ + boolean isPartner(IAllele allele); + + /** + * @param allele + * @return the other allele which was not passed as argument. + */ + IAllele getPartner(IAllele allele); + + /** + * @return true if the mutation should not be displayed in the beealyzer. + */ + boolean isSecret(); + +} diff --git a/src/main/java/forestry/api/genetics/IMutationCondition.java b/src/main/java/forestry/api/genetics/IMutationCondition.java new file mode 100644 index 000000000..0267d42de --- /dev/null +++ b/src/main/java/forestry/api/genetics/IMutationCondition.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +public interface IMutationCondition { + + /** + * Returns a float from 0 to 1 representing the chance for mutation to occur. + * Most will return 1 if the condition is met and 0 otherwise, + * but the float offers flexibility for more advanced conditions. + */ + float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); + + /** + * A localized description of the mutation condition. (i.e. "A temperature of HOT is required.") + */ + String getDescription(); +} diff --git a/src/main/java/forestry/api/genetics/IMutationCustom.java b/src/main/java/forestry/api/genetics/IMutationCustom.java new file mode 100644 index 000000000..42235eee4 --- /dev/null +++ b/src/main/java/forestry/api/genetics/IMutationCustom.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import net.minecraft.block.Block; + +import net.minecraftforge.common.BiomeDictionary; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; + +/** Set custom mutation requirements */ +public interface IMutationCustom extends IMutation { + + /** Prevent this mutation from being shown in the analyzers */ + IMutationCustom setIsSecret(); + + /** Require a specific temperature for this mutation to occur */ + IMutationCustom restrictTemperature(EnumTemperature temperature); + IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature); + + /** Require a specific humidity for this mutation to occur */ + IMutationCustom restrictHumidity(EnumHumidity humidity); + IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity); + + /** + * Restrict this mutation to certain types of biomes. + * @param types The types of biomes this mutation can occur. + */ + IMutationCustom restrictBiomeType(BiomeDictionary.Type... types); + + /** Restrict the days of the year that this mutation can occur */ + IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay); + + /** Restrict the time of day that this mutation can occur */ + IMutationCustom requireDay(); + IMutationCustom requireNight(); + + /** Require a specific resource to be under the location of the mutation */ + IMutationCustom requireResource(Block block, int meta); + IMutationCustom requireResource(String oreDictName); + + /** Require some other custom mutation condition */ + IMutationCustom addMutationCondition(IMutationCondition mutationCondition); +} diff --git a/src/main/java/forestry/api/genetics/IPollinatable.java b/src/main/java/forestry/api/genetics/IPollinatable.java new file mode 100644 index 000000000..a3716789f --- /dev/null +++ b/src/main/java/forestry/api/genetics/IPollinatable.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.EnumSet; + +import net.minecraftforge.common.EnumPlantType; + +/** + * Can be implemented by tile entities, if they wish to be pollinatable. + * + * @author SirSengir + */ +public interface IPollinatable { + + /** + * @return plant types this pollinatable is classified as. (Can be used by bees to determine whether to interact or not. + */ + EnumSet getPlantType(); + + /** + * @return IIndividual containing the genetic information of this IPollinatable + */ + IIndividual getPollen(); + + /** + * Checks whether this {@link IPollinatable} can mate with the given pollen. + * + * Must be the one to check genetic equivalency. + * + * @param pollen + * IIndividual representing the pollen. + * @return true if mating is possible, false otherwise. + */ + boolean canMateWith(IIndividual pollen); + + /** + * Pollinates this entity. + * + * @param pollen + * IIndividual representing the pollen. + */ + void mateWith(IIndividual pollen); + + /** + * @return true if this IPollinatable has already been pollinated. + * @since Forestry 4.1.0 + */ + boolean isPollinated(); +} diff --git a/src/main/java/forestry/api/genetics/ISpeciesRoot.java b/src/main/java/forestry/api/genetics/ISpeciesRoot.java new file mode 100644 index 000000000..f3652bea8 --- /dev/null +++ b/src/main/java/forestry/api/genetics/ISpeciesRoot.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +/** + * Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality. + */ +public interface ISpeciesRoot { + + /** + * @return A unique identifier for the species class. Should consist of "root" + a common name for the species class in camel-case, i.e. "rootBees", "rootTrees", "rootButterflies". + */ + String getUID(); + + /** + * @return Class of the sub-interface inheriting from {@link IIndividual}. + */ + Class getMemberClass(); + + /** + * @return Integer denoting the number of (counted) species of this type in the world. + */ + int getSpeciesCount(); + + /** + * Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class. + * @param stack itemstack to check. + * @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise. + */ + boolean isMember(ItemStack stack); + + /** + * Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class and matches the given type. + * @param stack itemstack to check. + * @param type Integer denoting the type needed to match. (i.e. butterfly vs. butterfly serum; bee queens, princesses, drones; etc.) + * @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise. + */ + boolean isMember(ItemStack stack, int type); + + /** + * Used to check whether the given {@link IIndividual} is member of this class. + * @param individual {@link IIndividual} to check. + * @return true if the individual is member of this class, false otherwise. + */ + boolean isMember(IIndividual individual); + + IIndividual getMember(ItemStack stack); + + IIndividual getMember(NBTTagCompound compound); + + ISpeciesType getType(ItemStack itemStack); + + ItemStack getMemberStack(IIndividual individual, int type); + + /* BREEDING TRACKER */ + IBreedingTracker getBreedingTracker(World world, GameProfile player); + + /** + * @deprecated since Forestry 4.2.1. Breeding tracker should be automatically synced. + */ + @Deprecated + void syncBreedingTrackerToPlayer(EntityPlayer player); + + /* GENOME MANIPULATION */ + IIndividual templateAsIndividual(IAllele[] template); + + IIndividual templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + IChromosome[] templateAsChromosomes(IAllele[] template); + + IChromosome[] templateAsChromosomes(IAllele[] templateActive, IAllele[] templateInactive); + + IGenome templateAsGenome(IAllele[] template); + + IGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* TEMPLATES */ + /** + * Registers a bee template using the UID of the first allele as identifier. + * + * @param template + */ + void registerTemplate(IAllele[] template); + + /** + * Registers a bee template using the passed identifier. + * + * @param template + */ + void registerTemplate(String identifier, IAllele[] template); + + /** + * Retrieves a registered template using the passed identifier. + * + * @param identifier + * @return Array of {@link IAllele} representing a genome. + */ + IAllele[] getTemplate(String identifier); + + /** + * @return Default individual template for use when stuff breaks. + */ + IAllele[] getDefaultTemplate(); + + /** + * @param rand Random to use. + * @return A random template from the pool of registered species templates. + */ + IAllele[] getRandomTemplate(Random rand); + + Map getGenomeTemplates(); + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + /** + * Use to register mutations. + * + * @param mutation + */ + void registerMutation(IMutation mutation); + + /** + * @return All registered mutations. + */ + Collection getMutations(boolean shuffle); + + /** + * @param other Allele to match mutations against. + * @return All registered mutations the given allele is part of. + */ + Collection getCombinations(IAllele other); + + /** + * @since Forestry 3.7 + * @return all possible mutations that result from breeding two species + */ + List getCombinations(IAlleleSpecies parentSpecies0, IAlleleSpecies parentSpecies1, boolean shuffle); + + Collection getPaths(IAllele result, IChromosomeType chromosomeType); + + /* RESEARCH */ + /** + * @return List of generic catalysts which should be accepted for research by species of this class. + */ + Map getResearchCatalysts(); + + /** + * Sets an item stack as a valid (generic) research catalyst for this class. + * @param itemstack ItemStack to set as suitable. + * @param suitability Float between 0 and 1 to indicate suitability. + */ + void setResearchSuitability(ItemStack itemstack, float suitability); + + /** + * @return Array of {@link IChromosomeType} which are in this species genome + */ + IChromosomeType[] getKaryotype(); + + /** + * @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome. + */ + IChromosomeType getKaryotypeKey(); +} diff --git a/src/main/java/forestry/api/genetics/ISpeciesType.java b/src/main/java/forestry/api/genetics/ISpeciesType.java new file mode 100644 index 000000000..036b9b8cd --- /dev/null +++ b/src/main/java/forestry/api/genetics/ISpeciesType.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.genetics; + +/** Species types, implemented by enums and compared with == */ +public interface ISpeciesType { +} diff --git a/src/main/java/forestry/api/genetics/package-info.java b/src/main/java/forestry/api/genetics/package-info.java new file mode 100644 index 000000000..1d7804648 --- /dev/null +++ b/src/main/java/forestry/api/genetics/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "4.7.1", owner = "ForestryAPI|core", provides = "ForestryAPI|genetics") +package forestry.api.genetics; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java b/src/main/java/forestry/api/lepidopterology/ButterflyManager.java old mode 100755 new mode 100644 similarity index 72% rename from src/main/java/forestry/energy/circuits/CircuitElectricChoke.java rename to src/main/java/forestry/api/lepidopterology/ButterflyManager.java index 859aae6bc..1620b8849 --- a/src/main/java/forestry/energy/circuits/CircuitElectricChoke.java +++ b/src/main/java/forestry/api/lepidopterology/ButterflyManager.java @@ -8,13 +8,14 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.energy.circuits; +package forestry.api.lepidopterology; -public class CircuitElectricChoke extends CircuitElectricChange { +public class ButterflyManager { - public CircuitElectricChoke(String uid) { - super(uid, false); - this.configureChange(-2, -10); - this.setLimit(1); - } + public static IButterflyRoot butterflyRoot; + + /** + * Used to create new butterflies. + */ + public static IButterflyFactory butterflyFactory; } diff --git a/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java b/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java new file mode 100644 index 000000000..798c898f2 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.util.Locale; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlleleArea; +import forestry.api.genetics.IAlleleBoolean; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleFlowers; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.ISpeciesRoot; + +public enum EnumButterflyChromosome implements IChromosomeType { + /** + * Species of the bee. Alleles here must implement {@link IAlleleButterflySpecies}. + */ + SPECIES(IAlleleButterflySpecies.class), + /** + * Physical size. + */ + SIZE(IAlleleFloat.class), + /** + * Flight speed. + */ + SPEED(IAlleleFloat.class), + /** + * How long the butterfly can last without access to matching pollinatables. + */ + LIFESPAN(IAlleleInteger.class), + /** + * Species with a higher metabolism have a higher appetite and may cause more damage to their environment. + */ + METABOLISM(IAlleleInteger.class), + /** + * Determines likelyhood of caterpillars and length of caterpillar/pupation phase. Also: Number of max caterpillars after mating? + */ + FERTILITY(IAlleleInteger.class), + /** + * Not sure yet. + */ + TEMPERATURE_TOLERANCE(IAlleleTolerance.class), + /** + * Not sure yet. + */ + HUMIDITY_TOLERANCE(IAlleleTolerance.class), + /** + * Only nocturnal butterflys/moths will fly at night. Allows daylight activity for naturally nocturnal species. + */ + NOCTURNAL(IAlleleBoolean.class), + /** + * Only tolerant flyers will fly in the rain. + */ + TOLERANT_FLYER(IAlleleBoolean.class), + /** + * Fire resistance. + */ + FIRE_RESIST(IAlleleBoolean.class), + /** + * Required flowers/leaves. + */ + FLOWER_PROVIDER(IAlleleFlowers.class), + /** + * Extra effect to surroundings. (?) + */ + EFFECT(IAlleleButterflyEffect.class), + /** + * Not used yet + */ + TERRITORY(IAlleleArea.class), + ; + + Class clss; + + EnumButterflyChromosome(Class clss) { + this.clss = clss; + } + + @Override + public Class getAlleleClass() { + return clss; + } + + @Override + public String getName() { + return this.toString().toLowerCase(Locale.ENGLISH); + } + + @Override + public ISpeciesRoot getSpeciesRoot() { + return ButterflyManager.butterflyRoot; + } +} diff --git a/src/main/java/forestry/api/lepidopterology/EnumFlutterType.java b/src/main/java/forestry/api/lepidopterology/EnumFlutterType.java new file mode 100644 index 000000000..d0c7aee60 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/EnumFlutterType.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.ISpeciesType; + +public enum EnumFlutterType implements ISpeciesType { + BUTTERFLY, + SERUM, + CATERPILLAR, + NONE; + + public static final EnumFlutterType[] VALUES = values(); +} diff --git a/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java b/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java new file mode 100644 index 000000000..6457dbe89 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IAlleleEffect; +import forestry.api.genetics.IEffectData; + +public interface IAlleleButterflyEffect extends IAlleleEffect { + + /** + * Used by butterflies to trigger effects in the world. + * @param butterfly {@link IEntityButterfly} + * @param storedData + * @return {@link forestry.api.genetics.IEffectData} for the next cycle. + */ + IEffectData doEffect(IEntityButterfly butterfly, IEffectData storedData); + +} diff --git a/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java new file mode 100644 index 000000000..c397b0422 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.util.EnumSet; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.common.BiomeDictionary; +import forestry.api.core.ISpriteProvider; +import forestry.api.genetics.IAlleleSpecies; + +public interface IAlleleButterflySpecies extends IAlleleSpecies { + + /** + * @return the IBeeRoot + */ + @Override + IButterflyRoot getRoot(); + + /** + * @return Path of the texture to use for entity rendering. + */ + String getEntityTexture(); + + /** + * Allows butterflies to restrict random spawns beyond the restrictions set by getTemperature() and getHumidity(). + * + * @return EnumSet of biome tags this butterfly species can be spawned in. + */ + EnumSet getSpawnBiomes(); + + /** + * @return true if a prospective spawn biome must not match a biome tag outside of getSpawnBiomes. + */ + boolean strictSpawnMatch(); + + /** + * @return Float between 0 and 1 representing the rarity of the species, will affect spawn rate. + */ + float getRarity(); + + /** + * @return Float representing the distance below which this butterfly will take flight if it detects a player which is not sneaking. + */ + float getFlightDistance(); + + /** + * @return true if this species is only active at night. + */ + boolean isNocturnal(); + + Map getButterflyLoot(); + + Map getCaterpillarLoot(); + + ISpriteProvider getSpriteProvider(); +} diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpeciesCustom.java old mode 100755 new mode 100644 similarity index 61% rename from src/main/java/forestry/energy/circuits/CircuitElectricBoost.java rename to src/main/java/forestry/api/lepidopterology/IAlleleButterflySpeciesCustom.java index 5cca5bf28..e89fd0fdd --- a/src/main/java/forestry/energy/circuits/CircuitElectricBoost.java +++ b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpeciesCustom.java @@ -8,14 +8,12 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.energy.circuits; +package forestry.api.lepidopterology; -public class CircuitElectricBoost extends CircuitElectricChange { - - public CircuitElectricBoost(String uid, int limit, int eu, int rf) { - super(uid, false); - this.setLimit(limit); - this.configureChange(eu, rf); - } +import forestry.api.genetics.IAlleleSpeciesCustom; +public interface IAlleleButterflySpeciesCustom extends IAlleleButterflySpecies, IAlleleSpeciesCustom { + IAlleleButterflySpeciesCustom setRarity(float rarity); + IAlleleButterflySpeciesCustom setFlightDistance(float flightDistance); + IAlleleButterflySpeciesCustom setNocturnal(); } diff --git a/src/main/java/forestry/api/lepidopterology/IButterfly.java b/src/main/java/forestry/api/lepidopterology/IButterfly.java new file mode 100644 index 000000000..97aec520e --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterfly.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import forestry.api.genetics.IIndividualLiving; + +public interface IButterfly extends IIndividualLiving { + + @Override + IButterflyGenome getGenome(); + + /** + * @return Genetic information of the mate, null if unmated. + */ + @Override + IButterflyGenome getMate(); + + /** + * @return Physical size of the butterfly. + */ + float getSize(); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the butterfly can naturally spawn at the given location at this time. (Used to auto-spawn butterflies from tree leaves.) + */ + boolean canSpawn(World world, double x, double y, double z); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the butterfly can take flight at the given location at this time. (Used to auto-spawn butterflies from dropped items.) + */ + boolean canTakeFlight(World world, double x, double y, double z); + + /** + * @param world + * @param x + * @param y + * @param z + * @return true if the environment (temperature, humidity) is valid for the butterfly at the given location. + */ + boolean isAcceptedEnvironment(World world, double x, double y, double z); + + IButterfly spawnCaterpillar(IButterflyNursery nursery); + + /** + * @param entity + * @param playerKill Whether or not the butterfly was killed by a player. + * @param lootLevel Loot level according to the weapon used to kill the butterfly. + * @return Array of itemstacks to drop on death of the given entity. + */ + ItemStack[] getLootDrop(IEntityButterfly entity, boolean playerKill, int lootLevel); + + /** + * @param nursery + * @param playerKill Whether or not the nursery was broken by a player. + * @param lootLevel Fortune level. + * @return Array of itemstacks to drop on breaking of the nursery. + */ + ItemStack[] getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel); + + /** + * Create an exact copy of this butterfly. + */ + @Override + IButterfly copy(); + +} diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyFactory.java b/src/main/java/forestry/api/lepidopterology/IButterflyFactory.java new file mode 100644 index 000000000..b66407ab1 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterflyFactory.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.awt.Color; + +import forestry.api.genetics.IClassification; + +public interface IButterflyFactory { + /** + * Creates a new butterfly species. + * Automatically registered with AlleleManager.alleleRegistry.registerAllele() + * See IAlleleButterflySpeciesCustom and IAlleleSpeciesCustom for adding additional properties to the returned species. + * + * @param uid Unique Identifier for this species + * @param unlocalizedName Unlocalized name for this species + * @param authority Authority for the binomial name, e.g. "Sengir" on species of base Forestry. + * @param unlocalizedDescription Unlocalized description for this species + * @param texturePath String texture path for this butterfly e.g. "forestry:textures/entities/butterfly/..." + * @param dominant Whether this species is genetically dominant (false means it is recessive) + * @param branch Classification of this species + * @param binomial Binomial name of the species sans genus. "humboldti" will have the bee species flavour name be "Apis humboldti". Feel free to use fun names or null. + * @param serumColour The color of this butterfly's serum. + * @return a new butterfly species allele. + */ + IAlleleButterflySpeciesCustom createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, String texturePath, boolean dominant, IClassification branch, String binomial, Color serumColour); +} diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java b/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java new file mode 100644 index 000000000..2659a3de3 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IFlowerProvider; +import forestry.api.genetics.IGenome; + +public interface IButterflyGenome extends IGenome { + + @Override + IAlleleButterflySpecies getPrimary(); + + @Override + IAlleleButterflySpecies getSecondary(); + + float getSize(); + + int getLifespan(); + + int getMetabolism(); + + int getFertility(); + + float getSpeed(); + + EnumTolerance getToleranceTemp(); + + EnumTolerance getToleranceHumid(); + + boolean getNocturnal(); + + boolean getTolerantFlyer(); + + boolean getFireResist(); + + IFlowerProvider getFlowerProvider(); + + IAlleleButterflyEffect getEffect(); + +} diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyMutation.java b/src/main/java/forestry/api/lepidopterology/IButterflyMutation.java new file mode 100644 index 000000000..027e96eb2 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterflyMutation.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IGenome; +import forestry.api.genetics.IMutation; + +public interface IButterflyMutation extends IMutation { + float getChance(IButterflyNursery housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1); +} diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java new file mode 100644 index 000000000..56e42f2ec --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IHousing; +import forestry.api.genetics.IIndividual; + +public interface IButterflyNursery extends IHousing { + + IButterfly getCaterpillar(); + + IIndividual getNanny(); + + void setCaterpillar(IButterfly butterfly); + + boolean canNurse(IButterfly butterfly); + +} diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java new file mode 100644 index 000000000..41ea06e4a --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.ISpeciesRoot; + +public interface IButterflyRoot extends ISpeciesRoot { + + @Override + boolean isMember(ItemStack stack); + + @Override + IButterfly getMember(ItemStack stack); + + @Override + IButterfly getMember(NBTTagCompound compound); + + @Override + ItemStack getMemberStack(IIndividual butterfly, int type); + + /* GENOME CONVERSION */ + @Override + IButterfly templateAsIndividual(IAllele[] template); + + @Override + IButterfly templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive); + + @Override + IButterflyGenome templateAsGenome(IAllele[] template); + + @Override + IButterflyGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); + + /* BUTTERFLY SPECIFIC */ + @Override + ILepidopteristTracker getBreedingTracker(World world, GameProfile player); + + /** + * Spawns the given butterfly in the world. + * @param butterfly + * @return butterfly entity on success, null otherwise. + */ + EntityLiving spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z); + + /** + * @return true if passed item is mated. + */ + boolean isMated(ItemStack stack); + + /* TEMPLATES */ + @Override + ArrayList getIndividualTemplates(); + + /* MUTATIONS */ + @Override + Collection getMutations(boolean shuffle); + + @Override + EnumFlutterType getType(ItemStack stack); + +} diff --git a/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java b/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java new file mode 100644 index 000000000..963c72103 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.IAnimals; + +import forestry.api.genetics.IIndividual; + +public interface IEntityButterfly extends IAnimals { + + void changeExhaustion(int change); + + int getExhaustion(); + + IButterfly getButterfly(); + + /** + * @return The entity as an EntityCreature to save casting. + */ + EntityCreature getEntity(); + + IIndividual getPollen(); + + void setPollen(IIndividual pollen); +} diff --git a/src/main/java/forestry/api/lepidopterology/ILepidopteristTracker.java b/src/main/java/forestry/api/lepidopterology/ILepidopteristTracker.java new file mode 100644 index 000000000..79926975f --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/ILepidopteristTracker.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.lepidopterology; + +import forestry.api.genetics.IBreedingTracker; + +public interface ILepidopteristTracker extends IBreedingTracker { + + void registerCatch(IButterfly butterfly); + +} diff --git a/src/main/java/forestry/api/lepidopterology/package-info.java b/src/main/java/forestry/api/lepidopterology/package-info.java new file mode 100644 index 000000000..827f1c9f1 --- /dev/null +++ b/src/main/java/forestry/api/lepidopterology/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="1.3.0", owner="ForestryAPI|core", provides="ForestryAPI|lepidopterology") +package forestry.api.lepidopterology; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/mail/EnumAddressee.java b/src/main/java/forestry/api/mail/EnumAddressee.java new file mode 100644 index 000000000..64dc6b5e7 --- /dev/null +++ b/src/main/java/forestry/api/mail/EnumAddressee.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.Locale; + +public enum EnumAddressee { + PLAYER, TRADER; + + public static EnumAddressee fromString(String ident) { + ident = ident.toLowerCase(Locale.ENGLISH); + for(EnumAddressee addr : values()) { + if(addr.toString().equals(ident)) + return addr; + } + + return null; + } + + @Override + public String toString() { + return super.toString().toLowerCase(Locale.ENGLISH); + } +} diff --git a/src/main/java/forestry/api/mail/EnumPostage.java b/src/main/java/forestry/api/mail/EnumPostage.java new file mode 100644 index 000000000..772114fb0 --- /dev/null +++ b/src/main/java/forestry/api/mail/EnumPostage.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +public enum EnumPostage { + P_0(0), P_1(1), P_2(2), P_5(5), P_10(10), P_20(20), P_50(50), P_100(100), P_200(200); + + private final int value; + + private EnumPostage(int value) { + this.value = value; + } + + public int getValue() { + return this.value; + } +} diff --git a/src/main/java/forestry/api/mail/ILetter.java b/src/main/java/forestry/api/mail/ILetter.java new file mode 100644 index 000000000..42df8acb5 --- /dev/null +++ b/src/main/java/forestry/api/mail/ILetter.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.List; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import forestry.api.core.INBTTagable; + +public interface ILetter extends IInventory, INBTTagable { + + ItemStack[] getPostage(); + + void setProcessed(boolean flag); + + boolean isProcessed(); + + boolean isMailable(); + + void setSender(IMailAddress address); + + IMailAddress getSender(); + + boolean hasRecipient(); + + void setRecipient(IMailAddress address); + + IMailAddress[] getRecipients(); + + String getRecipientString(); + + void setText(String text); + + String getText(); + + void addTooltip(List list); + + boolean isPostPaid(); + + int requiredPostage(); + + void invalidatePostage(); + + ItemStack[] getAttachments(); + + void addAttachment(ItemStack itemstack); + + void addAttachments(ItemStack[] itemstacks); + + int countAttachments(); + + void addStamps(ItemStack stamps); + +} diff --git a/src/main/java/forestry/api/mail/ILetterHandler.java b/src/main/java/forestry/api/mail/ILetterHandler.java new file mode 100644 index 000000000..576a0d7da --- /dev/null +++ b/src/main/java/forestry/api/mail/ILetterHandler.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface ILetterHandler { + IPostalState handleLetter(World world, IMailAddress recipient, ItemStack letterStack, boolean doLodge); +} diff --git a/src/main/java/forestry/api/mail/IMailAddress.java b/src/main/java/forestry/api/mail/IMailAddress.java new file mode 100644 index 000000000..8441b09a4 --- /dev/null +++ b/src/main/java/forestry/api/mail/IMailAddress.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import com.mojang.authlib.GameProfile; + +import forestry.api.core.INBTTagable; + +public interface IMailAddress extends INBTTagable { + + EnumAddressee getType(); + String getName(); + + boolean isValid(); + + boolean isPlayer(); + boolean isTrader(); + + GameProfile getPlayerProfile(); +} diff --git a/src/main/java/forestry/api/mail/IPostOffice.java b/src/main/java/forestry/api/mail/IPostOffice.java new file mode 100644 index 000000000..a8a14eac1 --- /dev/null +++ b/src/main/java/forestry/api/mail/IPostOffice.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IPostOffice { + + void collectPostage(ItemStack[] stamps); + + IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge); + + ItemStack getAnyStamp(int max); + + ItemStack getAnyStamp(EnumPostage postage, int max); + + ItemStack getAnyStamp(EnumPostage[] postages, int max); + + void registerTradeStation(ITradeStation trade); + + void deregisterTradeStation(ITradeStation trade); + + Map getActiveTradeStations(World world); +} diff --git a/src/main/java/forestry/api/mail/IPostRegistry.java b/src/main/java/forestry/api/mail/IPostRegistry.java new file mode 100644 index 000000000..f20352d93 --- /dev/null +++ b/src/main/java/forestry/api/mail/IPostRegistry.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +public interface IPostRegistry { + + /* POST OFFICE */ + IPostOffice getPostOffice(World world); + + /* MAIL ADDRESSES */ + IMailAddress getMailAddress(GameProfile gameProfile); + IMailAddress getMailAddress(String traderName); + + /* LETTERS */ + boolean isLetter(ItemStack itemstack); + + ILetter createLetter(IMailAddress sender, IMailAddress recipient); + + ILetter getLetter(ItemStack itemstack); + + ItemStack createLetterStack(ILetter letter); + + /* CARRIERS */ + /** + * Registers a new {@link IPostalCarrier}. See {@link IPostalCarrier} for details. + * @param carrier {@link IPostalCarrier} to register. + */ + void registerCarrier(IPostalCarrier carrier); + + IPostalCarrier getCarrier(EnumAddressee uid); + + Map getRegisteredCarriers(); + + /* TRADE STATIONS */ + void deleteTradeStation(World world, IMailAddress address); + + ITradeStation getOrCreateTradeStation(World world, GameProfile owner, IMailAddress address); + + ITradeStation getTradeStation(World world, IMailAddress address); + + boolean isAvailableTradeAddress(World world, IMailAddress address); + + boolean isValidTradeAddress(World world, IMailAddress address); + + /* PO BOXES */ + boolean isValidPOBox(World world, IMailAddress address); + +} diff --git a/src/main/java/forestry/api/mail/IPostalCarrier.java b/src/main/java/forestry/api/mail/IPostalCarrier.java new file mode 100644 index 000000000..e3b22b1d0 --- /dev/null +++ b/src/main/java/forestry/api/mail/IPostalCarrier.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Postal Carriers are systems which can be hooked into Forestry's mail system to handle mail delivery. + * + * The two available carriers in vanilla Forestry are + * "player" - Delivers mail to individual players. + * "trader" - Handles mail addressed to trade stations. + */ +public interface IPostalCarrier { + + /** + * @return An EnumAddressee identifying the type of carrier + */ + EnumAddressee getType(); + + /** + * @return A human-readable name for this carrier. + */ + String getName(); + + @SideOnly(Side.CLIENT) + TextureAtlasSprite getSprite(); + + /** + * Handle delivery of a letter addressed to this carrier. + * @param world The world the {@link IPostOffice} handles. + * @param office {link @IPostOffice} which received this letter and handed it to the carrier. + * @param recipient An identifier for the recipient as typed by the player into the address field. + * @param letterstack ItemStack representing the letter. See {@link IPostRegistry} for helper functions to validate and extract it. + * @param doDeliver Whether or not the letter is supposed to actually be delivered or if delivery is only to be simulated. + * @return {link IPostalState} holding information on success or failure for delivery. + */ + IPostalState deliverLetter(World world, IPostOffice office, IMailAddress recipient, ItemStack letterstack, boolean doDeliver); + +} diff --git a/src/main/java/forestry/api/mail/IPostalState.java b/src/main/java/forestry/api/mail/IPostalState.java new file mode 100644 index 000000000..bc843621a --- /dev/null +++ b/src/main/java/forestry/api/mail/IPostalState.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +public interface IPostalState { + boolean isOk(); + + String getIdentifier(); + + int ordinal(); +} diff --git a/src/main/java/forestry/api/mail/IStamps.java b/src/main/java/forestry/api/mail/IStamps.java new file mode 100644 index 000000000..4332a811c --- /dev/null +++ b/src/main/java/forestry/api/mail/IStamps.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.item.ItemStack; + +public interface IStamps { + + EnumPostage getPostage(ItemStack itemstack); + +} diff --git a/src/main/java/forestry/api/mail/ITradeStation.java b/src/main/java/forestry/api/mail/ITradeStation.java new file mode 100644 index 000000000..78a498a04 --- /dev/null +++ b/src/main/java/forestry/api/mail/ITradeStation.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import net.minecraft.inventory.IInventory; + +public interface ITradeStation extends ILetterHandler, IInventory { + + IMailAddress getAddress(); + + boolean isValid(); + + void invalidate(); + + void setVirtual(boolean isVirtual); + + boolean isVirtual(); + + TradeStationInfo getTradeInfo(); + +} diff --git a/src/main/java/forestry/api/mail/PostManager.java b/src/main/java/forestry/api/mail/PostManager.java new file mode 100644 index 000000000..c3f0e45bb --- /dev/null +++ b/src/main/java/forestry/api/mail/PostManager.java @@ -0,0 +1,11 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + + +public class PostManager { + public static IPostRegistry postRegistry; +} diff --git a/src/main/java/forestry/api/mail/TradeStationInfo.java b/src/main/java/forestry/api/mail/TradeStationInfo.java new file mode 100644 index 000000000..14424bedf --- /dev/null +++ b/src/main/java/forestry/api/mail/TradeStationInfo.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.mail; + +import java.lang.IllegalArgumentException; +import net.minecraft.item.ItemStack; +import com.mojang.authlib.GameProfile; + +public class TradeStationInfo { + public final IMailAddress address; + public final GameProfile owner; + public final ItemStack tradegood; + public final ItemStack[] required; + public final IPostalState state; + + public TradeStationInfo(IMailAddress address, GameProfile owner, ItemStack tradegood, ItemStack[] required, IPostalState state) { + if (!address.isTrader()) { + throw new IllegalArgumentException("TradeStation address must be a trader"); + } + this.address = address; + this.owner = owner; + this.tradegood = tradegood; + this.required = required; + this.state = state; + } +} diff --git a/src/main/java/forestry/api/mail/package-info.java b/src/main/java/forestry/api/mail/package-info.java new file mode 100644 index 000000000..3f5491f12 --- /dev/null +++ b/src/main/java/forestry/api/mail/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="3.0.0", owner="ForestryAPI|core", provides="ForestryAPI|mail") +package forestry.api.mail; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/multiblock/IAlvearyComponent.java b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java new file mode 100644 index 000000000..92c96d387 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import forestry.api.apiculture.IBeeListener; +import forestry.api.apiculture.IBeeModifier; +import forestry.api.core.IClimateControlled; + +/** + * Needs to be implemented by TileEntities that want to be part of an alveary. + * The sub-interfaces can be implemented to alter the operation of the alveary. + * They are automatically detected and handled by the alveary when they join its structure. + */ +public interface IAlvearyComponent extends IMultiblockComponent { + /** + * @return the multiblock logic for this component + */ + @Override + T getMultiblockLogic(); + + /** + * Implemented by alveary parts to apply a beeListener to the completed structure. + */ + interface BeeListener extends IAlvearyComponent { + IBeeListener getBeeListener(); + } + + /** + * Implemented by alveary parts to apply a beeModifier to the completed structure. + */ + interface BeeModifier extends IAlvearyComponent { + IBeeModifier getBeeModifier(); + } + + /** + * Implemented by alveary parts to apply a climate change to the completed structure. + */ + interface Climatiser extends IAlvearyComponent { + /** + * Called every tick by the alveary. + * @param tickCount the number of ticks in the world + * @param alveary the climate controlled alveary + */ + void changeClimate(int tickCount, IClimateControlled alveary); + } + + /** + * Implemented by alveary parts to receive ticks from the completed structure. + */ + interface Active extends IAlvearyComponent { + void updateServer(int tickCount); + void updateClient(int tickCount); + } + +} diff --git a/src/main/java/forestry/api/multiblock/IAlvearyController.java b/src/main/java/forestry/api/multiblock/IAlvearyController.java new file mode 100644 index 000000000..9645fc794 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IAlvearyController.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import forestry.api.apiculture.IBeeHousing; + +/** + * The IAlvearyController provides access to all the IMultiblockController and IBeeHousing methods + * necessary for an IAlvearyComponent to function. + */ +public interface IAlvearyController extends IMultiblockController, IBeeHousing { + +} diff --git a/src/main/java/forestry/api/multiblock/IFarmComponent.java b/src/main/java/forestry/api/multiblock/IFarmComponent.java new file mode 100644 index 000000000..28f22dacc --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IFarmComponent.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import forestry.api.farming.IFarmListener; + +/** + * Needs to be implemented by TileEntities that want to be part of a farm. + * The sub-interfaces can be implemented to alter the operation of the farm. + * They are automatically detected and handled by the farm when they join its structure. + */ +public interface IFarmComponent extends IMultiblockComponent { + + /** + * @return the multiblock logic for this component + */ + @Override + T getMultiblockLogic(); + + /** + * Implemented by farm parts to apply a farmListener to the completed structure. + */ + interface Listener extends IFarmComponent { + IFarmListener getFarmListener(); + } + + /** + * Implemented by farm parts to receive ticks from the completed structure. + */ + interface Active extends IFarmComponent { + void updateServer(int tickCount); + void updateClient(int tickCount); + } +} diff --git a/src/main/java/forestry/api/multiblock/IFarmController.java b/src/main/java/forestry/api/multiblock/IFarmController.java new file mode 100644 index 000000000..7629a0e80 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IFarmController.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import forestry.api.farming.IFarmHousing; + +/** + * The IFarmController provides access to all the IMultiblockController and IFarmHousing methods + * necessary for an IFarmComponent to function. + */ +public interface IFarmController extends IMultiblockController, IFarmHousing { + +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockComponent.java b/src/main/java/forestry/api/multiblock/IMultiblockComponent.java new file mode 100644 index 000000000..305af916d --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockComponent.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import com.mojang.authlib.GameProfile; + +import net.minecraft.util.BlockPos; + +/** + * Basic interface for a multiblock machine component. + * Implemented by TileEntities. + */ +public interface IMultiblockComponent { + + /** + * Returns the location of this tile entity in the world. + * @return ChunkCoordinates set to the location of this tile entity in the world. + */ + BlockPos getCoordinates(); + + /** + * @return the gameProfile of the player who owns this single component (not the entire multiblock) + */ + GameProfile getOwner(); + + /** + * @return the multiblock logic for this part + */ + IMultiblockLogic getMultiblockLogic(); + + /** + * Called when a machine is fully assembled from the disassembled state, meaning + * it was constructed by a player/entity action, not by chunks loading. + * Note that, for non-square machines, the min/max coordinates may not actually be part + * of the machine! They form an outer bounding box for the whole machine itself. + * @param multiblockController The controller to which this part is being assembled. + */ + void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord); + + /** + * Called when the machine is broken for game reasons, e.g. a player removed a block + * or an explosion occurred. + */ + void onMachineBroken(); +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockController.java b/src/main/java/forestry/api/multiblock/IMultiblockController.java new file mode 100644 index 000000000..f9e86bdd8 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockController.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import javax.annotation.Nonnull; +import java.util.Collection; + +/** + * IMultiblockController is used to handle the assembly of Multiblocks. + * This class is created and updated by IMultiblockLogic and Forestry. + * This is a minimal interface to hide the ugly details from the multiblock tile entities. + */ +public interface IMultiblockController { + /** + * @return True if this multiblock machine is considered assembled and ready to go. + */ + boolean isAssembled(); + + /** + * Call to force the controller to check the multiblock's validity. + * Use when important conditions around the multiblock change + * (i.e. Alveary slabs are removed and the alveary block detects it's neighbor changed) + * Changes to multiblock components are handled automatically and should not call this. + */ + void reassemble(); + + /** + * @return A string representing the last error encountered when trying to assemble this + * multiblock, or null if there is no error. + */ + String getLastValidationError(); + + /** + * @return all the multiblock components attached to this controller + */ + @Nonnull + Collection getComponents(); +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockLogic.java b/src/main/java/forestry/api/multiblock/IMultiblockLogic.java new file mode 100644 index 000000000..cd1f4c531 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockLogic.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import forestry.api.core.INBTTagable; + +/** + * Multiblock Logic implements the basic logic for IMultiblockComponent tile entities. + * Instances must come from MultiblockManager.logicFactory, most of the implementation is hidden. + * + * IMultiblockComponent tile entities must wire up the methods in the "Updating and Synchronization" section. + * As a starting point, you can use MultiblockTileEntityBase. + */ +public interface IMultiblockLogic extends INBTTagable { + + /** + * @return True if this block is connected to a multiblock controller. False otherwise. + */ + boolean isConnected(); + + /** + * @return the multiblock controller for this logic + */ + IMultiblockController getController(); + + /* Updating and Synchronization */ + + /** + * call on Tile.validate() + **/ + void validate(World world, IMultiblockComponent part); + + /** + * call on Tile.invalidate() + **/ + void invalidate(World world, IMultiblockComponent part); + + /** + * call on Tile.onChunkUnload() + **/ + void onChunkUnload(World world, IMultiblockComponent part); + + /** + * Writes data for client synchronization. + * Use this in Tile.getDescriptionPacket() + */ + void encodeDescriptionPacket(NBTTagCompound packetData); + + /** + * Reads data for client synchronization. + * Use this in Tile.onDataPacket() + */ + void decodeDescriptionPacket(NBTTagCompound packetData); + + /** + * Read the logic's data from file. + * Use this in Tile.readFromNBT() + */ + @Override + void readFromNBT(NBTTagCompound nbttagcompound); + + /** + * Write the logic's data to file. + * Use this in Tile.writeToNBT() + */ + @Override + void writeToNBT(NBTTagCompound nbttagcompound); +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockLogicAlveary.java b/src/main/java/forestry/api/multiblock/IMultiblockLogicAlveary.java new file mode 100644 index 000000000..611f3c803 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockLogicAlveary.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +public interface IMultiblockLogicAlveary extends IMultiblockLogic { + /** + * @return the multiblock controller for this logic + */ + @Override + IAlvearyController getController(); +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockLogicFactory.java b/src/main/java/forestry/api/multiblock/IMultiblockLogicFactory.java new file mode 100644 index 000000000..50eb52a13 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockLogicFactory.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +/** + * Creates new instances of IMultiblockLogic. + * Each IMultiblockComponent needs its own instance of IMultiblockLogic. + */ +public interface IMultiblockLogicFactory { + IMultiblockLogicAlveary createAlvearyLogic(); + + IMultiblockLogicFarm createFarmLogic(); +} diff --git a/src/main/java/forestry/api/multiblock/IMultiblockLogicFarm.java b/src/main/java/forestry/api/multiblock/IMultiblockLogicFarm.java new file mode 100644 index 000000000..78f599ce6 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/IMultiblockLogicFarm.java @@ -0,0 +1,14 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +public interface IMultiblockLogicFarm extends IMultiblockLogic { + /** + * @return the multiblock controller for this logic + */ + @Override + IFarmController getController(); +} diff --git a/src/main/java/forestry/api/multiblock/MultiblockManager.java b/src/main/java/forestry/api/multiblock/MultiblockManager.java new file mode 100644 index 000000000..c75b03f1b --- /dev/null +++ b/src/main/java/forestry/api/multiblock/MultiblockManager.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +public class MultiblockManager { + public static IMultiblockLogicFactory logicFactory; +} diff --git a/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java new file mode 100644 index 000000000..5ad4d3f53 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.multiblock; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; + +/** + * Base logic class for Multiblock-connected tile entities. + * Most multiblock components should derive from this. + * Supply it an IMultiblockLogic from MultiblockManager.logicFactory + */ +public abstract class MultiblockTileEntityBase extends TileEntity implements IMultiblockComponent { + private final T multiblockLogic; + + public MultiblockTileEntityBase(T multiblockLogic) { + this.multiblockLogic = multiblockLogic; + } + + @Override + public BlockPos getCoordinates() { + return getPos(); + } + + @Override + public T getMultiblockLogic() { + return multiblockLogic; + } + + @Override + public abstract void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord); + + @Override + public abstract void onMachineBroken(); + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + multiblockLogic.readFromNBT(data); + } + + @Override + public void writeToNBT(NBTTagCompound data) { + super.writeToNBT(data); + multiblockLogic.writeToNBT(data); + } + + @Override + public final void invalidate() { + super.invalidate(); + multiblockLogic.invalidate(worldObj, this); + } + + @Override + public final void onChunkUnload() { + super.onChunkUnload(); + multiblockLogic.onChunkUnload(worldObj, this); + } + + @Override + public final void validate() { + super.validate(); + multiblockLogic.validate(worldObj, this); + } + + @Override + public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) + { + return oldState.getBlock() != newSate.getBlock(); + } + + /* Network Communication */ + + @Override + public final Packet getDescriptionPacket() { + NBTTagCompound packetData = new NBTTagCompound(); + multiblockLogic.encodeDescriptionPacket(packetData); + this.encodeDescriptionPacket(packetData); + return new S35PacketUpdateTileEntity(getPos(), 0, packetData); + } + + @Override + public final void onDataPacket(NetworkManager network, S35PacketUpdateTileEntity packet) { + NBTTagCompound nbtData = packet.getNbtCompound(); + multiblockLogic.decodeDescriptionPacket(nbtData); + this.decodeDescriptionPacket(nbtData); + } + + /** + * Used to write tileEntity-specific data to the descriptionPacket + */ + protected void encodeDescriptionPacket(NBTTagCompound packetData) { + + } + + /** + * Used to read tileEntity-specific data from the descriptionPacket (onDataPacket) + */ + protected void decodeDescriptionPacket(NBTTagCompound packetData) { + + } +} diff --git a/src/main/java/forestry/api/multiblock/package-info.java b/src/main/java/forestry/api/multiblock/package-info.java new file mode 100644 index 000000000..d13db8ce3 --- /dev/null +++ b/src/main/java/forestry/api/multiblock/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|multiblock") +package forestry.api.multiblock; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/recipes/ICarpenterManager.java b/src/main/java/forestry/api/recipes/ICarpenterManager.java new file mode 100644 index 000000000..9dc700ac8 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ICarpenterManager.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the carpenter. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * Only shaped recipes can be added currently. + * + * @author SirSengir + */ +public interface ICarpenterManager extends ICraftingProvider { + /** + * Add a shaped recipe to the carpenter. + * + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(ItemStack box, ItemStack product, Object... materials); + + /** + * Add a shaped recipe to the carpenter. + * + * @param packagingTime + * Number of work cycles required to craft the recipe once. + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(int packagingTime, ItemStack box, ItemStack product, Object... materials); + + /** + * Add a shaped recipe to the carpenter. + * + * @param packagingTime + * Number of work cycles required to craft the recipe once. + * @param liquid + * Liquid required in carpenter's tank. + * @param box + * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null. + * @param product + * Crafting result. + * @param materials + * Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same. + */ + public void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object... materials); +} diff --git a/src/main/java/forestry/api/recipes/ICarpenterRecipe.java b/src/main/java/forestry/api/recipes/ICarpenterRecipe.java new file mode 100644 index 000000000..cb3e88b77 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ICarpenterRecipe.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface ICarpenterRecipe extends IForestryRecipe { + + /** + * @return Number of work cycles required to craft the recipe once. + */ + int getPackagingTime(); + + /** + * @return the crafting grid recipe. The crafting recipe's getRecipeOutput() is used as the ICarpenterRecipe's output. + */ + IDescriptiveRecipe getCraftingGridRecipe(); + + /** + * @return the box required for this recipe. return null if there is no required box. + * Examples of boxes are the Forestry cartons and crates. + */ + @Nullable + ItemStack getBox(); + + /** + * @return the fluid required for this recipe. return null if there is no required fluid. + */ + @Nullable + FluidStack getFluidResource(); + +} diff --git a/src/main/java/forestry/api/recipes/ICentrifugeManager.java b/src/main/java/forestry/api/recipes/ICentrifugeManager.java new file mode 100644 index 000000000..1d407f07d --- /dev/null +++ b/src/main/java/forestry/api/recipes/ICentrifugeManager.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Map; + +import net.minecraft.item.ItemStack; + +/** + * Provides an interface to the recipe manager of the centrifuge. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface ICentrifugeManager extends ICraftingProvider { + + /** + * Add a recipe to the centrifuge + * + * @param timePerItem Time to centrifugate one item of the given type. Default is 20. + * @param input ItemStack containing information on item id and damage. Stack size will be ignored. + * @param products Specifies the possible products and the chances of them resulting from centrifuging. + * Chances are from (0.0 to 1.0] + */ + void addRecipe(int timePerItem, ItemStack input, Map products); + +} diff --git a/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java b/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java new file mode 100644 index 000000000..595123f43 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Collection; +import java.util.Map; +import java.util.Random; + +import net.minecraft.item.ItemStack; + +public interface ICentrifugeRecipe extends IForestryRecipe { + + /** The item for this recipe to match against. **/ + ItemStack getInput(); + + /** The time it takes to process one item. Default is 20. **/ + int getProcessingTime(); + + /** Returns the randomized products from processing one input item. **/ + Collection getProducts(Random random); + + /** + * Returns a list of all possible products and their estimated probabilities (0.0 to 1.0], + * to help mods that display recipes + **/ + Map getAllProducts(); +} diff --git a/src/main/java/forestry/api/recipes/ICraftingProvider.java b/src/main/java/forestry/api/recipes/ICraftingProvider.java new file mode 100644 index 000000000..9e6ca8945 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ICraftingProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Collection; +import java.util.Map; + +public interface ICraftingProvider { + /** + * Add a new recipe to the crafting provider. + * @return true if this collection changed as a result of the call + * @since Forestry 4.1.0 + */ + boolean addRecipe(T recipe); + + /** + * Remove a specific recipe from the crafting provider. + * @return true if an element was removed as a result of this call + * @since Forestry 4.1.0 + */ + boolean removeRecipe(T recipe); + + /** + * @return an unmodifiable collection of all recipes registered to the crafting provider. + * @since Forestry 4.1.0 + */ + Collection recipes(); + + /** + * Access to the full list of recipes contained in the crafting provider. + * + * @return List of the given format where the first array represents inputs and the second outputs. Objects can be either ItemStack or LiquidStack. + * @deprecated since Forestry 4.1.0. Use recipes() + */ + @Deprecated + Map getRecipes(); +} diff --git a/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java new file mode 100644 index 000000000..654a47a5e --- /dev/null +++ b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +/** + * Extension of IRecipe to give better access to the expected crafting inputs. + * It can be matched against regular IInventory instead of just InventoryCrafting. + * Useful for displaying crafting recipes. + */ +public interface IDescriptiveRecipe extends IRecipe { + + /** + * @return width of the crafting ingredients in the crafting table + */ + int getWidth(); + + /** + * @return height of the crafting ingredients in the crafting table + */ + int getHeight(); + + /** + * @return array of all the ingredients in the crafting table. + * Ingredients may be null, ItemStack, ItemStack[], or a List of ItemStack + */ + Object[] getIngredients(); + + /** + * @return true if the recipe manager should copy NBT from input items to the output item. + * If true, all input items must have the same NBT for it to succeed. + * @deprecated since Forestry 4.2 wood itemStacks use item damage (meta) instead of NBT + */ + @Deprecated + boolean preserveNBT(); + + /** + * Used to check if a recipe matches current crafting inventory + * @deprecated Since Forestry 4.1. This is handled by Forestry. + */ + @Deprecated + boolean matches(IInventory inventoryCrafting, World world); +} diff --git a/src/main/java/forestry/api/recipes/IFabricatorManager.java b/src/main/java/forestry/api/recipes/IFabricatorManager.java new file mode 100644 index 000000000..342e0a3ee --- /dev/null +++ b/src/main/java/forestry/api/recipes/IFabricatorManager.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IFabricatorManager extends ICraftingProvider { + + void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern); + + /** + * @deprecated since Forestry 4.1. Use IFabricatorSmeltingManager + */ + @Deprecated + void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint); + +} diff --git a/src/main/java/forestry/api/recipes/IFabricatorRecipe.java b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java new file mode 100644 index 000000000..e7cab5e0c --- /dev/null +++ b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IFabricatorRecipe extends IForestryRecipe { + + /** + * @return the molten liquid (and amount) required for this recipe. + */ + FluidStack getLiquid(); + + /** + * @return the list of ingredients in the crafting grid to create this recipe. + */ + Object[] getIngredients(); + + /** + * @return the width of ingredients in the crafting grid to create this recipe. + */ + int getWidth(); + + /** + * @return the height of ingredients in the crafting grid to create this recipe. + */ + int getHeight(); + + /** + * @return the plan for this recipe (the item in the top right slot). + */ + @Nullable + ItemStack getPlan(); + + /** + * @return the result of this recipe + */ + ItemStack getRecipeOutput(); +} diff --git a/src/main/java/forestry/api/recipes/IFabricatorSmeltingManager.java b/src/main/java/forestry/api/recipes/IFabricatorSmeltingManager.java new file mode 100644 index 000000000..5ec9ef230 --- /dev/null +++ b/src/main/java/forestry/api/recipes/IFabricatorSmeltingManager.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IFabricatorSmeltingManager extends ICraftingProvider { + /** + * Add a smelting recipe to the Fabricator + * @param resource item to be melted down + * @param molten resulting fluid + * @param meltingPoint temperature at which the item melts. Glass is 1000, Sand is 3000. + */ + void addSmelting(ItemStack resource, FluidStack molten, int meltingPoint); +} diff --git a/src/main/java/forestry/energy/tiles/InventoryEngineElectric.java b/src/main/java/forestry/api/recipes/IFabricatorSmeltingRecipe.java similarity index 51% rename from src/main/java/forestry/energy/tiles/InventoryEngineElectric.java rename to src/main/java/forestry/api/recipes/IFabricatorSmeltingRecipe.java index 58c94e1c9..3b0a3565b 100644 --- a/src/main/java/forestry/energy/tiles/InventoryEngineElectric.java +++ b/src/main/java/forestry/api/recipes/IFabricatorSmeltingRecipe.java @@ -1,33 +1,32 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.tiles; - -import net.minecraft.item.ItemStack; - -import forestry.core.inventory.InventoryAdapterTile; - -import ic2.api.item.ElectricItem; - -public class InventoryEngineElectric extends InventoryAdapterTile { - public static final short SLOT_BATTERY = 0; - - public InventoryEngineElectric(TileEngineElectric engineTin) { - super(engineTin, 1, "electrical"); - } - - @Override - public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (slotIndex == SLOT_BATTERY) { - return ElectricItem.manager.getCharge(itemStack) > 0; - } - return false; - } -} +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface IFabricatorSmeltingRecipe extends IForestryRecipe { + /** + * @return item to be melted down + */ + ItemStack getResource(); + + /** + * @return temperature at which the item melts. Glass is 1000, Sand is 3000. + */ + int getMeltingPoint(); + + /** + * @return resulting fluid + */ + FluidStack getProduct(); +} diff --git a/src/main/java/forestry/api/recipes/IFermenterManager.java b/src/main/java/forestry/api/recipes/IFermenterManager.java new file mode 100644 index 000000000..5aa926ddf --- /dev/null +++ b/src/main/java/forestry/api/recipes/IFermenterManager.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the fermenter. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() + * cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be + * null even if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface IFermenterManager extends ICraftingProvider { + + /** + * Add a recipe to the fermenter + * + * @param resource ItemStack representing the resource. + * @param fermentationValue Value of the given resource, i.e. how much needs + * to be fermented for the output to be deposited into the product tank. + * @param modifier Modifies the amount of liquid output per work cycle. + * (water = 1.0f, honey = 1.5f) + * @param output LiquidStack representing output liquid. Amount is + * determined by fermentationValue*modifier. + * @param liquid LiquidStack representing resource liquid and amount. + * @throws NullPointerException if resource, output or liquid is null + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output, FluidStack liquid); + + /** + * Add a recipe to the fermenter. Defaults to water as input liquid. + * + * @param resource ItemStack representing the resource. + * @param modifier Modifies the amount of liquid output per work cycle. + * (water = 1.0f, honey = 1.5f) + * @param fermentationValue Value of the given resource, i.e. how much needs + * to be fermented for the output to be deposited into the product tank. + * @param output LiquidStack representing output liquid. Amount is + * determined by fermentationValue*modifier. + * @throws NullPointerException if resource, output or liquid is null + */ + public void addRecipe(ItemStack resource, int fermentationValue, float modifier, FluidStack output); +} diff --git a/src/main/java/forestry/api/recipes/IFermenterRecipe.java b/src/main/java/forestry/api/recipes/IFermenterRecipe.java new file mode 100644 index 000000000..4bbd0f54b --- /dev/null +++ b/src/main/java/forestry/api/recipes/IFermenterRecipe.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public interface IFermenterRecipe extends IForestryRecipe { + /** + * @return ItemStack representing the input resource. + */ + ItemStack getResource(); + + /** + * @return FluidStack representing the input fluid resource. + */ + FluidStack getFluidResource(); + + /** + * @return Value of the given resource, i.e. how much needs to be fermented for the output to be deposited into the product tank. + */ + int getFermentationValue(); + + /** + * @return Modifies the amount of liquid output per work cycle. + * (water = 1.0f, honey = 1.5f) + */ + float getModifier(); + + /** + * @return Fluid representing output. Amount is determined by fermentationValue * modifier. + */ + Fluid getOutput(); +} diff --git a/src/main/java/forestry/api/recipes/IForestryRecipe.java b/src/main/java/forestry/api/recipes/IForestryRecipe.java new file mode 100644 index 000000000..7153ffa0b --- /dev/null +++ b/src/main/java/forestry/api/recipes/IForestryRecipe.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +public interface IForestryRecipe { +} diff --git a/src/main/java/forestry/api/recipes/IMoistenerManager.java b/src/main/java/forestry/api/recipes/IMoistenerManager.java new file mode 100644 index 000000000..3bbd59d44 --- /dev/null +++ b/src/main/java/forestry/api/recipes/IMoistenerManager.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +/** + * Provides an interface to the recipe manager of the moistener. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface IMoistenerManager extends ICraftingProvider { + + /** + * Add a recipe to the moistener + * + * @param resource + * Item required in resource stack. Will be reduced by one per produced item. + * @param product + * Item to produce per resource processed. + * @param timePerItem + * Moistener runs at 1 - 4 time ticks per ingame tick depending on light level. For mycelium this value is currently 5000. + */ + public void addRecipe(ItemStack resource, ItemStack product, int timePerItem); +} diff --git a/src/main/java/forestry/api/recipes/IMoistenerRecipe.java b/src/main/java/forestry/api/recipes/IMoistenerRecipe.java new file mode 100644 index 000000000..73eaf5a92 --- /dev/null +++ b/src/main/java/forestry/api/recipes/IMoistenerRecipe.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +public interface IMoistenerRecipe extends IForestryRecipe { + /** + * Moistener runs at 1 - 4 time ticks per ingame tick depending on light level. For mycelium this value is currently 5000. + * @return moistener ticks to process one item. + */ + int getTimePerItem(); + + /** + * @return Item required in resource stack. Will be reduced by one per produced item. + */ + ItemStack getResource(); + + /** + * @return Item to produce per resource processed. + */ + ItemStack getProduct(); +} diff --git a/src/main/java/forestry/api/recipes/ISqueezerManager.java b/src/main/java/forestry/api/recipes/ISqueezerManager.java new file mode 100644 index 000000000..e02bf4dc2 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ISqueezerManager.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the suqeezer. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * @author SirSengir + */ +public interface ISqueezerManager extends ICraftingProvider { + + /** + * Add a recipe to the squeezer. + * + * @param timePerItem Number of work cycles required to squeeze one set of resources. + * @param resources Array of item stacks representing the required resources for one process. Stack size will be taken into account. + * @param liquid {@link FluidStack} representing the output of this recipe. + * @param remnants Item stack representing the possible remnants from this recipe. + * @param chance Chance remnants will be produced by a single recipe cycle, from 0 to 100. + */ + public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance); + + /** + * Add a recipe to the squeezer. + * + * @param timePerItem Number of work cycles required to squeeze one set of resources. + * @param resources Array of item stacks representing the required resources for one process. Stack size will be taken into account. + * @param liquid {@link FluidStack} representing the output of this recipe. + */ + public void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid); + + /** + * Add a recipe for a fluid container to the squeezer. + * This will add recipes to get all types of liquids out of this type of fluid container. + * + * @param timePerItem Number of work cycles required to squeeze one set of resources. + * @param emptyContainer The empty version of the fluid container that will be squeezed. + * @param remnants Item stack representing the possible remnants from this recipe. + * @param chance Chance remnants will be produced by a single recipe cycle, from 0 to 1. + */ + void addContainerRecipe(int timePerItem, ItemStack emptyContainer, @Nullable ItemStack remnants, float chance); +} diff --git a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java new file mode 100644 index 000000000..385b33799 --- /dev/null +++ b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface ISqueezerRecipe extends IForestryRecipe { + + /** + * @return Array of item stacks representing the required resources for one process. Stack size will be taken into account. + */ + ItemStack[] getResources(); + + /** + * @return Number of work cycles required to squeeze one set of resources. + */ + int getProcessingTime(); + + /** + * @return Item stack representing the possible remnants from this recipe. (i.e. tin left over from tin cans) + */ + ItemStack getRemnants(); + + /** + * @return Chance remnants will be produced by a single recipe cycle, from 0 to 1. + */ + float getRemnantsChance(); + + /** + * @return {@link FluidStack} representing the output of this recipe. + */ + FluidStack getFluidOutput(); + +} diff --git a/src/main/java/forestry/api/recipes/IStillManager.java b/src/main/java/forestry/api/recipes/IStillManager.java new file mode 100644 index 000000000..72cd7398f --- /dev/null +++ b/src/main/java/forestry/api/recipes/IStillManager.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraftforge.fluids.FluidStack; + +/** + * Provides an interface to the recipe manager of the still. + * + * The manager is initialized at the beginning of Forestry's BaseMod.load() cycle. Begin adding recipes in BaseMod.ModsLoaded() and this shouldn't be null even + * if your mod loads before Forestry. + * + * Accessible via {@link RecipeManagers} + * + * Note that this is untested with anything other than biomass->biofuel conversion. + * + * @author SirSengir + */ +public interface IStillManager extends ICraftingProvider { + /** + * Add a recipe to the still + * + * @param cyclesPerUnit + * Amount of work cycles required to run through the conversion once. + * @param input + * FluidStack representing the input liquid. + * @param output + * FluidStack representing the output liquid + */ + public void addRecipe(int cyclesPerUnit, FluidStack input, FluidStack output); +} diff --git a/src/main/java/forestry/api/recipes/IStillRecipe.java b/src/main/java/forestry/api/recipes/IStillRecipe.java new file mode 100644 index 000000000..384aa3e14 --- /dev/null +++ b/src/main/java/forestry/api/recipes/IStillRecipe.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraftforge.fluids.FluidStack; + +public interface IStillRecipe extends IForestryRecipe { + /** + * @return Amount of work cycles required to run through the conversion once. + */ + int getCyclesPerUnit(); + + /** + * @return FluidStack representing the input liquid. + */ + FluidStack getInput(); + + /** + * @return FluidStack representing the output liquid. + */ + FluidStack getOutput(); +} diff --git a/src/main/java/forestry/api/recipes/IVariableFermentable.java b/src/main/java/forestry/api/recipes/IVariableFermentable.java new file mode 100644 index 000000000..f0997f531 --- /dev/null +++ b/src/main/java/forestry/api/recipes/IVariableFermentable.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import net.minecraft.item.ItemStack; + +/** + * Fermenter checks any valid fermentation item for an implementation of this interface. + * This does not supersede adding a proper recipe to the fermenter! + */ +public interface IVariableFermentable { + + /** + * @param itemstack + * @return Float representing the modification to be applied to the matching recipe's biomass output. + */ + float getFermentationModifier(ItemStack itemstack); +} diff --git a/src/main/java/forestry/api/recipes/RecipeManagers.java b/src/main/java/forestry/api/recipes/RecipeManagers.java new file mode 100644 index 000000000..31cc0e2fd --- /dev/null +++ b/src/main/java/forestry/api/recipes/RecipeManagers.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.recipes; + +import java.util.Collection; + +/** + * Contains all available recipe managers for Forestry machines and items. + * + * @author SirSengir + */ +public class RecipeManagers { + + /** + * @deprecated since Forestry 4.1.0. Use the specific recipe managers below instead. + */ + @Deprecated + public static Collection craftingProviders; + + /** + * Allows you to add recipes to the carpenter. See {@link ICarpenterManager} for details. + */ + public static ICarpenterManager carpenterManager; + /** + * Allows you to add recipes to the centrifuge. See {@link ICentrifugeManager} for details. + */ + public static ICentrifugeManager centrifugeManager; + /** + * Allows you to add recipes to the fermenter. See {@link IFermenterManager} for details. + */ + public static IFermenterManager fermenterManager; + /** + * Allows you to add recipes to the moistener. See {@link IMoistenerManager} for details. + */ + public static IMoistenerManager moistenerManager; + /** + * Allows you to add recipes to the squeezer. See {@link ISqueezerManager} for details. + */ + public static ISqueezerManager squeezerManager; + /** + * Allows you to add recipes to the still. See {@link IStillManager} for details. + */ + public static IStillManager stillManager; + /** + * Allows you to add recipes to the fabricator. See {@link IFabricatorManager} for details. + */ + public static IFabricatorManager fabricatorManager; + /** + * Allows you to add smelting recipes to the fabricator. See {@link IFabricatorSmeltingManager} for details. + */ + public static IFabricatorSmeltingManager fabricatorSmeltingManager; +} diff --git a/src/main/java/forestry/api/recipes/package-info.java b/src/main/java/forestry/api/recipes/package-info.java new file mode 100644 index 000000000..34eff1c1a --- /dev/null +++ b/src/main/java/forestry/api/recipes/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="5.4.0", owner="ForestryAPI|core", provides="ForestryAPI|recipes") +package forestry.api.recipes; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/storage/BackpackEvent.java b/src/main/java/forestry/api/storage/BackpackEvent.java new file mode 100644 index 000000000..f9f215cf8 --- /dev/null +++ b/src/main/java/forestry/api/storage/BackpackEvent.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.fml.common.eventhandler.Event; + + +public abstract class BackpackEvent extends Event { + + public final EntityPlayer player; + public final IBackpackDefinition backpackDefinition; + public final IInventory backpackInventory; + + public BackpackEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) { + this.player = player; + this.backpackDefinition = backpackDefinition; + this.backpackInventory = backpackInventory; + } +} diff --git a/src/main/java/forestry/api/storage/BackpackManager.java b/src/main/java/forestry/api/storage/BackpackManager.java new file mode 100644 index 000000000..8805904d6 --- /dev/null +++ b/src/main/java/forestry/api/storage/BackpackManager.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import java.util.ArrayList; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +public class BackpackManager { + /** + * 0 - Miner's Backpack 1 - Digger's Backpack 2 - Forester's Backpack 3 - Hunter's Backpack 4 - Adventurer's Backpack + * + * Use IMC messages to achieve the same effect! + */ + public static ArrayList[] backpackItems; + + public static IBackpackInterface backpackInterface; + + /** + * Only use this if you know what you are doing. Prefer backpackInterface. + */ + public static HashMap definitions = new HashMap(); +} diff --git a/src/main/java/forestry/api/storage/BackpackResupplyEvent.java b/src/main/java/forestry/api/storage/BackpackResupplyEvent.java new file mode 100644 index 000000000..949ab0355 --- /dev/null +++ b/src/main/java/forestry/api/storage/BackpackResupplyEvent.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraftforge.fml.common.eventhandler.Cancelable; + +/** + * Use @SubscribeEvent on a method taking this event as an argument. Will fire whenever a backpack tries to resupply to a player inventory. Processing will stop + * if the event is canceled. + */ +@Cancelable +public class BackpackResupplyEvent extends BackpackEvent { + + public BackpackResupplyEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) { + super(player, backpackDefinition, backpackInventory); + } + +} diff --git a/src/main/java/forestry/api/storage/BackpackStowEvent.java b/src/main/java/forestry/api/storage/BackpackStowEvent.java new file mode 100644 index 000000000..b34bd0c7c --- /dev/null +++ b/src/main/java/forestry/api/storage/BackpackStowEvent.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.eventhandler.Cancelable; + +/** + * Use @SubscribeEvent on a method taking this event as an argument. Will fire whenever a backpack tries to store an item. Processing will stop if the stacksize + * of stackToStow drops to 0 or less or the event is canceled. + */ +@Cancelable +public class BackpackStowEvent extends BackpackEvent { + + public final ItemStack stackToStow; + + public BackpackStowEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory, ItemStack stackToStow) { + super(player, backpackDefinition, backpackInventory); + this.stackToStow = stackToStow; + } +} diff --git a/src/main/java/forestry/api/storage/EnumBackpackType.java b/src/main/java/forestry/api/storage/EnumBackpackType.java new file mode 100644 index 000000000..48ad7ee09 --- /dev/null +++ b/src/main/java/forestry/api/storage/EnumBackpackType.java @@ -0,0 +1,10 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +public enum EnumBackpackType { + APIARIST, T1, T2 +} diff --git a/src/main/java/forestry/api/storage/IBackpackDefinition.java b/src/main/java/forestry/api/storage/IBackpackDefinition.java new file mode 100644 index 000000000..31c666312 --- /dev/null +++ b/src/main/java/forestry/api/storage/IBackpackDefinition.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface IBackpackDefinition { + + /** + * @return A unique string identifier + */ + String getKey(); + + /** + * @return Human-readable name of the backpack. + */ + String getName(ItemStack backpack); + + /** + * @return Primary colour for the backpack icon. + */ + int getPrimaryColour(); + + /** + * @return Secondary colour for backpack icon. + */ + int getSecondaryColour(); + + /** + * Adds an item as valid for this backpack. + * + * @param validItem + */ + void addValidItem(ItemStack validItem); + void addValidItems(List validItems); + + /** + * Returns true if the itemstack is a valid item for this backpack type. + */ + boolean isValidItem(ItemStack itemstack); + +} diff --git a/src/main/java/forestry/api/storage/IBackpackInterface.java b/src/main/java/forestry/api/storage/IBackpackInterface.java new file mode 100644 index 000000000..27a2eba56 --- /dev/null +++ b/src/main/java/forestry/api/storage/IBackpackInterface.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.item.Item; + +public interface IBackpackInterface { + + /** + * Adds a backpack with the given definition and type, returning the item. + * + * @param definition + * Definition of backpack behaviour. + * @param type + * Type of backpack. (T1 or T2 (= Woven) + * @return Created backpack item. + */ + Item addBackpack(IBackpackDefinition definition, EnumBackpackType type); +} diff --git a/src/main/java/forestry/api/storage/ICrateRegistry.java b/src/main/java/forestry/api/storage/ICrateRegistry.java new file mode 100644 index 000000000..868511e3d --- /dev/null +++ b/src/main/java/forestry/api/storage/ICrateRegistry.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public interface ICrateRegistry { + + /** + * Makes a new crate, registers it with the game registry with uid, + * and creates crating and uncrating recipes for the Carpenter. + * The icon is rendered automatically from the contained item. + * + * Can only be called during the Init stage. + */ + void registerCrate(Item item, String uid); + void registerCrate(Block block, String uid); + void registerCrate(ItemStack stack, String uid); + + /** + * Same as the above, but uses the ore dictionary for the Carpenter crating recipe. + */ + void registerCrateUsingOreDict(Item item, String uid); + void registerCrateUsingOreDict(Block block, String uid); + void registerCrateUsingOreDict(ItemStack stack, String uid); + +} diff --git a/src/main/java/forestry/api/storage/StorageManager.java b/src/main/java/forestry/api/storage/StorageManager.java new file mode 100644 index 000000000..ef4ec4cf8 --- /dev/null +++ b/src/main/java/forestry/api/storage/StorageManager.java @@ -0,0 +1,12 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.storage; + +public class StorageManager { + + public static ICrateRegistry crateRegistry; + +} diff --git a/src/main/java/forestry/api/storage/package-info.java b/src/main/java/forestry/api/storage/package-info.java new file mode 100644 index 000000000..01dbc196e --- /dev/null +++ b/src/main/java/forestry/api/storage/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="3.0.0", owner="ForestryAPI|core", provides="ForestryAPI|storage") +package forestry.api.storage; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/world/ITreeGenData.java b/src/main/java/forestry/api/world/ITreeGenData.java new file mode 100644 index 000000000..bec04a509 --- /dev/null +++ b/src/main/java/forestry/api/world/ITreeGenData.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.world; + +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.arboriculture.ITreeGenome; + +public interface ITreeGenData { + + int getGirth(World world, BlockPos pos); + + float getHeightModifier(); + + boolean canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight); + + void setLeaves(World world, GameProfile owner, BlockPos pos); + void setLeavesDecorative(World world, GameProfile owner, BlockPos pos); + + void setLogBlock(World world, BlockPos pos, EnumFacing facing); + + boolean allowsFruitBlocks(); + + boolean trySpawnFruitBlock(World world, BlockPos pos); + + ITreeGenome getGenome(); +} diff --git a/src/main/java/forestry/api/world/package-info.java b/src/main/java/forestry/api/world/package-info.java new file mode 100644 index 000000000..bb6e6aa46 --- /dev/null +++ b/src/main/java/forestry/api/world/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion="2.1.0", owner="ForestryAPI|core", provides="ForestryAPI|world") +package forestry.api.world; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java index 95d9a8ed1..fd6fe70fd 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java @@ -20,8 +20,9 @@ import forestry.core.tiles.IActivatable; import forestry.energy.EnergyManager; import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyReceiver; -public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler, IActivatable, IAlvearyComponent.Climatiser { +public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyReceiver, IActivatable, IAlvearyComponent.Climatiser { private static final int WORK_CYCLES = 1; private static final int ENERGY_PER_OPERATION = 50; @@ -123,11 +124,6 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner return energyManager.receiveEnergy(from, maxReceive, simulate); } - @Override - public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - return energyManager.extractEnergy(from, maxExtract, simulate); - } - @Override public int getEnergyStored(EnumFacing from) { return energyManager.getEnergyStored(from); diff --git a/src/main/java/forestry/core/gui/GuiIdRegistry.java b/src/main/java/forestry/core/gui/GuiIdRegistry.java index 258cff8f0..1d213247a 100644 --- a/src/main/java/forestry/core/gui/GuiIdRegistry.java +++ b/src/main/java/forestry/core/gui/GuiIdRegistry.java @@ -31,9 +31,7 @@ import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileEscritoire; import forestry.core.tiles.TileNaturalistChest; import forestry.energy.tiles.TileEngineBiogas; -import forestry.energy.tiles.TileEngineElectric; import forestry.energy.tiles.TileEnginePeat; -import forestry.energy.tiles.TileGenerator; import forestry.factory.tiles.TileBottler; import forestry.factory.tiles.TileCarpenter; import forestry.factory.tiles.TileCentrifuge; @@ -86,9 +84,7 @@ public class GuiIdRegistry { TileFarm.class, TileEngineBiogas.class, - TileEngineElectric.class, TileEnginePeat.class, - TileGenerator.class, TileMailbox.class, TileStampCollector.class, diff --git a/src/main/java/forestry/core/items/ItemWrench.java b/src/main/java/forestry/core/items/ItemWrench.java index 64e69a0ee..2d9e7a6b4 100755 --- a/src/main/java/forestry/core/items/ItemWrench.java +++ b/src/main/java/forestry/core/items/ItemWrench.java @@ -11,6 +11,7 @@ package forestry.core.items; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; @@ -47,4 +48,11 @@ public class ItemWrench extends ItemForestry implements IToolWrench { @Override public void wrenchUsed(EntityPlayer player, BlockPos pos) {} + @Override + public boolean canWrench(EntityPlayer entityPlayer, Entity entity) { + return true; + } + + @Override + public void wrenchUsed(EntityPlayer entityPlayer, Entity entity) {} } diff --git a/src/main/java/forestry/core/models/ModelCrate.java b/src/main/java/forestry/core/models/ModelCrate.java index 1ee96d89c..36a6f2954 100644 --- a/src/main/java/forestry/core/models/ModelCrate.java +++ b/src/main/java/forestry/core/models/ModelCrate.java @@ -37,7 +37,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import forestry.core.utils.Log; -public class ModelCrate implements IModelCustomData{ +public class ModelCrate implements IModelCustomData { public static final ModelCrate instance = new ModelCrate(new ModelResourceLocation("forestry:crates", "crate"), EnumWorldBlockLayer.CUTOUT, "cratedStone", "forestry", new ModelResourceLocation("forestry:crates", "cratedStone")); private final ModelResourceLocation baseLocation; diff --git a/src/main/java/forestry/core/recipes/craftguide/CraftGuideCustomRecipes.java b/src/main/java/forestry/core/recipes/craftguide/CraftGuideCustomRecipes.java deleted file mode 100644 index bf825d28f..000000000 --- a/src/main/java/forestry/core/recipes/craftguide/CraftGuideCustomRecipes.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.recipes.craftguide; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; - -import forestry.api.recipes.IDescriptiveRecipe; -import forestry.core.recipes.RecipeUtil; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideCustomRecipes implements RecipeProvider { - - private final ItemSlot[] slots = new ItemSlot[10]; - - public CraftGuideCustomRecipes() { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16); - } - } - slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - - ItemStack machine = new ItemStack(Blocks.crafting_table); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine, "/gui/CraftGuideRecipe.png", 1, 1, 82, 1); - - for (Object rec : CraftingManager.getInstance().getRecipeList()) { - if (!(rec instanceof IDescriptiveRecipe)) { - continue; - } - - Object[] array = new Object[10]; - - Object[] flattened = RecipeUtil.getCraftingRecipeAsArray((IDescriptiveRecipe) rec); - if (flattened == null) { - continue; - } - System.arraycopy(flattened, 0, array, 0, flattened.length); - generator.addRecipe(template, array); - - } - } - -} diff --git a/src/main/java/forestry/core/recipes/craftguide/CraftGuideIntegration.java b/src/main/java/forestry/core/recipes/craftguide/CraftGuideIntegration.java deleted file mode 100644 index db9339524..000000000 --- a/src/main/java/forestry/core/recipes/craftguide/CraftGuideIntegration.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.recipes.craftguide; - -import java.lang.reflect.Method; - -import forestry.core.utils.Log; -import forestry.factory.recipes.craftguide.CraftGuideBottler; -import forestry.factory.recipes.craftguide.CraftGuideCarpenter; -import forestry.factory.recipes.craftguide.CraftGuideCentrifuge; -import forestry.factory.recipes.craftguide.CraftGuideFabricator; -import forestry.factory.recipes.craftguide.CraftGuideFermenter; -import forestry.factory.recipes.craftguide.CraftGuideSqueezer; -import forestry.factory.recipes.craftguide.CraftGuideStill; - -public class CraftGuideIntegration { - - public static void register() { - registerRecipeProviders(); - } - - private static void registerRecipeProviders() { - - Log.info("Registering CraftGuide integration."); - try { - Class c = Class.forName("uristqwerty.CraftGuide.ReflectionAPI"); - Method m = c.getMethod("registerAPIObject", Object.class); - - Log.fine("Adding crafting handler custom recipes."); - m.invoke(null, new CraftGuideCustomRecipes()); - Log.fine("Adding crafting handler for the carpenter."); - m.invoke(null, new CraftGuideCarpenter()); - Log.fine("Adding crafting handler for the thermionic fabricator."); - m.invoke(null, new CraftGuideFabricator()); - Log.fine("Adding crafting handler for the centrifuge."); - m.invoke(null, new CraftGuideCentrifuge()); - Log.fine("Adding crafting handler for the squeezer."); - m.invoke(null, new CraftGuideSqueezer()); - Log.fine("Adding crafting handler for the fermenter."); - m.invoke(null, new CraftGuideFermenter()); - Log.fine("Adding crafting handler for the still."); - m.invoke(null, new CraftGuideStill()); - Log.fine("Adding crafting handler for the bottler."); - m.invoke(null, new CraftGuideBottler()); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - -} diff --git a/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java b/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java index 85e8a79a5..593ad75b9 100644 --- a/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java +++ b/src/main/java/forestry/core/recipes/jei/JEIIntegrationPlugin.java @@ -1,5 +1,7 @@ package forestry.core.recipes.jei; +import javax.annotation.Nonnull; + import forestry.factory.gui.ContainerWorktable; import forestry.factory.recipes.jei.bottler.BottlerRecipeCategory; import forestry.factory.recipes.jei.bottler.BottlerRecipeHandler; @@ -27,34 +29,20 @@ import forestry.factory.recipes.jei.squeezer.SqueezerRecipeWrapper; import forestry.factory.recipes.jei.still.StillRecipeCategory; import forestry.factory.recipes.jei.still.StillRecipeHandler; import forestry.factory.recipes.jei.still.StillRecipeMaker; + +import mezz.jei.api.BlankModPlugin; import mezz.jei.api.IGuiHelper; -import mezz.jei.api.IItemRegistry; import mezz.jei.api.IJeiHelpers; -import mezz.jei.api.IModPlugin; import mezz.jei.api.IModRegistry; -import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.JEIPlugin; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry; @JEIPlugin -public class JEIIntegrationPlugin implements IModPlugin{ - - private IItemRegistry itemRegistry; - private IJeiHelpers jeiHelpers; - +public class JEIIntegrationPlugin extends BlankModPlugin { @Override - public void onJeiHelpersAvailable(IJeiHelpers jeiHelpers) { - this.jeiHelpers = jeiHelpers; - } - - @Override - public void onItemRegistryAvailable(IItemRegistry itemRegistry) { - this.itemRegistry = itemRegistry; - } - - @Override - public void register(IModRegistry registry) { + public void register(@Nonnull IModRegistry registry) { + IJeiHelpers jeiHelpers = registry.getJeiHelpers(); IGuiHelper guiHelper = jeiHelpers.getGuiHelper(); registry.addRecipeCategories(new BottlerRecipeCategory(guiHelper), @@ -73,8 +61,8 @@ public class JEIIntegrationPlugin implements IModPlugin{ new FabricatorRecipeHandler(), new FermenterRecipeHandler(), new MoistenerRecipeHandler(), - new SqueezerRecipeHandler(SqueezerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER), - new SqueezerRecipeHandler(SqueezerContainerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER_CONTAINER), + new SqueezerRecipeHandler<>(SqueezerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER), + new SqueezerRecipeHandler<>(SqueezerContainerRecipeWrapper.class, ForestryRecipeCategoryUid.SQUEEZER_CONTAINER), new StillRecipeHandler()); registry.addRecipes(BottlerRecipeMaker.getBottlerRecipes()); @@ -87,13 +75,7 @@ public class JEIIntegrationPlugin implements IModPlugin{ registry.addRecipes(SqueezerRecipeMaker.getSqueezerContainerRecipes()); registry.addRecipes(StillRecipeMaker.getStillRecipes()); - IRecipeTransferRegistry transferTegistry = registry.getRecipeTransferRegistry(); - transferTegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 19, 9, 1, 36); - + IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry(); + transferRegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 19, 9, 1, 36); } - - @Override - public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) { - } - } diff --git a/src/main/java/forestry/core/render/ParticleHelper.java b/src/main/java/forestry/core/render/ParticleHelper.java index dddd35b47..1364f5352 100644 --- a/src/main/java/forestry/core/render/ParticleHelper.java +++ b/src/main/java/forestry/core/render/ParticleHelper.java @@ -67,7 +67,7 @@ public class ParticleHelper { EntityDiggingFX fx = (EntityDiggingFX) effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(), px, py, pz, 0.0D, 0.0D, 0.0D, Block.getStateId(state)); callback.addHitEffects(fx, target.getBlockPos(), state); - effectRenderer.addEffect(fx.func_174846_a(new BlockPos(x, y, z)).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); + effectRenderer.addEffect(fx.setBlockPos(new BlockPos(x, y, z)).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); return true; } @@ -78,13 +78,6 @@ public class ParticleHelper { * your block. So be sure to do proper sanity checks before assuming that * the location is this block. * - * @param world The current world - * @param x X position to spawn the particle - * @param y Y position to spawn the particle - * @param z Z position to spawn the particle - * @param meta The metadata for the block before it was destroyed. - * @param effectRenderer A reference to the current effect renderer. - * @param callback * @return True to prevent vanilla break particles from spawning. */ @SideOnly(Side.CLIENT) @@ -104,7 +97,7 @@ public class ParticleHelper { EntityDiggingFX fx = (EntityDiggingFX) effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), px, py, pz, px - pos.getX() - 0.5D, py - pos.getY() - 0.5D, pz - pos.getZ() - 0.5D, Block.getStateId(state)); callback.addDestroyEffects(fx, pos, state); - effectRenderer.addEffect(fx.func_174846_a(pos)); + effectRenderer.addEffect(fx.setBlockPos(pos)); } } } diff --git a/src/main/java/forestry/core/tiles/TilePowered.java b/src/main/java/forestry/core/tiles/TilePowered.java index 0e69dbcff..2cc298f3f 100644 --- a/src/main/java/forestry/core/tiles/TilePowered.java +++ b/src/main/java/forestry/core/tiles/TilePowered.java @@ -27,9 +27,10 @@ import forestry.energy.EnergyManager; import net.minecraftforge.fml.common.Optional; import buildcraft.api.tiles.IHasWork; +import cofh.api.energy.IEnergyReceiver; @Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") -public abstract class TilePowered extends TileBase implements IRenderableTile, IPowerHandler, IHasWork, ISpeedUpgradable, IStreamableGui { +public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, IHasWork, ISpeedUpgradable, IStreamableGui { private static final int WORK_TICK_INTERVAL = 5; // one Forestry work tick happens every WORK_TICK_INTERVAL game ticks private final EnergyManager energyManager; @@ -201,11 +202,6 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I return energyManager.receiveEnergy(from, maxReceive, simulate); } - @Override - public int extractEnergy(EnumFacing from, int maxReceive, boolean simulate) { - return energyManager.extractEnergy(from, maxReceive, simulate); - } - @Override public int getEnergyStored(EnumFacing from) { return energyManager.getEnergyStored(from); diff --git a/src/main/java/forestry/core/triggers/Trigger.java b/src/main/java/forestry/core/triggers/Trigger.java index 007974991..b20a4f02f 100755 --- a/src/main/java/forestry/core/triggers/Trigger.java +++ b/src/main/java/forestry/core/triggers/Trigger.java @@ -13,10 +13,8 @@ package forestry.core.triggers; import forestry.core.render.TextureManager; import forestry.core.utils.StringUtil; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import buildcraft.api.core.SheetIcon; import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; import buildcraft.api.statements.ITriggerExternal; @@ -64,17 +62,15 @@ public abstract class Trigger implements ITriggerExternal { @SideOnly(Side.CLIENT) private TextureAtlasSprite icon; - private ResourceLocation location; - - @Override - public SheetIcon getIcon() { - return new SheetIcon(location, icon.getOriginX(), icon.getOriginY()); - } @SideOnly(Side.CLIENT) public void registerIcons() { icon = TextureManager.registerSprite("triggers/" + unlocalized.replace("trigger.", "")); - location = new ResourceLocation("forestry", "triggers/" + unlocalized.replace("trigger.", "")); + } + + @Override + public TextureAtlasSprite getGuiSprite() { + return icon; } @Override diff --git a/src/main/java/forestry/core/utils/DamageSourceForestry.java b/src/main/java/forestry/core/utils/DamageSourceForestry.java index 1d2113d06..699f4e176 100755 --- a/src/main/java/forestry/core/utils/DamageSourceForestry.java +++ b/src/main/java/forestry/core/utils/DamageSourceForestry.java @@ -24,7 +24,7 @@ public class DamageSourceForestry extends DamageSource { @Override public IChatComponent getDeathMessage(EntityLivingBase living) { - EntityLivingBase other = living.func_94060_bK(); + EntityLivingBase other = living.getAttackingEntity(); String ssp = "death." + this.damageType; String smp = ssp + ".player"; diff --git a/src/main/java/forestry/energy/EnergyManager.java b/src/main/java/forestry/energy/EnergyManager.java index 3aa0994f0..91db8f799 100644 --- a/src/main/java/forestry/energy/EnergyManager.java +++ b/src/main/java/forestry/energy/EnergyManager.java @@ -14,9 +14,10 @@ import forestry.core.utils.BlockUtil; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyReceiver; -public class EnergyManager implements IEnergyHandler, IStreamable { +public class EnergyManager implements IEnergyHandler, IEnergyReceiver, IEnergyProvider, IStreamable { private enum EnergyTransferMode { EXTRACT, RECEIVE, BOTH } diff --git a/src/main/java/forestry/energy/blocks/BlockEngineType.java b/src/main/java/forestry/energy/blocks/BlockEngineType.java index 5c04cbc55..a64631ec2 100644 --- a/src/main/java/forestry/energy/blocks/BlockEngineType.java +++ b/src/main/java/forestry/energy/blocks/BlockEngineType.java @@ -12,28 +12,19 @@ package forestry.energy.blocks; import java.util.Locale; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; + import forestry.core.blocks.IMachinePropertiesTESR; import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; import forestry.core.tiles.TileForestry; import forestry.energy.tiles.TileEngineBiogas; import forestry.energy.tiles.TileEngineClockwork; -import forestry.energy.tiles.TileEngineElectric; import forestry.energy.tiles.TileEnginePeat; -import forestry.energy.tiles.TileGenerator; import forestry.plugins.PluginEnergy; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; public enum BlockEngineType implements IMachinePropertiesTESR { - ELECTRIC(TileEngineElectric.class, "EngineTin", "/engine_tin_"), PEAT(TileEnginePeat.class, "EngineCopper", "/engine_copper_"), BIOGAS(TileEngineBiogas.class, "EngineBronze", "/engine_bronze_"), - GENERATOR(TileGenerator.class, "Generator", "/generator_") { - @Override - public TileEntitySpecialRenderer getRenderer() { - return Proxies.render.getRenderDefaultMachine(texturePath); - } - }, CLOCKWORK(TileEngineClockwork.class, "EngineClockwork", "/engine_clock_"); public static final BlockEngineType[] VALUES = values(); diff --git a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java b/src/main/java/forestry/energy/circuits/CircuitElectricChange.java deleted file mode 100755 index cecb6f416..000000000 --- a/src/main/java/forestry/energy/circuits/CircuitElectricChange.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.circuits; - -import forestry.core.circuits.Circuit; -import forestry.energy.tiles.TileEngineElectric; - -public abstract class CircuitElectricChange extends Circuit { - - private int euChange = 7; - private int rfChange = 20; - - protected CircuitElectricChange(String uid, boolean requiresDiscovery) { - super(uid, requiresDiscovery); - } - - protected void configureChange(int euChange, int rfChange) { - this.euChange = euChange; - this.rfChange = rfChange; - } - - @Override - public boolean isCircuitable(Object tile) { - return tile instanceof TileEngineElectric; - } - - @Override - public void onInsertion(int slot, Object tile) { - if (!isCircuitable(tile)) { - return; - } - - TileEngineElectric engine = (TileEngineElectric) tile; - engine.changeEnergyConfig(euChange, rfChange, 2 * euChange); - } - - @Override - public void onLoad(int slot, Object tile) { - onInsertion(slot, tile); - } - - @Override - public void onRemoval(int slot, Object tile) { - if (!isCircuitable(tile)) { - return; - } - - TileEngineElectric engine = (TileEngineElectric) tile; - engine.changeEnergyConfig(-euChange, -rfChange, -(2 * euChange)); - } - - @Override - public void onTick(int slot, Object tile) { - } -} diff --git a/src/main/java/forestry/energy/gui/ContainerEngineElectric.java b/src/main/java/forestry/energy/gui/ContainerEngineElectric.java deleted file mode 100644 index 3d43aeeda..000000000 --- a/src/main/java/forestry/energy/gui/ContainerEngineElectric.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; - -import forestry.core.gui.ContainerSocketed; -import forestry.core.gui.slots.SlotFiltered; -import forestry.energy.tiles.InventoryEngineElectric; -import forestry.energy.tiles.TileEngineElectric; - -public class ContainerEngineElectric extends ContainerSocketed { - - public ContainerEngineElectric(InventoryPlayer player, TileEngineElectric tile) { - super(tile, player, 8, 84); - - this.addSlotToContainer(new SlotFiltered(tile, InventoryEngineElectric.SLOT_BATTERY, 84, 53)); - } - - @Override - public void updateProgressBar(int i, int j) { - if (tile != null) { - tile.getGUINetworkData(i, j); - } - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - - if (tile == null) { - return; - } - - for (Object crafter : crafters) { - tile.sendGUINetworkData(this, (ICrafting) crafter); - } - } - -} diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java deleted file mode 100755 index fc10d9e64..000000000 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; - -import forestry.core.gui.ContainerLiquidTanks; -import forestry.core.gui.slots.SlotFiltered; -import forestry.energy.inventory.InventoryGenerator; -import forestry.energy.tiles.TileGenerator; - -public class ContainerGenerator extends ContainerLiquidTanks { - - public ContainerGenerator(InventoryPlayer player, TileGenerator tile) { - super(tile, player, 8, 84); - - this.addSlotToContainer(new SlotFiltered(tile, InventoryGenerator.SLOT_CAN, 22, 38)); - } - - @Override - public void updateProgressBar(int messageId, int data) { - super.updateProgressBar(messageId, data); - - tile.getGUINetworkData(messageId, data); - } - - @Override - @SuppressWarnings("unchecked") - public void detectAndSendChanges() { - super.detectAndSendChanges(); - - for (Object crafter : crafters) { - tile.sendGUINetworkData(this, (ICrafting) crafter); - } - } -} diff --git a/src/main/java/forestry/energy/gui/GuiEngineElectric.java b/src/main/java/forestry/energy/gui/GuiEngineElectric.java deleted file mode 100644 index 9e5cdaef8..000000000 --- a/src/main/java/forestry/energy/gui/GuiEngineElectric.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.gui; - -import net.minecraft.entity.player.InventoryPlayer; - -import forestry.core.config.Constants; -import forestry.core.gui.widgets.SocketWidget; -import forestry.core.render.EnumTankLevel; -import forestry.energy.tiles.TileEngineElectric; - -public class GuiEngineElectric extends GuiEngine { - - public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) { - super(Constants.TEXTURE_PATH_GUI + "/electricalengine.png", new ContainerEngineElectric(inventory, tile), tile); - widgetManager.add(new SocketWidget(this.widgetManager, 30, 40, tile, 0)); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); - - TileEngineElectric engine = inventory; - int storageHeight = engine.getStorageScaled(46); - int storageMaxHeight = engine.getStorageScaled(100); - EnumTankLevel rated = EnumTankLevel.rateTankLevel(storageMaxHeight); - - drawHealthMeter(guiLeft + 74, guiTop + 25, storageHeight, rated); - } - - private void drawHealthMeter(int x, int y, int height, EnumTankLevel rated) { - int i = 176 + rated.getLevelScaled(16); - int k = 0; - - this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height); - } - -} diff --git a/src/main/java/forestry/energy/gui/GuiGenerator.java b/src/main/java/forestry/energy/gui/GuiGenerator.java deleted file mode 100755 index 01b536bf7..000000000 --- a/src/main/java/forestry/energy/gui/GuiGenerator.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.gui; - -import net.minecraft.entity.player.InventoryPlayer; - -import forestry.core.config.Constants; -import forestry.core.gui.GuiForestryTitled; -import forestry.core.gui.widgets.TankWidget; -import forestry.energy.tiles.TileGenerator; - -public class GuiGenerator extends GuiForestryTitled { - - public GuiGenerator(InventoryPlayer inventory, TileGenerator tile) { - super(Constants.TEXTURE_PATH_GUI + "/generator.png", new ContainerGenerator(inventory, tile), tile); - widgetManager.add(new TankWidget(this.widgetManager, 49, 17, 0)); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { - super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); - - int progress = inventory.getStoredScaled(49); - if (progress > 0) { - drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); - } - } - -} diff --git a/src/main/java/forestry/energy/inventory/InventoryGenerator.java b/src/main/java/forestry/energy/inventory/InventoryGenerator.java deleted file mode 100644 index 457e5e269..000000000 --- a/src/main/java/forestry/energy/inventory/InventoryGenerator.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.inventory; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; - -import forestry.core.fluids.FluidHelper; -import forestry.core.inventory.InventoryAdapterTile; -import forestry.energy.tiles.TileGenerator; - -public class InventoryGenerator extends InventoryAdapterTile { - public static final short SLOT_CAN = 0; - - public InventoryGenerator(TileGenerator generator) { - super(generator, 1, "Items"); - } - - @Override - public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { - if (slotIndex == SLOT_CAN) { - Fluid fluid = FluidHelper.getFluidInContainer(itemStack); - return tile.getTankManager().accepts(fluid); - } - - return false; - } -} diff --git a/src/main/java/forestry/energy/tiles/TileEngineElectric.java b/src/main/java/forestry/energy/tiles/TileEngineElectric.java deleted file mode 100644 index fe4b672f6..000000000 --- a/src/main/java/forestry/energy/tiles/TileEngineElectric.java +++ /dev/null @@ -1,316 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.tiles; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.CircuitSocketType; -import forestry.api.circuits.ICircuitBoard; -import forestry.api.circuits.ICircuitSocketType; -import forestry.api.core.IErrorLogic; -import forestry.core.circuits.ISocketable; -import forestry.core.config.Constants; -import forestry.core.errors.EnumErrorCode; -import forestry.core.inventory.InventoryAdapter; -import forestry.core.tiles.TemperatureState; -import forestry.core.tiles.TileEngine; -import forestry.energy.gui.ContainerEngineElectric; -import forestry.energy.gui.GuiEngineElectric; -import forestry.plugins.compat.PluginIC2; -import ic2.api.energy.prefab.BasicSink; - -public class TileEngineElectric extends TileEngine implements ISocketable, IInventory { - protected static class EuConfig { - - public int euForCycle; - public int rfPerCycle; - public int euStorage; - - public EuConfig() { - this.euForCycle = Constants.ENGINE_TIN_EU_FOR_CYCLE; - this.rfPerCycle = Constants.ENGINE_TIN_ENERGY_PER_CYCLE; - this.euStorage = Constants.ENGINE_TIN_MAX_EU_STORED; - } - } - - private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); - private final EuConfig euConfig = new EuConfig(); - - private BasicSink ic2EnergySink; - - public TileEngineElectric() { - super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000); - - setInternalInventory(new InventoryEngineElectric(this)); - - if (PluginIC2.instance.isAvailable()) { - ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); - } - } - - // / SAVING / LOADING - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - if (ic2EnergySink != null) { - ic2EnergySink.readFromNBT(nbttagcompound); - } - sockets.readFromNBT(nbttagcompound); - - ItemStack chip = sockets.getStackInSlot(0); - if (chip != null) { - ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(chip); - if (chipset != null) { - chipset.onLoad(this); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - if (ic2EnergySink != null) { - ic2EnergySink.writeToNBT(nbttagcompound); - } - sockets.writeToNBT(nbttagcompound); - } - - @Override - public void onChunkUnload() { - if (ic2EnergySink != null) { - ic2EnergySink.onChunkUnload(); - } - - super.onChunkUnload(); - } - - @Override - public void invalidate() { - if (ic2EnergySink != null) { - ic2EnergySink.invalidate(); - } - - super.invalidate(); - } - - // / HEAT MANAGEMENT - @Override - public int dissipateHeat() { - if (heat <= 0) { - return 0; - } - - int loss = 0; - - if (!isBurning() || !isRedstoneActivated()) { - loss += 1; - } - - TemperatureState tempState = getTemperatureState(); - if (tempState == TemperatureState.OVERHEATING || tempState == TemperatureState.OPERATING_TEMPERATURE) { - loss += 1; - } - - heat -= loss; - return loss; - } - - @Override - public int generateHeat() { - - int gain = 0; - if (isRedstoneActivated() && isBurning()) { - gain++; - if (((double) energyManager.getTotalEnergyStored() / (double) energyManager.getMaxEnergyStored()) > 0.5) { - gain++; - } - } - - addHeat(gain); - return gain; - } - - // / WORK - @Override - public void updateServerSide() { - IErrorLogic errorLogic = getErrorLogic(); - - // No work to be done if IC2 is unavailable. - if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) { - return; - } - - ic2EnergySink.update(); - - super.updateServerSide(); - - if (forceCooldown) { - return; - } - - if (getStackInSlot(InventoryEngineElectric.SLOT_BATTERY) != null) { - replenishFromBattery(InventoryEngineElectric.SLOT_BATTERY); - } - - // Updating of gui delayed to prevent it from going crazy - if (!updateOnInterval(80)) { - return; - } - - boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle); - errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL); - } - - @Override - public void burn() { - - currentOutput = 0; - - if (!isRedstoneActivated()) { - return; - } - - if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { - currentOutput = euConfig.rfPerCycle; - energyManager.generateEnergy(euConfig.rfPerCycle); - } - - } - - private void replenishFromBattery(int slot) { - if (!isRedstoneActivated()) { - return; - } - - ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3); - } - - // / STATE INFORMATION - @Override - protected boolean isBurning() { - return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); - } - - public int getStorageScaled(int i) { - if (ic2EnergySink == null) { - return 0; - } - - return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); - } - - // / SMP GUI - @Override - public void getGUINetworkData(int i, int j) { - - switch (i) { - - case 0: - currentOutput = j; - break; - case 1: - energyManager.fromGuiInt(j); - break; - case 2: - heat = j; - break; - case 3: - if (ic2EnergySink != null) { - ic2EnergySink.setEnergyStored(j); - } - break; - } - - } - - @Override - public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) { - iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput); - iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toGuiInt()); - iCrafting.sendProgressBarUpdate(containerEngine, 2, heat); - if (ic2EnergySink != null) { - iCrafting.sendProgressBarUpdate(containerEngine, 3, (short) ic2EnergySink.getEnergyStored()); - } - } - - // / ENERGY CONFIG CHANGE - public void changeEnergyConfig(int euChange, int rfChange, int storageChange) { - euConfig.euForCycle += euChange; - euConfig.rfPerCycle += rfChange; - euConfig.euStorage += storageChange; - - if (ic2EnergySink != null) { - ic2EnergySink.setCapacity(euConfig.euStorage); - } - } - - /* ISocketable */ - @Override - public int getSocketCount() { - return sockets.getSizeInventory(); - } - - @Override - public ItemStack getSocket(int slot) { - return sockets.getStackInSlot(slot); - } - - @Override - public void setSocket(int slot, ItemStack stack) { - - if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) { - return; - } - - // Dispose correctly of old chipsets - if (sockets.getStackInSlot(slot) != null) { - if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) { - ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(sockets.getStackInSlot(slot)); - if (chipset != null) { - chipset.onRemoval(this); - } - } - } - - sockets.setInventorySlotContents(slot, stack); - if (stack == null) { - return; - } - - ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack); - if (chipset != null) { - chipset.onInsertion(this); - } - } - - @Override - public ICircuitSocketType getSocketType() { - return CircuitSocketType.ELECTRIC_ENGINE; - } - - @Override - public Object getGui(EntityPlayer player, int data) { - return new GuiEngineElectric(player.inventory, this); - } - - @Override - public Object getContainer(EntityPlayer player, int data) { - return new ContainerEngineElectric(player.inventory, this); - } -} diff --git a/src/main/java/forestry/energy/tiles/TileGenerator.java b/src/main/java/forestry/energy/tiles/TileGenerator.java deleted file mode 100644 index 499f4c4df..000000000 --- a/src/main/java/forestry/energy/tiles/TileGenerator.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.energy.tiles; - -import java.io.IOException; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - -import forestry.api.core.IErrorLogic; -import forestry.api.fuels.FuelManager; -import forestry.api.fuels.GeneratorFuel; -import forestry.core.config.Constants; -import forestry.core.errors.EnumErrorCode; -import forestry.core.fluids.FluidHelper; -import forestry.core.fluids.TankManager; -import forestry.core.fluids.tanks.FilteredTank; -import forestry.core.network.DataInputStreamForestry; -import forestry.core.network.DataOutputStreamForestry; -import forestry.core.render.TankRenderInfo; -import forestry.core.tiles.ILiquidTankTile; -import forestry.core.tiles.IRenderableTile; -import forestry.core.tiles.TileBase; -import forestry.energy.gui.ContainerGenerator; -import forestry.energy.gui.GuiGenerator; -import forestry.energy.inventory.InventoryGenerator; -import forestry.plugins.compat.PluginIC2; -import ic2.api.energy.prefab.BasicSource; - -public class TileGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile { - private static final int maxEnergy = 30000; - - private final TankManager tankManager; - private final FilteredTank resourceTank; - - private int tickCount = 0; - - private BasicSource ic2EnergySource; - - public TileGenerator() { - super("generator"); - - setInternalInventory(new InventoryGenerator(this)); - - resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet()); - tankManager = new TankManager(this, resourceTank); - - if (PluginIC2.instance.isAvailable()) { - ic2EnergySource = new BasicSource(this, maxEnergy, 1); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) { - super.writeToNBT(nbttagcompound); - - if (ic2EnergySource != null) { - ic2EnergySource.writeToNBT(nbttagcompound); - } - - tankManager.writeToNBT(nbttagcompound); - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - - if (ic2EnergySource != null) { - ic2EnergySource.readFromNBT(nbttagcompound); - } - - tankManager.readFromNBT(nbttagcompound); - } - - @Override - public void writeData(DataOutputStreamForestry data) throws IOException { - super.writeData(data); - tankManager.writeData(data); - } - - @Override - public void readData(DataInputStreamForestry data) throws IOException { - super.readData(data); - tankManager.readData(data); - } - - @Override - public void onChunkUnload() { - if (ic2EnergySource != null) { - ic2EnergySource.onChunkUnload(); - } - - super.onChunkUnload(); - } - - @Override - public void invalidate() { - if (ic2EnergySource != null) { - ic2EnergySource.invalidate(); - } - - super.invalidate(); - } - - @Override - public void updateServerSide() { - if (updateOnInterval(20)) { - FluidHelper.drainContainers(tankManager, this, InventoryGenerator.SLOT_CAN); - } - - IErrorLogic errorLogic = getErrorLogic(); - - // No work to be done if IC2 is unavailable. - if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) { - return; - } - - ic2EnergySource.update(); - - if (resourceTank.getFluidAmount() > 0) { - GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); - if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) { - ic2EnergySource.addEnergy(fuel.eu); - this.tickCount++; - - if (tickCount >= fuel.rate) { - tickCount = 0; - resourceTank.drain(fuel.fuelConsumed.amount, true); - } - } - - } - - boolean hasFuel = resourceTank.getFluidAmount() > 0; - errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL); - } - - public boolean isWorking() { - return resourceTank.getFluidAmount() > 0; - } - - public int getResourceScaled(int i) { - return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY; - } - - public int getStoredScaled(int i) { - if (ic2EnergySource == null) { - return 0; - } - - return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; - } - - @Override - public TankRenderInfo getResourceTankInfo() { - return new TankRenderInfo(resourceTank); - } - - @Override - public TankRenderInfo getProductTankInfo() { - return TankRenderInfo.EMPTY; - } - - /* SMP GUI */ - public void getGUINetworkData(int i, int j) { - if (i == 0) { - if (ic2EnergySource != null) { - ic2EnergySource.setEnergyStored(j); - } - } - } - - public void sendGUINetworkData(Container container, ICrafting iCrafting) { - if (ic2EnergySource != null) { - iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); - } - } - - /* ILiquidTankTile */ - @Override - public int fill(EnumFacing from, FluidStack resource, boolean doFill) { - return tankManager.fill(from, resource, doFill); - } - - @Override - public TankManager getTankManager() { - return tankManager; - } - - @Override - public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { - return tankManager.drain(from, resource, doDrain); - } - - @Override - public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { - return tankManager.drain(from, maxDrain, doDrain); - } - - @Override - public boolean canFill(EnumFacing from, Fluid fluid) { - return tankManager.canFill(from, fluid); - } - - @Override - public boolean canDrain(EnumFacing from, Fluid fluid) { - return tankManager.canDrain(from, fluid); - } - - @Override - public FluidTankInfo[] getTankInfo(EnumFacing from) { - return tankManager.getTankInfo(from); - } - - @Override - public Object getGui(EntityPlayer player, int data) { - return new GuiGenerator(player.inventory, this); - } - - @Override - public Object getContainer(EntityPlayer player, int data) { - return new ContainerGenerator(player.inventory, this); - } -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideBottler.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideBottler.java deleted file mode 100644 index 43f305c96..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideBottler.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidContainerRegistry; - -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.factory.recipes.BottlerRecipe; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideBottler implements RecipeProvider { - - private final Slot[] slots = new Slot[4]; - - public CraftGuideBottler() { - slots[0] = new ItemSlot(12, 12, 16, 16).drawOwnBackground(); - slots[1] = new LiquidSlot(12, 30); - slots[2] = new ItemSlot(50, 21, 16, 16).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); - slots[3] = new ItemSlot(31, 21, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.BOTTLER); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (FluidContainerRegistry.FluidContainerData container : FluidContainerRegistry.getRegisteredFluidContainerData()) { - BottlerRecipe recipe = BottlerRecipe.getRecipe(container.fluid, container.emptyContainer); - if (recipe != null) { - Object[] array = new Object[4]; - - array[0] = recipe.empty; - array[1] = recipe.input; - array[2] = recipe.filled; - array[3] = machine; - generator.addRecipe(template, array); - } - } - } -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCarpenter.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCarpenter.java deleted file mode 100644 index eb259cc83..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCarpenter.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.ICarpenterRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.core.recipes.RecipeUtil; -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideCarpenter implements RecipeProvider { - - private final Slot[] slots = new Slot[12]; - - public CraftGuideCarpenter() { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); - } - } - slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); - slots[10] = new LiquidSlot(59, 39); - slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.CARPENTER); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) { - Object[] array = new Object[12]; - - Object[] flattened = RecipeUtil.getCraftingRecipeAsArray(recipe.getCraftingGridRecipe()); - if (flattened == null) { - flattened = generator.getCraftingRecipe(recipe.getCraftingGridRecipe()); - } - if (flattened == null) { - continue; - } - System.arraycopy(flattened, 0, array, 0, flattened.length); - if (recipe.getFluidResource() != null) { - array[10] = recipe.getFluidResource(); - } - array[11] = machine; - generator.addRecipe(template, array); - } - } - -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCentrifuge.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCentrifuge.java deleted file mode 100644 index c1b1e81dc..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideCentrifuge.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.ICentrifugeRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ChanceSlot; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideCentrifuge implements RecipeProvider { - - private final Slot[] slots = new Slot[11]; - - public CraftGuideCentrifuge() { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - slots[i + j * 3] = new ChanceSlot(i * 18 + 24, j * 18 + 3, 16, 16).setRatio(100).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); - } - } - slots[9] = new ItemSlot(4, 31, 16, 16, true).drawOwnBackground(); - slots[10] = new ItemSlot(4, 11, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.CENTRIFUGE); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) { - Object[] array = new Object[11]; - - List> entries = new ArrayList<>(recipe.getAllProducts().entrySet()); - - for (int i = 0; i < Math.min(entries.size(), 9); i++) { - Entry entry = entries.get(i); - array[i] = entry.getValue() > 0 ? new Object[]{entry.getKey(), entry.getValue()} : null; - } - - array[9] = recipe.getInput(); - array[10] = machine; - - generator.addRecipe(template, array); - } - } -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFabricator.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFabricator.java deleted file mode 100644 index cc07c1808..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFabricator.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.IFabricatorRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.factory.blocks.BlockFactoryPlainType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideFabricator implements RecipeProvider { - - private final Slot[] slots = new Slot[12]; - - public CraftGuideFabricator() { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); - } - } - slots[9] = new ItemSlot(59, 21, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); - slots[10] = new LiquidSlot(59, 39); - slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - if (PluginFactory.blocks.factoryPlain == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryPlain.get(BlockFactoryPlainType.FABRICATOR); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (IFabricatorRecipe recipe : RecipeManagers.fabricatorManager.recipes()) { - Object[] array = new Object[12]; - - Object[] recipeIngredients = recipe.getIngredients(); - if (recipeIngredients == null) { - continue; - } - - System.arraycopy(recipeIngredients, 0, array, 0, recipeIngredients.length); - array[9] = recipe.getRecipeOutput(); - - if (recipe.getLiquid() != null) { - array[10] = recipe.getLiquid(); - } - array[11] = machine; - generator.addRecipe(template, array); - } - } - -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFermenter.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFermenter.java deleted file mode 100644 index 63aae2acc..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideFermenter.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -import forestry.api.fuels.FuelManager; -import forestry.api.recipes.IFermenterRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideFermenter implements RecipeProvider { - - private final Slot[] slots = new Slot[5]; - - public CraftGuideFermenter() { - slots[0] = new ItemSlot(3, 12, 16, 16, true); - slots[1] = new ItemSlot(3, 30, 16, 16, true); - slots[2] = new LiquidSlot(21, 21); - slots[3] = new LiquidSlot(59, 21).setSlotType(SlotType.OUTPUT_SLOT); - slots[4] = new ItemSlot(40, 21, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.FERMENTER); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - List fuels = new ArrayList(FuelManager.fermenterFuel.keySet()); - - for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) { - Object[] array = new Object[5]; - - array[0] = recipe.getResource(); - array[1] = fuels; - array[2] = recipe.getFluidResource(); - int amount = Math.round(recipe.getFermentationValue() * recipe.getModifier()); - FluidStack output = new FluidStack(recipe.getOutput(), amount); - array[3] = output; - array[4] = machine; - generator.addRecipe(template, array); - } - } -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideSqueezer.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideSqueezer.java deleted file mode 100644 index 5a38c982f..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideSqueezer.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.ISqueezerRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ChanceSlot; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideSqueezer implements RecipeProvider { - - private final Slot[] slots = new Slot[12]; - - public CraftGuideSqueezer() { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - slots[i + j * 3] = new ItemSlot(i * 18 + 3, j * 18 + 3, 16, 16).drawOwnBackground(); - } - } - slots[9] = new ChanceSlot(59, 39, 16, 16, true).setRatio(100).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(); - slots[10] = new LiquidSlot(59, 21).setSlotType(SlotType.OUTPUT_SLOT); - slots[11] = new ItemSlot(59, 3, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.SQUEEZER); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (ISqueezerRecipe recipe : RecipeManagers.squeezerManager.recipes()) { - Object[] array = new Object[12]; - - System.arraycopy(recipe.getResources(), 0, array, 0, recipe.getResources().length); - if (recipe.getRemnants() != null) { - array[9] = recipe.getRemnantsChance() > 0 ? new Object[]{recipe.getRemnants().copy(), recipe.getRemnantsChance()} : null; - } - if (recipe.getFluidOutput() != null) { - array[10] = recipe.getFluidOutput(); - } - array[11] = machine; - generator.addRecipe(template, array); - } - } - -} diff --git a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideStill.java b/src/main/java/forestry/factory/recipes/craftguide/CraftGuideStill.java deleted file mode 100644 index 75375aa71..000000000 --- a/src/main/java/forestry/factory/recipes/craftguide/CraftGuideStill.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.factory.recipes.craftguide; - -import net.minecraft.item.ItemStack; - -import forestry.api.recipes.IStillRecipe; -import forestry.api.recipes.RecipeManagers; -import forestry.factory.blocks.BlockFactoryTesrType; -import forestry.plugins.PluginFactory; - -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.LiquidSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class CraftGuideStill implements RecipeProvider { - - private final Slot[] slots = new Slot[3]; - - public CraftGuideStill() { - slots[0] = new LiquidSlot(12, 21); - slots[1] = new LiquidSlot(50, 21).setSlotType(SlotType.OUTPUT_SLOT); - slots[2] = new ItemSlot(31, 21, 16, 16).setSlotType(SlotType.MACHINE_SLOT); - } - - @Override - public void generateRecipes(RecipeGenerator generator) { - if (PluginFactory.blocks.factoryTESR == null) { - return; - } - - ItemStack machine = PluginFactory.blocks.factoryTESR.get(BlockFactoryTesrType.STILL); - RecipeTemplate template = generator.createRecipeTemplate(slots, machine); - - for (IStillRecipe recipe : RecipeManagers.stillManager.recipes()) { - Object[] array = new Object[3]; - - array[0] = recipe.getInput(); - array[1] = recipe.getOutput(); - array[2] = machine; - generator.addRecipe(template, array); - } - } -} diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java deleted file mode 100644 index ca0d5014e..000000000 --- a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java +++ /dev/null @@ -1,28 +0,0 @@ -package forestry.farming.logic; - -import forestry.core.utils.vect.Vect; -import forestry.plugins.compat.PluginIC2; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import java.util.Collection; - -public class CropBasicIC2Crop extends Crop { - private final TileEntity tileEntity; - - public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) { - super(world, position); - this.tileEntity = tileEntity; - } - - @Override - protected boolean isCrop(Vect pos) { - return PluginIC2.instance.canHarvestCrop(this.tileEntity); - } - - @Override - protected Collection harvestBlock(Vect pos) { - return PluginIC2.instance.getCropDrops(this.tileEntity); - } -} diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java deleted file mode 100755 index 345ae1078..000000000 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.farming.logic; - -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import forestry.core.config.Constants; -import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; -import forestry.plugins.compat.PluginIC2; - -public class CropRubber extends CropBlock { - - public CropRubber(World world, Block block, int meta, Vect position) { - super(world, block, meta, position); - } - - @Override - protected Collection harvestBlock(Vect pos) { - Collection harvested = new ArrayList<>(); - harvested.add(PluginIC2.resin.copy()); - Proxies.common.addBlockDestroyEffects(world, pos, block.getStateFromMeta(0)); - world.setBlockState(pos, block.getStateFromMeta(meta + 6), Constants.FLAG_BLOCK_SYNCH); - return harvested; - } - -} diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java deleted file mode 100755 index 960b5aec1..000000000 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.farming.logic; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.Stack; - -import net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.Log; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; -import forestry.plugins.compat.PluginIC2; - -public class FarmLogicRubber extends FarmLogic { - - private boolean inActive; - - public FarmLogicRubber(IFarmHousing housing) { - super(housing); - if (PluginIC2.rubberwood == null || PluginIC2.resin == null) { - Log.warning("Failed to init a farm logic %s since IC2 was not found", getClass().getName()); - inActive = true; - } - } - - @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - if (!inActive) { - return PluginIC2.resin.getItem(); - } else { - return Items.gunpowder; - } - } - - @Override - public String getName() { - return "Rubber Plantation"; - } - - @Override - public int getFertilizerConsumption() { - return 40; - } - - @Override - public int getWaterConsumption(float hydrationModifier) { - return (int) (5 * hydrationModifier); - } - - @Override - public boolean isAcceptedResource(ItemStack itemstack) { - return false; - } - - @Override - public boolean isAcceptedGermling(ItemStack itemstack) { - return false; - } - - @Override - public boolean isAcceptedWindfall(ItemStack stack) { - return false; - } - - @Override - public Collection collect() { - return null; - } - - @Override - public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) { - return false; - } - - private final HashMap lastExtents = new HashMap<>(); - - @Override - public Collection harvest(BlockPos pos, FarmDirection direction, int extent) { - if (inActive) { - return null; - } - - Vect start = new Vect(pos); - if (!lastExtents.containsKey(start)) { - lastExtents.put(start, 0); - } - - int lastExtent = lastExtents.get(start); - if (lastExtent > extent) { - lastExtent = 0; - } - - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); - Collection crops = getHarvestBlocks(position); - lastExtent++; - lastExtents.put(start, lastExtent); - - return crops; - } - - private Collection getHarvestBlocks(Vect position) { - - Set seen = new HashSet<>(); - Stack crops = new Stack<>(); - - World world = getWorld(); - - // Determine what type we want to harvest. - Block block = VectUtil.getBlock(world, position); - if (!ItemStackUtil.equals(block, PluginIC2.rubberwood)) { - return crops; - } - - int meta = VectUtil.getBlockMeta(world, position); - if (meta >= 2 && meta <= 5) { - crops.push(new CropRubber(getWorld(), block, meta, position)); - } - - ArrayList candidates = processHarvestBlock(crops, seen, position); - ArrayList temp = new ArrayList<>(); - while (!candidates.isEmpty() && crops.size() < 100) { - for (Vect candidate : candidates) { - temp.addAll(processHarvestBlock(crops, seen, candidate)); - } - candidates.clear(); - candidates.addAll(temp); - temp.clear(); - } - - return crops; - } - - private ArrayList processHarvestBlock(Stack crops, Set seen, Vect position) { - World world = getWorld(); - - ArrayList candidates = new ArrayList<>(); - - // Get additional candidates to return - for (int j = 0; j < 2; j++) { - Vect candidate = new Vect(position.getX(), position.getY() + j, position.getZ()); - if (candidate.equals(position)) { - continue; - } - - // See whether the given position has already been processed - if (seen.contains(candidate)) { - continue; - } - - Block block = VectUtil.getBlock(world, candidate); - if (ItemStackUtil.equals(block, PluginIC2.rubberwood)) { - int meta = VectUtil.getBlockMeta(world, candidate); - if (meta >= 2 && meta <= 5) { - crops.push(new CropRubber(world, block, meta, candidate)); - } - candidates.add(candidate); - seen.add(candidate); - } - } - - return candidates; - } - -} diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java deleted file mode 100644 index d7688c6c0..000000000 --- a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java +++ /dev/null @@ -1,53 +0,0 @@ -package forestry.farming.logic; - -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.vect.Vect; -import forestry.plugins.compat.PluginIC2; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; - -public class FarmableBasicIC2Crop implements IFarmable { - @Override - public boolean isSaplingAt(World world, BlockPos pos) { - TileEntity crop = world.getTileEntity(pos); - if(PluginIC2.instance.isIC2Crop(crop)) { - PluginIC2.instance.babysitCrop(crop); - return true; - } - return false; - } - - @Override - public ICrop getCropAt(World world, BlockPos pos) { - TileEntity crop = world.getTileEntity(pos); - if (crop == null) { - return null; - } - if (!PluginIC2.instance.isIC2Crop(crop)) { - return null; - } - if (!PluginIC2.instance.canHarvestCrop(crop)) { - return null; - } - return new CropBasicIC2Crop(world, crop, new Vect(pos)); - } - - @Override - public boolean isGermling(ItemStack itemstack) { - return false; - } - - @Override - public boolean isWindfall(ItemStack itemstack) { - return false; - } - - @Override - public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - return false; - } -} diff --git a/src/main/java/forestry/farming/tiles/TileFarmGearbox.java b/src/main/java/forestry/farming/tiles/TileFarmGearbox.java index 96d1eeab8..3b3c22dfb 100644 --- a/src/main/java/forestry/farming/tiles/TileFarmGearbox.java +++ b/src/main/java/forestry/farming/tiles/TileFarmGearbox.java @@ -12,12 +12,15 @@ package forestry.farming.tiles; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; + import forestry.api.multiblock.IFarmComponent; import forestry.api.multiblock.IFarmController; -import forestry.core.tiles.IPowerHandler; import forestry.energy.EnergyManager; -public class TileFarmGearbox extends TileFarm implements IPowerHandler, IFarmComponent.Active { +import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyReceiver; + +public class TileFarmGearbox extends TileFarm implements IEnergyReceiver, IEnergyHandler, IFarmComponent.Active { private static final int WORK_CYCLES = 4; private static final int ENERGY_PER_OPERATION = WORK_CYCLES * 50; @@ -85,20 +88,14 @@ public class TileFarmGearbox extends TileFarm implements IPowerHandler, IFarmCom } - /* IPowerHandler */ - @Override - public EnergyManager getEnergyManager() { - return energyManager; - } - + /* IEnergyReceiver */ @Override public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { return energyManager.receiveEnergy(from, maxReceive, simulate); } - @Override - public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - return energyManager.extractEnergy(from, maxExtract, simulate); + public EnergyManager getEnergyManager() { + return energyManager; } @Override diff --git a/src/main/java/forestry/plugins/PluginFactory.java b/src/main/java/forestry/plugins/PluginFactory.java index dbc30e025..7a2a5e123 100644 --- a/src/main/java/forestry/plugins/PluginFactory.java +++ b/src/main/java/forestry/plugins/PluginFactory.java @@ -45,10 +45,7 @@ import forestry.core.items.ItemElectronTube; import forestry.core.items.ItemRegistryCore; import forestry.core.network.IPacketRegistry; import forestry.core.recipes.RecipeUtil; -import forestry.core.recipes.craftguide.CraftGuideIntegration; import forestry.core.tiles.MachineDefinition; -import forestry.core.utils.Log; -import forestry.core.utils.ModUtil; import forestry.core.utils.datastructures.FluidMap; import forestry.core.utils.datastructures.ItemStackMap; import forestry.factory.DummyManagers; @@ -211,17 +208,6 @@ public class PluginFactory extends ForestryPlugin { Circuit.machineEfficiencyUpgrade1 = new CircuitSpeedUpgrade("machine.efficiency.1", 0, -0.10f, 2); } - @Override - public void postInit() { - super.postInit(); - - if (ModUtil.isModLoaded("craftguide")) { - CraftGuideIntegration.register(); - } else { - Log.info("Skipping CraftGuide integration."); - } - } - @Override protected void registerRecipes() { diff --git a/src/main/java/forestry/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java deleted file mode 100644 index 81db5ddb9..000000000 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ /dev/null @@ -1,423 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.plugins.compat; - -import com.google.common.collect.ImmutableMap; - -import java.util.ArrayList; -import java.util.EnumSet; - -import forestry.api.farming.Farmables; -import forestry.farming.logic.FarmableBasicIC2Crop; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.Optional; -import net.minecraftforge.fml.common.event.FMLInterModComms; -import net.minecraftforge.fml.common.registry.GameRegistry; -import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.CircuitSocketType; -import forestry.api.circuits.ICircuitLayout; -import forestry.api.core.ForestryAPI; -import forestry.api.fuels.EngineBronzeFuel; -import forestry.api.fuels.FuelManager; -import forestry.api.recipes.RecipeManagers; -import forestry.api.storage.BackpackManager; -import forestry.api.storage.IBackpackDefinition; -import forestry.api.storage.ICrateRegistry; -import forestry.api.storage.StorageManager; -import forestry.apiculture.items.EnumPropolis; -import forestry.apiculture.items.ItemRegistryApiculture; -import forestry.core.circuits.Circuit; -import forestry.core.circuits.CircuitLayout; -import forestry.core.config.Constants; -import forestry.core.fluids.Fluids; -import forestry.core.items.EnumElectronTube; -import forestry.core.recipes.RecipeUtil; -import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.Log; -import forestry.core.utils.ModUtil; -import forestry.energy.blocks.BlockEngineType; -import forestry.energy.blocks.BlockRegistryEnergy; -import forestry.energy.circuits.CircuitElectricBoost; -import forestry.energy.circuits.CircuitElectricChoke; -import forestry.energy.circuits.CircuitElectricEfficiency; -import forestry.energy.tiles.EngineDefinition; -import forestry.farming.circuits.CircuitFarmLogic; -import forestry.farming.logic.FarmLogicRubber; -import forestry.plugins.ForestryPlugin; -import forestry.plugins.Plugin; -import forestry.plugins.PluginApiculture; -import forestry.plugins.PluginCore; -import forestry.plugins.PluginEnergy; -import forestry.plugins.PluginManager; -import ic2.api.item.IC2Items; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.Recipes; - -@Plugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description") -public class PluginIC2 extends ForestryPlugin { - - public static PluginIC2 instance; - - private static ItemStack plantBall; - private static ItemStack compressedPlantBall; - private static ItemStack wrench; - private static ItemStack treetap; - private static ItemStack rubbersapling; - private static ItemStack rubberleaves; - private static ItemStack emptyCell; - private static ItemStack lavaCell; - private static ItemStack waterCell; - private static ItemStack rubber; - private static ItemStack scrap; - private static ItemStack silver; - private static ItemStack brass; - private static ItemStack uuMatter; - - public static ItemStack resin; - public static ItemStack rubberwood; - - public PluginIC2() { - if (PluginIC2.instance == null) { - PluginIC2.instance = this; - } - } - - @Override - public boolean isAvailable() { - return ModUtil.isModLoaded("IC2"); - } - - @Override - public String getFailMessage() { - return "IndustrialCraft2 not found"; - } - - @Override - public EnumSet getDependancies() { - EnumSet deps = super.getDependancies(); - deps.add(PluginManager.Module.FARMING); - deps.add(PluginManager.Module.FACTORY); - return deps; - } - - @Override - @Optional.Method(modid = "IC2") - public void preInit() { - super.preInit(); - - BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; - if (energyBlocks != null) { - energyBlocks.engine.addDefinitions( - new EngineDefinition(BlockEngineType.ELECTRIC), - new EngineDefinition(BlockEngineType.GENERATOR) - ); - } - - emptyCell = IC2Items.getItem("cell"); - if (emptyCell != null) { - lavaCell = IC2Items.getItem("lavaCell"); - waterCell = IC2Items.getItem("waterCell"); - } else { - Log.fine("IC2 empty cell could not be found. Skipped adding IC2 liquid containers."); - } - - // rubber chain - treetap = IC2Items.getItem("treetap"); - rubberwood = IC2Items.getItem("rubberWood"); - resin = IC2Items.getItem("resin"); - rubbersapling = IC2Items.getItem("rubberSapling"); - rubberleaves = IC2Items.getItem("rubberLeaves"); - - // fermentation - plantBall = IC2Items.getItem("plantBall"); - compressedPlantBall = IC2Items.getItem("compressedPlantBall"); - - // crated - resin = IC2Items.getItem("resin"); - rubber = IC2Items.getItem("rubber"); - scrap = IC2Items.getItem("scrap"); - uuMatter = IC2Items.getItem("matter"); - silver = IC2Items.getItem("silverIngot"); - brass = IC2Items.getItem("bronzeIngot"); - - Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class); - - ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); - ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); - } - - @Override - @Optional.Method(modid = "IC2") - public void doInit() { - super.doInit(); - - // Remove some items from the recycler - if (Recipes.recyclerBlacklist != null) { - if (PluginManager.Module.APICULTURE.isEnabled()) { - ItemRegistryApiculture beeItems = PluginApiculture.items; - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beeQueenGE))); - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beePrincessGE))); - } - } else { - Log.severe("IC2 Recipes.recyclerBlacklist not found."); - } - - Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1"); - Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1"); - Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20); - Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40); - } - - @Override - @Optional.Method(modid = "IC2") - protected void registerBackpackItems() { - if (BackpackManager.definitions == null) { - return; - } - - IBackpackDefinition forester = BackpackManager.definitions.get("forester"); - - if (resin != null) { - forester.addValidItem(resin); - } - if (rubber != null) { - forester.addValidItem(rubber); - } - if (rubbersapling != null) { - forester.addValidItem(rubbersapling); - } - if (rubberleaves != null) { - forester.addValidItem(rubberleaves); - } - } - - @Override - @Optional.Method(modid = "IC2") - protected void registerCrates() { - ICrateRegistry crateRegistry = StorageManager.crateRegistry; - if (resin != null) { - crateRegistry.registerCrate(resin, "cratedResin"); - } - - if (rubber != null) { - crateRegistry.registerCrate(rubber, "cratedRubber"); - } - - if (scrap != null) { - crateRegistry.registerCrate(scrap, "cratedScrap"); - } - - if (uuMatter != null) { - crateRegistry.registerCrate(uuMatter, "cratedUUM"); - } - - if (silver != null) { - crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver"); - } - - if (brass != null) { - crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass"); - } - } - - @Override - @Optional.Method(modid = "IC2") - protected void registerRecipes() { - - if (rubber != null) { - for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), PluginCore.items.tubes.get(EnumElectronTube.RUBBER, 4), - new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', rubberOreDict}); - } - } - - if (plantBall != null) { - RecipeUtil.addFermenterRecipes(plantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); - } - if (compressedPlantBall != null) { - RecipeUtil.addFermenterRecipes(compressedPlantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); - } - - if (PluginManager.Module.APICULTURE.isEnabled()) { - if (resin != null) { - ItemRegistryApiculture beeItems = PluginApiculture.items; - RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(resin, 1.0f)); - } else { - Log.fine("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); - } - } - - if (rubbersapling != null) { - RecipeUtil.addFermenterRecipes(rubbersapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); - } else { - Log.fine("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); - } - - if (rubbersapling != null && resin != null) { - String saplingName = ItemStackUtil.getBlockNameFromRegistryAsSting(ItemStackUtil.getBlock(rubbersapling)); - String resinName = ItemStackUtil.getItemNameFromRegistryAsSting(resin.getItem()); - String imc = String.format("farmArboreal@%s.%s.%s.%s", - saplingName, rubbersapling.getItemDamage(), - resinName, resin.getItemDamage()); - Log.finest("Sending IMC '%s'.", imc); - FMLInterModComms.sendMessage(Constants.MOD, "add-farmable-sapling", imc); - } - - FluidStack biogas = FluidRegistry.getFluidStack("ic2biogas", 1000); - if (biogas != null && PluginManager.Module.ENERGY.isEnabled()) { - FuelManager.bronzeEngineFuel.put(biogas.getFluid(), new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), - Constants.ENGINE_FUEL_VALUE_BIOMASS, (int) ((Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas"))), 1)); - } - - if (waterCell != null) { - ItemStack bogEarthCan = ForestryAPI.activeMode.getStackSetting("recipe.output.bogearth.can"); - if (bogEarthCan.stackSize > 0) { - RecipeUtil.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.dirt, 'X', waterCell, 'Y', "sand"); - } - } - - ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); - - // / Solder Manager - ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.COPPER, 1), Circuit.energyElectricChoke1); - ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.TIN, 1), Circuit.energyElectricBoost1); - ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1), Circuit.energyElectricBoost2); - ChipsetManager.solderManager.addRecipe(layout, PluginCore.items.tubes.get(EnumElectronTube.IRON, 1), Circuit.energyElectricEfficiency1); - - if (PluginManager.Module.FARMING.isEnabled() && resin != null && rubberwood != null) { - ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); - ChipsetManager.solderManager.addRecipe(layoutManual, PluginCore.items.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); - } - - Block ic2Crop = GameRegistry.findBlock("IC2", "blockCrop"); - if (PluginManager.Module.FARMING.isEnabled() && ic2Crop != null) { - Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); - } - - BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; - if (energyBlocks != null) { - RecipeUtil.addRecipe(energyBlocks.engine.get(BlockEngineType.GENERATOR), - "X#X", - "XYX", - "X#X", - '#', "blockGlass", - 'X', "ingotGold", - 'Y', PluginCore.items.sturdyCasing); - - RecipeUtil.addRecipe(energyBlocks.engine.get(BlockEngineType.ELECTRIC), - "###", - " X ", - "YVY", - '#', "ingotTin", - 'X', "blockGlass", - 'Y', "gearTin", - 'V', Blocks.piston); - } - } - - /** - * Check if there is an instance of ICropTile. - * @param tileEntity tile entity to be checked. - * @return true if there is an IC2 crop and false otherwise. - */ - /*@Optional.Method(modid = "IC2") - public boolean isIC2Crop(TileEntity tileEntity) { - if (tileEntity != null && tileEntity instanceof ICropTile) { - return true; - } - return false; - }*/ - - /** - * Check if an IC2 crop is ready to be harvested. - * @param tileEntity tile entity to be checked. - * @return true if crop size is optimal for harvest and false otherwise. - */ - /*@Optional.Method(modid = "IC2") - public boolean canHarvestCrop(TileEntity tileEntity) { - if (isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile)tileEntity; - if (crop.getCrop() == null) { - return false; - } - if (crop.getSize() == crop.getCrop().getOptimalHavestSize(crop)) { - return true; - } - } - return false; - }*/ - - /** - * Perform some of the actions of the crop-matron. - * @param tileEntity - */ - /*@Optional.Method(modid = "IC2") - public void babysitCrop(TileEntity tileEntity) { - if (isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile)tileEntity; - /* - This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. - if (crop.getCrop() != null) { - if (crop.getCrop().isWeed(crop)) { - crop.reset(); - } - }*/ - /*if (crop.getHydrationStorage() <= 200) { - crop.setHydrationStorage(200); - } - if (crop.getNutrientStorage() <= 100) { - crop.setNutrientStorage(crop.getNutrientStorage() + 100); - } - } - }*/ - - /** - * This function takes care of everything related to the harvesting of the - * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). - * @param tileEntity tile entity to be checked. - * @return arraylist containing the drops. - */ - /*@Optional.Method(modid = "IC2") - public ArrayList getCropDrops(TileEntity tileEntity) { - if (isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile)tileEntity; - ItemStack[] cropDrops = crop.harvest_automated(true); - if (cropDrops != null) { - return new ArrayList<>(Arrays.asList(cropDrops)); - } - } - return null; - }*/ - - @Optional.Method(modid = "IC2") - public boolean isIC2Crop(TileEntity tileEntity) { - return false; - } - - @Optional.Method(modid = "IC2") - public boolean canHarvestCrop(TileEntity tileEntity) { - return false; - } - - @Optional.Method(modid = "IC2") - public void babysitCrop(TileEntity tileEntity) { - } - - @Optional.Method(modid = "IC2") - public ArrayList getCropDrops(TileEntity tileEntity) { - return null; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/LICENSE.txt b/src/main/java/uristqwerty/CraftGuide/LICENSE.txt deleted file mode 100644 index 1adbf8c41..000000000 --- a/src/main/java/uristqwerty/CraftGuide/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Uristqwerty - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/main/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java b/src/main/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java deleted file mode 100644 index f69fe627b..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - * Supports a simple filter, allowing recipes to be removed - * if they match certain conditions. - */ -public interface BasicRecipeFilter -{ - /** - * When CraftGuide loads or reloads its recipe list, this - * method will be called for every recipe. If this method - * returns false for a recipe, that recipe will be removed. - * - * @param recipe - * @param recipeType - * @return - */ - public boolean shouldKeepRecipe(CraftGuideRecipe recipe, ItemStack recipeType); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/ChanceSlot.java b/src/main/java/uristqwerty/CraftGuide/api/ChanceSlot.java deleted file mode 100644 index 19bf803d6..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/ChanceSlot.java +++ /dev/null @@ -1,82 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -/** - * An ItemSlot that appends probability information to the name of - * the item it contains. To use it, instead of putting an ItemStack - * or List in the data array, put an Object[] containing the item - * at index 0, and an Integer representing the probability at index - * 1. - * - * Also worth noting, this class does not require any additional support - * within the rest of CraftGuide. If you copy it into a different package, - * and use that copy, it will function just fine with older versions of - * CraftGuide, as well as newer ones. It also shows how the API is set up - * to make that sort of extension possible. - */ -public class ChanceSlot extends ItemSlot -{ - private int ratio = 100; - private String formatString = " (%1$.0f%% chance)"; - - public ChanceSlot(int x, int y, int width, int height) - { - super(x, y, width, height); - } - - public ChanceSlot(int x, int y, int width, int height, boolean drawQuantity) - { - super(x, y, width, height, drawQuantity); - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, stack(data, dataIndex), isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - if(data[dataIndex] == null || stack(data, dataIndex) == null) - { - return implementation.getTooltip(this, null); - } - - List tooltip = implementation.getTooltip(this, stack(data, dataIndex)); - double probability = ((Integer)((Object[])data[dataIndex])[1]) * 100 / (double)ratio; - - tooltip.set(0, tooltip.get(0) + String.format(formatString, probability)); - return tooltip; - } - - @Override - public boolean matches(ItemFilter search, Object[] data, int dataIndex, SlotType type) - { - return implementation.matches(this, search, stack(data, dataIndex), type); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return implementation.getClickedFilter(x, y, stack(data, dataIndex)); - } - - private Object stack(Object[] data, int dataIndex) - { - return data[dataIndex] != null? ((Object[])data[dataIndex])[0] : null; - } - - public ChanceSlot setRatio(int ratio) - { - this.ratio = ratio; - return this; - } - - public ChanceSlot setFormatString(String format) - { - formatString = format; - return this; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java b/src/main/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java deleted file mode 100644 index b21b29ae0..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java +++ /dev/null @@ -1,52 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * Uses reflection to register itself with CraftGuide when created. - *

- * You do not need to use this class, it is provided only for convenience, - * as the static method it calls will accept any Object that implements - * zero or more of the following interfaces: - *
  • {@link RecipeProvider} - */ - -public class CraftGuideAPIObject -{ - /** - * When an instance of this class is created, it immediately registers itself - * with CraftGuide (through a static method, invoked through reflection). - *

    - * If you don't want to extend this class, you need to use the code similar to - * this in order for CraftGuide to know that your object exists. - */ - public CraftGuideAPIObject() - { - try - { - Class c = Class.forName("uristqwerty.CraftGuide.ReflectionAPI"); - - Method m = c.getMethod("registerAPIObject", Object.class); - m.invoke(null, this); - } - catch(ClassNotFoundException e) - { - } - catch(NoSuchMethodException e) - { - } - catch(SecurityException e) - { - } - catch(InvocationTargetException e) - { - } - catch(IllegalAccessException e) - { - } - catch(IllegalArgumentException e) - { - } - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java b/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java deleted file mode 100644 index cb8da8d23..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java +++ /dev/null @@ -1,103 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * An instance of a single recipe to be displayed by CraftGuide. - *

    - * Contains a number of methods related to searching, drawing, - * and interaction with the user. - *

    - * It is possible to implement your own recipe, if the default - * functionality is not adequate, although you won't have access - * to any of the default implementation, so it may require a bit - * of work. - */ -public interface CraftGuideRecipe -{ - /** - * Checks whether a certain item is contained in this recipe. - *

    - * This method is provided as a convenience for anyone writing a - * RecipeFilter; {@link #containsItem(ItemFilter)} will generally - * be used elsewhere. - * @param filter - * @return - */ - public boolean containsItem(ItemStack filter); - - /** - * Checks whether this recipe contains an item that matches the - * supplied ItemFilter. Implementations of RecipeFilter may either - * use this or {@link #containsItem(ItemFilter)}; CraftGuide itself - * always uses this. - * @param filter - * @return - */ - public boolean containsItem(ItemFilter filter); - - /** - * When a mouse click occurs within the rectangle occupied by this recipe, - * this method is used to determine if the current ItemFilter should be - * changed as a result. Generally involves iterating over each Slot within - * the recipe, and, if any of them is at the coordinates, returning - * {@link Slot#getClickedFilter}. - * @param x coordinate, relative to the top left of this recipe - * @param y coordinate, relative to the top left of this recipe - * @return a new ItemFilter, or null to keep the current one - */ - public ItemFilter getRecipeClickedResult(int x, int y); - - /** - * Draws this recipe at the specified screen coordinates. If isMouseOver - * is true, mouseX and moyseY are the coordinates of the user's curosr, - * relative to the top left of this recipe; otherwise they are undefined, - * and may be anything, depending on the implementation of CraftGuide, - * and may change between CraftGuide versions. - * @param renderer - * @param x - * @param y - * @param isMouseOver - * @param mouseX - * @param mouseY - */ - public void draw(Renderer renderer, int x, int y, boolean isMouseOver, int mouseX, int mouseY); - - /** - * Called to get the text to display when the user moves their cursor - * over this recipe. Generally, and in the default recipe implementation, - * this means checking if the cursor is over a Slot, and if so, - * returning whatever the slot returns for {@link Slot#getTooltip} - * @param mouseX - * @param mouseY - * @return a List of Strings, or null - */ - public List getItemText(int mouseX, int mouseY); - - /** - * Gets an array of Objects, representing the contents of this recipe. - *

    - * Currently used by craftGuide to create a list of every type of item - * that is used (CraftGuide does not have any logic for finding items - * on its own). Some recipe filters may use this, although - * {@link containsItem} is preferred wherever possible. - * @return - */ - public Object[] getItems(); - - /** - * Gets the width of this recipe; used to determine grid spacing and - * if the cursor is currently positioned over this recipe - * @return - */ - public int width(); - - /** - * Gets the height of this recipe; used to determine grid spacing and - * if the cursor is currently positioned over this recipe - * @return - */ - public int height(); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java b/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java deleted file mode 100644 index fac578916..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java +++ /dev/null @@ -1,15 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - - -/** - * Contains two forgotten methods from CraftGuideRecipe. Allows - * searching for items, limiting the search to a specific - * SlotType. - */ -public interface CraftGuideRecipeExtra1 -{ - public boolean containsItem(ItemStack filter, SlotType type); - public boolean containsItem(ItemFilter filter, SlotType type); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/EUSlot.java b/src/main/java/uristqwerty/CraftGuide/api/EUSlot.java deleted file mode 100644 index 90a1a9c26..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/EUSlot.java +++ /dev/null @@ -1,126 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - - -public class EUSlot implements Slot -{ - public static final int VALUE_UNSPECIFIED = Integer.MIN_VALUE; - private int constantValue = VALUE_UNSPECIFIED; - private int constantSize = VALUE_UNSPECIFIED; - private final int x, y; - private final static int width = 16; - private final static int height = 16; - - private static NamedTexture image; - - public EUSlot(int x, int y) - { - this.x = x; - this.y = y; - - if(image == null) - { - image = Util.instance.getTexture("EU-icon"); - } - } - - @Override - public void draw(Renderer renderer, int recipeX, int recipeY, Object[] data, int dataIndex, boolean isMouseOver) - { - renderer.renderRect(recipeX + x, recipeY + y, width, height, image); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return null; - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return x >= this.x && x < this.x + width - && y >= this.y && y < this.y + height; - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - int value = EUVaue(data[dataIndex]); - int size = PacketSize(data[dataIndex]); - - ArrayList tooltip = new ArrayList(); - tooltip.add("\u00a7fIC2 energy"); - - if(value != -1) - { - tooltip.add("\u00a77 " + Math.abs(value) + " EU " + (value > 0? "produced" : "used")); - } - - if(size != -1) - { - tooltip.add("\u00a77 " + size + " EU/t"); - } - - return tooltip; - } - - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - return false; - } - - public int EUVaue(Object data) - { - if(data instanceof Object[] && ((Object[])data)[0] instanceof Integer) - { - return (Integer)((Object[])data)[0]; - } - else if(constantValue != VALUE_UNSPECIFIED) - { - return constantValue; - } - else if(data instanceof Integer) - { - return (Integer)data; - } - else - { - return VALUE_UNSPECIFIED; - } - } - - public int PacketSize(Object data) - { - if(data instanceof Object[] && ((Object[])data)[1] instanceof Integer) - { - return (Integer)((Object[])data)[1]; - } - else if(constantSize != VALUE_UNSPECIFIED) - { - return constantSize; - } - else if(data instanceof Integer) - { - return (Integer)data; - } - else - { - return VALUE_UNSPECIFIED; - } - } - - public EUSlot setConstantEUValue(int value) - { - constantValue = value; - return this; - } - public EUSlot setConstantPacketSize(int size) - { - constantSize = size; - return this; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/ExtraSlot.java b/src/main/java/uristqwerty/CraftGuide/api/ExtraSlot.java deleted file mode 100644 index b372e7a08..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/ExtraSlot.java +++ /dev/null @@ -1,106 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * An extension of ItemSlot that allows certain interactions - * to be disabled, and uses fixed Object provided during - * initialisation rather than the object matching this slot - * in the recipe. - *

    - * Unlike in the old API, there is no "can filter" option, - * as that can be accomplished through {@link #setSlotType} - * which is already present in ItemSlot. - */ -public class ExtraSlot extends ItemSlot -{ - public Object displayed; - public boolean showName = false; - public boolean canClick = false; - - public ExtraSlot(int x, int y, int width, int height, Object displayedItem) - { - super(x, y, width, height); - displayed = displayedItem; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, displayed, canClick && isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - if(showName) - { - return implementation.getTooltip(this, displayed); - } - else - { - return null; - } - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - if(canClick) - { - return implementation.getClickedFilter(x, y, displayed); - } - else - { - return null; - } - } - - /** - * Sets whether this slot, if clicked, sets the current - * filter to the displayed Object, or doesn't do anything - * - * @param clickable - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot clickable(boolean clickable) - { - canClick = clickable; - return this; - } - - /** - * Sets whether this slot shows a tooltip on mouseover - * - * @param showName - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot showName(boolean showName) - { - this.showName = showName; - return this; - } - - /** - * A shortened version of {@link #clickable(boolean)} - * that passes true - * - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot clickable() - { - return clickable(true); - } - - /** - * A shortened version of {@link #showName(boolean)} - * that passes true - * - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot showName() - { - return showName(true); - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/InfoSlot.java b/src/main/java/uristqwerty/CraftGuide/api/InfoSlot.java deleted file mode 100644 index a67d54e35..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/InfoSlot.java +++ /dev/null @@ -1,74 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -public class InfoSlot extends ItemSlot -{ - private final ItemStack displayed; - private final String[] format; - private boolean clickable; - private boolean searchable; - - public InfoSlot(int x, int y, ItemStack displayedStack, String[] lines) - { - super(x, y, 16, 16, true); - displayed = displayedStack; - format = lines; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - ItemSlot.implementation.draw(this, renderer, x, y, displayed, isMouseOver && clickable); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return clickable? null : ItemSlot.implementation.getClickedFilter(x, y, displayed); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - List tooltip = new ArrayList(); - - if(data[dataIndex] instanceof Object[]) - { - for(int i = 0; i < format.length; i++) - { - tooltip.add(String.format(format[i], (Object[])data[dataIndex])); - } - } - else - { - for(int i = 0; i < format.length; i++) - { - tooltip.add(String.format(format[i], data[dataIndex])); - } - } - - return tooltip; - } - - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - return searchable && ItemSlot.implementation.matches(this, filter, displayed, type); - } - - public InfoSlot setSeachable(boolean searchable) - { - this.searchable = searchable; - return this; - } - - public InfoSlot setClickable(boolean clickable) - { - this.clickable = clickable; - return this; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/ItemFilter.java b/src/main/java/uristqwerty/CraftGuide/api/ItemFilter.java deleted file mode 100644 index 745329900..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/ItemFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * - */ -public interface ItemFilter -{ - /** - * Compares this filter with an Object. Common types include an - * ItemStack, a List of ItemStacks, or a String. - *

    - * If the object type is unknown, return false. - * @param item - * @return - */ - public boolean matches(Object item); - - /** - * Draw a visual representation of this filter at (x, y), within a - * 16 by 16 rectangle. May extend out of that rectangle, although it - * might not look very good. - * @param renderer - * @param x - * @param y - */ - public void draw(Renderer renderer, int x, int y); - - /** - * Gets a description of the filter, displayed when the user moves - * their cursor over the filter display. - * @return a List of lines of text - */ - public List getTooltip(); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/ItemSlot.java b/src/main/java/uristqwerty/CraftGuide/api/ItemSlot.java deleted file mode 100644 index 4c2bebef7..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/ItemSlot.java +++ /dev/null @@ -1,154 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * When a recipe is rendered, the ItemSlots provided to the template are - * used to determine the layout of the recipe's items. - */ -public class ItemSlot implements Slot -{ - /** - * This slot's size and location relative to the containing - * recipe's top left corner - */ - public int x, y, width, height; - - /** - * Used by {@link ItemSlotImplementation#draw} to decide - * whether to draw a background before drawing the actual - * slot contents. - */ - public boolean drawBackground; - - /** - * A sneaky field that is read by the default recipe implementation - * when an instance is created. If an ItemStack with a quantity - * greater than one would match up to an ItemSlot where - * drawQuantity equals false, it replaces the stack with one - * with a size of 1. This is only provided for convenience, it - * is entirely possibly to implement the same logic if it - * is needed but unavailable, such as with a custom recipe, - * or an implementation of Slot that is not an ItemSlot. - *

    - * The actual effect of this field may change in the future - * (for example, copying only part of the method that Minecraft - * uses to draw the item overlay, making the part that draws the - * stack size conditional), but for the moment, I'm assuming that - * doing it this way will be more compatible if Minecraft changes - * its implementation in the future, or if another mod edits - * {@link net.minecraft.src.RenderItem#renderItemOverlayIntoGUI}. - */ - public boolean drawQuantity; - - /** - * Used by {@link ItemSlotImplementation#matches} to - * restrict what sort of searches can match this slot - */ - public SlotType slotType = SlotType.INPUT_SLOT; - - /** - * Implementation of ItemSlot functionality, allowing it - * to change if needed, without altering the API. This - * field is set during CraftGuide's {@literal @PreInit}. - */ - public static ItemSlotImplementation implementation; - - /** - * Creates a new ItemSlot. Same as - * {@link #ItemSlot(int, int, int, int, boolean)}, with - * false as the last parameter. - * @param x - * @param y - * @param width - * @param height - */ - public ItemSlot(int x, int y, int width, int height) - { - this(x, y, width, height, false); - } - - /** - * Creates a new ItemSlot - * @param x - * @param y - * @param width - * @param height - * @param drawQuantity - */ - public ItemSlot(int x, int y, int width, int height, boolean drawQuantity) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.drawQuantity = drawQuantity; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, data[dataIndex], isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - return implementation.getTooltip(this, data[dataIndex]); - } - - @Override - public boolean matches(ItemFilter search, Object[] data, int dataIndex, SlotType type) - { - return implementation.matches(this, search, data[dataIndex], type); - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return implementation.isPointInBounds(this, x, y); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return implementation.getClickedFilter(x, y, data[dataIndex]); - } - - /** - * Sets whether or not this ItemSlot draws a background square - * during its draw method. - * @param draw - * @return this, to permit method chaining - */ - public ItemSlot drawOwnBackground(boolean draw) - { - drawBackground = draw; - return this; - } - - /** - * Sets whether or not this ItemSlot draws a background square - * during its draw method. Same as {@link #drawOwnBackground()}, - * but uses the default value of true. - * @return this, to permit method chaining - */ - public ItemSlot drawOwnBackground() - { - return drawOwnBackground(true); - } - - /** - * Sets the {@link SlotType} associated with this ItemSlot. - * The SlotType is used for searches, both from in-game, and - * from the use of the API - * @param type - * @return this ItemSlot, to permit method chaining - */ - public ItemSlot setSlotType(SlotType type) - { - slotType = type; - return this; - } -} \ No newline at end of file diff --git a/src/main/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java b/src/main/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java deleted file mode 100644 index 618f0d276..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java +++ /dev/null @@ -1,61 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * A collections of methods implementing the functionality required - * by ItemStack, without needing the code to be included as part of - * the API. - */ -public interface ItemSlotImplementation -{ - /** - * Gets the tooltip for an ItemSlot - * @param itemSlot - * @param data - * @return - */ - public List getTooltip(ItemSlot itemSlot, Object data); - - /** - * Draws an ItemSlot. - * @param itemSlot - * @param renderer - * @param x - * @param y - * @param data - * @param isMouseOver - */ - public void draw(ItemSlot itemSlot, Renderer renderer, int x, int y, Object data, boolean isMouseOver); - - /** - * Return an ItemFilter representing the ItemSlot contents. - * @param x - * @param y - * @param object - * @return - */ - public ItemFilter getClickedFilter(int x, int y, Object object); - - /** - * Compare the contents of an ItemSlot with an ItemFilter. - * @param itemSlot - * @param search - * @param object - * @param type - * @return - */ - public boolean matches(ItemSlot itemSlot, ItemFilter search, Object object, SlotType type); - - /** - * Does some simple math to test if a point, relative to the containing - * recipe's top left corner, is within the boundary rectangle of an - * ItemSlot. - * @param itemSlot - * @param x - * @param y - * @return - */ - public boolean isPointInBounds(ItemSlot itemSlot, int x, int y); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/LiquidFilter.java b/src/main/java/uristqwerty/CraftGuide/api/LiquidFilter.java deleted file mode 100644 index d90219dde..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/LiquidFilter.java +++ /dev/null @@ -1,117 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -public class LiquidFilter implements ItemFilter -{ - private static NamedTexture containerTexture = null; - private FluidStack liquid; - private String liquidName; - private List tooltip = new ArrayList(); - - public LiquidFilter(FluidStack liquid) - { - if(containerTexture == null) - { - containerTexture = Util.instance.getTexture("liquidFilterContainer"); - } - - setLiquid(liquid); - } - - public void setLiquid(FluidStack liquid) - { - String name = liquid.getFluid().getLocalizedName(liquid); - this.liquid = liquid; - liquidName = name.toLowerCase(Locale.ENGLISH); - tooltip.clear(); - tooltip.add(name); - } - - @Override - public boolean matches(Object item) - { - if(item instanceof ItemStack) - { - return liquid.isFluidEqual((ItemStack)item); - } - else if(item instanceof FluidStack) - { - return liquid.isFluidEqual((FluidStack)item); - } - else if(item instanceof String) - { - return liquidName.contains(((String)item).toLowerCase(Locale.ENGLISH)); - } - else if(item instanceof List) - { - for(Object object: ((List)item)) - { - if(matches(object)) - { - return true; - } - } - } - - return false; - } - - @Override - public void draw(Renderer renderer, int x, int y) - { - if(liquid != null) - { - TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - - Fluid fluid = liquid.getFluid(); - IIcon icon = fluid.getStillIcon(); - - if(icon != null) - { - textureManager.bindTexture(TextureMap.locationBlocksTexture); - - double u = icon.getInterpolatedU(3.0); - double u2 = icon.getInterpolatedU(13.0); - double v = icon.getInterpolatedV(1.0); - double v2 = icon.getInterpolatedV(15.0); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glColor4d(1.0, 1.0, 1.0, 1.0); - - GL11.glBegin(GL11.GL_QUADS); - GL11.glTexCoord2d(u, v); - GL11.glVertex2i(x + 3, y + 1); - - GL11.glTexCoord2d(u, v2); - GL11.glVertex2i(x + 3, y + 15); - - GL11.glTexCoord2d(u2, v2); - GL11.glVertex2i(x + 13, y + 15); - - GL11.glTexCoord2d(u2, v); - GL11.glVertex2i(x + 13, y + 1); - GL11.glEnd(); - } - } - - renderer.renderRect(x - 1, y - 1, 18, 18, containerTexture); - } - - @Override - public List getTooltip() - { - return tooltip; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/LiquidSlot.java b/src/main/java/uristqwerty/CraftGuide/api/LiquidSlot.java deleted file mode 100644 index b8ffd1f8c..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/LiquidSlot.java +++ /dev/null @@ -1,157 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -public class LiquidSlot implements Slot -{ - private int x; - private int y; - private int width = 16; - private int height = 16; - private SlotType slotType = SlotType.INPUT_SLOT; - - private static NamedTexture containerTexture = null; - - public LiquidSlot(int x, int y) - { - this.x = x; - this.y = y; - - if(containerTexture == null) - { - containerTexture = Util.instance.getTexture("liquidFilterContainer"); - } - } - - @Override - public void draw(Renderer renderer, int recipeX, int recipeY, Object[] data, int dataIndex, boolean isMouseOver) - { - int x = recipeX + this.x; - int y = recipeY + this.y; - - if(data[dataIndex] instanceof FluidStack) - { - FluidStack liquid = (FluidStack)data[dataIndex]; - - TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - - Fluid fluid = liquid.getFluid(); - IIcon icon = fluid.getStillIcon(); - - if(icon != null) - { - textureManager.bindTexture(TextureMap.locationBlocksTexture); - - double u = icon.getInterpolatedU(3.0); - double u2 = icon.getInterpolatedU(13.0); - double v = icon.getInterpolatedV(1.0); - double v2 = icon.getInterpolatedV(15.0); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glColor4d(1.0, 1.0, 1.0, 1.0); - - GL11.glBegin(GL11.GL_QUADS); - GL11.glTexCoord2d(u, v); - GL11.glVertex2i(x + 3, y + 1); - - GL11.glTexCoord2d(u, v2); - GL11.glVertex2i(x + 3, y + 15); - - GL11.glTexCoord2d(u2, v2); - GL11.glVertex2i(x + 13, y + 15); - - GL11.glTexCoord2d(u2, v); - GL11.glVertex2i(x + 13, y + 1); - GL11.glEnd(); - } - } - - renderer.renderRect(x - 1, y - 1, 18, 18, containerTexture); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - if(data[dataIndex] instanceof FluidStack) - { - return new LiquidFilter((FluidStack)data[dataIndex]); - } - else - { - return null; - } - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return x >= this.x && x < this.x + width - && y >= this.y && y < this.y + height; - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - List tooltip = null; - - if(data[dataIndex] instanceof FluidStack) - { - tooltip = new ArrayList(1); - FluidStack stack = (FluidStack)data[dataIndex]; - tooltip.add(stack.getFluid().getLocalizedName(stack) + " (" + stack.amount + " milliBuckets)"); - } - - return tooltip; - } - - //Check if the filter directly matches the contained LiquidStack, or - // matches any liquid container containing the liquid. - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - if(!(data[dataIndex] instanceof FluidStack) || - (type != slotType && ( - type != SlotType.ANY_SLOT || - slotType == SlotType.DISPLAY_SLOT || - slotType == SlotType.HIDDEN_SLOT))) - { - return false; - } - - FluidStack stack = (FluidStack)data[dataIndex]; - - if(filter.matches(stack)) - { - return true; - } - else - { - for(FluidContainerData liquidData: FluidContainerRegistry.getRegisteredFluidContainerData()) - { - if(stack.isFluidEqual(liquidData.fluid) && filter.matches(liquidData.filledContainer)) - { - return true; - } - } - - return false; - } - } - - public Slot setSlotType(SlotType type) - { - slotType = type; - return this; - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/NamedTexture.java b/src/main/java/uristqwerty/CraftGuide/api/NamedTexture.java deleted file mode 100644 index 690f1678b..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/NamedTexture.java +++ /dev/null @@ -1,11 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * This interface represents an internal object to be used with - * {@link Renderer#renderRect(int, int, int, int, NamedTexture)}. - * It exists only to provide a type-safe way of storing the objects - * returned by {@link Util#getTexture}. - */ -public interface NamedTexture -{ -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/RecipeFilter.java b/src/main/java/uristqwerty/CraftGuide/api/RecipeFilter.java deleted file mode 100644 index 9d6203be7..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/RecipeFilter.java +++ /dev/null @@ -1,24 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * More advanced than {@link BasicRecipeFilter}, this - * interface also allows re-ordering and insertion of - * entirely new recipes for each recipe type. - */ -public interface RecipeFilter -{ - /** - * Given a List of {@link CraftGuideRecipe}s, returns a - * modified list. May either return the provided list, or - * create a new List object. If a new List is created, it - * must allow element removal from its iterator. - * @param source - * @param recipeType - * @return - */ - public List filterRecipes(List source, ItemStack recipeType); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/RecipeGenerator.java b/src/main/java/uristqwerty/CraftGuide/api/RecipeGenerator.java deleted file mode 100644 index ab4c1395b..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/RecipeGenerator.java +++ /dev/null @@ -1,120 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -/** - * This interface contains methods that can be used to provide CraftGuide with - * crafting recipes. - *

    - * To do so, use one of the methods returning an {@link RecipeTemplate} - * to create a template from a list of {@link ItemSlot}s and optionally an - * ItemStack representing the recipe type (generally the block/item used to - * craft the recipe, if not provided, defaults to the workbench). - *

    - * With the template, call addRecipe for each recipe, passing an ItemStack[] - * corresponding to the ItemSlot[] provided when creating the template. - */ - -public interface RecipeGenerator -{ - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. Create a default - * background based on the size of the template. - * @param slots - * @param craftingType - * @return - */ - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType); - - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. The background is - * a rectangle taken out of the supplied texture file, at the - * coordinate pairs given. - * @param slots - * @param craftingType - * @param backgroundTexture - * @param backgroundX - * @param backgroundY - * @param backgroundSelectedX - * @param backgroundSelectedY - * @return - */ - - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, int backgroundSelectedX, int backgroundSelectedY); - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. The background is - * a rectangle taken out of the supplied texture file, at the - * coordinate pairs given. - * @param slots - * @param craftingType - * @param backgroundTexture - * @param backgroundX - * @param backgroundY - * @param backgroundSelectedTexture - * @param backgroundSelectedX - * @param backgroundSelectedY - * @return - */ - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY); - - /** - * Generates a recipe from the template and Object[] passed to - * this method, and then adds it to CraftGuide to display in - * game. - * @param template - * @param crafting - */ - public void addRecipe(RecipeTemplate template, Object[] crafting); - - /** - * If you have your own recipe implementation, you can use this - * method to add recipes without needing a RecipeTemplate. - * @param recipe - * @param craftingType - */ - public void addRecipe(CraftGuideRecipe recipe, ItemStack craftingType); - - /** - * Sets whether a certain type of recipe is initially visible. - *

    - * Useful for hiding recipe types that have a lot of recipes, but - * few people need, so they would normally just add excessive - * clutter to the recipe list. - * @param type an ItemStack associated with the recipe type - * @param visible whether it is initially visible or not - */ - public void setDefaultTypeVisibility(ItemStack type, boolean visible); - - /** - * Takes an IRecipe, and returns an array representing a - * 3x3 crafting grid, plus a single output, for that recipe's - * contents. Each element is either null, an ItemStack, or a - * List containing zero or more ItemStacks (for Forge ore - * dictionary recipes). - *

    - * May return null if given an IRecipe implementation that it - * cannot interpret. - * @see #getCraftingRecipe(IRecipe, boolean) - * @param recipe the IRecipe to be read - * @return an Object[10], where the first nine elements form - * the 3x3 input grid, and the last element is the recipe output. - */ - public Object[] getCraftingRecipe(IRecipe recipe); - - /** - * Takes an IRecipe, and returns an array representing a - * 3x3 or 2x2 crafting grid, plus a single output. - *

    - * See {@link #getCraftingRecipe(IRecipe)} for details. - * @see #getCraftingRecipe(IRecipe) - * @param recipe - * @param allowSmallGrid if true, may return an Object[5] if - * the recipe fits in a 2x2 grid. - * @return an Object[10] or an Object[5] - */ - public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/RecipeProvider.java b/src/main/java/uristqwerty/CraftGuide/api/RecipeProvider.java deleted file mode 100644 index a8abb8e38..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/RecipeProvider.java +++ /dev/null @@ -1,18 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * When CraftGuide (re)loads its recipe list, every Object that implements this - * interface, and has been registered with CraftGuide, will have its generateRecipes - * method called. - */ -public interface RecipeProvider -{ - /** - * Called by CraftGuide when it is (re)populating its recipe list, as a request - * for the implementing Object to provide recipes through the RecipeGenerator - * instance passed to it. - * @param generator - * @see RecipeGenerator - */ - void generateRecipes(RecipeGenerator generator); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/RecipeTemplate.java b/src/main/java/uristqwerty/CraftGuide/api/RecipeTemplate.java deleted file mode 100644 index c03051d02..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/RecipeTemplate.java +++ /dev/null @@ -1,36 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - */ -public interface RecipeTemplate -{ - /** - * Sets the width and height that will be used for recipes - * produced by this template - * @param width - * @param height - * @return this template, to allow method chaining - */ - public RecipeTemplate setSize(int width, int height); - - /** - * Gets an ItemStack that represents the type of the recipe. - * Generally, this should be the block or item that players - * would most closely associate with it, such as the machine - * that the recipe is crafted in, or an item that opens the - * crafting GUI used by the recipe. - * - * @return the ItemStack, or null to default to a workbench - */ - public ItemStack getCraftingType(); - - /** - * Generate a recipe from an Object[] representing the contents - * of the recipe. - * @param items - * @return - */ - public CraftGuideRecipe generate(Object[] items); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/Renderer.java b/src/main/java/uristqwerty/CraftGuide/api/Renderer.java deleted file mode 100644 index 16ac69dae..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/Renderer.java +++ /dev/null @@ -1,108 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - * Provides useful methods to render common things, in - * {@link Slot#draw} and {@link CraftGuideRecipe#draw}. - */ -public interface Renderer -{ - /** - * Draws an ItemStack at the specified screen coordinates. - * @param x - * @param y - * @param stack - */ - public void renderItemStack(int x, int y, ItemStack stack); - - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param color_argb Red, Green, Blue, and Alpha, packed into a single int, - * in the form 0xaarrggbb - */ - public void renderRect(int x, int y, int width, int height, int color_argb); - - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param color_rgb Red, Green, and Blue, packed into a single int, in the - * form 0x00rrggbb - * @param alpha - */ - public void renderRect(int x, int y, int width, int height, int color_rgb, int alpha); - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param red - * @param green - * @param blue - * @param alpha - */ - public void renderRect(int x, int y, int width, int height, int red, int green, int blue, int alpha); - - /** - * Draws a rectangle, textured with a NamedTexture obtained from - * {@link Util#getTexture}. - * @param x - * @param y - * @param width - * @param height - * @param texture - */ - public void renderRect(int x, int y, int width, int height, NamedTexture texture); - - /** - * Draws a rectangle, containing a vertical gradient - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param topColor_argb - * @param bottomColor_argb - */ - public void renderVerticalGradient(int x, int y, int width, int height, int topColor_argb, int bottomColor_argb); - - /** - * Draws a rectangle, containing a horizontal gradient. - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param leftColor_argb - * @param rightColor_argb - */ - public void renderHorizontalGradient(int x, int y, int width, int height, int leftColor_argb, int rightColor_argb); - - /** - * Draws a rectangle, containing an arbitrary gradient. - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param topLeftColor_argb - * @param topRightColor_argb - * @param bottomLeftColor_argb - * @param bottomRightColor_argb - */ - public void renderGradient(int x, int y, int width, int height, int topLeftColor_argb, int topRightColor_argb, int bottomLeftColor_argb, int bottomRightColor_argb); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/Slot.java b/src/main/java/uristqwerty/CraftGuide/api/Slot.java deleted file mode 100644 index 6aa3a3d3e..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/Slot.java +++ /dev/null @@ -1,92 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -/** - * A Slot represents a single component of a recipe being displayed by - * CraftGuide. Similar to how Minecraft handles items and blocks, one - * instance of a slot is used to handle the logic of multiple recipes. - *

    - * Each method's parameters include an Object[] representing the specific - * recipe, and the index of the Object related to this slot, allowing - * implementations that react differently based on more than one component - * of the recipe. - *

    - * Slot is only used by the default implementation of CraftGuideRecipe, a - * custom implementation may opt to ignore any part of this, or not use it - * entirely, but if it does, then it should provide some sort of logic to - * perform the same functionality. For example, one mod may opt to extend - * this interface with a number of more specific methods, and implement a - * recipe that mainly uses the alternate methods in certain situations. - * For most mods, however, the existing recipe mechanics should be - * sufficient (most shouldn't even need more than the provided ItemSlot). - */ -public interface Slot -{ - /** - * This method is called in order to draw this slot. (x, y) is the - * absolute coordinate of the top left corner of the containing - * recipe. - * @param renderer - * @param x - * @param y - * @param data - * @param dataIndex - * @param isMouseOver - */ - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver); - - /** - * When this slot is clicked on in a recipe, this method is called in - * order to get the filter Object that is used to search the recipe list - * for related recipes. If null is returned, then the filter will not - * change. - *

    - * For common types, {@link Util#getCommonFilter(Object)} can provide - * a filter if given a known type of Object. - * @param x clicked coordinate, relative to the recipe's top left corner - * @param y clicked coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return null, or an IItemFilter - */ - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex); - - /** - * This method is used by CraftGuide to determine whether a specific point - * is considered within the bounds of this particular slot. It is typically - * used to determine what slot, if any, the user's cursor is currently over. - * - * @param x coordinate, relative to the recipe's top left corner - * @param y coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return true if (x, y) is within this slot's bounds, otherwise false - */ - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex); - - /** - * When the user moves their cursor over a recipe containing this slot, and - * the cursor's position is within the bounds of this slot (relative to the - * containing recipe), this method is called to determine whether to display - * a tooltip, and, if so, what text should be displayed. - * - * @param x cursor coordinate, relative to the recipe's top left corner - * @param y cursor coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return a List of Strings, representing one or more lines of text, or - * null if the tooltip should not be displayed - */ - public List getTooltip(int x, int y, Object[] data, int dataIndex); - - /** - * Used to test if a specific slot matches the searched {@link ItemFilter} - * - * @param filter the Object being compared the the contents of this slot - * @param data the recipe's raw data array - * @param dataIndex this slot's index - * @param type the type of slot that is being searched for - */ - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/SlotType.java b/src/main/java/uristqwerty/CraftGuide/api/SlotType.java deleted file mode 100644 index 3310e352f..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/SlotType.java +++ /dev/null @@ -1,38 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * SlotType is used to declare the purpose of a {@link Slot}, used - * by searches (both in-game and through the API). - */ -public enum SlotType -{ - /** - * For searches; matches anything except - * {@link HIDDEN_SLOT} and {@link DISPLAY_SLOT} - */ - ANY_SLOT, - - /** Resources required for the recipe */ - INPUT_SLOT, - /** Products produced by the recipe */ - OUTPUT_SLOT, - /** Machine(s) that processes the recipe */ - MACHINE_SLOT, - - /** - * Just in case {@link INPUT_SLOT}, {@link OUTPUT_SLOT}, - * and {@link MACHINE_SLOT} aren't adequate descriptions - * of this slot's purpose. - */ - OTHER_SLOT, - - /** - * Does not show up in searches for {@link ANY_SLOT}. - * Use for visual effects and such. - */ - DISPLAY_SLOT, - /** - * Does not show up in searches for {@link ANY_SLOT}. - */ - HIDDEN_SLOT, -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/StackInfo.java b/src/main/java/uristqwerty/CraftGuide/api/StackInfo.java deleted file mode 100644 index 7148dfe04..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/StackInfo.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -/** - * Contains a list of objects polled by CraftGuide every time the - * tooltip text of an item is needed, allowing additional lines - * of information about the stack to be displayed. - * - * @see StackInfoSource - */ -public class StackInfo -{ - public static List sources = new ArrayList(); - - public static void addSource(StackInfoSource source) - { - sources.add(source); - } -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/StackInfoSource.java b/src/main/java/uristqwerty/CraftGuide/api/StackInfoSource.java deleted file mode 100644 index 62ea3f244..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/StackInfoSource.java +++ /dev/null @@ -1,17 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - * When CraftGuide gets the tooltip of an item, every StackInfoSource - * listed by {@link StackInfo} is polled, so that it may provide - * additional lines of information about the stack. - */ -public interface StackInfoSource -{ - /** - * May return null to indicate that no additional information - * about the stack is provided by this StackInfoSource. - */ - public String getInfo(ItemStack itemStack); -} diff --git a/src/main/java/uristqwerty/CraftGuide/api/Util.java b/src/main/java/uristqwerty/CraftGuide/api/Util.java deleted file mode 100644 index 3e16fc6bc..000000000 --- a/src/main/java/uristqwerty/CraftGuide/api/Util.java +++ /dev/null @@ -1,90 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * Contains a number of methods that implement common functionality - * that would otherwise need to be implemented by everyone who uses - * the API, or that relies on parts of CraftGuide not included in - * the API. - */ -public abstract class Util -{ - /** - * An instance of Util, containing the method implementations. - *

    - * It is set during CraftGuide's {@literal @PreInit}. - */ - public static Util instance; - - /** - * Causes CraftGuide to clear its list of recipes, and reload them with - * exactly the same process that was originally used to build the list. - */ - public abstract void reloadRecipes(); - - /** - * Converts the passed ItemStack's name and information into a List - * of Strings for display, similar to how GuiContainer does it. - * Additionally, contains logic to try an alternative if given a stack - * with a damage of -1 which produces an unusable name and information, - * if CraftGuide is set to always show item IDs it will insert the item's - * ID and damage value as the second line. If an exception is thrown - * at any time during the process, it will log it to CraftGuide.log and - * generate an error text to display that at least shows the item ID and - * damage. - * @param stack - * @return - */ - public abstract List getItemStackText(ItemStack stack); - - /** - * Gets a standard {@link ItemFilter} for any of the common types: - *
  • ItemStack - *
  • List of ItemStacks - *
  • String - * - * @param item - * @return - */ - public abstract ItemFilter getCommonFilter(Object item); - - /** - * Gets a texture usable with {@link Renderer#renderRect} - * from a String identifier. - * If the texture does not exist in the current theme, nothing will be drawn. - *

    - * In addition to anything defined by the - * currently-active theme, converts the following aliases to the equivalent - * name used in theme files for backwards compatibility: - * - *
  • "ItemStack-Any": ItemStack overlay indicating that any metadata value - * matches
  • - *
  • "ItemStack-OreDict": ItemStack overlay indicating that any one of a - * list of ItemStacks are acceptable.
  • - *
  • "ItemStack-OreDict-Single": Used in place of ItemStack-OreDict when - * the list of ItemStacks is exactly one element long.
  • - *
  • "ItemStack-Background": Image used as background for GUI slots
  • - *
  • "TextFilter": Icon used in place of an ItemStack when searching for - * a String
  • - *
  • "Error": Displayed in place of an ItemStack when an error prevents - * that stack from being rendered.
  • - * - * @param identifier - * @return - */ - public abstract NamedTexture getTexture(String identifier); - - /** - * Returns the number of partial ticks for this frame. I don't know - * quite what they do, but it's the third parameter to - * {@link net.minecraft.src.GuiScreen#drawScreen}, so I'm assuming - * that at least something needs it. Rather than pass it as an - * extra argument to every drawing method, it is stored at the - * start of rendering the GUI, and can be retrieved with this method. - * @return - */ - public abstract float getPartialTicks(); -}