Start of work on Doing It Right™. Appears to work for cofh's API, not yet for IC2 or BC. Not sure why. Might have to ask @cpw.

This commit is contained in:
Ben Spiers 2014-06-26 01:10:53 +01:00
parent 82a708c7b2
commit 9c58ed549f
81 changed files with 425 additions and 155 deletions

View file

@ -1,6 +1,6 @@
minecraft_version=1.7.2
forge_version=10.12.1.1112
FMP_version=1.1.0.282
CCLIB_version=1.1.1.81
forge_version=10.12.2.1121
FMP_version=1.1.0.288
CCLIB_version=1.1.1.87
NEI_version=1.0.1
mod_version=7.0.0

View file

@ -3,9 +3,13 @@ package mekanism.api.gas;
import java.util.HashMap;
import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils;
import net.minecraftforge.fluids.FluidContainerRegistry;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional.Method;
import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.fuels.IronEngineFuel.Fuel;
@ -25,7 +29,7 @@ public class FuelHandler
return fuels.get(gas.getName());
}
if(gas.hasFluid())
if(Loader.isModLoaded("BuildCraftAPI|fuel") && gas.hasFluid())
{
Fuel bcFuel = IronEngineFuel.getFuelForFluid(gas.getFluid());

View file

@ -202,19 +202,19 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
{
sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending);
}
else if(acceptor instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler)acceptor;
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*Mekanism.TO_TE), false);
sent += used*Mekanism.FROM_TE;
}
else if(acceptor instanceof IEnergySink)
else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
{
double toSend = Math.min(currentSending, ((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2);
toSend = Math.min(toSend, ((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2);
sent += (toSend - (((IEnergySink)acceptor).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2));
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
{
PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite());
@ -262,7 +262,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(acceptor instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler)acceptor;
@ -274,7 +274,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(acceptor instanceof IEnergySink)
else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink)
{
IEnergySink handler = (IEnergySink)acceptor;
@ -286,7 +286,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor)
{
IPowerReceptor handler = (IPowerReceptor)acceptor;

View file

@ -1,18 +1,25 @@
package mekanism.common;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Coord4D;
import mekanism.api.IFilterAccess;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.IEnergyHandler;
import dan200.computercraft.api.peripheral.IPeripheral;
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
@InterfaceList({
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy")
})
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
{
public int[] getBoundSlots(Coord4D location, int side);

View file

@ -175,7 +175,7 @@ public class Mekanism
public static Mekanism instance;
/** Mekanism hooks instance */
public static MekanismHooks hooks = new MekanismHooks();
public static MekanismHooks hooks;
/** Mekanism configuration instance */
public static Configuration configuration;
@ -1091,7 +1091,7 @@ public class Mekanism
OreDictionary.registerOre("ingotIron", new ItemStack(Items.iron_ingot));
OreDictionary.registerOre("ingotGold", new ItemStack(Items.gold_ingot));
OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.redstone_ore));
OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.lit_redstone_ore));
//OreDictionary.registerOre("oreRedstone", new ItemStack(Blocks.lit_redstone_ore));
if(controlCircuitOreDict || !hooks.BasicComponentsLoaded)
{
@ -1344,6 +1344,7 @@ public class Mekanism
public void postInit(FMLPostInitializationEvent event)
{
proxy.loadSoundHandler();
hooks = new MekanismHooks();
hooks.hook();
MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent());

View file

@ -31,6 +31,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -151,7 +153,7 @@ public class BlockEnergyCube extends BlockContainer
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
{
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
{

View file

@ -22,6 +22,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -96,7 +98,7 @@ public class BlockGasTank extends BlockContainer
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
{
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
{

View file

@ -85,6 +85,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IPeripheral;
@ -657,7 +659,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
if(Loader.isModLoaded("BuildCraftAPI|tools") && tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench"))
{
if(((IToolWrench)tool).canWrench(entityplayer, x, y, z))
{

View file

@ -18,6 +18,8 @@ import mekanism.common.RobitAIPickup;
import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemRobit;
import mekanism.common.tile.TileEntityChargepad;
import mekanism.common.util.MekanismUtils;
import micdoodle8.mods.galacticraft.api.entity.IEntityBreathable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
@ -170,7 +172,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
{
setEnergy(getEnergy() + EnergizedItemManager.discharge(inventory[27], MAX_ELECTRICITY - getEnergy()));
}
else if(Mekanism.hooks.IC2Loaded && inventory[27].getItem() instanceof IElectricItem)
else if(MekanismUtils.useIC2() && inventory[27].getItem() instanceof IElectricItem)
{
IElectricItem item = (IElectricItem)inventory[27].getItem();
@ -180,7 +182,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
setEnergy(getEnergy() + gain);
}
}
else if(inventory[27].getItem() instanceof IEnergyContainerItem)
else if(MekanismUtils.useRF() && inventory[27].getItem() instanceof IEnergyContainerItem)
{
ItemStack itemStack = inventory[27];
IEnergyContainerItem item = (IEnergyContainerItem)inventory[27].getItem();

View file

@ -1,11 +1,5 @@
package mekanism.common.integration;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.RecipeInputOreDict;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes;
import java.util.List;
import java.util.Map;
@ -19,8 +13,15 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.common.event.FMLInterModComms;
import dan200.computercraft.api.ComputerCraftAPI;
import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.RecipeInputOreDict;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes;
/**
* Hooks for Mekanism. Use to grab items or blocks out of different mods.
@ -34,9 +35,11 @@ public final class MekanismHooks
private Class BuildCraftEnergy;
public boolean IC2Loaded = false;
public boolean IC2APILoaded = false;
public boolean RailcraftLoaded = false;
public boolean BasicComponentsLoaded = false;
public boolean BuildCraftLoaded = false;
public boolean BuildCraftPowerLoaded = false;
public boolean RedstoneFluxLoaded = false;
public boolean TELoaded = false;
public boolean CCLoaded = false;
@ -45,10 +48,12 @@ public final class MekanismHooks
public void hook()
{
if(ModAPIManager.INSTANCE.hasAPI("IC2API")) IC2APILoaded = true;
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|power")) BuildCraftPowerLoaded = true;
if(ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy")) RedstoneFluxLoaded = true;
if(Loader.isModLoaded("IC2")) IC2Loaded = true;
if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true;
if(Loader.isModLoaded("BasicComponents")) BasicComponentsLoaded = true;
if(Loader.isModLoaded("BuildCraft|Energy")) BuildCraftLoaded = true;
if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true;
if(Loader.isModLoaded("ComputerCraft")) CCLoaded = true;
@ -60,6 +65,44 @@ public final class MekanismHooks
}
if(IC2Loaded)
{
hookIC2Recipes();
Mekanism.logger.info("Hooked into IC2 successfully.");
}
if(BasicComponentsLoaded)
{
if(Mekanism.disableBCSteelCrafting)
{
MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelDust"));
MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelIngot"));
}
if(Mekanism.disableBCBronzeCrafting)
{
MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeDust"));
MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeIngot"));
}
Mekanism.logger.info("Hooked into BasicComponents successfully.");
}
if(BuildCraftPowerLoaded)
{
Mekanism.logger.info("Hooked into BuildCraft successfully.");
}
if(CCLoaded)
{
try {
ComputerCraftAPI.registerPeripheralProvider((BlockMachine)Mekanism.MachineBlock);
} catch(Exception ex) {}
}
}
@Method(modid = "IC2API")
public void hookIC2Recipes()
{
for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
{
@ -112,39 +155,6 @@ public final class MekanismHooks
tag.setInteger("amplification", 50000);
Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag);
Mekanism.logger.info("Hooked into IC2 successfully.");
}
if(BasicComponentsLoaded)
{
if(Mekanism.disableBCSteelCrafting)
{
MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelDust"));
MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelIngot"));
}
if(Mekanism.disableBCBronzeCrafting)
{
MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeDust"));
MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeIngot"));
}
Mekanism.logger.info("Hooked into BasicComponents successfully.");
}
if(BuildCraftLoaded)
{
Mekanism.logger.info("Hooked into BuildCraft successfully.");
}
if(CCLoaded)
{
try {
ComputerCraftAPI.registerPeripheralProvider((BlockMachine)Mekanism.MachineBlock);
} catch(Exception ex) {}
}
}
public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy)

View file

@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Optional.Method;
public final class OreDictManager
{
@ -348,9 +349,9 @@ public final class OreDictManager
try {
RecipeHandler.addCrusherRecipe(new ItemStack(Mekanism.Ingot, 1, 2), MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
if(Mekanism.hooks.IC2Loaded)
if(Mekanism.hooks.IC2APILoaded)
{
Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
addIC2BronzeRecipe();
}
} catch(Exception e) {}
@ -456,6 +457,13 @@ public final class OreDictManager
}
@Method(modid = "IC2API")
public static void addIC2BronzeRecipe()
{
Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
}
/**
* Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Taken from CofhCore.
*/

View file

@ -5,6 +5,8 @@ import mekanism.common.inventory.slot.SlotEnergy.SlotCharge;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.tile.TileEntityEnergyCube;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
@ -181,6 +183,6 @@ public class ContainerEnergyCube extends Container
private boolean canTransfer(ItemStack slotStack)
{
return slotStack.getItem() instanceof IElectricItem;
return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem;
}
}

View file

@ -31,9 +31,17 @@ import net.minecraftforge.common.util.Constants.NBT;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"),
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API")
})
public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem
{
public Block metaBlock;
@ -126,24 +134,28 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE
}
@Override
@Method(modid = "IC2API")
public boolean canProvideEnergy(ItemStack itemStack)
{
return true;
}
@Override
@Method(modid = "IC2API")
public int getMaxCharge(ItemStack itemStack)
{
return 0;
}
@Override
@Method(modid = "IC2API")
public int getTier(ItemStack itemStack)
{
return 4;
}
@Override
@Method(modid = "IC2API")
public int getTransferLimit(ItemStack itemStack)
{
return 0;
@ -291,18 +303,21 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE
}
@Override
@Method(modid = "IC2API")
public IElectricItemManager getManager(ItemStack itemStack)
{
return IC2ItemManager.getManager(this);
}
@Override
@Method(modid = "IC2API")
public Item getChargedItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public Item getEmptyItem(ItemStack itemStack)
{
return this;

View file

@ -65,6 +65,10 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -101,6 +105,10 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"),
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API")
})
public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem
{
public Block metaBlock;
@ -385,24 +393,28 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
@Override
@Method(modid = "IC2API")
public boolean canProvideEnergy(ItemStack itemStack)
{
return false;
}
@Override
@Method(modid = "IC2API")
public int getMaxCharge(ItemStack itemStack)
{
return 0;
}
@Override
@Method(modid = "IC2API")
public int getTier(ItemStack itemStack)
{
return 4;
}
@Override
@Method(modid = "IC2API")
public int getTransferLimit(ItemStack itemStack)
{
return 0;
@ -425,7 +437,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
{
setEnergy(itemstack, getEnergy(itemstack) + EnergizedItemManager.discharge(inv.getStackInSlot(54), getMaxEnergy(itemstack) - getEnergy(itemstack)));
}
else if(Mekanism.hooks.IC2Loaded && inv.getStackInSlot(54).getItem() instanceof IElectricItem)
else if(MekanismUtils.useIC2() && inv.getStackInSlot(54).getItem() instanceof IElectricItem)
{
IElectricItem item = (IElectricItem)inv.getStackInSlot(54).getItem();
@ -435,7 +447,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
setEnergy(itemstack, getEnergy(itemstack) + gain);
}
}
else if(inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem)
else if(MekanismUtils.useRF() && inv.getStackInSlot(54).getItem() instanceof IEnergyContainerItem)
{
ItemStack itemStack = inv.getStackInSlot(54);
IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(54).getItem();
@ -981,6 +993,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
@Override
@Method(modid = "IC2API")
public double getMaxTransfer(ItemStack itemStack)
{
return getMaxEnergy(itemStack)*0.005;
@ -1055,18 +1068,21 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
@Override
@Method(modid = "IC2API")
public IElectricItemManager getManager(ItemStack itemStack)
{
return IC2ItemManager.getManager(this);
}
@Override
@Method(modid = "IC2API")
public Item getChargedItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public Item getEmptyItem(ItemStack itemStack)
{
return this;

View file

@ -22,8 +22,12 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import buildcraft.api.tools.IToolWrench;
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools")
public class ItemConfigurator extends ItemEnergized implements IToolWrench
{
public final int ENERGY_PER_CONFIGURE = 400;
@ -304,11 +308,13 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench
}
@Override
@Method(modid = "BuildCraftAPI|tools")
public boolean canWrench(EntityPlayer player, int x, int y, int z)
{
return !(player.worldObj.getTileEntity(x, y, z) instanceof TileEntityBasicBlock);
}
@Override
@Method(modid = "BuildCraftAPI|tools")
public void wrenchUsed(EntityPlayer player, int x, int y, int z) {}
}

View file

@ -15,8 +15,16 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cofh.api.energy.IEnergyContainerItem;
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"),
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API")
})
public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem
{
/** The maximum amount of energy this item can hold. */
@ -57,36 +65,42 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec
}
@Override
@Method(modid = "IC2API")
public boolean canProvideEnergy(ItemStack itemStack)
{
return canSend(itemStack);
}
@Override
@Method(modid = "IC2API")
public Item getChargedItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public Item getEmptyItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public int getMaxCharge(ItemStack itemStack)
{
return 0;
}
@Override
@Method(modid = "IC2API")
public int getTier(ItemStack itemStack)
{
return 4;
}
@Override
@Method(modid = "IC2API")
public int getTransferLimit(ItemStack itemStack)
{
return 0;
@ -200,6 +214,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec
}
@Override
@Method(modid = "IC2API")
public IElectricItemManager getManager(ItemStack itemStack)
{
return IC2ItemManager.getManager(this);

View file

@ -27,10 +27,18 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"),
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API")
})
public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem
{
/** The maximum amount of energy this item can hold. */
@ -96,36 +104,42 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci
}
@Override
@Method(modid = "IC2API")
public boolean canProvideEnergy(ItemStack itemStack)
{
return canSend(itemStack);
}
@Override
@Method(modid = "IC2API")
public Item getChargedItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public Item getEmptyItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public int getMaxCharge(ItemStack itemStack)
{
return 0;
}
@Override
@Method(modid = "IC2API")
public int getTier(ItemStack itemStack)
{
return 4;
}
@Override
@Method(modid = "IC2API")
public int getTransferLimit(ItemStack itemStack)
{
return 0;
@ -239,6 +253,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci
}
@Override
@Method(modid = "IC2API")
public IElectricItemManager getManager(ItemStack itemStack)
{
return IC2ItemManager.getManager(this);

View file

@ -37,9 +37,13 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeWire;
import codechicken.lib.vec.Vector3;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Interface(iface = "buildcraft.api.transport.IPipeTile", modid = "BuildCraftAPI|transport")
public class PartLogisticalTransporter extends PartSidedPipe implements ILogisticalTransporter, IPipeTile
{
public static TransmitterIcons transporterIcons = new TransmitterIcons(3, 2);
@ -760,6 +764,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti
}
@Override
@Method(modid = "BuildCraftAPI|transport")
public boolean isWireActive(PipeWire wire)
{
return false;

View file

@ -47,6 +47,8 @@ import codechicken.multipart.NormalOcclusionTest;
import codechicken.multipart.PartMap;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -421,7 +423,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
return false;
}
if(item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking())
if(Loader.isModLoaded("BuildCraftAPI|tools") && item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking())
{
if(!world().isRemote)
{

View file

@ -1,6 +1,6 @@
package mekanism.common.multipart;
import ic2.api.energy.tile.IEnergySource;
//import ic2.api.energy.tile.IEnergySource;
import java.util.List;
import java.util.Set;
@ -26,9 +26,17 @@ import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import codechicken.lib.vec.Vector3;
import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
})
public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implements IStrictEnergyAcceptor, IEnergyHandler, IPowerReceptor
{
public Tier.CableTier tier;
@ -46,10 +54,14 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
public PartUniversalCable(Tier.CableTier cableTier)
{
tier = cableTier;
if(MekanismUtils.useBuildCraft())
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
}
@Override
public void update()
@ -80,6 +92,8 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
cacheEnergy = 0;
}
/*if(MekanismUtils.useIC2())
{
List<ForgeDirection> sides = getConnections(ConnectionType.PULL);
if(!sides.isEmpty())
{
@ -93,18 +107,19 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
if(acceptor instanceof IEnergySource)
{
double received = ((IEnergySource) acceptor).getOfferedEnergy()*Mekanism.FROM_IC2;
double received = ((IEnergySource) acceptor).getOfferedEnergy() * Mekanism.FROM_IC2;
double toDraw = received;
if(received > 0)
{
toDraw -= getTransmitterNetwork().emit(received);
}
((IEnergySource) acceptor).drawEnergy(toDraw*Mekanism.TO_IC2);
((IEnergySource) acceptor).drawEnergy(toDraw * Mekanism.TO_IC2);
}
}
}
}
}*/
}
super.update();
@ -252,6 +267,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
}
@Override
@Method(modid = "CoFHAPI|energy")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if(!simulate)
@ -263,24 +279,28 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
}
@Override
@Method(modid = "CoFHAPI|energy")
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
return 0;
}
@Override
@Method(modid = "CoFHAPI|energy")
public boolean canConnectEnergy(ForgeDirection from)
{
return true;
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getEnergyStored(ForgeDirection from)
{
return 0;
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getMaxEnergyStored(ForgeDirection from)
{
return (int)Math.round(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_TE);
@ -331,6 +351,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getTransmitterNetwork().getEnergyNeeded() == 0)
@ -342,6 +363,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
return world();

View file

@ -1,7 +1,6 @@
package mekanism.common.tile;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Coord4D;
import mekanism.api.IFilterAccess;
import mekanism.api.energy.IStrictEnergyAcceptor;
@ -15,6 +14,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
@ -23,7 +26,12 @@ import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
@InterfaceList({
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy")
})
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
{
@Override
public int getSizeInventory()
@ -186,6 +194,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "IC2API")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
if(getInv() == null)
@ -197,6 +206,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "CoFHAPI|energy")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if(getInv() == null)
@ -208,6 +218,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "CoFHAPI|energy")
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
if(getInv() == null)
@ -219,6 +230,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "CoFHAPI|energy")
public boolean canConnectEnergy(ForgeDirection from)
{
if(getInv() == null)
@ -230,6 +242,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getEnergyStored(ForgeDirection from)
{
if(getInv() == null)
@ -241,6 +254,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getMaxEnergyStored(ForgeDirection from)
{
if(getInv() == null)
@ -285,6 +299,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getInv() == null)
@ -296,6 +311,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "BuildCraftAPI|power")
public void doWork(PowerHandler workProvider)
{
if(getInv() == null)
@ -307,6 +323,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
if(getInv() == null)
@ -340,6 +357,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "IC2API")
public double demandedEnergyUnits()
{
if(getInv() == null)
@ -351,6 +369,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "IC2API")
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
{
if(getInv() == null)
@ -362,6 +381,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
}
@Override
@Method(modid = "IC2API")
public int getMaxSafeInput()
{
if(getInv() == null)

View file

@ -22,7 +22,10 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
@Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2API")
public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork
{
/** The direction this block is facing. */
@ -158,18 +161,21 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
}
@Override
@Method(modid = "IC2API")
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
{
return true;
}
@Override
@Method(modid = "IC2API")
public short getFacing()
{
return (short)facing;
}
@Override
@Method(modid = "IC2API")
public void setFacing(short direction)
{
if(canSetFacing(direction))
@ -196,18 +202,21 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench
}
@Override
@Method(modid = "IC2API")
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
return true;
}
@Override
@Method(modid = "IC2API")
public float getWrenchDropRate()
{
return 1.0F;
}
@Override
@Method(modid = "IC2API")
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return getBlockType().getPickBlock(null, worldObj, xCoord, yCoord, zCoord);

View file

@ -21,9 +21,19 @@ import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
})
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl
{
/** This machine's side configuration. */

View file

@ -123,12 +123,12 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
{
setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy()));
}
else if(Mekanism.hooks.IC2Loaded && itemstack.getItem() instanceof IElectricItem)
else if(MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem)
{
double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2;
setEnergy(getEnergy() - sent);
}
else if(itemstack.getItem() instanceof IEnergyContainerItem)
else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem)
{
IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem();

View file

@ -3,7 +3,6 @@ package mekanism.common.tile;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IEnergyStorage;
import io.netty.buffer.ByteBuf;
@ -23,13 +22,25 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import cofh.api.energy.IEnergyHandler;
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
@InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
})
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
{
/** How much energy is stored in this block. */
public double electricityStored;
@ -51,14 +62,17 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
super(name);
MAX_ELECTRICITY = maxEnergy;
if(Loader.isModLoaded("BuildCraftAPI|power"))
{
powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE);
powerHandler.configurePowerPerdition(0, 0);
powerHandler.configure(0, 0, 0, 0);
}
}
public void register()
{
if(!worldObj.isRemote)
if(!worldObj.isRemote && Loader.isModLoaded("IC2API"))
{
if(!Mekanism.ic2Registered.contains(Coord4D.get(this)))
{
@ -70,7 +84,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
public void deregister()
{
if(!worldObj.isRemote)
if(!worldObj.isRemote && Loader.isModLoaded("IC2API"))
{
if(Mekanism.ic2Registered.contains(Coord4D.get(this)))
{
@ -171,6 +185,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "BuildCraftAPI|power")
public PowerReceiver getPowerReceiver(ForgeDirection side)
{
if(getConsumingSides().contains(side))
@ -183,13 +198,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
protected void reconfigure()
{
if(MekanismUtils.useBuildCraft())
if(Loader.isModLoaded("BuildCraftAPI|power"))
{
powerHandler.configure(1, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC));
}
}
@Override
@Method(modid = "BuildCraftAPI|power")
public void doWork(PowerHandler workProvider)
{
if(powerHandler.getEnergyStored() > 0)
@ -206,6 +222,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "BuildCraftAPI|power")
public World getWorld()
{
return worldObj;
@ -222,6 +239,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "CoFHAPI|energy")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
if(getConsumingSides().contains(from))
@ -240,6 +258,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "CoFHAPI|energy")
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
if(getOutputtingSides().contains(from))
@ -258,36 +277,42 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "CoFHAPI|energy")
public boolean canConnectEnergy(ForgeDirection from)
{
return getConsumingSides().contains(from) || getOutputtingSides().contains(from);
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getEnergyStored(ForgeDirection from)
{
return (int)Math.round(getEnergy()*Mekanism.TO_TE);
}
@Override
@Method(modid = "CoFHAPI|energy")
public int getMaxEnergyStored(ForgeDirection from)
{
return (int)Math.round(getMaxEnergy()*Mekanism.TO_TE);
}
@Override
@Method(modid = "IC2API")
public int getMaxSafeInput()
{
return Integer.MAX_VALUE;
}
@Override
@Method(modid = "IC2API")
public void setStored(int energy)
{
setEnergy(energy*Mekanism.FROM_IC2);
}
@Override
@Method(modid = "IC2API")
public int addEnergy(int amount)
{
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
@ -295,6 +320,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "IC2API")
public boolean isTeleporterCompatible(ForgeDirection side)
{
return getOutputtingSides().contains(side);
@ -307,30 +333,35 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "IC2API")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
return !getOutputtingSides().contains(direction);
}
@Override
@Method(modid = "IC2API")
public int getStored()
{
return (int)Math.round(getEnergy()*Mekanism.TO_IC2);
}
@Override
@Method(modid = "IC2API")
public int getCapacity()
{
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2);
}
@Override
@Method(modid = "IC2API")
public int getOutput()
{
return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2);
}
@Override
@Method(modid = "IC2API")
public double demandedEnergyUnits()
{
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
@ -343,12 +374,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "IC2API")
public double getOutputEnergyUnitsPerTick()
{
return getMaxOutput()*Mekanism.TO_IC2;
}
@Override
@Method(modid = "IC2API")
public double injectEnergyUnits(ForgeDirection direction, double i)
{
if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter)
@ -374,6 +407,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
}
@Override
@Method(modid = "BuildCraftAPI|power")
public boolean canEmitPowerFrom(ForgeDirection side)
{
return getOutputtingSides().contains(side);

View file

@ -11,9 +11,19 @@ import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
@InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
})
public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
{
/**

View file

@ -7,7 +7,16 @@ import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
@InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power")
})
public class TileEntityEnergizedSmelter extends TileEntityElectricMachine
{
public static Map<ItemStack, ItemStack> furnaceRecipes = new HashMap<ItemStack, ItemStack>();

View file

@ -59,9 +59,9 @@ public final class CableUtils
public static boolean isEnergyAcceptor(TileEntity tileEntity)
{
return (tileEntity instanceof IStrictEnergyAcceptor ||
tileEntity instanceof IEnergySink ||
(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildCraft()) ||
tileEntity instanceof IEnergyHandler);
(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink) ||
(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter)) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler));
}
/**
@ -149,9 +149,9 @@ public final class CableUtils
public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side)
{
return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
(tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) ||
(tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) ||
(tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite()));
(MekanismUtils.useIC2() && tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) ||
(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite()));
}
/**
@ -186,7 +186,7 @@ public final class CableUtils
return true;
}
}
else if(tileEntity instanceof IEnergyAcceptor)
else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergyAcceptor)
{
if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(orig, side.getOpposite()))
{
@ -200,14 +200,14 @@ public final class CableUtils
return true;
}
}
else if(tileEntity instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler)
{
if(((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite()))
{
return true;
}
}
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
else if(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor)
{
if(((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()) != null)
{
@ -305,7 +305,7 @@ public final class CableUtils
sent += acceptor.transferEnergyToAcceptor(side.getOpposite(), sendingEnergy);
}
}
else if(tileEntity instanceof IEnergyHandler)
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler)tileEntity;
@ -315,7 +315,7 @@ public final class CableUtils
sent += used*Mekanism.FROM_TE;
}
}
else if(tileEntity instanceof IEnergySink)
else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink)
{
if(((IEnergySink)tileEntity).acceptsEnergyFrom(from, side.getOpposite()))
{
@ -324,7 +324,7 @@ public final class CableUtils
sent += (toSend - rejects);
}
}
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
else if(MekanismUtils.useBuildCraft() && tileEntity instanceof IPowerReceptor)
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite());

View file

@ -25,7 +25,7 @@ public final class ChargeUtils
{
storer.setEnergy(storer.getEnergy() + EnergizedItemManager.discharge(storer.inventory[slotID], storer.getMaxEnergy() - storer.getEnergy()));
}
else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem)
else if(MekanismUtils.useIC2() && storer.inventory[slotID].getItem() instanceof IElectricItem)
{
IElectricItem item = (IElectricItem)storer.inventory[slotID].getItem();
@ -35,7 +35,7 @@ public final class ChargeUtils
storer.setEnergy(storer.getEnergy() + gain);
}
}
else if(storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
else if(MekanismUtils.useRF() && storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
{
ItemStack itemStack = storer.inventory[slotID];
IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem();
@ -71,12 +71,12 @@ public final class ChargeUtils
{
storer.setEnergy(storer.getEnergy() - EnergizedItemManager.charge(storer.inventory[slotID], storer.getEnergy()));
}
else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem)
else if(Mekanism.hooks.IC2APILoaded && storer.inventory[slotID].getItem() instanceof IElectricItem)
{
double sent = ElectricItem.manager.charge(storer.inventory[slotID], (int)(storer.getEnergy()*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2;
storer.setEnergy(storer.getEnergy() - sent);
}
else if(storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
else if(MekanismUtils.useRF() && storer.inventory[slotID].getItem() instanceof IEnergyContainerItem)
{
ItemStack itemStack = storer.inventory[slotID];
IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem();
@ -96,9 +96,9 @@ public final class ChargeUtils
*/
public static boolean canBeDischarged(ItemStack itemstack)
{
return (itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) ||
return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) ||
(itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
itemstack.getItem() == Items.redstone;
}
@ -109,9 +109,9 @@ public final class ChargeUtils
*/
public static boolean canBeCharged(ItemStack itemstack)
{
return itemstack.getItem() instanceof IElectricItem ||
return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) ||
(itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0);
(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0);
}
/**
@ -125,10 +125,10 @@ public final class ChargeUtils
{
if(chargeSlot)
{
return itemstack.getItem() instanceof IElectricItem;
return MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem;
}
else {
return itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack);
return MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack);
}
}
}

View file

@ -1173,13 +1173,33 @@ public final class MekanismUtils
}
/**
* Whether or not BuildCraft power should be used, taking into account both whether or not it is installed or if
* the player has configured the mod to do so.
* Whether or not BuildCraft power should be used, taking into account whether it is installed or another mod is
* providing its API.
* @return if BuildCraft power should be used
*/
public static boolean useBuildCraft()
{
return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft;
return Mekanism.hooks.BuildCraftPowerLoaded;
}
/**
* Whether or not IC2 power should be used, taking into account whether or not it is installed or another mod is
* providing its API.
* @return if IC2 power should be used
*/
public static boolean useIC2()
{
return Mekanism.hooks.IC2APILoaded;
}
/**
* Whether or not RF power should be used, taking into account whether or not it is installed or another mod is
* providing its API.
* @return if RF power should be used
*/
public static boolean useRF()
{
return Mekanism.hooks.RedstoneFluxLoaded;
}
/**

View file

@ -24,6 +24,8 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import buildcraft.api.fuels.IronEngineFuel;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@ -60,6 +62,8 @@ public class MekanismGenerators implements IModule
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
if(Loader.isModLoaded("BuildCraftAPI|fuels"))
{
for(String s : IronEngineFuel.fuels.keySet())
{
@ -71,7 +75,8 @@ public class MekanismGenerators implements IModule
}
}
IronEngineFuel.addFuel("ethene", (float)(240*Mekanism.TO_BC), 40*FluidContainerRegistry.BUCKET_VOLUME);
IronEngineFuel.addFuel("ethene", (float) (240 * Mekanism.TO_BC), 40 * FluidContainerRegistry.BUCKET_VOLUME);
}
}
@EventHandler

View file

@ -39,6 +39,8 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.tools.IToolWrench;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -302,7 +304,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds
if(entityplayer.getCurrentEquippedItem() != null)
{
if(entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench"))
if(Loader.isModLoaded("BuildCraftAPI|tools") && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench"))
{
if(entityplayer.isSneaking())
{

View file

@ -31,6 +31,10 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -45,6 +49,11 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
@InterfaceList({
@Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "CoFHAPI|energy"),
@Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2API")
})
public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem
{
public Block metaBlock;
@ -176,36 +185,42 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
}
@Override
@Method(modid = "IC2API")
public boolean canProvideEnergy(ItemStack itemStack)
{
return canSend(itemStack);
}
@Override
@Method(modid = "IC2API")
public Item getChargedItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public Item getEmptyItem(ItemStack itemStack)
{
return this;
}
@Override
@Method(modid = "IC2API")
public int getMaxCharge(ItemStack itemStack)
{
return 0;
}
@Override
@Method(modid = "IC2API")
public int getTier(ItemStack itemStack)
{
return 4;
}
@Override
@Method(modid = "IC2API")
public int getTransferLimit(ItemStack itemStack)
{
return 0;
@ -397,6 +412,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
}
@Override
@Method(modid = "IC2API")
public IElectricItemManager getManager(ItemStack itemStack)
{
return IC2ItemManager.getManager(this);

View file

@ -17,13 +17,13 @@ import mekanism.common.util.MekanismUtils;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.power.IPowerReceptor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPeripheral, IActiveState, IHasSound, IRedstoneControl
{
/** Output per tick this generator can transfer. */
public double output;
@ -44,7 +44,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
* Generator -- a block that produces energy. It has a certain amount of fuel it can store as well as an output rate.
* @param name - full name of this generator
* @param maxEnergy - how much energy this generator can store
* @param maxFuel - how much fuel this generator can store
*/
public TileEntityGenerator(String name, double maxEnergy, double out)
{