Update CoFH API to 1.0.13

This commit is contained in:
tterrag1098 committed 2015-09-08 20:37:18 -04:00
1 parent a51268cb6c
commit 0194b54cd2
7 files changed
+148 -25

No files matched your search

+1 -1
View File
@@ -6,6 +6,6 @@ public class CoFHAPIProps {
}
public static final String VERSION = "1.7.10R1.0.3";
public static final String VERSION = "1.7.10R1.0.13";
}
@@ -0,0 +1,21 @@
package cofh.api.transport;
public interface IEnderDestination extends IEnderAttuned {
public boolean isNotValid();
public int x();
public int y();
public int z();
public int dimension();
public int getDestination();
public boolean setDestination(int frequency);
public boolean clearDestination();
}
@@ -2,9 +2,9 @@ package cofh.api.transport;
/**
* This interface is implemented on Ender Attuned objects which can receive Energy (Redstone Flux).
*
*
* @author King Lemming
*
*
*/
public interface IEnderEnergyHandler extends IEnderAttuned {
@@ -15,7 +15,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned {
/**
* This should be checked to see if the Ender Attuned object can currently receive energy (Redstone Flux).
*
*
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
*/
boolean canReceiveEnergy();
@@ -23,7 +23,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned {
/**
* This tells the Ender Attuned object to receive energy. This returns the amount remaining, *not* the amount received - a return of 0 means that all energy
* was received!
*
*
* @param energy
* Amount of energy to be received.
* @param simulate
@@ -4,9 +4,9 @@ import net.minecraftforge.fluids.FluidStack;
/**
* This interface is implemented on Ender Attuned objects which can receive Fluid.
*
*
* @author King Lemming
*
*
*/
public interface IEnderFluidHandler extends IEnderAttuned {
@@ -17,7 +17,7 @@ public interface IEnderFluidHandler extends IEnderAttuned {
/**
* This should be checked to see if the Ender Attuned object can currently receive a FluidStack.
*
*
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
*/
boolean canReceiveFluid();
@@ -25,7 +25,7 @@ public interface IEnderFluidHandler extends IEnderAttuned {
/**
* This tells the Ender Attuned object to receive a FluidStack. This returns what remains of the original stack, *not* the amount received - a null return
* means that the entire stack was received!
*
*
* @param fluid
* FluidStack to be received.
* @param simulate
@@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack;
/**
* This interface is implemented on Ender Attuned objects which can receive Items.
*
*
* @author King Lemming
*
*
*/
public interface IEnderItemHandler extends IEnderAttuned {
@@ -17,7 +17,7 @@ public interface IEnderItemHandler extends IEnderAttuned {
/**
* This should be checked to see if the Ender Attuned object can currently receive an ItemStack.
*
*
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
*/
boolean canReceiveItems();
@@ -25,10 +25,10 @@ public interface IEnderItemHandler extends IEnderAttuned {
/**
* This tells the Ender Attuned object to receive an ItemStack. This returns what remains of the original stack, *not* the amount received - a null return
* means that the entire stack was received!
*
*
* This function does not support simulation because Inventory manipulation in Minecraft is an absolute mess and it would be a computational liability to do
* so.
*
*
* @param item
* ItemStack to be received.
* @return An ItemStack representing how much is remaining.
@@ -5,16 +5,16 @@ import net.minecraftforge.common.util.ForgeDirection;
/**
* This interface is implemented on ItemDucts. Use it to attempt to eject items into an entry point.
*
*
* @author Zeldo Kavira, King Lemming
*
*
*/
public interface IItemDuct {
/**
* Insert an ItemStack into the IItemDuct. Will only accept items if there is a valid destination. This returns what is remaining of the original stack - a
* null return means that the entire stack was accepted/routed!
*
*
* @param from
* Orientation the item is inserted from.
* @param item
@@ -1,7 +1,5 @@
package cofh.api.transport;
import gnu.trove.map.hash.THashMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -10,23 +8,69 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.config.Configuration;
public final class RegistryEnderAttuned {
public static Map<String, Map<Integer, List<IEnderItemHandler>>> inputItem = new THashMap<String, Map<Integer, List<IEnderItemHandler>>>();
public static Map<String, Map<Integer, List<IEnderFluidHandler>>> inputFluid = new THashMap<String, Map<Integer, List<IEnderFluidHandler>>>();
public static Map<String, Map<Integer, List<IEnderEnergyHandler>>> inputEnergy = new THashMap<String, Map<Integer, List<IEnderEnergyHandler>>>();
public static Map<String, Map<Integer, List<IEnderItemHandler>>> inputItem = new HashMap<String, Map<Integer, List<IEnderItemHandler>>>();
public static Map<String, Map<Integer, List<IEnderFluidHandler>>> inputFluid = new HashMap<String, Map<Integer, List<IEnderFluidHandler>>>();
public static Map<String, Map<Integer, List<IEnderEnergyHandler>>> inputEnergy = new HashMap<String, Map<Integer, List<IEnderEnergyHandler>>>();
public static Map<String, Map<Integer, List<IEnderItemHandler>>> outputItem = new THashMap<String, Map<Integer, List<IEnderItemHandler>>>();
public static Map<String, Map<Integer, List<IEnderFluidHandler>>> outputFluid = new THashMap<String, Map<Integer, List<IEnderFluidHandler>>>();
public static Map<String, Map<Integer, List<IEnderEnergyHandler>>> outputEnergy = new THashMap<String, Map<Integer, List<IEnderEnergyHandler>>>();
public static Map<String, Map<Integer, List<IEnderItemHandler>>> outputItem = new HashMap<String, Map<Integer, List<IEnderItemHandler>>>();
public static Map<String, Map<Integer, List<IEnderFluidHandler>>> outputFluid = new HashMap<String, Map<Integer, List<IEnderFluidHandler>>>();
public static Map<String, Map<Integer, List<IEnderEnergyHandler>>> outputEnergy = new HashMap<String, Map<Integer, List<IEnderEnergyHandler>>>();
public static Map<String, Map<Integer, EnderDestination>> outputTeleport = new HashMap<String, Map<Integer, EnderDestination>>();
public static Configuration linkConf;
public static Map<String, String> clientFrequencyNames = new LinkedHashMap<String, String>();
public static Map<String, String> clientFrequencyNamesReversed = new LinkedHashMap<String, String>();
private static class EnderDestination {
private final int dimension;
private final int x, y, z;
private IEnderDestination output;
public EnderDestination(IEnderDestination output) {
x = output.x();
y = output.y();
z = output.z();
dimension = output.dimension();
this.output = output;
}
public boolean hasOutput() {
return DimensionManager.isDimensionRegistered(dimension);
}
public IEnderDestination getOutput() {
if (output == null || output.isNotValid()) {
output = null;
if (!DimensionManager.isDimensionRegistered(dimension)) {
return null;
}
WorldServer world = DimensionManager.getWorld(dimension);
if (world == null) {
DimensionManager.initDimension(dimension);
world = DimensionManager.getWorld(dimension);
}
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof IEnderDestination) {
output = (IEnderDestination) te;
}
}
return output;
}
}
public static void clear() {
inputItem.clear();
@@ -85,6 +129,31 @@ public final class RegistryEnderAttuned {
return outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static boolean hasDestination(IEnderDestination theAttuned) {
return hasDestination(theAttuned, true);
}
public static boolean hasDestination(IEnderDestination theAttuned, boolean to) {
Map<Integer, EnderDestination> map = outputTeleport.get(theAttuned.getChannelString());
if (map == null) {
return false;
}
EnderDestination dest = map.get(to ? theAttuned.getDestination() : theAttuned.getFrequency());
return dest == null ? false : dest.hasOutput();
}
public static IEnderDestination getDestination(IEnderDestination theAttuned) {
Map<Integer, EnderDestination> map = outputTeleport.get(theAttuned.getChannelString());
if (map == null) {
return null;
}
EnderDestination dest = map.get(theAttuned.getDestination());
return dest == null ? null : dest.getOutput();
}
/* HELPER FUNCTIONS */
public static void addItemHandler(IEnderItemHandler theAttuned) {
@@ -164,6 +233,16 @@ public final class RegistryEnderAttuned {
}
}
public static void addDestination(IEnderDestination theAttuned) {
if (!hasDestination(theAttuned, false)) {
if (outputTeleport.get(theAttuned.getChannelString()) == null) {
outputTeleport.put(theAttuned.getChannelString(), new HashMap<Integer, EnderDestination>());
}
outputTeleport.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new EnderDestination(theAttuned));
}
}
public static void removeItemHandler(IEnderItemHandler theAttuned) {
if (inputItem.get(theAttuned.getChannelString()) != null) {
@@ -224,6 +303,23 @@ public final class RegistryEnderAttuned {
}
}
public static void removeDestination(IEnderDestination theAttuned) {
Map<Integer, EnderDestination> map = outputTeleport.get(theAttuned.getChannelString());
if (map == null) {
return;
}
EnderDestination dest = map.get(theAttuned.getFrequency());
if (dest == null) {
return;
}
if (dest.dimension == theAttuned.dimension()) {
if (dest.x == theAttuned.x() && dest.y == theAttuned.x() && dest.z == theAttuned.x()) {
map.remove(theAttuned.getFrequency());
}
}
}
public static void add(IEnderAttuned theAttuned) {
if (theAttuned instanceof IEnderItemHandler) {
@@ -235,6 +331,9 @@ public final class RegistryEnderAttuned {
if (theAttuned instanceof IEnderEnergyHandler) {
addEnergyHandler((IEnderEnergyHandler) theAttuned);
}
if (theAttuned instanceof IEnderDestination) {
addDestination((IEnderDestination) theAttuned);
}
}
public static void remove(IEnderAttuned theAttuned) {
@@ -248,6 +347,9 @@ public final class RegistryEnderAttuned {
if (theAttuned instanceof IEnderEnergyHandler) {
removeEnergyHandler((IEnderEnergyHandler) theAttuned);
}
if (theAttuned instanceof IEnderDestination) {
removeDestination((IEnderDestination) theAttuned);
}
}
public static void sortClientNames() {