mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Ender IO now runs without the Build Craft API!
This commit is contained in:
1 parent
33629d6e9d
commit
be0198c6a1
7 files changed
+127
-15
No files matched your search
@@ -10,6 +10,12 @@ public class BuildCraftToolProvider implements IToolProvider, IToolImpl {
|
||||
|
||||
private BCWrench wrench = new BCWrench();
|
||||
|
||||
public BuildCraftToolProvider() throws Exception {
|
||||
//Do a check for so we throw an exception in the constructor if we dont have the
|
||||
// wrench class
|
||||
Class.forName("buildcraft.api.tools.IToolWrench");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITool getTool(ItemStack stack) {
|
||||
if(MpsUtil.instance.isPowerFistEquiped(stack) && !MpsUtil.instance.isOmniToolActive(stack)) {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
public class BuildcraftUtil implements IItemReceptor, IFluidReceptor {
|
||||
|
||||
static {
|
||||
//Only register if we can actually load the IPipeTile class
|
||||
try {
|
||||
Class.forName("buildcraft.api.transport.IPipeTile");
|
||||
BuildcraftUtil instance = new BuildcraftUtil();
|
||||
ItemUtil.receptors.add(instance);
|
||||
FluidUtil.fluidReceptors.add(instance);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int doInsertItem(Object into, ItemStack item, ForgeDirection side) {
|
||||
if(into instanceof IPipeTile) {
|
||||
return ((IPipeTile) into).injectItem(item, true, side);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertIntoObject(Object into, ForgeDirection side) {
|
||||
if(into instanceof IPipeTile) {
|
||||
IPipeTile pipe = (IPipeTile) into;
|
||||
return pipe.getPipeType() == PipeType.ITEM;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidReceptor(IFluidHandler handler) {
|
||||
if(handler instanceof IPipeTile) {
|
||||
IPipeTile pipe = (IPipeTile) handler;
|
||||
return pipe.getPipeType() == PipeType.FLUID;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,12 +16,24 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.Log;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
|
||||
public class FluidUtil {
|
||||
|
||||
public static final List<IFluidReceptor> fluidReceptors = new ArrayList<IFluidReceptor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("crazypants.util.BuildcraftUtil");
|
||||
} catch (Exception e) {
|
||||
if(Loader.isModLoaded("BuildCraft|Transport")) {
|
||||
Log.warn("ItemUtil: Could not register Build Craft pipe handler. Fluid conduits will show connections to all Build Craft pipes.");
|
||||
} //Don't log if BC isn't installed, but we still check in case another mod is using their API
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<ForgeDirection, IFluidHandler> getNeighbouringFluidHandlers(IBlockAccess world, BlockCoord bc) {
|
||||
Map<ForgeDirection, IFluidHandler> res = new HashMap<ForgeDirection, IFluidHandler>();
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -49,12 +61,13 @@ public class FluidUtil {
|
||||
|
||||
public static IFluidHandler getFluidHandler(TileEntity te) {
|
||||
if(te instanceof IFluidHandler) {
|
||||
if(te instanceof IPipeTile) {
|
||||
if(((IPipeTile) te).getPipeType() != PipeType.FLUID) {
|
||||
IFluidHandler res = (IFluidHandler) te;
|
||||
for (IFluidReceptor rec : fluidReceptors) {
|
||||
if(!rec.isValidReceptor(res)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (IFluidHandler) te;
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface IFluidReceptor {
|
||||
|
||||
boolean isValidReceptor(IFluidHandler handler);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IItemReceptor {
|
||||
|
||||
boolean canInsertIntoObject(Object into, ForgeDirection side);
|
||||
|
||||
int doInsertItem(Object into, ItemStack item, ForgeDirection side);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package crazypants.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
@@ -7,16 +10,29 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import crazypants.enderio.Log;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
public static final List<IItemReceptor> receptors = new ArrayList<IItemReceptor>();
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("crazypants.util.BuildcraftUtil");
|
||||
} catch (Exception e) {
|
||||
if(Loader.isModLoaded("BuildCraft|Transport")) {
|
||||
Log.warn("ItemUtil: Could not register Build Craft pipe handler. Machines will not be able to output to BC pipes.");
|
||||
} //Don't log if BC isn't installed, but we still check in case another mod is using their API
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDurabilityString(ItemStack item) {
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage();
|
||||
return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage();
|
||||
}
|
||||
|
||||
public static NBTTagCompound getOrCreateNBT(ItemStack stack) {
|
||||
@@ -36,9 +52,14 @@ public class ItemUtil {
|
||||
return ItemUtil.doInsertItem(getInventory((IInventory) into), item);
|
||||
} else if(into instanceof IItemDuct) {
|
||||
return ItemUtil.doInsertItem((IItemDuct) into, item, side);
|
||||
} else if(into instanceof IPipeTile) {
|
||||
return ((IPipeTile) into).injectItem(item, true, side);
|
||||
}
|
||||
|
||||
for (IItemReceptor rec : receptors) {
|
||||
if(rec.canInsertIntoObject(into, side)) {
|
||||
return rec.doInsertItem(into, item, side);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -119,7 +140,7 @@ public class ItemUtil {
|
||||
toInsert.stackSize = 0;
|
||||
}
|
||||
}
|
||||
if (!inv.isItemValidForSlot(slot, toInsert)) {
|
||||
if(!inv.isItemValidForSlot(slot, toInsert)) {
|
||||
inserted = 0;
|
||||
}
|
||||
|
||||
@@ -166,6 +187,7 @@ public class ItemUtil {
|
||||
|
||||
/**
|
||||
* Checks if items, damage and NBT are equal and the items are stackable.
|
||||
*
|
||||
* @param s1
|
||||
* @param s2
|
||||
* @return
|
||||
@@ -176,12 +198,13 @@ public class ItemUtil {
|
||||
}
|
||||
if(!s1.isItemEqual(s2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ItemStack.areItemStackTagsEqual(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if items, damage and NBT are equal.
|
||||
*
|
||||
* @param s1
|
||||
* @param s2
|
||||
* @return
|
||||
@@ -192,7 +215,7 @@ public class ItemUtil {
|
||||
}
|
||||
if(!s1.isItemEqual(s2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ItemStack.areItemStackTagsEqual(s1, s2);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user