Refactor cofh-core dependency

This commit is contained in:
Johann Bernhardt committed 2021-11-23 19:55:31 +01:00
1 parent 61dc345018
commit de3475bdcf
12 files changed
+4 -589

No files matched your search

+1
View File
@@ -2,4 +2,5 @@
dependencies {
compile("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev")
compileOnly("curse.maven:cofh-core-69162:2388751")
}
+3
View File
@@ -1,6 +1,9 @@
// Add any additional repositiroes for your dependencies here
repositories {
maven {
url "https://cursemaven.com"
}
maven {
url = "https://jitpack.io"
}
-11
View File
@@ -1,11 +0,0 @@
package cofh.api;
public class CoFHAPIProps {
private CoFHAPIProps() {
}
public static final String VERSION = "1.7.10R1.0.13";
}
-9
View File
@@ -1,9 +0,0 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
package cofh.api;
import cpw.mods.fml.common.API;
@@ -1,13 +0,0 @@
package cofh.api.transport;
interface IEnderAttuned {
public String getChannelString();
public int getFrequency();
public boolean setFrequency(int frequency);
public boolean clearFrequency();
}
@@ -1,21 +0,0 @@
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();
}
@@ -1,35 +0,0 @@
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 {
/**
* Return whether or not the Ender Attuned object can currently send energy (Redstone Flux).
*/
boolean canSendEnergy();
/**
* 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();
/**
* 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
* If TRUE, the result will only be simulated.
* @return Amount of energy that is remaining (or would be remaining, if simulated).
*/
int receiveEnergy(int energy, boolean simulate);
}
@@ -1,37 +0,0 @@
package cofh.api.transport;
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 {
/**
* Return whether or not the Ender Attuned object can currently send FluidStacks.
*/
boolean canSendFluid();
/**
* 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();
/**
* 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
* If TRUE, the result will only be simulated.
* @return FluidStack representing how much fluid is remaining (or would be remaining, if simulated).
*/
FluidStack receiveFluid(FluidStack fluid, boolean simulate);
}
@@ -1,38 +0,0 @@
package cofh.api.transport;
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 {
/**
* Return whether or not the Ender Attuned object can currently send ItemStacks.
*/
boolean canSendItems();
/**
* 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();
/**
* 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.
*/
ItemStack receiveItem(ItemStack item);
}
@@ -1,26 +0,0 @@
package cofh.api.transport;
import net.minecraft.item.ItemStack;
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
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
* @return An ItemStack representing how much is remaining after the item was inserted into the Duct.
*/
public ItemStack insertItem(ForgeDirection from, ItemStack item);
}
@@ -1,389 +0,0 @@
package cofh.api.transport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
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 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 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();
inputFluid.clear();
inputEnergy.clear();
outputItem.clear();
outputFluid.clear();
outputEnergy.clear();
}
public static List<IEnderItemHandler> getLinkedItemInputs(IEnderItemHandler theAttuned) {
if (inputItem.get(theAttuned.getChannelString()) == null) {
return null;
}
return inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static List<IEnderItemHandler> getLinkedItemOutputs(IEnderItemHandler theAttuned) {
if (outputItem.get(theAttuned.getChannelString()) == null) {
return null;
}
return outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static List<IEnderFluidHandler> getLinkedFluidInputs(IEnderFluidHandler theAttuned) {
if (inputFluid.get(theAttuned.getChannelString()) == null) {
return null;
}
return inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static List<IEnderFluidHandler> getLinkedFluidOutputs(IEnderFluidHandler theAttuned) {
if (outputFluid.get(theAttuned.getChannelString()) == null) {
return null;
}
return outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static List<IEnderEnergyHandler> getLinkedEnergyInputs(IEnderEnergyHandler theAttuned) {
if (inputEnergy.get(theAttuned.getChannelString()) == null) {
return null;
}
return inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency());
}
public static List<IEnderEnergyHandler> getLinkedEnergyOutputs(IEnderEnergyHandler theAttuned) {
if (outputEnergy.get(theAttuned.getChannelString()) == null) {
return null;
}
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) {
if (theAttuned.canSendItems()) {
if (inputItem.get(theAttuned.getChannelString()) == null) {
inputItem.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderItemHandler>>());
}
if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
inputItem.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderItemHandler>());
}
if (!inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
if (theAttuned.canReceiveItems()) {
if (outputItem.get(theAttuned.getChannelString()) == null) {
outputItem.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderItemHandler>>());
}
if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
outputItem.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderItemHandler>());
}
if (!outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
}
public static void addFluidHandler(IEnderFluidHandler theAttuned) {
if (theAttuned.canSendFluid()) {
if (inputFluid.get(theAttuned.getChannelString()) == null) {
inputFluid.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderFluidHandler>>());
}
if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
inputFluid.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderFluidHandler>());
}
if (!inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
if (theAttuned.canReceiveFluid()) {
if (outputFluid.get(theAttuned.getChannelString()) == null) {
outputFluid.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderFluidHandler>>());
}
if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
outputFluid.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderFluidHandler>());
}
if (!outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
}
public static void addEnergyHandler(IEnderEnergyHandler theAttuned) {
if (theAttuned.canSendEnergy()) {
if (inputEnergy.get(theAttuned.getChannelString()) == null) {
inputEnergy.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderEnergyHandler>>());
}
if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
inputEnergy.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderEnergyHandler>());
}
if (!inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
if (theAttuned.canReceiveEnergy()) {
if (outputEnergy.get(theAttuned.getChannelString()) == null) {
outputEnergy.put(theAttuned.getChannelString(), new HashMap<Integer, List<IEnderEnergyHandler>>());
}
if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) == null) {
outputEnergy.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new ArrayList<IEnderEnergyHandler>());
}
if (!outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).contains(theAttuned)) {
outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).add(theAttuned);
}
}
}
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) {
if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (inputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
inputItem.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
if (outputItem.get(theAttuned.getChannelString()) != null) {
if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (outputItem.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
outputItem.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
}
public static void removeFluidHandler(IEnderFluidHandler theAttuned) {
if (inputFluid.get(theAttuned.getChannelString()) != null) {
if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (inputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
inputFluid.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
if (outputFluid.get(theAttuned.getChannelString()) != null) {
if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (outputFluid.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
outputFluid.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
}
public static void removeEnergyHandler(IEnderEnergyHandler theAttuned) {
if (inputEnergy.get(theAttuned.getChannelString()) != null) {
if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (inputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
inputEnergy.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
if (outputEnergy.get(theAttuned.getChannelString()) != null) {
if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()) != null) {
outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).remove(theAttuned);
if (outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()).size() == 0) {
outputEnergy.get(theAttuned.getChannelString()).remove(theAttuned.getFrequency());
}
}
}
}
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) {
addItemHandler((IEnderItemHandler) theAttuned);
}
if (theAttuned instanceof IEnderFluidHandler) {
addFluidHandler((IEnderFluidHandler) theAttuned);
}
if (theAttuned instanceof IEnderEnergyHandler) {
addEnergyHandler((IEnderEnergyHandler) theAttuned);
}
if (theAttuned instanceof IEnderDestination) {
addDestination((IEnderDestination) theAttuned);
}
}
public static void remove(IEnderAttuned theAttuned) {
if (theAttuned instanceof IEnderItemHandler) {
removeItemHandler((IEnderItemHandler) theAttuned);
}
if (theAttuned instanceof IEnderFluidHandler) {
removeFluidHandler((IEnderFluidHandler) theAttuned);
}
if (theAttuned instanceof IEnderEnergyHandler) {
removeEnergyHandler((IEnderEnergyHandler) theAttuned);
}
if (theAttuned instanceof IEnderDestination) {
removeDestination((IEnderDestination) theAttuned);
}
}
public static void sortClientNames() {
List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(clientFrequencyNames.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, String>>() {
@Override
public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
int int1 = Integer.valueOf(clientFrequencyNamesReversed.get(o1.getValue()));
int int2 = Integer.valueOf(clientFrequencyNamesReversed.get(o2.getValue()));
return int1 > int2 ? 1 : int1 == int2 ? 0 : -1;
}
});
Map<String, String> result = new LinkedHashMap<String, String>();
for (Map.Entry<String, String> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
clientFrequencyNames = result;
}
public static void clearClientNames() {
clientFrequencyNames.clear();
clientFrequencyNamesReversed.clear();
}
public static void addClientNames(String owner, String name) {
if (!owner.isEmpty()) {
clientFrequencyNames.put(owner, name);
clientFrequencyNamesReversed.put(name, owner);
}
}
}
@@ -1,10 +0,0 @@
/**
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
* http://www.teamcofh.com
*/
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|transport")
package cofh.api.transport;
import cofh.api.CoFHAPIProps;
import cpw.mods.fml.common.API;