From 1393304f00cd1e018e3229b02125b989f378aa67 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sat, 23 Aug 2014 19:15:21 -0400 Subject: [PATCH 01/26] Allowed Aer-imbued fire to work on grass (cherry picked from commit b02410d) --- .../common/block/fire/BlockFireAir.java | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java index 4f1841f1..a54d35dc 100644 --- a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java +++ b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java @@ -19,34 +19,35 @@ import thaumic.tinkerer.common.research.TTResearchItem; import java.util.HashMap; public class BlockFireAir extends BlockFireBase { - @Override - public String getBlockName() { - return LibBlockNames.BLOCK_FIRE_AIR; - } + @Override + public String getBlockName() { + return LibBlockNames.BLOCK_FIRE_AIR; + } - @Override - public IRegisterableResearch getResearchItem() { - return (TTResearchItem) new TTResearchItem(LibResearch.KEY_FIRE_AER, new AspectList().add(Aspect.FIRE, 5).add(Aspect.AIR, 5), 3, -7, 2, new ItemStack(this)).setParents(LibResearch.KEY_BRIGHT_NITOR).setConcealed() - .setPages(new ResearchPage("0"), ResearchHelper.crucibleRecipePage(LibResearch.KEY_FIRE_AER)).setSecondary(); - } + @Override + public IRegisterableResearch getResearchItem() { + return (TTResearchItem) new TTResearchItem(LibResearch.KEY_FIRE_AER, new AspectList().add(Aspect.FIRE, 5).add(Aspect.AIR, 5), 3, -7, 2, new ItemStack(this)).setParents(LibResearch.KEY_BRIGHT_NITOR).setConcealed() + .setPages(new ResearchPage("0"), ResearchHelper.crucibleRecipePage(LibResearch.KEY_FIRE_AER)).setSecondary(); + } - @Override - public ThaumicTinkererRecipe getRecipeItem() { - return new ThaumicTinkererCrucibleRecipe(LibResearch.KEY_FIRE_AER, new ItemStack(this), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemBrightNitor.class)), new AspectList().add(Aspect.FIRE, 5).add(Aspect.MAGIC, 5).add(Aspect.AIR, 5)); - } + @Override + public ThaumicTinkererRecipe getRecipeItem() { + return new ThaumicTinkererCrucibleRecipe(LibResearch.KEY_FIRE_AER, new ItemStack(this), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemBrightNitor.class)), new AspectList().add(Aspect.FIRE, 5).add(Aspect.MAGIC, 5).add(Aspect.AIR, 5)); + } - @Override - public HashMap getBlockTransformation() { - HashMap result = new HashMap(); - result.put(Blocks.log, Blocks.sand); - result.put(Blocks.leaves, Blocks.sandstone); - result.put(Blocks.leaves2, Blocks.sandstone); - result.put(Blocks.log2, Blocks.sand); - result.put(Blocks.ice, Blocks.glass); - result.put(Blocks.water, Blocks.cake); - result.put(Blocks.dirt, Blocks.sand); - return result; - } + @Override + public HashMap getBlockTransformation() { + HashMap result = new HashMap(); + result.put(Blocks.log, Blocks.sand); + result.put(Blocks.leaves, Blocks.sandstone); + result.put(Blocks.leaves2, Blocks.sandstone); + result.put(Blocks.log2, Blocks.sand); + result.put(Blocks.ice, Blocks.glass); + result.put(Blocks.water, Blocks.cake); + result.put(Blocks.dirt, Blocks.sand); + result.put(Blocks.grass, Blocks.sand); + return result; + } } From 9e4f99c777ae908152f7a9dfff2bc469f0de26c7 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sat, 23 Aug 2014 19:44:01 -0400 Subject: [PATCH 02/26] Added config option for fire. In completley unrelated news, I hate users. --- .../common/block/fire/BlockFireAir.java | 5 ++++- .../common/block/fire/BlockFireBase.java | 3 ++- .../common/core/handler/ConfigHandler.java | 22 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java index a54d35dc..a76051b0 100644 --- a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java +++ b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireAir.java @@ -7,6 +7,7 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.research.ResearchPage; import thaumic.tinkerer.common.ThaumicTinkerer; +import thaumic.tinkerer.common.core.handler.ConfigHandler; import thaumic.tinkerer.common.item.ItemBrightNitor; import thaumic.tinkerer.common.lib.LibBlockNames; import thaumic.tinkerer.common.lib.LibResearch; @@ -43,7 +44,9 @@ public class BlockFireAir extends BlockFireBase { result.put(Blocks.leaves2, Blocks.sandstone); result.put(Blocks.log2, Blocks.sand); result.put(Blocks.ice, Blocks.glass); - result.put(Blocks.water, Blocks.cake); + if (ConfigHandler.enableCake) { + result.put(Blocks.water, Blocks.cake); + } result.put(Blocks.dirt, Blocks.sand); result.put(Blocks.grass, Blocks.sand); return result; diff --git a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireBase.java b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireBase.java index ffd40711..846d57d6 100644 --- a/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireBase.java +++ b/src/main/java/thaumic/tinkerer/common/block/fire/BlockFireBase.java @@ -15,6 +15,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import thaumic.tinkerer.client.core.helper.IconHelper; +import thaumic.tinkerer.common.core.handler.ConfigHandler; import thaumic.tinkerer.common.item.ItemBlockFire; import thaumic.tinkerer.common.registry.ITTinkererBlock; @@ -83,7 +84,7 @@ public abstract class BlockFireBase extends BlockFire implements ITTinkererBlock } public void updateTick(World world, int x, int y, int z, Random rand) { - if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { + if (world.getGameRules().getGameRuleBooleanValue("doFireTick") && ConfigHandler.enableFire) { if (world.isRaining() && (world.canLightningStrikeAt(x, y, z) || world.canLightningStrikeAt(x - 1, y, z) || world.canLightningStrikeAt(x + 1, y, z) || world.canLightningStrikeAt(x, y, z - 1) || world.canLightningStrikeAt(x, y, z + 1))) { world.setBlockToAir(x, y, z); diff --git a/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java b/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java index f60f04a8..ae475b0b 100644 --- a/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java +++ b/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java @@ -45,13 +45,16 @@ public final class ConfigHandler { public static boolean useOreDictMetal = true; public static boolean repairTConTools = false; + public static boolean enableCake = true; + public static boolean showPlacementMirrorBlocks = true; public static int netherDimensionID = -1; public static int endDimensionID = 1; public static int bedrockDimensionID = 19; + public static boolean enableFire = true; - public static void loadConfig(File configFile) { - config = new Configuration(configFile); + public static void loadConfig(File configFile) { + config = new Configuration(configFile); new ConfigCategory(CATEGORY_POTIONS); new ConfigCategory(CATEGORY_ENCHANTMENTS); @@ -59,16 +62,16 @@ public final class ConfigHandler { new ConfigCategory(CATEGORY_KAMI_BLOCKS); new ConfigCategory(CATEGORY_KAMI_GENERAL); - String comment = "These will only be used if KAMI is loaded. (KAMI is a separate download you can find in the Thaumic Tinkerer thread)"; - config.addCustomCategoryComment(CATEGORY_KAMI_ITEMS, comment); + String comment = "These will only be used if KAMI is loaded"; + config.addCustomCategoryComment(CATEGORY_KAMI_ITEMS, comment); config.addCustomCategoryComment(CATEGORY_KAMI_BLOCKS, comment); config.addCustomCategoryComment(CATEGORY_KAMI_GENERAL, comment); config.load(); Property propEnableKami = config.get(Configuration.CATEGORY_GENERAL, "kami.forceenabled", true); - propEnableKami.comment = "Set to true to enable all kami stuff (note, either this OR the kami mod file will work)"; - enableKami = Loader.isModLoaded("ThaumicTinkererKami") || propEnableKami.getBoolean(true); + propEnableKami.comment = "Set to true to enable all kami stuff"; + enableKami = Loader.isModLoaded("ThaumicTinkererKami") || propEnableKami.getBoolean(true); Property propEnableTooltips = config.get(Configuration.CATEGORY_GENERAL, "tooltipIndicators.enabled", true); propEnableTooltips.comment = "Set to false to disable the [TT] tooltips in the thauminomicon."; @@ -99,6 +102,13 @@ public final class ConfigHandler { propOreDict.comment = "Set to false to disable usage of ore dictionary metals (tin and copper)."; useOreDictMetal = propOreDict.getBoolean(true); + Property propImbuedFire = config.get(Configuration.CATEGORY_GENERAL, "imbuedFire.enabled", true); + enableFire = propImbuedFire.getBoolean(true); + + Property propImbuedFireCake = config.get(Configuration.CATEGORY_GENERAL, "imbuedFire.cake.enabled", true); + propImbuedFireCake.comment = "Set to false to disable imbued fire making cake. For those people who don't like cake"; + enableCake = propImbuedFireCake.getBoolean(true); + if (enableKami) { Property propDimensionID = config.get(CATEGORY_KAMI_GENERAL, "Bedrock dimension id", -19); propDimensionID.comment = "Set to the dimension id wished for bedrock dimension, or 0 to disable"; From c149c75b540eb78934e9bedce837e17d6057bdf4 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sat, 23 Aug 2014 19:49:04 -0400 Subject: [PATCH 03/26] Made the fireworks in ichor robes non-metadata-specific --- .../thaumic/tinkerer/common/item/kami/armor/ItemGemChest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemChest.java b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemChest.java index 37f107e3..5eb24156 100644 --- a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemChest.java +++ b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemChest.java @@ -87,7 +87,7 @@ public class ItemGemChest extends ItemIchorclothArmorAdv { @Override public ThaumicTinkererRecipe getRecipeItem() { return new ThaumicTinkererInfusionRecipe(LibResearch.KEY_ICHORCLOTH_CHEST_GEM, new ItemStack(this), 13, new AspectList().add(Aspect.AIR, 50).add(Aspect.ARMOR, 32).add(Aspect.FLIGHT, 32).add(Aspect.ORDER, 32).add(Aspect.LIGHT, 64).add(Aspect.ELDRITCH, 16).add(Aspect.SENSES, 16), new ItemStack(ThaumicTinkerer.registry.getItemFromClassAndName(ItemIchorclothArmor.class, LibItemNames.ICHOR_CHEST)), - new ItemStack(Items.diamond, 1), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemKamiResource.class)), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemKamiResource.class)), new ItemStack(ConfigItems.itemFocusPrimal), new ItemStack(ConfigItems.itemThaumonomicon), new ItemStack(Items.golden_chestplate), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemFocusFlight.class)), new ItemStack(ConfigItems.itemHoverHarness), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemFocusDeflect.class)), new ItemStack(Items.feather), new ItemStack(Items.fireworks), new ItemStack(Items.arrow)); + new ItemStack(Items.diamond, 1), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemKamiResource.class)), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemKamiResource.class)), new ItemStack(ConfigItems.itemFocusPrimal), new ItemStack(ConfigItems.itemThaumonomicon), new ItemStack(Items.golden_chestplate), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemFocusFlight.class)), new ItemStack(ConfigItems.itemHoverHarness), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemFocusDeflect.class)), new ItemStack(Items.feather), new ItemStack(Items.fireworks, 1, 32767), new ItemStack(Items.arrow)); } From 8f6efcaf4537f3163cc34c0eb97259102b8182db Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sat, 23 Aug 2014 21:45:01 -0400 Subject: [PATCH 04/26] Fixed #462 --- .../common/block/tile/TileSummon.java | 119 +++++++++--------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/TileSummon.java b/src/main/java/thaumic/tinkerer/common/block/tile/TileSummon.java index 4354d35e..08b1db1f 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/TileSummon.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/TileSummon.java @@ -25,89 +25,90 @@ public class TileSummon extends TileEntity { if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) { return; } - ArrayList pedestals = new ArrayList(); - for (int x = xCoord - 5; x < xCoord + 5; x++) { - for (int z = zCoord - 5; z < zCoord + 5; z++) { - TileEntity tile = worldObj.getTileEntity(x, yCoord, z); - if (tile instanceof TilePedestal && ((TilePedestal) tile).getStackInSlot(0) != null && ((TilePedestal) tile).getStackInSlot(0).getItem() instanceof ItemMobAspect) { - pedestals.add(tile); + for (int radius = 1; radius < 6; radius++) { + ArrayList pedestals = new ArrayList(); + for (int x = xCoord - radius; x < xCoord + radius; x++) { + for (int z = zCoord - radius; z < zCoord + radius; z++) { + TileEntity tile = worldObj.getTileEntity(x, yCoord, z); + if (tile instanceof TilePedestal && ((TilePedestal) tile).getStackInSlot(0) != null && ((TilePedestal) tile).getStackInSlot(0).getItem() instanceof ItemMobAspect) { + pedestals.add(tile); + } } } - } - for (int i = 0; i < pedestals.size(); i++) { - for (int j = 0; j < pedestals.size(); j++) { - for (int k = 0; k < pedestals.size(); k++) { - TilePedestal ped1 = (TilePedestal) pedestals.get(i); - TilePedestal ped2 = (TilePedestal) pedestals.get(j); - TilePedestal ped3 = (TilePedestal) pedestals.get(k); + for (int i = 0; i < pedestals.size(); i++) { + for (int j = 0; j < pedestals.size(); j++) { + for (int k = 0; k < pedestals.size(); k++) { + TilePedestal ped1 = (TilePedestal) pedestals.get(i); + TilePedestal ped2 = (TilePedestal) pedestals.get(j); + TilePedestal ped3 = (TilePedestal) pedestals.get(k); - if ((ped1 != ped2) && (ped2 != ped3) && (ped1 != ped3)) { - ArrayList aspects = new ArrayList(); - aspects.add(ItemMobAspect.getAspect(ped1.getStackInSlot(0))); + if ((ped1 != ped2) && (ped2 != ped3) && (ped1 != ped3)) { + ArrayList aspects = new ArrayList(); + aspects.add(ItemMobAspect.getAspect(ped1.getStackInSlot(0))); - aspects.add(ItemMobAspect.getAspect(ped2.getStackInSlot(0))); + aspects.add(ItemMobAspect.getAspect(ped2.getStackInSlot(0))); - aspects.add(ItemMobAspect.getAspect(ped3.getStackInSlot(0))); + aspects.add(ItemMobAspect.getAspect(ped3.getStackInSlot(0))); - for (EnumMobAspect recipe : EnumMobAspect.values()) { - if (Arrays.asList(recipe.aspects).containsAll(aspects) && aspects.containsAll(Arrays.asList(recipe.aspects))) { + for (EnumMobAspect recipe : EnumMobAspect.values()) { + if (Arrays.asList(recipe.aspects).containsAll(aspects) && aspects.containsAll(Arrays.asList(recipe.aspects))) { - boolean isInfused = ItemMobAspect.isInfused(ped1.getStackInSlot(0)) && - ItemMobAspect.isInfused(ped2.getStackInSlot(0)) && - ItemMobAspect.isInfused(ped3.getStackInSlot(0)); + boolean isInfused = ItemMobAspect.isInfused(ped1.getStackInSlot(0)) && + ItemMobAspect.isInfused(ped2.getStackInSlot(0)) && + ItemMobAspect.isInfused(ped3.getStackInSlot(0)); - if (isInfused && worldObj.getTotalWorldTime() % 1200 != 0) { - return; - } + if (isInfused && worldObj.getTotalWorldTime() % 1200 != 0) { + return; + } - if (!isInfused) { - ped1.setInventorySlotContents(0, null); - ped2.setInventorySlotContents(0, null); - ped3.setInventorySlotContents(0, null); - } + if (!isInfused) { + ped1.setInventorySlotContents(0, null); + ped2.setInventorySlotContents(0, null); + ped3.setInventorySlotContents(0, null); + } - if (!isInfused || ItemMobAspect.lastUsedTabletMatches(ped1.getStackInSlot(0), this) - && ItemMobAspect.lastUsedTabletMatches(ped2.getStackInSlot(0), this) - && ItemMobAspect.lastUsedTabletMatches(ped3.getStackInSlot(0), this)) { + if (!isInfused || ItemMobAspect.lastUsedTabletMatches(ped1.getStackInSlot(0), this) + && ItemMobAspect.lastUsedTabletMatches(ped2.getStackInSlot(0), this) + && ItemMobAspect.lastUsedTabletMatches(ped3.getStackInSlot(0), this)) { - if (!worldObj.isRemote) { - Entity spawn = EntityList.createEntityByName(recipe.toString(), worldObj); - spawn.setLocationAndAngles(xCoord + .5, yCoord + 1, zCoord + .5, 0, 0); - if (spawn instanceof EntitySkeleton && worldObj.provider.isHellWorld) { - ((EntitySkeleton) spawn).setSkeletonType(1); + if (!worldObj.isRemote) { + Entity spawn = EntityList.createEntityByName(recipe.toString(), worldObj); + spawn.setLocationAndAngles(xCoord + .5, yCoord + 1, zCoord + .5, 0, 0); + if (spawn instanceof EntitySkeleton && worldObj.provider.isHellWorld) { + ((EntitySkeleton) spawn).setSkeletonType(1); + } + worldObj.spawnEntityInWorld(spawn); + ((EntityLiving) spawn).onSpawnWithEgg(null); + ((EntityLiving) spawn).playLivingSound(); } - worldObj.spawnEntityInWorld(spawn); - ((EntityLiving) spawn).onSpawnWithEgg(null); - ((EntityLiving) spawn).playLivingSound(); + + if (worldObj.isRemote) { + ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped1.xCoord, ped1.yCoord, ped1.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(0).getColor(), 20); + ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped2.xCoord, ped2.yCoord, ped2.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(1).getColor(), 20); + ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped3.xCoord, ped3.yCoord, ped3.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(2).getColor(), 20); + } + } + if (isInfused) { + ItemMobAspect.markLastUsedTablet(ped1.getStackInSlot(0), this); + + ItemMobAspect.markLastUsedTablet(ped2.getStackInSlot(0), this); + + ItemMobAspect.markLastUsedTablet(ped3.getStackInSlot(0), this); } - if (worldObj.isRemote) { - ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped1.xCoord, ped1.yCoord, ped1.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(0).getColor(), 20); - ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped2.xCoord, ped2.yCoord, ped2.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(1).getColor(), 20); - ThaumicTinkerer.tcProxy.essentiaTrailFx(worldObj, ped3.xCoord, ped3.yCoord, ped3.zCoord, xCoord, yCoord, zCoord, 20, aspects.get(2).getColor(), 20); - } + return; + } - if (isInfused) { - ItemMobAspect.markLastUsedTablet(ped1.getStackInSlot(0), this); - - ItemMobAspect.markLastUsedTablet(ped2.getStackInSlot(0), this); - - ItemMobAspect.markLastUsedTablet(ped3.getStackInSlot(0), this); - } - - return; - } + } } - } } } - } } From 20fd6305dbe65775e71b0c9f75be076703cbdfaa Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sun, 24 Aug 2014 08:35:23 -0400 Subject: [PATCH 05/26] Fixed dimension id conflict --- .../thaumic/tinkerer/common/core/handler/ConfigHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java b/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java index ae475b0b..e40f5b88 100644 --- a/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java +++ b/src/main/java/thaumic/tinkerer/common/core/handler/ConfigHandler.java @@ -110,8 +110,8 @@ public final class ConfigHandler { enableCake = propImbuedFireCake.getBoolean(true); if (enableKami) { - Property propDimensionID = config.get(CATEGORY_KAMI_GENERAL, "Bedrock dimension id", -19); - propDimensionID.comment = "Set to the dimension id wished for bedrock dimension, or 0 to disable"; + Property propDimensionID = config.get(CATEGORY_KAMI_GENERAL, "Bedrock dimension id", -47); + propDimensionID.comment = "Set to the dimension id wished for bedrock dimension, or 0 to disable"; bedrockDimensionID = propDimensionID.getInt(-19); Property oreBlacklist = config.get(CATEGORY_KAMI_GENERAL, "Bedrock dimension ore Blacklist", new String[]{ "oreFirestone" }); From e7cc9de002cf99a16df0cce0511b36383021c8cb Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sun, 24 Aug 2014 09:01:43 -0400 Subject: [PATCH 06/26] Fixed #461 --- src/api/java/ic2/api/Direction.java | 126 ++++ src/api/java/ic2/api/crops/BaseSeed.java | 56 ++ src/api/java/ic2/api/crops/CropCard.java | 371 +++++++++++ src/api/java/ic2/api/crops/Crops.java | 117 ++++ src/api/java/ic2/api/crops/ICropTile.java | 250 ++++++++ src/api/java/ic2/api/crops/package-info.java | 4 + src/api/java/ic2/api/energy/EnergyNet.java | 18 + src/api/java/ic2/api/energy/IEnergyNet.java | 74 +++ .../ic2/api/energy/event/EnergyTileEvent.java | 23 + .../api/energy/event/EnergyTileLoadEvent.java | 14 +- .../energy/event/EnergyTileUnloadEvent.java | 14 +- .../ic2/api/energy/event/package-info.java | 4 + src/api/java/ic2/api/energy/package-info.java | 4 + .../java/ic2/api/energy/prefab/BasicSink.java | 363 +++++++++++ .../ic2/api/energy/prefab/BasicSource.java | 364 +++++++++++ .../ic2/api/energy/prefab/package-info.java | 4 + .../ic2/api/energy/tile/IEnergyAcceptor.java | 27 + .../ic2/api/energy/tile/IEnergyConductor.java | 53 ++ .../ic2/api/energy/tile/IEnergyEmitter.java | 28 + .../java/ic2/api/energy/tile/IEnergySink.java | 43 ++ .../ic2/api/energy/tile/IEnergySource.java | 36 ++ .../java/ic2/api/energy/tile/IEnergyTile.java | 15 + .../java/ic2/api/energy/tile/IHeatSource.java | 23 + .../ic2/api/energy/tile/IKineticSource.java | 22 + .../ic2/api/energy/tile/IMetaDelegate.java | 33 + .../ic2/api/energy/tile/package-info.java | 4 + .../java/ic2/api/energy/usage.txt | 79 ++- src/api/java/ic2/api/event/LaserEvent.java | 114 ++++ src/api/java/ic2/api/event/PaintEvent.java | 32 + .../java/ic2/api/event/RetextureEvent.java | 37 ++ src/api/java/ic2/api/event/package-info.java | 4 + .../ic2/api/info/IEnergyValueProvider.java | 17 + .../java/ic2/api/info/IFuelValueProvider.java | 15 + src/api/java/ic2/api/info/Info.java | 32 + src/api/java/ic2/api/info/package-info.java | 4 + src/api/java/ic2/api/item/ElectricItem.java | 59 ++ .../api/item/IBackupElectricItemManager.java | 12 + .../java/ic2/api/item/IBlockCuttingBlade.java | 6 + src/api/java/ic2/api/item/IBoxable.java | 14 + src/api/java/ic2/api/item/IC2Items.java | 598 ++++++++++++++++++ src/api/java/ic2/api/item/IDebuggable.java | 22 + src/api/java/ic2/api/item/IElectricItem.java | 55 ++ .../ic2/api/item/IElectricItemManager.java | 93 +++ src/api/java/ic2/api/item/IItemHudInfo.java | 24 + .../java/ic2/api/item/IKineticWindRotor.java | 15 + src/api/java/ic2/api/item/IMetalArmor.java | 20 + .../ic2/api/item/ISpecialElectricItem.java | 13 + .../java/ic2/api/item/ITerraformingBP.java | 34 + src/api/java/ic2/api/item/ItemWrapper.java | 50 ++ src/api/java/ic2/api/item/package-info.java | 4 + ...INetworkClientTileEntityEventListener.java | 14 +- .../ic2/api/network/INetworkDataProvider.java | 14 +- .../network/INetworkItemEventListener.java | 19 + .../INetworkTileEntityEventListener.java | 12 +- .../api/network/INetworkUpdateListener.java | 14 + .../java/ic2/api/network/NetworkHelper.java | 199 ++++++ .../java/ic2/api/network/package-info.java | 4 + src/api/java/ic2/api/package-info.java | 4 + src/api/java/ic2/api/reactor/IReactor.java | 158 +++++ .../java/ic2/api/reactor/IReactorChamber.java | 19 + .../ic2/api/reactor/IReactorComponent.java | 101 +++ .../java/ic2/api/reactor/package-info.java | 4 + .../recipe/ICannerBottleRecipeManager.java | 51 ++ .../recipe/ICannerEnrichRecipeManager.java | 54 ++ .../api/recipe/ICraftingRecipeManager.java | 26 + .../ic2/api/recipe/IFluidHeatManager.java | 32 + .../ic2/api/recipe/ILiquidAcceptManager.java | 11 + .../ic2/api/recipe/IListRecipeManager.java | 41 ++ .../ic2/api/recipe/IMachineRecipeManager.java | 43 ++ .../java/ic2/api/recipe/IPatternStorage.java | 11 + src/api/java/ic2/api/recipe/IRecipeInput.java | 31 + .../java/ic2/api/recipe/IScrapboxManager.java | 13 + .../ic2/api/recipe/ISemiFluidFuelManager.java | 32 + .../api/recipe/RecipeInputFluidContainer.java | 54 ++ .../ic2/api/recipe/RecipeInputItemStack.java | 46 ++ .../ic2/api/recipe/RecipeInputOreDict.java | 71 +++ src/api/java/ic2/api/recipe/RecipeOutput.java | 28 + src/api/java/ic2/api/recipe/Recipes.java | 60 ++ src/api/java/ic2/api/recipe/package-info.java | 4 + .../java/ic2/api/tile/ExplosionWhitelist.java | 47 ++ src/api/java/ic2/api/tile/IEnergyStorage.java | 61 ++ src/api/java/ic2/api/tile/IWrenchable.java | 61 ++ src/api/java/ic2/api/tile/package-info.java | 4 + src/api/java/ic2/api/util/IKeyboard.java | 21 + src/api/java/ic2/api/util/Keys.java | 6 + src/api/java/ic2/api/util/package-info.java | 4 + src/main/java/ic2/api/Direction.java | 108 ---- src/main/java/ic2/api/crops/BaseSeed.java | 56 -- src/main/java/ic2/api/crops/CropCard.java | 366 ----------- src/main/java/ic2/api/crops/Crops.java | 103 --- src/main/java/ic2/api/crops/ICropTile.java | 253 -------- src/main/java/ic2/api/energy/EnergyNet.java | 175 ----- .../ic2/api/energy/event/EnergyTileEvent.java | 17 - .../energy/event/EnergyTileSourceEvent.java | 33 - .../ic2/api/energy/tile/IEnergyAcceptor.java | 22 - .../ic2/api/energy/tile/IEnergyConductor.java | 51 -- .../ic2/api/energy/tile/IEnergyEmitter.java | 23 - .../java/ic2/api/energy/tile/IEnergySink.java | 41 -- .../ic2/api/energy/tile/IEnergySource.java | 15 - .../java/ic2/api/energy/tile/IEnergyTile.java | 18 - src/main/java/ic2/api/event/PaintEvent.java | 29 - .../java/ic2/api/event/RetextureEvent.java | 33 - .../ic2/api/info/IEnergyValueProvider.java | 14 - .../java/ic2/api/info/IFuelValueProvider.java | 15 - src/main/java/ic2/api/info/Info.java | 6 - src/main/java/ic2/api/item/ElectricItem.java | 108 ---- src/main/java/ic2/api/item/IBoxable.java | 18 - .../ic2/api/item/ICustomElectricItem.java | 67 -- src/main/java/ic2/api/item/IElectricItem.java | 54 -- .../ic2/api/item/IElectricItemManager.java | 92 --- src/main/java/ic2/api/item/IMetalArmor.java | 20 - .../ic2/api/item/ISpecialElectricItem.java | 13 - .../java/ic2/api/item/ITerraformingBP.java | 35 - src/main/java/ic2/api/item/ItemWrapper.java | 50 -- src/main/java/ic2/api/item/Items.java | 407 ------------ .../network/INetworkItemEventListener.java | 18 - .../api/network/INetworkUpdateListener.java | 14 - .../java/ic2/api/network/NetworkHelper.java | 237 ------- src/main/java/ic2/api/reactor/IC2Reactor.java | 34 - src/main/java/ic2/api/reactor/IReactor.java | 140 ---- .../java/ic2/api/reactor/IReactorChamber.java | 13 - .../ic2/api/reactor/IReactorComponent.java | 97 --- .../api/recipe/ICraftingRecipeManager.java | 26 - .../ic2/api/recipe/IListRecipeManager.java | 36 -- .../ic2/api/recipe/IMachineRecipeManager.java | 37 -- src/main/java/ic2/api/recipe/Recipes.java | 38 -- .../java/ic2/api/tile/ExplosionWhitelist.java | 46 -- .../java/ic2/api/tile/IEnergyStorage.java | 54 -- src/main/java/ic2/api/tile/IWrenchable.java | 59 -- .../transvector/TileTransvectorInterface.java | 75 ++- .../PeripheralTransvectorInterface.java | 2 +- 131 files changed, 4812 insertions(+), 3173 deletions(-) create mode 100644 src/api/java/ic2/api/Direction.java create mode 100644 src/api/java/ic2/api/crops/BaseSeed.java create mode 100644 src/api/java/ic2/api/crops/CropCard.java create mode 100644 src/api/java/ic2/api/crops/Crops.java create mode 100644 src/api/java/ic2/api/crops/ICropTile.java create mode 100644 src/api/java/ic2/api/crops/package-info.java create mode 100644 src/api/java/ic2/api/energy/EnergyNet.java create mode 100644 src/api/java/ic2/api/energy/IEnergyNet.java create mode 100644 src/api/java/ic2/api/energy/event/EnergyTileEvent.java rename src/{main => api}/java/ic2/api/energy/event/EnergyTileLoadEvent.java (78%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileUnloadEvent.java (78%) create mode 100644 src/api/java/ic2/api/energy/event/package-info.java create mode 100644 src/api/java/ic2/api/energy/package-info.java create mode 100644 src/api/java/ic2/api/energy/prefab/BasicSink.java create mode 100644 src/api/java/ic2/api/energy/prefab/BasicSource.java create mode 100644 src/api/java/ic2/api/energy/prefab/package-info.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyConductor.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyEmitter.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergySink.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergySource.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyTile.java create mode 100644 src/api/java/ic2/api/energy/tile/IHeatSource.java create mode 100644 src/api/java/ic2/api/energy/tile/IKineticSource.java create mode 100644 src/api/java/ic2/api/energy/tile/IMetaDelegate.java create mode 100644 src/api/java/ic2/api/energy/tile/package-info.java rename src/{main => api}/java/ic2/api/energy/usage.txt (53%) create mode 100644 src/api/java/ic2/api/event/LaserEvent.java create mode 100644 src/api/java/ic2/api/event/PaintEvent.java create mode 100644 src/api/java/ic2/api/event/RetextureEvent.java create mode 100644 src/api/java/ic2/api/event/package-info.java create mode 100644 src/api/java/ic2/api/info/IEnergyValueProvider.java create mode 100644 src/api/java/ic2/api/info/IFuelValueProvider.java create mode 100644 src/api/java/ic2/api/info/Info.java create mode 100644 src/api/java/ic2/api/info/package-info.java create mode 100644 src/api/java/ic2/api/item/ElectricItem.java create mode 100644 src/api/java/ic2/api/item/IBackupElectricItemManager.java create mode 100644 src/api/java/ic2/api/item/IBlockCuttingBlade.java create mode 100644 src/api/java/ic2/api/item/IBoxable.java create mode 100644 src/api/java/ic2/api/item/IC2Items.java create mode 100644 src/api/java/ic2/api/item/IDebuggable.java create mode 100644 src/api/java/ic2/api/item/IElectricItem.java create mode 100644 src/api/java/ic2/api/item/IElectricItemManager.java create mode 100644 src/api/java/ic2/api/item/IItemHudInfo.java create mode 100644 src/api/java/ic2/api/item/IKineticWindRotor.java create mode 100644 src/api/java/ic2/api/item/IMetalArmor.java create mode 100644 src/api/java/ic2/api/item/ISpecialElectricItem.java create mode 100644 src/api/java/ic2/api/item/ITerraformingBP.java create mode 100644 src/api/java/ic2/api/item/ItemWrapper.java create mode 100644 src/api/java/ic2/api/item/package-info.java rename src/{main => api}/java/ic2/api/network/INetworkClientTileEntityEventListener.java (51%) rename src/{main => api}/java/ic2/api/network/INetworkDataProvider.java (66%) create mode 100644 src/api/java/ic2/api/network/INetworkItemEventListener.java rename src/{main => api}/java/ic2/api/network/INetworkTileEntityEventListener.java (54%) create mode 100644 src/api/java/ic2/api/network/INetworkUpdateListener.java create mode 100644 src/api/java/ic2/api/network/NetworkHelper.java create mode 100644 src/api/java/ic2/api/network/package-info.java create mode 100644 src/api/java/ic2/api/package-info.java create mode 100644 src/api/java/ic2/api/reactor/IReactor.java create mode 100644 src/api/java/ic2/api/reactor/IReactorChamber.java create mode 100644 src/api/java/ic2/api/reactor/IReactorComponent.java create mode 100644 src/api/java/ic2/api/reactor/package-info.java create mode 100644 src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/ICraftingRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/IFluidHeatManager.java create mode 100644 src/api/java/ic2/api/recipe/ILiquidAcceptManager.java create mode 100644 src/api/java/ic2/api/recipe/IListRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/IMachineRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/IPatternStorage.java create mode 100644 src/api/java/ic2/api/recipe/IRecipeInput.java create mode 100644 src/api/java/ic2/api/recipe/IScrapboxManager.java create mode 100644 src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputItemStack.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputOreDict.java create mode 100644 src/api/java/ic2/api/recipe/RecipeOutput.java create mode 100644 src/api/java/ic2/api/recipe/Recipes.java create mode 100644 src/api/java/ic2/api/recipe/package-info.java create mode 100644 src/api/java/ic2/api/tile/ExplosionWhitelist.java create mode 100644 src/api/java/ic2/api/tile/IEnergyStorage.java create mode 100644 src/api/java/ic2/api/tile/IWrenchable.java create mode 100644 src/api/java/ic2/api/tile/package-info.java create mode 100644 src/api/java/ic2/api/util/IKeyboard.java create mode 100644 src/api/java/ic2/api/util/Keys.java create mode 100644 src/api/java/ic2/api/util/package-info.java delete mode 100644 src/main/java/ic2/api/Direction.java delete mode 100644 src/main/java/ic2/api/crops/BaseSeed.java delete mode 100644 src/main/java/ic2/api/crops/CropCard.java delete mode 100644 src/main/java/ic2/api/crops/Crops.java delete mode 100644 src/main/java/ic2/api/crops/ICropTile.java delete mode 100644 src/main/java/ic2/api/energy/EnergyNet.java delete mode 100644 src/main/java/ic2/api/energy/event/EnergyTileEvent.java delete mode 100644 src/main/java/ic2/api/energy/event/EnergyTileSourceEvent.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyConductor.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyEmitter.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergySink.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergySource.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyTile.java delete mode 100644 src/main/java/ic2/api/event/PaintEvent.java delete mode 100644 src/main/java/ic2/api/event/RetextureEvent.java delete mode 100644 src/main/java/ic2/api/info/IEnergyValueProvider.java delete mode 100644 src/main/java/ic2/api/info/IFuelValueProvider.java delete mode 100644 src/main/java/ic2/api/info/Info.java delete mode 100644 src/main/java/ic2/api/item/ElectricItem.java delete mode 100644 src/main/java/ic2/api/item/IBoxable.java delete mode 100644 src/main/java/ic2/api/item/ICustomElectricItem.java delete mode 100644 src/main/java/ic2/api/item/IElectricItem.java delete mode 100644 src/main/java/ic2/api/item/IElectricItemManager.java delete mode 100644 src/main/java/ic2/api/item/IMetalArmor.java delete mode 100644 src/main/java/ic2/api/item/ISpecialElectricItem.java delete mode 100644 src/main/java/ic2/api/item/ITerraformingBP.java delete mode 100644 src/main/java/ic2/api/item/ItemWrapper.java delete mode 100644 src/main/java/ic2/api/item/Items.java delete mode 100644 src/main/java/ic2/api/network/INetworkItemEventListener.java delete mode 100644 src/main/java/ic2/api/network/INetworkUpdateListener.java delete mode 100644 src/main/java/ic2/api/network/NetworkHelper.java delete mode 100644 src/main/java/ic2/api/reactor/IC2Reactor.java delete mode 100644 src/main/java/ic2/api/reactor/IReactor.java delete mode 100644 src/main/java/ic2/api/reactor/IReactorChamber.java delete mode 100644 src/main/java/ic2/api/reactor/IReactorComponent.java delete mode 100644 src/main/java/ic2/api/recipe/ICraftingRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/IListRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/IMachineRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/Recipes.java delete mode 100644 src/main/java/ic2/api/tile/ExplosionWhitelist.java delete mode 100644 src/main/java/ic2/api/tile/IEnergyStorage.java delete mode 100644 src/main/java/ic2/api/tile/IWrenchable.java diff --git a/src/api/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java new file mode 100644 index 00000000..ecfdee2d --- /dev/null +++ b/src/api/java/ic2/api/Direction.java @@ -0,0 +1,126 @@ +package ic2.api; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Represents the 6 possible directions along the axis of a block. + */ +public enum Direction { + /** + * -X + */ + XN(0), + /** + * +X + */ + XP(1), + + /** + * -Y + */ + YN(2), //MC-Code starts with 0 here + /** + * +Y + */ + YP(3), // 1... + + /** + * -Z + */ + ZN(4), + /** + * +Z + */ + ZP(5); + + Direction(int dir1) { + this.dir = dir1; + } + + /*public CoordinateTuple ApplyToCoordinates(CoordinateTuple coordinates) { + CoordinateTuple ret = new CoordinateTuple(coordinates); + + ret.coords[dir/2] += GetSign(); + + return ret; + }*/ + + /** + * Get the tile entity next to a tile entity following this direction. + * + * @param tileEntity tile entity to check + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyToTileEntity(TileEntity te) { + return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); + } + + /** + * Get the tile entity next to a position following this direction. + * + * @param world World to check + * @param x X coordinate to check from + * @param y Y coordinate to check from + * @param z Z coordinate to check from + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyTo(World world, int x, int y, int z) { + int coords[] = {x, y, z}; + + coords[dir / 2] += getSign(); + + if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { + try { + return world.getTileEntity(coords[0], coords[1], coords[2]); + } catch (Exception e) { + throw new RuntimeException("error getting TileEntity at dim " + world.provider.dimensionId + " " + coords[0] + "/" + coords[1] + "/" + coords[2]); + } + } + + return null; + } + + /** + * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) + * + * @return Inverse direction + */ + public Direction getInverse() { + int inverseDir = dir - getSign(); + + for (Direction direction : directions) { + if (direction.dir == inverseDir) return direction; + } + + return this; + } + + /** + * Convert this direction to a Minecraft side value. + * + * @return Minecraft side value + */ + public int toSideValue() { + return (dir + 4) % 6; + } + + /** + * Determine direction sign (N for negative or P for positive). + * + * @return -1 if the direction is negative, +1 if the direction is positive + */ + private int getSign() { + return (dir % 2) * 2 - 1; + } + + public ForgeDirection toForgeDirection() { + return ForgeDirection.getOrientation(toSideValue()); + } + + private int dir; + public static final Direction[] directions = Direction.values(); +} + diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java new file mode 100644 index 00000000..38a1a216 --- /dev/null +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -0,0 +1,56 @@ +package ic2.api.crops; + +/** + * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. + */ +public class BaseSeed { + /** + * Plant ID. + */ + public int id; + + /** + * Plant size. + */ + public int size; + + /** + * Plant growth stat. + */ + public int statGrowth; + + /** + * Plant gain stat. + */ + public int statGain; + + /** + * Plant resistance stat. + */ + public int statResistance; + + /** + * For internal usage only. + */ + public int stackSize; + + /** + * Create a BaseSeed object. + * + * @param id1 plant ID + * @param size1 plant size + * @param statGrowth1 plant growth stat + * @param statGain1 plant gain stat + * @param statResistance1 plant resistance stat + * @param stackSize1 for internal usage only + */ + public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) { + super(); + this.id = id1; + this.size = size1; + this.statGrowth = statGrowth1; + this.statGain = statGain1; + this.statResistance = statResistance1; + this.stackSize = stackSize1; + } +} diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java new file mode 100644 index 00000000..0df1b512 --- /dev/null +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -0,0 +1,371 @@ +package ic2.api.crops; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Base agriculture crop. + *

+ * Any crop extending this can be registered using registerCrop to be added into the game. + */ +public abstract class CropCard { + /** + * Plant name. Will be displayed to the player. + * + * @return Plant name + */ + public abstract String name(); + + /** + * Your name here, will be shown in "Discovered by:" when analyzing seeds. + * + * @return Your name + */ + public String discoveredBy() { + return "Alblaka"; + } + + /** + * Description of your plant. Keep it short, a few characters per line for up to two lines. + * Default is showing attributes of your plant, 2 per line. + * + * @param i line to get, starting from 0 + * @return The line + */ + public String desc(int i) { + String[] att = attributes(); + if (att == null || att.length == 0) return ""; + if (i == 0) { + String s = att[0]; + if (att.length >= 2) { + s += ", " + att[1]; + if (att.length >= 3) s += ","; + } + return s; + } + if (att.length < 3) return ""; + String s = att[2]; + if (att.length >= 4) s += ", " + att[3]; + return s; + } + + /** + * Tier of the plant. Ranges from 1 to 16, 0 is Weed. + * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. + * + * @return Tier + */ + public abstract int tier(); + + /** + * Describe the plant through a set of stats, influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + *

+ * Stats: + * - 0: Chemistry (Industrial uses based on chemical plant components) + * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) + * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) + * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) + * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) + * + * @param n index of the requested stat + * @return The requested value of the stats + */ + public abstract int stat(int n); + + /** + * Additional attributes of the plant, also influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + * + * @return Attributes as an array of strings + */ + public abstract String[] attributes(); + + /** + * Determine the max crop size. + *

+ * Currently only used for texture allocation. + */ + public abstract int maxSize(); + + /** + * Instantiate your Icons here. + *

+ * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + textures = new IIcon[maxSize()]; + + for (int i = 1; i <= textures.length; i++) { + textures[i - 1] = iconRegister.registerIcon("ic2:crop/blockCrop." + name() + "." + i); + } + } + + /** + * Sprite the crop is meant to be rendered with. + * + * @param crop reference to ICropTile + * @return 0-255, representing the sprite index on the crop's spritesheet. + */ + @SideOnly(Side.CLIENT) + public IIcon getSprite(ICropTile crop) { + if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; + + return textures[crop.getSize() - 1]; + } + + /** + * Get the crop's spritesheet. + * Per default crops_0.png of ic2-sprites + * + * @return Texture file path + */ + public String getTextureFile() { + return "/ic2/sprites/crops_0.png"; + } + + /** + * Amount of growth points needed to increase the plant's size. + * Default is 200 * tier. + */ + public int growthDuration(ICropTile crop) { + return tier() * 200; + } + + /** + * Check whether the plant can grow further. + *

+ * Consider: + * - Humidity, nutrients and air quality + * - Current size + * - Light level + * - Special biomes or conditions, accessible through crop.worldObj + *

+ * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. + * + * @param crop reference to ICropTile + * @return Whether the crop can grow + */ + public abstract boolean canGrow(ICropTile crop); + + /** + * Calculate the influence for the plant to grow based on humidity, nutrients and air. + * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. + * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) + *

+ * Default is humidity + nutrients + air (no factors). + * + * @param crop reference to ICropTile + * @param humidity ground humidity, influenced by hydration + * @param nutrients nutrient quality in ground, based on fertilizers + * @param air air quality, influences by open gardens and less crops surrounding this one + * @return 0-30 + */ + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) (humidity + nutrients + air); + } + + /** + * Used to determine whether the plant can crossbreed with another crop. + * Default is allow crossbreeding if the size is greater or equal than 3. + * + * @param crop crop to crossbreed with + */ + public boolean canCross(ICropTile crop) { + return crop.getSize() >= 3; + } + + + /** + * Called when the plant is rightclicked by a player. + * Default action is harvesting. + *

+ * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player rightclicking the crop + * @return Whether the plant has changed + */ + public boolean rightclick(ICropTile crop, EntityPlayer player) { + return crop.harvest(true); + } + + /** + * Check whether the crop can be harvested. + * + * @param crop reference to ICropTile + * @return Whether the crop can be harvested in its current state. + */ + public abstract boolean canBeHarvested(ICropTile crop); + + /** + * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. + * Default is 0.95^tier. + * + * @return Chance to drop the gains + */ + public float dropGainChance() { + float base = 1F; + for (int i = 0; i < tier(); i++) { + base *= 0.95; + } + return base; + } + + /** + * Item obtained from harvesting the plant. + * + * @param crop reference to ICropTile + * @return Item obtained + */ + public abstract ItemStack getGain(ICropTile crop); + + /** + * Get the size of the plant after harvesting. + * Default is 1. + * + * @param crop reference to ICropTile + * @return Plant size after harvesting + */ + public byte getSizeAfterHarvest(ICropTile crop) { + return 1; + } + + + /** + * Called when the plant is leftclicked by a player. + * Default action is picking the plant. + *

+ * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player leftclicked the crop + * @return Whether the plant has changed + */ + public boolean leftclick(ICropTile crop, EntityPlayer player) { + return crop.pick(true); + } + + /** + * Base chance for dropping seeds when the plant is picked. + * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. + * + * @param crop reference to ICropTile + * @return Chance to drop the seeds + */ + public float dropSeedChance(ICropTile crop) { + if (crop.getSize() == 1) return 0; + float base = 0.5F; + if (crop.getSize() == 2) base /= 2F; + for (int i = 0; i < tier(); i++) { + base *= 0.8; + } + return base; + } + + /** + * Obtain seeds dropped when the plant is picked. + * Multiple drops of the returned ItemStack can occur. + * Default action is generating a seed from this crop. + * + * @param crop reference to ICropTile + * @return Seeds + */ + public ItemStack getSeeds(ICropTile crop) { + return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); + } + + /** + * Called when a neighbor block to the crop has changed. + * + * @param crop reference to ICropTile + */ + public void onNeighbourChange(ICropTile crop) { + // + } + + /** + * Check if the crop should emit redstone. + * + * @return Whether the crop should emit redstone + */ + public int emitRedstone(ICropTile crop) { + return 0; + } + + /** + * Called when the crop is destroyed. + * + * @param crop reference to ICropTile + */ + public void onBlockDestroyed(ICropTile crop) { + // + } + + /** + * Get the light value emitted by the plant. + * + * @param crop reference to ICropTile + * @return Light value emitted + */ + public int getEmittedLight(ICropTile crop) { + return 0; + } + + /** + * Default is true if the entity is an EntityLiving in jumping or sprinting state. + * + * @param crop reference to ICropTile + * @param entity entity colliding + * @return Whether trampling calculation should happen, return false if the plant is no longer valid. + */ + public boolean onEntityCollision(ICropTile crop, Entity entity) { + if (entity instanceof EntityLivingBase) { + return ((EntityLivingBase) entity).isSprinting(); + } + return false; + } + + + /** + * Called every time the crop ticks. + * Should be called every 256 ticks or around 13 seconds. + * + * @param crop reference to ICropTile + */ + public void tick(ICropTile crop) { + // + } + + /** + * Check whether this plant spreads weed to surrounding tiles. + * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. + * + * @param crop reference to ICropTile + * @return Whether the plant spreads weed + */ + public boolean isWeed(ICropTile crop) { + return crop.getSize() >= 2 && (crop.getID() == 0 || crop.getGrowth() >= 24); + } + + + /** + * Get this plant's ID. + * + * @return ID of this CropCard or -1 if it's not registered + */ + public final int getId() { + return Crops.instance.getIdFor(this); + } + + @SideOnly(Side.CLIENT) + protected IIcon textures[]; +} diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/api/java/ic2/api/crops/Crops.java new file mode 100644 index 00000000..3f16665a --- /dev/null +++ b/src/api/java/ic2/api/crops/Crops.java @@ -0,0 +1,117 @@ +package ic2.api.crops; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraftforge.common.BiomeDictionary.Type; + +/** + * General management of the crop system. + */ +public abstract class Crops { + public static Crops instance; + + /** + * Adds a crop humidity and nutrient biome bonus. + *

+ * 0 indicates no bonus and negative values indicate a penalty. + * + * @param biome Biome to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); + + /** + * Adds a crop humidity and nutrient biome bonus. + *

+ * 0 indicates no bonus and negative values indicate a penalty. + * + * @param type Forge biome type to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus); + + /** + * Gets the humidity bonus for a biome. + * + * @param biome Biome to check + * @return Humidity bonus or 0 if none + */ + public abstract int getHumidityBiomeBonus(BiomeGenBase biome); + + /** + * Gets the nutrient bonus for a biome. + * + * @param biome Biome to check + * @return Nutrient bonus or 0 if none + */ + public abstract int getNutrientBiomeBonus(BiomeGenBase biome); + + /** + * Returns the list of registered crops. + * + * @return Registered crops by ID + */ + public abstract CropCard[] getCropList(); + + /** + * Auto-assign an ID to a plant and register it. + * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. + * + * @param crop plant to register + * @return The ID assigned to the plant + */ + public abstract short registerCrop(CropCard crop); + + /** + * Attempt to register a plant to an ID. + * If the ID is taken, the crop will not be registered and a console print will notify the user. + * + * @param crop plant to register + * @param i ID to register the plant to + * @return Whether the crop was registered + */ + public abstract boolean registerCrop(CropCard crop, int i); + + /** + * Registers a base seed, an item used to plant a crop. + * + * @param stack item + * @param id plant ID + * @param size initial size + * @param growth initial growth stat + * @param gain initial gain stat + * @param resistance initial resistance stat + * @return True if successful + */ + public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); + + /** + * Finds a base seed from the given item. + * + * @return Base seed or null if none found + */ + public abstract BaseSeed getBaseSeed(ItemStack stack); + + /** + * Execute registerSprites for all registered crop cards. + *

+ * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public abstract void startSpriteRegistration(IIconRegister iconRegister); + + /** + * Returns the ID for the given crop. + * + * @param crop Crop to look up + * @return ID, or -1 if not found + */ + public abstract int getIdFor(CropCard crop); +} diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java new file mode 100644 index 00000000..b85820f9 --- /dev/null +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -0,0 +1,250 @@ +package ic2.api.crops; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +/** + * Interface implemented by the crop tile entity. + */ +public interface ICropTile { + /** + * Get the crop's plant ID. + * + * @return Plant ID, or -1 if there is no plant currently on the crop + */ + public short getID(); + + /** + * Set the crop's plant ID. + * + * @param id Plant ID, or -1 for no plant + */ + public void setID(short id); + + /** + * Get the crop's plant size. + * + * @return Plant size, starting with 1 and maximum varies depending on plant + */ + public byte getSize(); + + /** + * Set the crop's plant size. + * + * @param size Plant size + */ + public void setSize(byte size); + + /** + * Get the crop's plant growth stat. + * Higher values indicate faster growth. + * + * @return Plant growth stat + */ + public byte getGrowth(); + + /** + * Set the crop's plant growth stat. + * + * @param growth Plant growth stat + */ + public void setGrowth(byte growth); + + /** + * Get the crop's plant gain stat. + * Higher values indicate more drops. + * + * @return Plant gain stat + */ + public byte getGain(); + + /** + * Set the crop's plant gain stat. + * + * @param gain Plant gain stat + */ + public void setGain(byte gain); + + /** + * Get the crop's plant resistance stat. + * Higher values indicate more resistance against trampling. + * + * @return Plant resistance stat + */ + public byte getResistance(); + + /** + * Set the crop's plant resistance stat. + * + * @param resistance Plant resistance stat + */ + public void setResistance(byte resistance); + + /** + * Get the crop's plant scan level. + * Increases every time the seed is analyzed. + * + * @return Plant scan level + */ + public byte getScanLevel(); + + /** + * Set the crop's plant scan level. + * + * @param scanLevel Plant scan level + */ + public void setScanLevel(byte scanLevel); + + /** + * Get the crop's plant custom data, stored alongside the crop. + * Can be modified in place. + * + * @return Plant custom data + */ + public NBTTagCompound getCustomData(); + + /** + * Get the crop's nutrient storage. + * Ranges from 0 to 100. + * + * @return Crop nutrient storage + */ + public int getNutrientStorage(); + + /** + * Set the crop's nutrient storage. + * + * @param nutrientStorage Crop nutrient storage + */ + public void setNutrientStorage(int nutrientStorage); + + /** + * Get the crop's hydration storage. + * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. + * + * @return Crop hydration storage + */ + public int getHydrationStorage(); + + /** + * Set the crop's hydration storage. + * + * @param hydrationStorage Crop hydration storage + */ + public void setHydrationStorage(int hydrationStorage); + + /** + * Get the crop's Weed-Ex storage. + * + * @return Crop Weed-Ex storage + */ + public int getWeedExStorage(); + + /** + * Set the crop's Weed-Ex storage. + * + * @param weedExStorage Crop Weed-Ex storage + */ + public void setWeedExStorage(int weedExStorage); + + /** + * Get the crop's humidity. + * Ranges from 0 (dry) to 10 (humid). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop humidity level + * @see #updateState() + */ + public byte getHumidity(); + + /** + * Get the crop's nutrient level. + * Ranges from 0 (empty) to 10 (full). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop nutrient level + * @see #updateState() + */ + public byte getNutrients(); + + /** + * Get the crop's air quality. + * Ranges from 0 (cluttered) to 10 (fresh). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop air quality + * @see #updateState() + */ + public byte getAirQuality(); + + /** + * Get the crop's world. + * + * @return Crop world + */ + public World getWorld(); + + /** + * Get the crop's location. + * + * @return Crop location + */ + public ChunkCoordinates getLocation(); + + /** + * Get the crop's light level. + * + * @return Crop light level + */ + public int getLightLevel(); + + /** + * Pick the crop, removing and giving seeds for the plant. + * + * @param manual whether it was done by hand (not automated) + * @return true if successfully picked + */ + public boolean pick(boolean manual); + + /** + * Harvest the crop, turning it into gain and resetting its size. + * + * @param manual whether it one by hand (not automated) + * @return true if successfully harvested + */ + public boolean harvest(boolean manual); + + /** + * Fully clears the crop without dropping anything. + */ + public void reset(); + + /** + * Request a texture and lighting update. + */ + public void updateState(); + + /** + * Check if a block is under the farmland containing the crop. + * Searches up to 2 blocks below the farmland or an air space, whichever appears first. + * + * @param block block to search + * @return Whether the block was found + */ + public boolean isBlockBelow(Block block); + + /** + * Generate plant seeds with the given parameters. + * + * @param plant plant ID + * @param growth plant growth stat + * @param gain plant gain stat + * @param resis plant resistance stat + * @param scan plant scan level + * @return Plant seed item + */ + public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); +} diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/api/java/ic2/api/crops/package-info.java new file mode 100644 index 00000000..f5041cdc --- /dev/null +++ b/src/api/java/ic2/api/crops/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.crops; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/EnergyNet.java b/src/api/java/ic2/api/energy/EnergyNet.java new file mode 100644 index 00000000..9ddf6b86 --- /dev/null +++ b/src/api/java/ic2/api/energy/EnergyNet.java @@ -0,0 +1,18 @@ +package ic2.api.energy; + + +/** + * Provides access to the energy network. + *

+ * The old EnergyNet methods missing in IEnergyNet have been migrated to events (load, unload) or + * removed (tiles no longer emit energy actively, the energy net implementation requests it). + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public final class EnergyNet { + /** + * Instance of the global EnergyNet class. + */ + public static IEnergyNet instance; +} + diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java new file mode 100644 index 00000000..d24d3acf --- /dev/null +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -0,0 +1,74 @@ +package ic2.api.energy; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Interface representing the methods provided by the global EnergyNet class. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyNet { + /** + * Get the EnergyNet-registered tile entity at the specified position. + *

+ * This is not the same as World.getTileEntity(), it's possible to register delegate tile + * entities with the energy net which are different from what's actually in the world. Those + * delegates allow to use separate TileEntity objects just for the EnergyNet interfaces, + * simplifying cross-mod dependencies and multi-blocks. + * + * @param world World containing the tile entity + * @param x x-coordinate + * @param y y-coordinate + * @param z z-coordinate + * @return tile entity registered to the energy net or null if none is registered + */ + TileEntity getTileEntity(World world, int x, int y, int z); + + /** + * Get the EnergyNet-registered neighbor tile entity at the specified position. + * + * @param te TileEntity indicating the world and position to search from + * @param dir direction the neighbor is to be found + * @return neighbor tile entity registered to the energy net or null if none is registered + */ + TileEntity getNeighbor(TileEntity te, ForgeDirection dir); + + /** + * determine how much energy has been emitted by the EnergyEmitter specified + * + * @param tileEntity energy emitter + * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergyEmitted(TileEntity tileEntity); + + /** + * determine how much energy has been sunken by the EnergySink specified + * + * @param tileEntity energy emitter + * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergySunken(TileEntity tileEntity); + + /** + * Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2. + * + * @param tier tier + * @return power in eu/t + */ + double getPowerFromTier(int tier); + + /** + * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. + * + * @param power in eu/t + * @return tier + */ + int getTierFromPower(double power); +} diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java new file mode 100644 index 00000000..1b824672 --- /dev/null +++ b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java @@ -0,0 +1,23 @@ +package ic2.api.energy.event; + +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.event.world.WorldEvent; + +import ic2.api.energy.tile.IEnergyTile; + +/** + * Base class for energy net events, don't use it directly. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public class EnergyTileEvent extends WorldEvent { + public final IEnergyTile energyTile; + + public EnergyTileEvent(IEnergyTile energyTile1) { + super(((TileEntity) energyTile1).getWorldObj()); + + this.energyTile = energyTile1; + } +} + diff --git a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java similarity index 78% rename from src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java index b80d45b3..d302f894 100644 --- a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java @@ -4,21 +4,23 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing new energy tiles. - * + *

* This event notifies subscribers of loaded energy tiles, e.g. after getting * loaded through the chunk they are in or after being placed down by the * player or another deployer mechanism. - * + *

* Every energy tile which wants to get connected to the IC2 Energy Network has * to either post this event or alternatively call EnergyNet.addTileEntity(). - * + *

* You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileLoadEvent extends EnergyTileEvent { - public EnergyTileLoadEvent(IEnergyTile energyTile) { - super(energyTile); - } + public EnergyTileLoadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java similarity index 78% rename from src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java index 5e046375..727c8a11 100644 --- a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java @@ -4,22 +4,24 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing terminated energy tiles. - * + *

* This event notifies subscribers of unloaded energy tiles, e.g. after getting * unloaded through the chunk they are in or after being destroyed by the * player or another block pick/destruction mechanism. - * + *

* Every energy tile which wants to get disconnected from the IC2 Energy * Network has to either post this event or alternatively call * EnergyNet.removeTileEntity(). - * + *

* You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileUnloadEvent extends EnergyTileEvent { - public EnergyTileUnloadEvent(IEnergyTile energyTile) { - super(energyTile); - } + public EnergyTileUnloadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java new file mode 100644 index 00000000..f1cc9ea0 --- /dev/null +++ b/src/api/java/ic2/api/energy/event/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.event; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java new file mode 100644 index 00000000..a92380fb --- /dev/null +++ b/src/api/java/ic2/api/energy/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/api/java/ic2/api/energy/prefab/BasicSink.java new file mode 100644 index 00000000..461e6d04 --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSink.java @@ -0,0 +1,363 @@ +package ic2.api.energy.prefab; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; + +/** + * BasicSink is a simple adapter to provide an ic2 energy sink. + *

+ * It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a + * one-time configurable input energy buffer, thus providing a common use case for machines. + *

+ * Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended. + * The delegate can be extended with additional functionality through a sub class though. + *

+ * The constraints set by BasicSink like the strict tank-like energy buffering should provide a + * more easy to use and stable interface than using IEnergySink directly while aiming for + * optimal performance. + *

+ * Using BasicSink involves the following steps: + * - create a BasicSink instance in your TileEntity, typically in a field + * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. + * - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available + * without consuming the energy. + * - optionally use getEnergyStored to display the output buffer charge level + * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) + *

+ * Example implementation code: + * + * @code{.java} public class SomeTileEntity extends TileEntity { + * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); + * @Override public void invalidate() { + * ic2EnergySink.invalidate(); // notify the energy sink + * ... + * super.invalidate(); // this is important for mc! + * } + * @Override public void onChunkUnload() { + * ic2EnergySink.onChunkUnload(); // notify the energy sink + * ... + * } + * @Override public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + *

+ * ic2EnergySink.readFromNBT(tag); + * ... + * } + * @Override public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + *

+ * ic2EnergySink.writeToNBT(tag); + * ... + * } + * @Override public void updateEntity() { + * ic2EnergySink.updateEntity(); // notify the energy sink + * ... + * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick + * ... // do something with the energy + * } + * ... + * } + *

+ * ... + * } + * @endcode + */ +public class BasicSink extends TileEntity implements IEnergySink { + // ********************************** + // *** Methods for use by the mod *** + // ********************************** + + /** + * Constructor for a new BasicSink delegate. + * + * @param parent1 TileEntity represented by this energy sink. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSink(TileEntity parent1, int capacity1, int tier1) { + this.parent = parent1; + this.capacity = capacity1; + this.tier = tier1; + } + + // in-world te forwards >> + + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } + + /** + * Notification that the base TileEntity finished loaded, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; + + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + + addedToEnet = true; + } + } + + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); + + onChunkUnload(); + } + + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + + addedToEnet = false; + } + } + + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + + NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); + + energyStored = data.getDouble("energy"); + } + + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } + + NBTTagCompound data = new NBTTagCompound(); + + data.setDouble("energy", energyStored); + + tag.setTag("IC2BasicSink", data); + } + + // << in-world te forwards + // methods for using this adapter >> + + /** + * Get the maximum amount of energy this sink can hold in its buffer. + * + * @return Capacity in EU. + */ + public int getCapacity() { + return capacity; + } + + /** + * Set the maximum amount of energy this sink can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(int capacity1) { + this.capacity = capacity1; + } + + /** + * Get the IC2 energy tier for this sink. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } + + /** + * Set the IC2 energy tier for this sink. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + this.tier = tier1; + } + + /** + * Determine the energy stored in the sink's input buffer. + * + * @return amount in EU, may be above capacity + */ + public double getEnergyStored() { + return energyStored; + } + + /** + * Set the stored energy to the specified amount. + *

+ * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } + + /** + * Determine if the specified amount of energy is available. + * + * @param amount in EU + * @return true if the amount is available + */ + public boolean canUseEnergy(double amount) { + return energyStored >= amount; + } + + /** + * Use the specified amount of energy, if available. + * + * @param amount amount to use + * @return true if the amount was available + */ + public boolean useEnergy(double amount) { + if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { + energyStored -= amount; + + return true; + } + return false; + } + + /** + * Discharge the supplied ItemStack into this sink's energy buffer. + * + * @param stack ItemStack to discharge (null is ignored) + * @param limit Transfer limit, values <= 0 will use the battery's limit + * @return true if energy was transferred + */ + public boolean discharge(ItemStack stack, int limit) { + if (stack == null || !Info.isIc2Available()) return false; + + double amount = capacity - energyStored; + if (amount <= 0) return false; + + if (limit > 0 && limit < amount) amount = limit; + + amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); + + energyStored += amount; + + return amount > 0; + } + + // << methods for using this adapter + + // backwards compatibility (ignore these) >> + + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } + + @Deprecated + public void onInvalidate() { + invalidate(); + } + + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } + + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } + + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } + + // << backwards compatibility + + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** + + // energy net interface >> + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return true; + } + + @Override + public double getDemandedEnergy() { + return Math.max(0, capacity - energyStored); + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + energyStored += amount; + + return 0; + } + + @Override + public int getSinkTier() { + return tier; + } + + // << energy net interface + + + public final TileEntity parent; + + protected int capacity; + protected int tier; + protected double energyStored; + protected boolean addedToEnet; +} diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/api/java/ic2/api/energy/prefab/BasicSource.java new file mode 100644 index 00000000..e5f74fa6 --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSource.java @@ -0,0 +1,364 @@ +package ic2.api.energy.prefab; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +import ic2.api.energy.EnergyNet; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySource; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; + +/** + * BasicSource is a simple adapter to provide an ic2 energy source. + *

+ * It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a + * one-time configurable output energy buffer, thus providing a common use case for generators. + *

+ * Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended. + * The delegate can be extended with additional functionality through a sub class though. + *

+ * The constraints set by BasicSource like the strict tank-like energy buffering should provide a + * more easy to use and stable interface than using IEnergySource directly while aiming for + * optimal performance. + *

+ * Using BasicSource involves the following steps: + * - create a BasicSource instance in your TileEntity, typically in a field + * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. + * - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator + * should run + * - optionally use getEnergyStored to display the output buffer charge level + * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) + *

+ * Example implementation code: + * + * @code{.java} public class SomeTileEntity extends TileEntity { + * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); + * @Override public void invalidate() { + * ic2EnergySource.invalidate(); // notify the energy source + * ... + * super.invalidate(); // this is important for mc! + * } + * @Override public void onChunkUnload() { + * ic2EnergySource.onChunkUnload(); // notify the energy source + * ... + * } + * @Override public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + *

+ * ic2EnergySource.readFromNBT(tag); + * ... + * } + * @Override public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + *

+ * ic2EnergySource.writeToNBT(tag); + * ... + * } + * @Override public void updateEntity() { + * ic2EnergySource.updateEntity(); // notify the energy source + * ... + * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick + * ... + * } + *

+ * ... + * } + * @endcode + */ +public class BasicSource extends TileEntity implements IEnergySource { + // ********************************** + // *** Methods for use by the mod *** + // ********************************** + + /** + * Constructor for a new BasicSource delegate. + * + * @param parent1 Base TileEntity represented by this energy source. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSource(TileEntity parent1, double capacity1, int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); + + this.parent = parent1; + this.capacity = capacity1 < power ? power : capacity1; + this.tier = tier1; + } + + // in-world te forwards >> + + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } + + /** + * Notification that the base TileEntity finished loading, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; + + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + + addedToEnet = true; + } + } + + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); + + onChunkUnload(); + } + + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + + addedToEnet = false; + } + } + + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + + NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); + + energyStored = data.getDouble("energy"); + } + + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } + + NBTTagCompound data = new NBTTagCompound(); + + data.setDouble("energy", energyStored); + + tag.setTag("IC2BasicSource", data); + } + + // << in-world te forwards + // methods for using this adapter >> + + /** + * Get the maximum amount of energy this source can hold in its buffer. + * + * @return Capacity in EU. + */ + public double getCapacity() { + return capacity; + } + + /** + * Set the maximum amount of energy this source can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(double capacity1) { + double power = EnergyNet.instance.getPowerFromTier(tier); + + if (capacity1 < power) capacity1 = power; + + this.capacity = capacity1; + } + + /** + * Get the IC2 energy tier for this source. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } + + /** + * Set the IC2 energy tier for this source. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); + + if (capacity < power) capacity = power; + + this.tier = tier1; + } + + + /** + * Determine the energy stored in the source's output buffer. + * + * @return amount in EU + */ + public double getEnergyStored() { + return energyStored; + } + + /** + * Set the stored energy to the specified amount. + *

+ * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } + + /** + * Determine the free capacity in the source's output buffer. + * + * @return amount in EU + */ + public double getFreeCapacity() { + return capacity - energyStored; + } + + /** + * Add some energy to the output buffer. + * + * @param amount maximum amount of energy to add + * @return amount added/used, NOT remaining + */ + public double addEnergy(double amount) { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; + if (amount > capacity - energyStored) amount = capacity - energyStored; + + energyStored += amount; + + return amount; + } + + /** + * Charge the supplied ItemStack from this source's energy buffer. + * + * @param stack ItemStack to charge (null is ignored) + * @return true if energy was transferred + */ + public boolean charge(ItemStack stack) { + if (stack == null || !Info.isIc2Available()) return false; + + double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); + + energyStored -= amount; + + return amount > 0; + } + + // << methods for using this adapter + + // backwards compatibility (ignore these) >> + + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } + + @Deprecated + public void onInvalidate() { + invalidate(); + } + + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } + + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } + + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } + + // << backwards compatibility + + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** + + // energy net interface >> + + @Override + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return true; + } + + @Override + public double getOfferedEnergy() { + return energyStored; + } + + @Override + public void drawEnergy(double amount) { + energyStored -= amount; + } + + @Override + public int getSourceTier() { + return tier; + } + + // << energy net interface + + + public final TileEntity parent; + + protected double capacity; + protected int tier; + protected double energyStored; + protected boolean addedToEnet; +} diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/api/java/ic2/api/energy/prefab/package-info.java new file mode 100644 index 00000000..b244b0ff --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.prefab; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java new file mode 100644 index 00000000..18b827c0 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java @@ -0,0 +1,27 @@ +package ic2.api.energy.tile; + +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * For internal/multi-block usage only. + * + * @see IEnergySink + * @see IEnergyConductor + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyAcceptor extends IEnergyTile { + /** + * Determine if this acceptor can accept current from an adjacent emitter in a direction. + *

+ * The TileEntity in the emitter parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param emitter energy emitter, may also be null or an IMetaDelegate + * @param direction direction the energy is being received from + */ + boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java new file mode 100644 index 00000000..6d917546 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java @@ -0,0 +1,53 @@ +package ic2.api.energy.tile; + +/** + * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this + * interface. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { + /** + * Energy loss for the conductor in EU per block. + * + * @return Energy loss + */ + double getConductionLoss(); + + /** + * Amount of energy the insulation will handle before shocking nearby players and mobs. + * + * @return Insulation energy absorption in EU + */ + double getInsulationEnergyAbsorption(); + + /** + * Amount of energy the insulation will handle before it is destroyed. + * Ensure that this value is greater than the insulation energy absorption + 64. + * + * @return Insulation-destroying energy in EU + */ + double getInsulationBreakdownEnergy(); + + /** + * Amount of energy the conductor will handle before it melts. + * + * @return Conductor-destroying energy in EU + */ + double getConductorBreakdownEnergy(); + + /** + * Remove the conductor's insulation if the insulation breakdown energy was exceeded. + * + * @see #getInsulationBreakdownEnergy() + */ + void removeInsulation(); + + /** + * Remove the conductor if the conductor breakdown energy was exceeded. + * + * @see #getConductorBreakdownEnergy() + */ + void removeConductor(); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java new file mode 100644 index 00000000..5988db01 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java @@ -0,0 +1,28 @@ +package ic2.api.energy.tile; + +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * For internal/multi-block usage only. + * + * @see IEnergySource + * @see IEnergyConductor + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyEmitter extends IEnergyTile { + /** + * Determine if this emitter can emit energy to an adjacent receiver. + *

+ * The TileEntity in the receiver parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param receiver receiver, may also be null or an IMetaDelegate + * @param direction direction the receiver is from the emitter + * @return Whether energy should be emitted + */ + boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java new file mode 100644 index 00000000..4a943f05 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergySink.java @@ -0,0 +1,43 @@ +package ic2.api.energy.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Allows a tile entity (mostly a machine) to receive energy. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergySink extends IEnergyAcceptor { + /** + * Determine how much energy the sink accepts. + *

+ * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. + * + * @return max accepted input in eu + * @note Modifying the energy net from this method is disallowed. + */ + double getDemandedEnergy(); + + /** + * Determine the tier of this energy sink. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @return tier of this energy sink + * @note Modifying the energy net from this method is disallowed. + * @note Return Integer.MAX_VALUE to allow any voltage. + */ + int getSinkTier(); + + /** + * Transfer energy to the sink. + *

+ * It's highly recommended to accept all energy by letting the internal buffer overflow to + * increase the performance and accuracy of the distribution simulation. + * + * @param directionFrom direction from which the energy comes from + * @param amount energy to be transferred + * @return Energy not consumed (leftover) + */ + double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergySource.java b/src/api/java/ic2/api/energy/tile/IEnergySource.java new file mode 100644 index 00000000..7964e682 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergySource.java @@ -0,0 +1,36 @@ +package ic2.api.energy.tile; + +/** + * Allows a tile entity (mostly a generator) to emit energy. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergySource extends IEnergyEmitter { + /** + * Energy output provided by the source this tick. + * This is typically Math.min(stored energy, max output/tick). + * + * @return Energy offered this tick + * @note Modifying the energy net from this method is disallowed. + */ + double getOfferedEnergy(); + + /** + * Draw energy from this source's buffer. + *

+ * If the source doesn't have a buffer, this is a no-op. + * + * @param amount amount of EU to draw, may be negative + */ + void drawEnergy(double amount); + + /** + * Determine the tier of this energy source. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @return tier of this energy source + * @note Modifying the energy net from this method is disallowed. + */ + int getSourceTier(); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyTile.java b/src/api/java/ic2/api/energy/tile/IEnergyTile.java new file mode 100644 index 00000000..2c8973a5 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyTile.java @@ -0,0 +1,15 @@ +package ic2.api.energy.tile; + +/** + * For internal usage only, base class for all energy tiles. + * + * @see IEnergySink + * @see IEnergySource + * @see IEnergyConductor + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyTile { + // +} + diff --git a/src/api/java/ic2/api/energy/tile/IHeatSource.java b/src/api/java/ic2/api/energy/tile/IHeatSource.java new file mode 100644 index 00000000..f40ce755 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IHeatSource.java @@ -0,0 +1,23 @@ +package ic2.api.energy.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IHeatSource { + + /* + * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestHeatTick(ForgeDirection directionFrom); + + /* + * @param requested amount of heat to transfer + * + * @return transmitted amount of heat + * + * example: You Request 100 units of heat but the Source have only 50 units left + * + * requestHeat(100) : return 50 : so 50 units of heat remove from HeatSource + */ + + int requestHeat(ForgeDirection directionFrom, int requestheat); +} diff --git a/src/api/java/ic2/api/energy/tile/IKineticSource.java b/src/api/java/ic2/api/energy/tile/IKineticSource.java new file mode 100644 index 00000000..2276f2c7 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IKineticSource.java @@ -0,0 +1,22 @@ +package ic2.api.energy.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IKineticSource { + /* + * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestkineticenergyTick(ForgeDirection directionFrom); + + /* + * @param requested amount of kinetic energy to transfer + * + * @return transmitted amount of kineticenergy + * + * example: You Request 100 units of kinetic energy but the Source have only 50 units left + * + * requestkineticenergy(100) : return 50 : so 50 units of kinetic energy remove from KineticSource + */ + + int requestkineticenergy(ForgeDirection directionFrom, int requestkineticenergy); +} diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java new file mode 100644 index 00000000..a9525552 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java @@ -0,0 +1,33 @@ +package ic2.api.energy.tile; + +import java.util.List; + +import net.minecraft.tileentity.TileEntity; + +/** + * Interface for grouping multi-block structures to a single energy net delegate. + *

+ * The energy net uses TileEntity to refer to a specific xyz+world position. If multiple of those + * positions should belong to the same functional structure, i.e. they consume or produce energy + * only once for the whole multi-block instead of once per every single block, this interface + * allows to do so. + *

+ * The tile entity implementing IMetaDelegate has to be added/removed to/from the energy net + * instead of every single sub-TileEntity. The energy net interaction will be handled by the + * IMetaDelegate TileEntity as well. + *

+ * The sub tile array TileEntity[] just provides optional connectivity (IEnergyAcceptor, + * IEnergyEmitter) and mandatory position (x, y, z, World) data. + * If the connectivity data on the sub tile is missing, the meta delegate is queried instead. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IMetaDelegate extends IEnergyTile { + /** + * Get the sub-TileEntities belonging to this Meta TileEntity. + * + * @return sub-TileEntity array + * @note the list has to be consistent between the EnergyNet Load and Unload events. + */ + List getSubTiles(); +} diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java new file mode 100644 index 00000000..a1667397 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.tile; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/energy/usage.txt b/src/api/java/ic2/api/energy/usage.txt similarity index 53% rename from src/main/java/ic2/api/energy/usage.txt rename to src/api/java/ic2/api/energy/usage.txt index b01b3c0b..49bd9955 100644 --- a/src/main/java/ic2/api/energy/usage.txt +++ b/src/api/java/ic2/api/energy/usage.txt @@ -1,6 +1,6 @@ ------------------------------------------------------ --- How to implement your own energy network blocks -- ------------------------------------------------------ +-------------------------------- +-- Energy Network Description -- +-------------------------------- There are currently three different types of energy network blocks: - energy sources, e.g. generators or the output side of a storage block/transformer @@ -16,8 +16,17 @@ The energy generation, distribution and consumption is strictly limited to the s side, use the proper side checks before posting the related events. One possibility is to check for FMLCommonHandler.instance().getEffectiveSide().isClient() being false. -The energy network works by sources pushing energy into the grid through EnergyTileSourceEvent, -conductors will carry the energy to sinks which will then receive it through injectEnergy(). +The energy network works by calculating the energy flow between the sources which offer energy +through getOfferedEnergy() and the sinks which request energy through demandedEnergyUnits(). +Conductors will carry the energy over a distance. Once the energy distribution is calculated, the +energy net will update the sources and sinks through drawEnergy() and injectEnergyUnits() respectively. + + +--------------------------- +-- Energy Network Events -- +--------------------------- + +The energy network currently requires 2 events to manage its internal representation of the grids: -- EnergyTileLoadEvent -- @@ -49,18 +58,21 @@ TileEntity.invalidate() and the beginning of TileEntity.onChunkUnload(). It is important that the tile entity is still properly linked to the world while posting the unload event, otherwise the energy net can't find all affected connections. + +-------------------------------------- +-- Participating Block Requirements -- +-------------------------------------- + +The energy net blocks have to do the following to work properly: + -- energy source -- An energy source has to post the following events: - EnergyTileLoadEvent on load - EnergyTileUnloadEvent on unload - - EnergyTileSourceEvent whenever it wants to send energy Additionally the interface IEnergySource has to be implemented. -The EnergyTileSourceEvent contains a field amount, which should be evaluated after having posted -the event. The value determines how much energy couldn't be delivered somewhere. - -- energy sink -- An energy sink has to post the following events: @@ -69,10 +81,6 @@ An energy sink has to post the following events: Additionally the interface IEnergySink has to be implemented. -The method demandsEnergy() will be called fairly often and should be implemented with performance -in mind. It's usually recommended to always fill some small internal buffer regardless of other -conditions, e.g. even if an enabling redstone signal is off. - -- energy conductor -- An energy conductor has to post the following events: @@ -82,6 +90,46 @@ An energy conductor has to post the following events: Additionally the interface IEnergyConductor has to be implemented. +------------------------------ +-- Energy Network Delegates -- +------------------------------ + +A delegate is a separate object which performs tasks for the original object, in this case handling +the energy net interaction. + +The TileEntity instances used by the events don't have to be the same as the in-world TileEntity +instance for the corresponding position, it can be delegated to a separate TileEntity instance. +This separate instance (delegate) needs to have its world and xyz coordinate fields set to match +the in-world instance. The delegate implements the energy net interfaces and is added and removed +to/from the energy net through EnergyTileLoadEvent and EnergyTileUnloadEvent. + +Separating the interfaces through a delegate allows to isolate the IC2 API usage into separate +classes an potentially share common code like an input buffer with battery discharging outside the +class hierarchy. +It's even possible to use an ic2 energy net delegate alongside an in-world TileEntity which isn't +designed to work with ic2 energy at all, like making a furnace electric by receiving energy through +a delegate and adding the corresponding fuel amount to the in-world furnace TileEntity. + +Getting the in-world TileEntity for a delegate involves calling World.getBlockTileEntity() with the +delegate's world and xyz coordinate information. + + +------------------ +-- Multi Blocks -- +------------------ + +Multi blocks are a group of blocks which act as one functional entity. + +The IMetaDelegate interface groups multiple TileEntity instances (=sub tiles) representing the +individual blocks to a single Energy Net relevant node. The sub tiles may be normal in-world or +delegate TileEntity instances. + +The meta delegate is added to energy net once for the whole multi block structure and implements +the energy net interfaces as well. The sub tiles may optionally implement IEnergyEmitter and/or +IEnergyAcceptor to specify their connectivity rules independently, otherwise the meta delegate will +be queried. + + -------------------------------------------------- -- How to implement/add your own energy network -- -------------------------------------------------- @@ -94,8 +142,3 @@ required to use conversion blocks. IC2's EnergyNet itself is built on top of the api events and interfaces, providing their default use case. -Note that is you have a pull-type energy network which lets the sinks retrieve energy from the -sources instead of IC2's method of pushing energy from the sources to the sinks, you'll currently -have to monitor the energy sinks regularly for their energy demand and start/stop pulling energy -accordingly. The load and unload events will tell you when to start/stop monitoring demandsEnergy. - diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/api/java/ic2/api/event/LaserEvent.java new file mode 100644 index 00000000..6c7e1777 --- /dev/null +++ b/src/api/java/ic2/api/event/LaserEvent.java @@ -0,0 +1,114 @@ +package ic2.api.event; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +import net.minecraftforge.event.world.WorldEvent; + +/** + * A bunch of Events to handle the power of the Mining Laser. + */ +@Cancelable +public class LaserEvent extends WorldEvent { + // the Laser Entity + public final Entity lasershot; + + // the following variables can be changed and the Laser will adjust to them + + // the Player firing the Laser. If the Laser gets "reflected" the Player could change. + public EntityLivingBase owner; + // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. + public float range, power; + public int blockBreaks; + // Determines whether the laser will explode upon hitting something + public boolean explosive, smelt; + + public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { + super(world1); + this.lasershot = lasershot1; + this.owner = owner1; + this.range = range1; + this.power = power1; + this.blockBreaks = blockBreaks1; + this.explosive = explosive1; + this.smelt = smelt1; + } + + /** + * Event when the Laser is getting shot by a Player. + *

+ * The Item is the Laser Gun which the "Player" has shot + */ + public static class LaserShootEvent extends LaserEvent { + ItemStack laseritem; + + public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.laseritem = laseritem1; + } + } + + /** + * Event when the Laser is exploding for some Reason. + *

+ * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. + */ + public static class LaserExplodesEvent extends LaserEvent { + // explosion strength, even that can be changed! + public float explosionpower, explosiondroprate, explosionentitydamage; + + public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.explosionpower = explosionpower1; + this.explosiondroprate = explosiondroprate1; + this.explosionentitydamage = explosionentitydamage1; + } + } + + /** + * Event when the Laser is hitting a Block + * x, y and z are the Coords of the Block. + *

+ * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsBlockEvent extends LaserEvent { + // targeted block, even that can be changed! + public int x, y, z; + public int side; + // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. + public boolean removeBlock, dropBlock; + public float dropChance; + + public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.removeBlock = removeBlock1; + this.dropBlock = dropBlock1; + this.dropChance = dropChance1; + } + } + + /** + * Event when the Laser is getting at a Living Entity + *

+ * Canceling this Event ignores the Entity + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsEntityEvent extends LaserEvent { + // the Entity which the Laser has shot at, even the target can be changed! + public Entity hitentity; + + public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.hitentity = hitentity1; + } + } +} diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/api/java/ic2/api/event/PaintEvent.java new file mode 100644 index 00000000..88f07030 --- /dev/null +++ b/src/api/java/ic2/api/event/PaintEvent.java @@ -0,0 +1,32 @@ +package ic2.api.event; + +import net.minecraft.world.World; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +import net.minecraftforge.event.world.WorldEvent; + +@Cancelable +public class PaintEvent extends WorldEvent { + // target block + public final int x; + public final int y; + public final int z; + public final int side; + + // color to paint the block + public final int color; + + // set to true to confirm the operation + public boolean painted = false; + + public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { + super(world1); + + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.color = color1; + } +} diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/api/java/ic2/api/event/RetextureEvent.java new file mode 100644 index 00000000..49ed9ac5 --- /dev/null +++ b/src/api/java/ic2/api/event/RetextureEvent.java @@ -0,0 +1,37 @@ +package ic2.api.event; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +import net.minecraftforge.event.world.WorldEvent; + +@Cancelable +public class RetextureEvent extends WorldEvent { + // target block + public final int x; + public final int y; + public final int z; + public final int side; + + // referenced block (to grab the texture from) + public final Block referencedBlock; + public final int referencedMeta; + public final int referencedSide; + + // set to true to confirm the operation + public boolean applied = false; + + public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { + super(world1); + + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.referencedBlock = referencedBlock; + this.referencedMeta = referencedMeta1; + this.referencedSide = referencedSide1; + } +} diff --git a/src/api/java/ic2/api/event/package-info.java b/src/api/java/ic2/api/event/package-info.java new file mode 100644 index 00000000..58e5bdf4 --- /dev/null +++ b/src/api/java/ic2/api/event/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.event; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java new file mode 100644 index 00000000..14a6db90 --- /dev/null +++ b/src/api/java/ic2/api/info/IEnergyValueProvider.java @@ -0,0 +1,17 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IEnergyValueProvider { + /** + * Determine the energy value for a single item in the supplied stack. + * The value is used by most machines in the discharge slot. + *

+ * This only applies to basic single use items, others are to be queried + * through e.g. ElectricItem.manager.getCharge(). + * + * @param itemStack ItemStack containing the item to evaluate. + * @return energy in EU + */ + double getEnergyValue(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java new file mode 100644 index 00000000..21fee297 --- /dev/null +++ b/src/api/java/ic2/api/info/IFuelValueProvider.java @@ -0,0 +1,15 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IFuelValueProvider { + /** + * Determine the fuel value for a single item in the supplied stack. + * The information currently applies to Generators and the Iron Furnace. + * + * @param itemStack ItemStack containing the item to evaluate. + * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. + * @return fuel value + */ + int getFuelValue(ItemStack itemStack, boolean allowLava); +} diff --git a/src/api/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java new file mode 100644 index 00000000..3c8a7146 --- /dev/null +++ b/src/api/java/ic2/api/info/Info.java @@ -0,0 +1,32 @@ +package ic2.api.info; + +import net.minecraft.util.DamageSource; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState; + +public class Info { + public static IEnergyValueProvider itemEnergy; + public static IFuelValueProvider itemFuel; + public static Object ic2ModInstance; + + /** + * Damage Sources used by IC2. + * Getting assigned in preload. + */ + public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; + + public static boolean isIc2Available() { + if (ic2Available != null) return ic2Available; + + boolean loaded = Loader.isModLoaded("IC2"); + + if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { + ic2Available = loaded; + } + + return loaded; + } + + private static Boolean ic2Available = null; +} \ No newline at end of file diff --git a/src/api/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java new file mode 100644 index 00000000..7714e222 --- /dev/null +++ b/src/api/java/ic2/api/info/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.info; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/item/ElectricItem.java b/src/api/java/ic2/api/item/ElectricItem.java new file mode 100644 index 00000000..cc2b959a --- /dev/null +++ b/src/api/java/ic2/api/item/ElectricItem.java @@ -0,0 +1,59 @@ +package ic2.api.item; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +/** + * Allows for charging, discharging and using electric items (IElectricItem). + */ +public final class ElectricItem { + /** + * IElectricItemManager to use for interacting with IElectricItem ItemStacks. + *

+ * This manager will act as a gateway and delegate the tasks to the final implementation + * (rawManager or a custom one) as necessary. + */ + public static IElectricItemManager manager; + + /** + * Standard IElectricItemManager implementation, only call it directly from another + * IElectricItemManager. Use manager instead. + */ + public static IElectricItemManager rawManager; + + /** + * Register an electric item manager for items not implementing IElectricItem. + *

+ * This method is only designed for special purposes, implementing IElectricItem or + * ISpecialElectricItem instead of using this is faster. + *

+ * Managers used with ISpecialElectricItem shouldn't be registered. + * + * @param manager Manager to register. + */ + public static void registerBackupManager(IBackupElectricItemManager manager) { + backupManagers.add(manager); + } + + /** + * Get the electric item manager suitable for the supplied item stack. + *

+ * This method is for internal use only. + * + * @param stack ItemStack to be handled. + * @return First suitable electric item manager. + */ + public static IBackupElectricItemManager getBackupManager(ItemStack stack) { + for (IBackupElectricItemManager manager : backupManagers) { + if (manager.handles(stack)) return manager; + } + + return null; + } + + + private static final List backupManagers = new ArrayList(); +} + diff --git a/src/api/java/ic2/api/item/IBackupElectricItemManager.java b/src/api/java/ic2/api/item/IBackupElectricItemManager.java new file mode 100644 index 00000000..e3fa60d7 --- /dev/null +++ b/src/api/java/ic2/api/item/IBackupElectricItemManager.java @@ -0,0 +1,12 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager applicable to items not implementing IElectricItem. + *

+ * The manager implementing this has to be registered with ElectricItem.registerBackupManager(). + */ +public interface IBackupElectricItemManager extends IElectricItemManager { + boolean handles(ItemStack stack); +} diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.java b/src/api/java/ic2/api/item/IBlockCuttingBlade.java new file mode 100644 index 00000000..b53c461c --- /dev/null +++ b/src/api/java/ic2/api/item/IBlockCuttingBlade.java @@ -0,0 +1,6 @@ +package ic2.api.item; + + +public interface IBlockCuttingBlade { + int gethardness(); +} diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/api/java/ic2/api/item/IBoxable.java new file mode 100644 index 00000000..7b268632 --- /dev/null +++ b/src/api/java/ic2/api/item/IBoxable.java @@ -0,0 +1,14 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + + +public interface IBoxable { + /** + * Determine whether an item can be stored in a toolbox or not. + * + * @param itemstack item to be stored + * @return Whether to store the item in the toolbox or not + */ + public abstract boolean canBeStoredInToolbox(ItemStack itemstack); +} diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java new file mode 100644 index 00000000..bd9305af --- /dev/null +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -0,0 +1,598 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +/** + * Provides access to IC2 blocks and items. + *

+ * Some items can be acquired through the ore dictionary which is the recommended way. + * The items are initialized while IC2 is being loaded - try to use ModsLoaded() or load your mod after IC2. + * Some blocks/items can be disabled by a config setting, so it's recommended to check if they're null first. + *

+ * Getting the associated Block/Item for an ItemStack x: + * Blocks: Block.blocksList[x.itemID] + * Items: x.getItem() + */ +public final class IC2Items { + /** + * Get an ItemStack for a specific item name, example: Items.getItem("resin") + * See the list below for item names. + * Make sure to copy() the ItemStack if you want to modify it. + * + * @param name item name + * @return The item or null if the item does not exist or an error occurred + */ + public static ItemStack getItem(String name) { + try { + if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); + + Object ret = Ic2Items.getField(name).get(null); + + if (ret instanceof ItemStack) { + return (ItemStack) ret; + } + return null; + } catch (Exception e) { + System.out.println("IC2 API: Call getItem failed for " + name); + + return null; + } + } + + /* Possible values: + + // ores + copperOre; // Copper Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreCopper, null with enableWorldGenOreCopper = false + tinOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreTin, null with enableWorldGenOreTin = false + uraniumOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreUranium, null with enableWorldGenOreUranium = false + leadOre; // Lead Ore Block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreLead, null with enableWorldGenOreLead = false + + // rubber related + + Rubber wood block, meta reflects the state, meta in ItemStack set to 0, ore dictionary: woodRubber (with meta 0), null with enableWorldGenTreeRubber = false + dropped (as an item) -> metadata 0 + block, no resin spot -> metadata 0 or 1 + block, wet resin spot -> metadata 2-5 (according to the side) + block, dry resin spot -> metadata 8-11 (wet state + 6) + + rubberWood; + rubberLeaves; // Rubber Leaves block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber = false + rubberSapling; // Rubber Sapling block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber = false + resinSheet; // Resin Sheet block, currently not meta sensitive + rubberTrampoline; // Rubber Trampoline block, meta reflects internal state, meta in ItemStack set to 0 + + // building/storage + ironFence; // Iron Fence block, currently not meta sensitive + + reinforcedStone; // Reinforced Stone block, currently not meta sensitive + reinforcedGlass; // Reinforced Glass block, currently not meta sensitive + reinforcedDoorBlock; // Reinforced Door block, meta reflects the state (see vanilla doors), meta in ItemStack set to 0 + + constructionreinforcedFoam; // Construction Reinforced Foam block, currently not meta sensitive + constructionFoam; // Construction Foam block, currently not meta sensitive + constructionFoamWall; // Construction Foam Wall block, meta = color, implements IPaintableBlock + scaffold; // Scaffold block, meta reflects internal physical model data + ironScaffold; // Scaffold block, meta reflects internal physical model data + + bronzeBlock; // Bronze block, meta sensitive + copperBlock; // Copper block, meta sensitive + tinBlock; // Tin block, meta sensitive + uraniumBlock; // Uranium block, meta sensitive + leadBlock; // Uranium block, meta sensitive + + // cables (when placed as a block, inventory items are different; TE implements IEnergyConductor) + + copperCableBlock; // Copper Cable block, meta sensitive + insulatedCopperCableBlock; // Insulated Copper Cable block, meta sensitive + + goldCableBlock; // Gold Cable block, meta sensitive + insulatedGoldCableBlock; // Insulated Gold Cable block, meta sensitive + doubleInsulatedGoldCableBlock; // Double Insulated Gold Cable block, meta sensitive + + ironCableBlock; // Iron Cable block, meta sensitive + insulatedIronCableBlock; // Insulated Iron Cable block, meta sensitive + doubleInsulatedIronCableBlock; // Double Insulated Iron Cable block, meta sensitive + trippleInsulatedIronCableBlock; // Tripple Insulated Iron Cable block, meta sensitive + + glassFiberCableBlock; // Glass Fiber Cable block, meta sensitive + + tinCableBlock; // Tin Cable block, meta sensitive + insulatedtinCableBlock; // Insulated Tin Cable item, meta sensitive + detectorCableBlock; // Detector Cable block, meta sensitive + splitterCableBlock; // Splitter Cable block, meta sensitive + + // generators + related (TE implements IEnergySource ex. reactorChamber) + + generator; // Generator block, meta sensitive + geothermalGenerator; // Geothermal Generator block, meta sensitive + waterMill; // Water Mill block, meta sensitive + solarPanel; // Solar Panel block, meta sensitive + windMill; // Wind Mill block, meta sensitive + nuclearReactor; // Nuclear Reactor block, meta sensitive + reactorChamber; // Reactor Chamber block, currently not meta sensitive + RTGenerator; // Radioisotope Thermoelectric Generator block, meta sensitive + semifluidGenerator; // Semifluid Generator block, meta sensitive + + + // energy storages (TE implements IEnergySource and IEnergyConductor) + + batBox; // BatBox block, meta sensitive + cesuUnit; // CESU Unit block, meta sensitive + mfeUnit; // MFE Unit block, meta sensitive + mfsUnit; // MFS Unit block, meta sensitive + + // transformers (TE implements IEnergySource and IEnergyConductor) + + lvTransformer; // LV Transformer block, meta sensitive + mvTransformer; // MV Transformer block, meta sensitive + hvTransformer; // HV Transformer block, meta sensitive + evTransformer; // EV Transformer block, meta sensitive + + // machines + related (TE implements IEnergySink ex. machine, miningPipe, miningPipeTip) + + machine; // Machine block, meta sensitive + advancedMachine; // Advanced Machine block, meta sensitive + + ironFurnace; // Iron Furnace block, meta sensitive + electroFurnace; // Electro Furnace block, meta sensitive + macerator; // Macerator block, meta sensitive + extractor; // Extractor block, meta sensitive + compressor; // Compressor block, meta sensitive + canner; // Canner block, meta sensitive + miner; // Miner block, meta sensitive + pump; // Pump block, meta sensitive + magnetizer; // Magnetizer block, meta sensitive + electrolyzer; // Electrolyzer block, meta sensitive + recycler; // Recycler block, meta sensitive + inductionFurnace; // Induction Furnace block, meta sensitive + massFabricator; // Mass Fabricator block, meta sensitive + terraformer; // Terraformer block, meta sensitive + teleporter; // Teleporter block, meta sensitive + teslaCoil; // Tesla Coil block, meta sensitive + luminator; // Passive (dark) Luminator block, meta = facing + activeLuminator; // Active (bright) Luminator block, meta = facing + centrifuge; // Centrifuge block, meta sensitive + metalformer; // MetalFormer block , meta sensitive + orewashingplant; // Ore Wasching Plant, Meta sensitive + patternstorage; // Pattern Storage, Meta sensitive + scanner; // Scanner, Meta sensitive + replicator; // Replicator, Meta sensitive + + miningPipe; // Mining Pipe block, currently not meta sensitive, meta in ItemStack set to 0 + miningPipeTip; // Mining Pipe Tip block, currently not meta sensitive, meta in ItemStack set to 0 + + + // personal blocks + + personalSafe; // Personal Safe block, meta sensitive + tradeOMat; // Trade-O-Mat block, meta sensitive + energyOMat; // Energy-O-Mat block, meta sensitive + + // explosives + + industrialTnt; // Industrial TNT block, currently not meta sensitive + nuke; // Nuke block, currently not meta sensitive + dynamiteStick; // Dynamite Stick block, meta = placement, meta in ItemStack set to 0 + dynamiteStickWithRemote; // Dynamite Stick with Remote block, meta = placement, meta in ItemStack set to 0 + + // Agriculture Stuff + + crop; // Crop Block, empty, not meta sensitive + cropmatron; // Cropmatron machien block, meta sensititve + + // ----- items ----- + + // rubber + related + resin; // Resin item, currently not meta sensitive + rubber; // Rubber item, currently not meta sensitive, ore dictionary: itemRubber + + FluidCell; + + // Lithium -> Tritium + + reactorLithiumCell; // LithiumCell use in Reaktor, , meta = damage value + TritiumCell; // Tritium, currently not meta sensitive + + // Nuclear Fuel + + UranFuel; // , currently not meta sensitive + MOXFuel; // , currently not meta sensitive + Plutonium; // , currently not meta sensitive + smallPlutonium; // , currently not meta sensitive + Uran235; // , currently not meta sensitive + smallUran235; // , currently not meta sensitive + Uran238; // , currently not meta sensitive + + reactorDepletedUraniumSimple; // Depleted Uranium Cell items, currently not meta sensitive + reactorDepletedUraniumDual; + reactorDepletedUraniumQuad; + reactorDepletedMOXSimple; // Depleted MOX Cell items, currently not meta sensitive + reactorDepletedMOXDual; + reactorDepletedMOXQuad; + reactorMOXSimple; // Depleted MOX Cell items, currently not meta sensitive + reactorMOXDual; + reactorMOXQuad; + RTGPellets; + + + // Recipe Parts + + coil; // Coil, meta sensitive + elemotor; // electric motor, meta sensitive + powerunit; // Item Power Unit, meta sensitive + powerunitsmall; // Item Power Unit, meta sensitive + + + // ItemCasing + + casingcopper; // Copper ItemCasing, meta sensitive + casingtin; // Tin ItemCasing, meta sensitive + casingbronze; // Bronze ItemCasing, meta sensitive + casinggold; // Gold ItemCasing, meta sensitive + casingiron; // Iron ItemCasing, meta sensitive + @Deprecated + casingadviron; // Refined Iron ItemCasing, meta sensitive + casinglead; // Lead ItemCasing, meta sensitive + + // Crushed Ore + crushedIronOre; // Crushed Iron Ore, meta sensitive + crushedCopperOre; // Crushed Copper Ore, meta sensitive + crushedGoldOre; // Crushed Gold Ore, meta sensitive + crushedTinOre; // Crushed Tin Ore, meta sensitive + crushedUraniumOre; // Crushed Uranium Ore, meta sensitive + crushedSilverOre; // Crushed Silver Ore, meta sensitive + crushedLeadOre; // Crushed Lead Ore, meta sensitive + + + //Purify Crushed Ore + purifiedCrushedIronOre; // Purify Crushed Iron Ore, meta sensitive + purifiedCrushedCopperOre; // Purify Crushed Copper Ore, meta sensitive + purifiedCrushedGoldOre; // Purify Crushed Gold Ore, meta sensitive + purifiedCrushedTinOre; // Purify Crushed Tin Ore, meta sensitive + purifiedCrushedUraniumOre; // Purify Crushed Uranium Ore, meta sensitive + purifiedCrushedSilverOre; // Purify Crushed Silver Ore, meta sensitive + purifiedCrushedLeadOre; // Purify Crushed Lead Ore, meta sensitive + + // dusts + stoneDust; + bronzeDust; // Bronze Dust item, meta sensitive, ore dictionary: dustBronze + clayDust; // Clay Dust item, meta sensitive, ore dictionary: dustClay + coalDust; // Coal Dust item, meta sensitive, ore dictionary: dustCoal + copperDust; // Copper Dust item, meta sensitive, ore dictionary: dustCopper + goldDust; // Gold Dust item, meta sensitive, ore dictionary: dustGold + ironDust; // Iron Dust item, meta sensitive, ore dictionary: dustIron + silverDust; // Silver Dust item, meta sensitive, ore dictionary: dustSilver + tinDust; // Tin Dust item, meta sensitive, ore dictionary: dustTin + hydratedCoalDust; // Hydrated Coal Dust item, meta sensitive + leadDust; // Lead Dust item, meta sensitive, ore dictionary: dustLead + obsidianDust; // Obsidian Dust item, meta sensitive, ore dictionary: dustObsidian + lapiDust; // Lapi Dust item, meta sensitive, ore dictionary: dustLapi + sulfurDust; // Sulfur Dust item, meta sensitive, ore dictionary: dustSulfur + lithiumDust; // Lithium dust, meta sensitive, ore dictionary: dustLithium + + // small dusts + + smallIronDust; // Small Iron Dust item, meta sensitive + smallCopperDust; // Small Copper Dust item, meta sensitive + smallGoldDust; // Small Gold Dust item, meta sensitive + smallTinDust; // Small Tin Dust item, meta sensitive + smallSilverDust; // Small Silver Dust item, meta sensitive + smallLeadDust; // Small Lead Dust item, meta sensitive + smallSulfurDust; // Small Sulfur Dust item, meta sensitive + smallLithiumDust; // Small Lithium Dust item, meta sensitive + + + // ingots + @Deprecated + refinedIronIngot; // Refined Iron Ingot item, currently not meta sensitive, ore dictionary: ingotRefinedIron + copperIngot; // Copper Ingot item, currently not meta sensitive, ore dictionary: ingotCopper + tinIngot; // Tin Ingot item, currently not meta sensitive, ore dictionary: ingotTin + bronzeIngot; // Bronze Ingot item, currently not meta sensitive, ore dictionary: ingotBronze + mixedMetalIngot; // Mixed Metal Ingot item, currently not meta sensitive + leadIngot; // Lead Ingot item, currently not meta sensitive + + + // tools/weapons (without electric tools) + treetap; // Treetap item, meta = damage value + wrench; // Wrench item, meta = damage value + cutter; // Insulation Cutter item, meta = damage value + constructionFoamSprayer; // Construction Foam Sprayer item, meta = charges (as of v1.45) + + bronzePickaxe; // Bronze Pickaxe item, meta = damage value + bronzeAxe; // Bronze Axe item, meta = damage value + bronzeSword; // Bronze Sword item, meta = damage value + bronzeShovel; // Bronze Shovel item, meta = damage value + bronzeHoe; // Bronze Hoe item, meta = damage value + + ForgeHammer; // Refine Iron Hammer item, meta = damage value + + // el. tools/devices/weapons + miningDrill; // Mining Drill item, meta = damage value for charge level + diamondDrill; // Diamond Tipped Mining Drill item, meta = damage value for charge level + iridiumDrill; // Iridium Tipped Mining Drill item, meta = damage value for charge level + chainsaw; // Chainsaw item, meta = damage value for charge level + electricWrench; // Electric Wrench item, meta = damage value for charge level + electricTreetap; // Electric Treetap item, meta = damage value for charge level + miningLaser; // Mining Laser item, meta = damage value for charge level + + ecMeter; // EC-Mater item, meta = itemdata db index (as of v1.45) + odScanner; // Ore Density Scanner item, meta = damage value for charge level + ovScanner; // Ore Value Scanner item, meta = damage value for charge level + obscurator; // Obscurator item, meta = damage value for charge level + + frequencyTransmitter; // Frequency Transmitter item, meta = itemdata db index (as of v1.45) + + nanoSaber; // Idle Nano Saber item, meta = damage value for charge level + enabledNanoSaber; // Enabled Nano Saber item, meta = damage value for charge level + + toolbox; // Open/Empty toolbox, meta = Open (0) / Closed (1) + + // armor/wearable + hazmatHelmet; // Hazmat Helmet item, meta = damage value + hazmatChestplate; // Hazmat Chestplate item, meta = damage value + hazmatLeggings; // Hazmat Leggings item, meta = damage value + hazmatBoots; // Hazmat Boots item, meta = damage value + + bronzeHelmet; // Bronze Helmet Armor item, meta = damage value + bronzeChestplate; // Bronze Chestplate Armor item, meta = damage value + bronzeLeggings; // Bronze Leggings Armor item, meta = damage value + bronzeBoots; // Bronze Boots Armor item, meta = damage value + + compositeArmor; // Composite Armor item, meta = damage value for charge level + + nanoHelmet; // Nano Helmet Armor item, meta = damage value for charge level + nanoBodyarmor; // Nano Bodyarmor item, meta = damage value for charge level + nanoLeggings; // Nano Leggings Armor item, meta = damage value for charge level + nanoBoots; // Nano Boots Armor item, meta = damage value for charge level + + quantumHelmet; // Quantum Helmet Armor item, meta = damage value for charge level + quantumBodyarmor; // Quantum Bodyarmor item, meta = damage value for charge level + quantumLeggings; // Quantum Leggings Armor item, meta = damage value for charge level + quantumBoots; // Quantum Boots Armor item, meta = damage value for charge level + + jetpack; // Jetpack item, meta = damage value for fuel level + electricJetpack; // Electric Jetpack item, meta = damage value for charge level + + batPack; // BatPack item, meta = damage value for charge level + advbatPack; // Adv.BatPack item, meta = damage value for charge level + lapPack; // LapPack item, meta = damage value for charge level + energyPack; // EnergyPack item, meta = damage value for charge level + + cfPack; // CF Pack item, meta = charges (as of v1.45) + solarHelmet; // Solar Helmet, currently not meta sensitive + staticBoots; // Static Boots, currently not meta sensitive + nightvisionGoggles; // Nightvision Goggles, meta = damage value for charge level + + // batteries + reBattery; // Empty RE Battery item, currently not meta sensitive + chargedReBattery; // RE Battery item, meta = damage value for charge level + advBattery; // Adv Batteryitem, meta = damage value for charge level + energyCrystal; // Energy Crystal item, meta = damage value for charge level + lapotronCrystal; // Lapotron Crystal item, meta = damage value for charge level + suBattery; // SU Battery item, meta = damage value for charge level + + // cables + copperCableItem; // Copper Cable item, meta sensitive + insulatedCopperCableItem; // Insulated Copper Cable item, meta sensitive + + goldCableItem; // Gold Cable item, meta sensitive + insulatedGoldCableItem; // Insulated Gold Cable item, meta sensitive + + @Deprecated + doubleInsulatedGoldCableItem; // Double Insulated Gold Cable item, meta sensitive + + ironCableItem; // Iron Cable item, meta sensitive + insulatedIronCableItem; // Insulated Iron Cable item, meta sensitive + + @Deprecated + doubleInsulatedIronCableItem; // Double Insulated Iron Cable item, meta sensitive + @Deprecated + trippleInsulatedIronCableItem; // Tripple Insulated Iron Cable item, meta sensitive + insulatedTinCableItem; + glassFiberCableItem; // Glass Fiber Cable item, meta sensitive + tinCableItem; // Tin Cable item, meta sensitive + + + detectorCableItem; // Detector Cable item, meta sensitive + splitterCableItem; // Splitter Cable item, meta sensitive + + // cells/containers (without reactor components) + + cell; // Empty Cell item, meta sensitive + lavaCell; // Lava Cell item, meta sensitive + waterCell; // Water Cell item, meta sensitive + UuMatterCell; // UUMatter Cell item, meta sensitive + CFCell; // constructionFoam Cell item, meta sensitive + + + fuelRod; // Empy Fuel Rod item, currently not meta sensitive + hydratedCoalCell; // Hydrated Coal Cell item, currently not meta sensitive + bioCell; // Bio Cell item, currently not meta sensitive + coalfuelCell; // Coalfuel Cell item, currently not meta sensitive + biofuelCell; // Biofuel Cell item, currently not meta sensitive + electrolyzedWaterCell; // Electrolyzed Water Cell item, currently not meta sensitive + airCell; // Compressed Air item, currently not meta sensitive + + fuelCan; // Empty Fuel Can item, currently not meta sensitive + filledFuelCan; // Fuel Can item, meta = fuel value (as of v1.45) + + tinCan; // Empty Tin Can item, currently not meta sensitive + filledTinCan; // Filled Tin Can item, currently not meta sensitive + + // reactor components + reactorUraniumSimple; // Uranium Cell items, meta = consumed uranium ticks + reactorUraniumDual; + reactorUraniumQuad; + + reactorCoolantSimple; + reactorCoolantTriple ; // Coolant Cell item, NBT for heat-storage, meta is 0-10000 for display + reactorCoolantSix; + + reactorPlating; // Integrated Reactor Plating item, currently not meta sensitive + reactorPlatingHeat; + reactorPlatingExplosive; + + reactorHeatSwitch; // Integrated Heat Disperser item, NBT for heat-storage, meta is 0-10000 for display + reactorHeatSwitchCore; + reactorHeatSwitchSpread; + reactorHeatSwitchDiamond; + + reactorVent; // Heat Venting component, NBT for heat-storage, meta is 0-10000 for display + reactorVentCore; + reactorVentGold; + reactorVentSpread;// Special: Does not store heat + reactorVentDiamond; + + reactorReflector; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display + reactorReflectorThick; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display + reactorCondensator; // Consumes redstone to absorb heat, NBT for storage, meta is 0-10000 for display + reactorCondensatorLap; // Consumes redstone/lapis to absorb heat, mNBT for storage, meta is 0-10000 for display + + // terraformer blueprints + terraformerBlueprint; // Empty Terraformer Blueprint item, currently not meta sensitive + cultivationTerraformerBlueprint; // Cultivation Terraformer Blueprint item, currently not meta sensitive + irrigationTerraformerBlueprint; // Irrigation Terraformer Blueprint item, currently not meta sensitive + chillingTerraformerBlueprint; // Chilling Terraformer Blueprint item, currently not meta sensitive + desertificationTerraformerBlueprint; // Desertification Terraformer Blueprint item, currently not meta sensitive + flatificatorTerraformerBlueprint; // Flatificator Terraformer Blueprint item, currently not meta sensitive + mushroomTerraformerBlueprint; // Mushroom Terraformer Blueprint item, currently not meta sensitive + + // diamond chain + coalBall; // Coal Ball item, currently not meta sensitive + compressedCoalBall; // Compressed Coal Ball item, currently not meta sensitive + coalChunk; // Coal Chunk item, currently not meta sensitive + industrialDiamond; // Industrial Diamond item, currently not meta sensitive, DEPRECATED + + // recycler chain + scrap; // Scrap item, currently not meta sensitive + scrapBox; // Scrap Box item, currently not meta sensitive + + // fuel production chain + hydratedCoalClump; // Hydrated Coal Clump item, currently not meta sensitive + plantBall; // Plant Ball item, currently not meta sensitive + compressedPlantBall; // Compressed Plant Ball item, currently not meta sensitive + + // painting + painter; // Painter item, currently not meta sensitive + + blackPainter; // Black Painter item, meta = damage value + redPainter; // Red Painter item, meta = damage value + greenPainter; // Green Painter item, meta = damage value + brownPainter; // Brown Painter item, meta = damage value + bluePainter; // Blue Painter item, meta = damage value + purplePainter; // Purple Painter item, meta = damage value + cyanPainter; // Cyan Painter item, meta = damage value + lightGreyPainter; // Light Grey Painter item, meta = damage value + darkGreyPainter; // Dark Grey Painter item, meta = damage value + pinkPainter; // Pink Painter item, meta = damage value + limePainter; // Lime Painter item, meta = damage value + yellowPainter; // Yellow Painter item, meta = damage value + cloudPainter; // Cloud Painter item, meta = damage value + magentaPainter; // Magenta Painter item, meta = damage value + orangePainter; // Orange Painter item, meta = damage value + whitePainter; // White Painter item, meta = damage value + + // explosives + related + dynamite; // Throwable Dynamite item, currently not meta sensitive + stickyDynamite; // Throwable Sticky Dynamite item, currently not meta sensitive + + remote; // Dynamite Remote item, currently not meta sensitive + + // misc intermediate recipe ingredients + electronicCircuit; // Electronic Circuit item, currently not meta sensitive + advancedCircuit; // Advanced Circuit item, currently not meta sensitive + + advancedAlloy; // Advanced Alloy item, currently not meta sensitive + + carbonFiber; // Raw Carbon Fiber item, currently not meta sensitive + carbonMesh; // Raw Carbon Mesh item, currently not meta sensitive + carbonPlate; // Carbon Plate item, currently not meta sensitive + + matter; // UUA item, currently not meta sensitive + iridiumOre; // Iridium Ore item, currently not meta sensitive + iridiumPlate; // Iridium Plate item, currently not meta sensitive + + + // Metal Plates + + platecopper; // Metal plate item, meta sensitive + platetin; // Metal plate item, meta sensitive + platebronze; // Metal plate item, meta sensitive + plategold; // Metal plate item, meta sensitive + plateiron; // Metal plate item, meta sensitive + platelead; // Metal plate item, meta sensitive + platelapi; // Metal plate item, meta sensitive + plateobsidian; // Metal plate item, meta sensitive + plateadviron; // Metal plate item, meta sensitive + + // Metal Dense Plates + denseplatecopper; // Metal dense plate item, meta sensitive + denseplatetin; // Metal dense plate item, meta sensitive + denseplatebronze; // Metal dense plate item, meta sensitive + denseplategold; // Metal dense plate item, meta sensitive + denseplateiron; // Metal dense plate item, meta sensitive + @Deprecated + denseplateadviron; // Metal dense plate item, meta sensitive + denseplatelead; // Metal dense plate item, meta sensitive + denseplatelapi; // Metal dense plate item, meta sensitive + denseplateobsidian; // Metal dense plate item, meta sensitive + + + // upgrade modules + overclockerUpgrade; // overclocker upgrade item, meta sensitive + transformerUpgrade; // transformer upgrade item, meta sensitive + energyStorageUpgrade; // energy storage upgrade item, meta sensitive + ejectorUpgrade; // ejector upgrade item, meta sensitive + + // misc + coin; // Coin item, currently not meta sensitive + reinforcedDoor; // Reinforced Door item, currently not meta sensitive + constructionFoamPowder; // Construction Foam Powder item, currently not meta sensitive + grinPowder; // Poisonous ingrident, currently not meta sensitive + debug; // Debug item, currently not meta sensitive + boatCarbon; // Carbon Fiber Canoe item, meta sensitive + boatRubber; // Rubber Dinghy item, meta sensitive + boatRubberBroken; // Damaged Rubber Dinghy item, meta sensitive + boatElectric; // Electric Boat item, meta sensitive + + //Agriculture + cropSeed; // Crop seeds, stuff stored in NBT, don't use for crafting recipes! + cropnalyzer; // Cropnalyzer handheld device + fertilizer; // Basic IC2Item, used to provide nutrients toCropBlocks + hydratingCell; // Cell used to hydrate Crops, meta = Content, 0= Full, 9999 = Near empty + electricHoe; // Electric Hoe, Metadata indicates charge level + terraWart; // Mystic opposite of NEtherWart, cures StatusEffects, simply consumeable + weedEx; // Spraying can of WEED-EX, meta indicates usages left + + //Boozeception + mugEmpty; // Simple stone mug + coffeeBeans; // Harvested CoffeeBeans + coffeePowder; // Processed Coffee Beans, used to craft drinkable Coffee + mugCoffee; // Mug of Coffee, Meta indicates status 0 = cold, 1 = Normal, 2 = Sugar'd + hops; // Hops, harvested freshly from crop + barrel; // Carried Barrel, metadata encrypts the information about the liquid inside + blockBarrel; // Unobtainable "placed barrel", TileEntity controlling the Fermentation process + mugBooze; // Mug filled with booze, metadata encrypts the information about the liquid inside + + */ + + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = IC2Items.class.getPackage(); + + if (pkg != null) { + String packageName = pkg.getName(); + + return packageName.substring(0, packageName.length() - ".api.item".length()); + } + + return "ic2"; + } + + private static Class Ic2Items; +} + diff --git a/src/api/java/ic2/api/item/IDebuggable.java b/src/api/java/ic2/api/item/IDebuggable.java new file mode 100644 index 00000000..404c7eb7 --- /dev/null +++ b/src/api/java/ic2/api/item/IDebuggable.java @@ -0,0 +1,22 @@ +package ic2.api.item; + + +/** + * Allows a tile entity to output a debug message when the debugItem is used on it. + * Suggestions by Myrathi + */ +public abstract interface IDebuggable { + /** + * Checks if the tile entity is in a state that can be debugged. + * + * @return True if the tile entity can be debugged + */ + public abstract boolean isDebuggable(); + + /** + * Gets the debug text for the tile entity. + * + * @return The text that the debugItem should show + */ + public abstract String getDebugText(); +} diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java new file mode 100644 index 00000000..ceaa2606 --- /dev/null +++ b/src/api/java/ic2/api/item/IElectricItem.java @@ -0,0 +1,55 @@ +package ic2.api.item; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Provides the ability to store energy on the implementing item. + *

+ * The item should have a maximum damage of 13. + */ +public interface IElectricItem { + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); + + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); + + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); + + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); +} + diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java new file mode 100644 index 00000000..ecae1459 --- /dev/null +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -0,0 +1,93 @@ +package ic2.api.item; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + *

+ * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * more atomic features in the gateway manager. + */ +public interface IElectricItemManager { + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); + + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); + + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); + + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); +} diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java new file mode 100644 index 00000000..66e32bdf --- /dev/null +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -0,0 +1,24 @@ +package ic2.api.item; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface IItemHudInfo { + /* + Add Info to Nano- and Quantum-Suit Helm Hud + for itemStack + + @Override + public List getHudInfo(ItemStack itemStack) { + List info = new LinkedList(); + info.add("i am a Cool Item"); + info.add("and have Cool info"); + return info; + } + + + */ + + public List getHudInfo(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.java b/src/api/java/ic2/api/item/IKineticWindRotor.java new file mode 100644 index 00000000..90522808 --- /dev/null +++ b/src/api/java/ic2/api/item/IKineticWindRotor.java @@ -0,0 +1,15 @@ +package ic2.api.item; + +import net.minecraft.util.ResourceLocation; + +public interface IKineticWindRotor { + public int getDiameter(); + + public ResourceLocation getRotorRenderTexture(); + + public float getefficiency(); + + int getminWindStrength(); + + int getmaxWindStrength(); +} diff --git a/src/api/java/ic2/api/item/IMetalArmor.java b/src/api/java/ic2/api/item/IMetalArmor.java new file mode 100644 index 00000000..e4a85db0 --- /dev/null +++ b/src/api/java/ic2/api/item/IMetalArmor.java @@ -0,0 +1,20 @@ +package ic2.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Armor items implementing this can be considered metal armor. + *

+ * Currently used for determining which boots can be used to slide up a magnetic pole. + */ +public interface IMetalArmor { + /** + * Determine if the given armor piece is metal armor. + * + * @param itemstack Armor piece as worn by the player + * @param player The player + * @return Whether the armor piece is metal armor + */ + public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); +} diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java new file mode 100644 index 00000000..d3497a76 --- /dev/null +++ b/src/api/java/ic2/api/item/ISpecialElectricItem.java @@ -0,0 +1,13 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +public interface ISpecialElectricItem extends IElectricItem { + /** + * Supply a custom IElectricItemManager. + * + * @param itemStack ItemStack to get the manager for + * @return IElectricItemManager instance + */ + IElectricItemManager getManager(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/api/java/ic2/api/item/ITerraformingBP.java new file mode 100644 index 00000000..5c9bf7ca --- /dev/null +++ b/src/api/java/ic2/api/item/ITerraformingBP.java @@ -0,0 +1,34 @@ +package ic2.api.item; + +import net.minecraft.world.World; + +/** + * Allows an item to act as a terraformer blueprint. + */ +public interface ITerraformingBP { + /** + * Get the energy consumption per operation of the blueprint. + * + * @return Energy consumption in EU + */ + public abstract int getConsume(); + + /** + * Get the maximum range of the blueprint. + * Should be a divisor of 5. + * + * @return Maximum range in blocks + */ + public abstract int getRange(); + + /** + * Perform the terraforming operation. + * + * @param world world to terraform + * @param x X position to terraform + * @param z Z position to terraform + * @param yCoord Y position of the terraformer + * @return Whether the operation was successful and the terraformer should consume energy. + */ + public abstract boolean terraform(World world, int x, int z, int yCoord); +} diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/api/java/ic2/api/item/ItemWrapper.java new file mode 100644 index 00000000..593cd1dc --- /dev/null +++ b/src/api/java/ic2/api/item/ItemWrapper.java @@ -0,0 +1,50 @@ +package ic2.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; + +/** + * Wrapper for inserting interfaces into items you don't own. + * + * @author Richard + */ +public class ItemWrapper { + private static final Multimap boxableItems = ArrayListMultimap.create(); + private static final Multimap metalArmorItems = ArrayListMultimap.create(); + + public static void registerBoxable(Item item, IBoxable boxable) { + boxableItems.put(item, boxable); + } + + public static boolean canBeStoredInToolbox(ItemStack stack) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IBoxable boxable : boxableItems.get(item)) { + if (boxable.canBeStoredInToolbox(stack)) return true; + } + + if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; + + return false; + } + + public static void registerMetalArmor(Item item, IMetalArmor armor) { + metalArmorItems.put(item, armor); + } + + public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IMetalArmor metalArmor : metalArmorItems.get(item)) { + if (metalArmor.isMetalArmor(stack, player)) return true; + } + + if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; + + return false; + } +} diff --git a/src/api/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java new file mode 100644 index 00000000..d814f54b --- /dev/null +++ b/src/api/java/ic2/api/item/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.item; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java similarity index 51% rename from src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java rename to src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java index ed3ea38f..53cca72a 100644 --- a/src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java @@ -6,12 +6,12 @@ import net.minecraft.entity.player.EntityPlayer; * Allows a tile entity to receive network events received from clients. */ public interface INetworkClientTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param player client which sent the event - * @param event event ID - */ - void onNetworkEvent(EntityPlayer player, int event); + /** + * Called when a network event is received. + * + * @param player client which sent the event + * @param event event ID + */ + void onNetworkEvent(EntityPlayer player, int event); } diff --git a/src/main/java/ic2/api/network/INetworkDataProvider.java b/src/api/java/ic2/api/network/INetworkDataProvider.java similarity index 66% rename from src/main/java/ic2/api/network/INetworkDataProvider.java rename to src/api/java/ic2/api/network/INetworkDataProvider.java index c3f283e5..cc59205f 100644 --- a/src/main/java/ic2/api/network/INetworkDataProvider.java +++ b/src/api/java/ic2/api/network/INetworkDataProvider.java @@ -4,15 +4,15 @@ import java.util.List; /** * Tile entities which want to synchronized specific fields between client and server have to implement this. - * + *

* The fields don't update themselves, a field update must be sent every time a synchronized field changes. */ public interface INetworkDataProvider { - /** - * Get the list of synchronized fields. - * - * @return Names of the synchronized fields - */ - List getNetworkedFields(); + /** + * Get the list of synchronized fields. + * + * @return Names of the synchronized fields + */ + List getNetworkedFields(); } diff --git a/src/api/java/ic2/api/network/INetworkItemEventListener.java b/src/api/java/ic2/api/network/INetworkItemEventListener.java new file mode 100644 index 00000000..85ac2a99 --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkItemEventListener.java @@ -0,0 +1,19 @@ +package ic2.api.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Allows an item to receive network events received from the server. + */ +public interface INetworkItemEventListener { + /** + * Called when a network event is received. + * + * @param itemStack item stack + * @param player player containing the item + * @param event event ID + */ + void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); +} + diff --git a/src/main/java/ic2/api/network/INetworkTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java similarity index 54% rename from src/main/java/ic2/api/network/INetworkTileEntityEventListener.java rename to src/api/java/ic2/api/network/INetworkTileEntityEventListener.java index fbb4753c..23b11c5b 100644 --- a/src/main/java/ic2/api/network/INetworkTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java @@ -4,11 +4,11 @@ package ic2.api.network; * Allows a tile entity to receive network events received from the server. */ public interface INetworkTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param event Event ID - */ - void onNetworkEvent(int event); + /** + * Called when a network event is received. + * + * @param event Event ID + */ + void onNetworkEvent(int event); } diff --git a/src/api/java/ic2/api/network/INetworkUpdateListener.java b/src/api/java/ic2/api/network/INetworkUpdateListener.java new file mode 100644 index 00000000..05548dee --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkUpdateListener.java @@ -0,0 +1,14 @@ +package ic2.api.network; + +/** + * Allows a tile entity to receive field sync updates received from the server. + */ +public interface INetworkUpdateListener { + /** + * Called when a field is synchronized. + * + * @param field field synchronized + */ + void onNetworkUpdate(String field); +} + diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java new file mode 100644 index 00000000..c0aea0fe --- /dev/null +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -0,0 +1,199 @@ +package ic2.api.network; + +import java.lang.reflect.Method; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +/** + * Provides methods to initiate events and synchronize tile entity fields in SMP. + *

+ * The methods are transparent between singleplayer and multiplayer - if a method is called in + * singleplayer, the associated callback will be locally executed. The implementation is different + * between the client and server versions of IC2. + *

+ * You'll usually want to use the server->client methods defined here to synchronize information + * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or + * producing effects. Anything which is only visible inside the GUI should be synchronized through + * the Container class associated to the GUI in Container.updateProgressBar(). + */ +public final class NetworkHelper { + // server -> client + + + /** + * Schedule a TileEntity's field to be updated to the clients in range. + *

+ * The updater will query the field's value during the next update, updates happen usually + * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. + *

+ * IC2's network updates have to get triggered every time, it doesn't continuously poll/send + * the field value. Just call updateTileEntityField after every change to a field which needs + * network synchronization. + *

+ * The following field data types are currently supported: + * - int, int[], short, short[], byte, byte[], long, long[] + * - float, float[], double, double[] + * - boolean, boolean[] + * - String, String[] + * - ItemStack + * - NBTBase (includes NBTTagCompound) + * - Block, Item, Achievement, Potion, Enchantment + * - ChunkCoordinates, ChunkCoordIntPair + * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) + * - World (does not sync the actual world, instead looks up the world by its dimension ID) + *

+ * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- + * side TileEntity if it implements INetworkUpdateListener. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). + * + * @param te TileEntity to update + * @param field Name of the field to update + */ + public static void updateTileEntityField(TileEntity te, String field) { + try { + if (NetworkManager_updateTileEntityField == null) + NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); + if (instance == null) instance = getInstance(); + + NetworkManager_updateTileEntityField.invoke(instance, te, field); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified TileEntity to the clients in range. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). + * + * @param te TileEntity to notify, should implement INetworkTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { + try { + if (NetworkManager_initiateTileEntityEvent == null) + NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified Item to the clients in range. + *

+ * The item should implement INetworkItemEventListener to receive the event. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkItemEventListener.onNetworkEvent (if implemented by the item). + * + * @param player EntityPlayer holding the item + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { + try { + if (NetworkManager_initiateItemEvent == null) + NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + // client -> server + + /** + * Immediately send an event for the specified TileEntity to the server. + *

+ * This method doesn't do anything if executed on the server. + * + * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientTileEntityEvent(TileEntity te, int event) { + try { + if (NetworkManager_initiateClientTileEntityEvent == null) + NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified Item to the clients in range. + *

+ * The item should implement INetworkItemEventListener to receive the event. + *

+ * This method doesn't do anything if executed on the server. + * + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientItemEvent(ItemStack itemStack, int event) { + try { + if (NetworkManager_initiateClientItemEvent == null) + NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = NetworkHelper.class.getPackage(); + + if (pkg != null) { + String packageName = pkg.getName(); + + return packageName.substring(0, packageName.length() - ".api.network".length()); + } + + return "ic2"; + } + + /** + * Get the NetworkManager instance, used internally. + * + * @return NetworkManager instance + */ + private static Object getInstance() { + try { + return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + private static Object instance; + private static Method NetworkManager_updateTileEntityField; + private static Method NetworkManager_initiateTileEntityEvent; + private static Method NetworkManager_initiateItemEvent; + private static Method NetworkManager_initiateClientTileEntityEvent; + private static Method NetworkManager_initiateClientItemEvent; +} + diff --git a/src/api/java/ic2/api/network/package-info.java b/src/api/java/ic2/api/network/package-info.java new file mode 100644 index 00000000..d925e4a3 --- /dev/null +++ b/src/api/java/ic2/api/network/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.network; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java new file mode 100644 index 00000000..3440426c --- /dev/null +++ b/src/api/java/ic2/api/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/api/java/ic2/api/reactor/IReactor.java new file mode 100644 index 00000000..c7a7a609 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -0,0 +1,158 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +/** + * Interface implemented by the tile entity of nuclear reactors. + */ +public interface IReactor { + /** + * Get the reactor's position in the world. + * + * @return Position of the reactor + */ + public ChunkCoordinates getPosition(); + + /** + * Get the reactor's corresponding world. + * + * @return The reactor's world + */ + public World getWorld(); + + /** + * Get the reactor's heat. + * + * @return The reactor's heat + */ + public int getHeat(); + + /** + * Set the reactor's heat. + * + * @param heat reactor heat + */ + public void setHeat(int heat); + + /** + * Increase the reactor's heat. + *

+ * Use negative values to decrease. + * + * @param amount amount of heat to add + * @return The reactor's heat after adding the specified amount + */ + public int addHeat(int amount); + + /** + * Get the reactor's maximum heat before exploding. + * + * @return Maximum heat value + */ + public int getMaxHeat(); + + /** + * Set the reactor's stored maxHeat variable. + * Used by plating to increase the reactors MaxHeat capacity. + * Needs to be called during each cycle process. + */ + public void setMaxHeat(int newMaxHeat); + + /** + * add Heat to a EmitHeat Buffer + * for use in Reactor operation.. need to be use + * for all Componetents with self-cooling + * no more magic heat disappear + */ + + + public void addEmitHeat(int heat); + + /** + * Get's the reactor's HEM (Heat Effect Modifier) + * Basic value is 1.0F. + * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors + * (F.e. water evaporation, melting, damaging entitys, etc) + * + * @return HEM + */ + public float getHeatEffectModifier(); + + /** + * Set's the reactor's HEM + * Needs to be called during each cycle process. + */ + public void setHeatEffectModifier(float newHEM); + + /** + * Get the reactor's energy output. + * + * @return Energy output, not multiplied by the base EU/t value + */ + public float getReactorEnergyOutput(); + + /** + * Get the reactor's energy output. + * + * @return Energy output, multiplied with base EU/t value and MainConfig.get().getFloat("balance/energy/generator/nuclear") + */ + public double getReactorEUEnergyOutput(); + + /** + * Add's the given amount of energy to the Reactor's output. + * + * @return Energy output after adding the value, not multiplied by the base EU/t value + */ + public float addOutput(float energy); + + /** + * Get the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds returns null + * @param y Y position of the item, out of bounds returns null + * @return The item or null if there is no item + */ + public ItemStack getItemAt(int x, int y); + + /** + * Set the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds is a no-op + * @param y Y position of the item, out of bounds is a no-op + * @param item The item to set. + */ + public void setItemAt(int x, int y, ItemStack item); + + /** + * Explode the reactor. + */ + public void explode(); + + /** + * Get the reactor's tick rate (game ticks per reactor tick). + * + * @return Tick rate + */ + public int getTickRate(); + + /** + * Get whether the reactor is active and supposed to produce energy + * + * @return Whether the reactor is active + */ + public boolean produceEnergy(); + + /** + * Set Redstone Signal without direct contact + */ + + public void setRedstoneSignal(boolean redstone); + + /** + * @return true if the reactor is FluidCooled + */ + + public boolean isFluidCooled(); +} diff --git a/src/api/java/ic2/api/reactor/IReactorChamber.java b/src/api/java/ic2/api/reactor/IReactorChamber.java new file mode 100644 index 00000000..7199c43b --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactorChamber.java @@ -0,0 +1,19 @@ +package ic2.api.reactor; + +/** + * Interface implemented by the reactor chamber tile entity. + */ +public interface IReactorChamber { + /** + * Get the chamber's reactor. + * + * @return The reactor + */ + public IReactor getReactor(); + + /** + * Set Redstone Signal without direct contact + */ + + public void setRedstoneSignal(boolean redstone); +} diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/api/java/ic2/api/reactor/IReactorComponent.java new file mode 100644 index 00000000..80bfa659 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -0,0 +1,101 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; + +/** + * Design custom Reactor components by implementing this Interface + * Items implementing the interface will not be ejected from Reactors in their clean-up + * and can/will be interacted with by other elements, f.e. Uranium Cells. + *

+ * All IC2 ReactorComponents implement and use this Interface + */ +public interface IReactorComponent { + /** + * Called by reactor upon iterating through it's inventory (every cycle). + * Perform all necessary calculation/interaction here + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heatrun every Stack will cycle 2 time (true, false) first run for heat, sec for Eu calculation + */ + public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun); + + /** + * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. + * Uranium-Uranium interaction (f.e.) uses this method. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of called ItemStack + * @param pulsingStack Reference to the specific instance of pulsing ItemStack + * @param youX X-coordinate of your stack in the grid + * @param youY Y-coordinate of your stack in the grid + * @param pulseX X-coordinate of pulsing stack in the grid + * @param pulseY Y-coordinate of pulsing stack in the grid + * @param heatrun true for only create heat not EU, false for only EU not heat + * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) + */ + public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); + + /** + * Called by components to determine whether your component can be heated. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return true if your component can take heat + */ + public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the maximum capacity of your heat-containing component here. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Maximum heat + */ + public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the current amount of heat stored in this component + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Current Heat + */ + public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by components to distribute heat to your component. + * Perform heating-calculations and increase your heat (dmg) level accordingly. + * This method will as well be called to REDUCE heat, by providing a negative amount. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heat Amount of heat to be added (may be negative to subtract heat) + * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) + */ + public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); + + /** + * Called upon reactor explosion + * Alter the explosion size. + * Returning a float 0 < f < 1 will be counted as multiplier. + * Anything else will be counted as a flat addition (in case of <0 = reduction). + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @return your explosion modifier + */ + public float influenceExplosion(IReactor reactor, ItemStack yourStack); +} diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/api/java/ic2/api/reactor/package-info.java new file mode 100644 index 00000000..43a08227 --- /dev/null +++ b/src/api/java/ic2/api/reactor/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.reactor; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java new file mode 100644 index 00000000..f5934125 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java @@ -0,0 +1,51 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraft.item.ItemStack; + +public interface ICannerBottleRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param output Filled container + */ + public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output); + + /** + * Gets the recipe output for the given input. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); + + + public static class Input { + public Input(IRecipeInput container1, IRecipeInput fill1) { + this.container = container1; + this.fill = fill1; + } + + public boolean matches(ItemStack container1, ItemStack fill1) { + return this.container.matches(container1) && this.fill.matches(fill1); + } + + public final IRecipeInput container; + public final IRecipeInput fill; + } +} diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java new file mode 100644 index 00000000..d5df6755 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java @@ -0,0 +1,54 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +public interface ICannerEnrichRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param output Output fluid + */ + public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output); + + /** + * Gets the recipe output for the given input. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow input or additive to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none, output fluid in nbt + */ + public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); + + + public static class Input { + public Input(FluidStack fluid1, IRecipeInput additive1) { + this.fluid = fluid1; + this.additive = additive1; + } + + public boolean matches(FluidStack fluid1, ItemStack additive1) { + return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && + this.additive.matches(additive1); + } + + public final FluidStack fluid; + public final IRecipeInput additive; + } +} diff --git a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java new file mode 100644 index 00000000..b70c7e1f --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java @@ -0,0 +1,26 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +/** + * Recipe manager interface for crafting recipes. + * + * @author Richard + */ +public interface ICraftingRecipeManager { + /** + * Adds a shaped crafting recipe. + * + * @param output Recipe output + * @param input Recipe input format + */ + public void addRecipe(ItemStack output, Object... input); + + /** + * Adds a shapeless crafting recipe. + * + * @param output Recipe output + * @param input Recipe input + */ + public void addShapelessRecipe(ItemStack output, Object... input); +} diff --git a/src/api/java/ic2/api/recipe/IFluidHeatManager.java b/src/api/java/ic2/api/recipe/IFluidHeatManager.java new file mode 100644 index 00000000..7bfff1d2 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IFluidHeatManager.java @@ -0,0 +1,32 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; + + +public interface IFluidHeatManager extends ILiquidAcceptManager { + /** + * Add a new fluid to the Fluid Heat Generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param heat amount of heat generated per tick + */ + void addFluid(String fluidName, int amount, int heat); + + BurnProperty getBurnProperty(Fluid fluid); + + Map getBurnProperties(); + + + public static class BurnProperty { + public BurnProperty(int amount1, int heat1) { + this.amount = amount1; + this.heat = heat1; + } + + public final int amount; + public final int heat; + } +} diff --git a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java new file mode 100644 index 00000000..39459d27 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java @@ -0,0 +1,11 @@ +package ic2.api.recipe; + +import java.util.Set; + +import net.minecraftforge.fluids.Fluid; + +public interface ILiquidAcceptManager { + boolean acceptsFluid(Fluid fluid); + + Set getAcceptedFluids(); +} diff --git a/src/api/java/ic2/api/recipe/IListRecipeManager.java b/src/api/java/ic2/api/recipe/IListRecipeManager.java new file mode 100644 index 00000000..4b5ab28d --- /dev/null +++ b/src/api/java/ic2/api/recipe/IListRecipeManager.java @@ -0,0 +1,41 @@ +package ic2.api.recipe; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +/** + * Recipe manager interface for basic lists. + * + * @author Richard + */ +public interface IListRecipeManager extends Iterable { + /** + * Adds a stack to the list. + * + * @param stack Stack to add + */ + public void add(IRecipeInput input); + + /** + * Checks whether the specified stack is in the list. + * + * @param stack Stack to check + * @return Whether the stack is in the list + */ + public boolean contains(ItemStack stack); + + /** + * @return if the List is Empty + */ + public boolean isEmpty(); + + /** + * Gets the list of stacks. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of stacks + */ + public List getInputs(); +} diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java new file mode 100644 index 00000000..9bc465c1 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java @@ -0,0 +1,43 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Recipe manager interface for basic machines. + * + * @author RichardG, Player + */ +public interface IMachineRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param input Recipe input + * @param metadata meta data for additional recipe properties, may be null + * @param outputs Recipe outputs, zero or more depending on the machine + *

+ * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} + * For the ore washing plant @param metadata meta data {"amount": 1-8000} + */ + public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); + + /** + * Gets the recipe output for the given input. + * + * @param input Recipe input + * @param adjustInput modify the input according to the recipe's requirements + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); +} diff --git a/src/api/java/ic2/api/recipe/IPatternStorage.java b/src/api/java/ic2/api/recipe/IPatternStorage.java new file mode 100644 index 00000000..02719342 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IPatternStorage.java @@ -0,0 +1,11 @@ +package ic2.api.recipe; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface IPatternStorage { + boolean addPattern(ItemStack itemstack); + + List getPatterns(); +} diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java new file mode 100644 index 00000000..200d2428 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IRecipeInput.java @@ -0,0 +1,31 @@ +package ic2.api.recipe; + +import java.util.List; + +import net.minecraft.item.ItemStack; + +public interface IRecipeInput { + /** + * Check if subject matches this recipe input, ignoring the amount. + * + * @param subject ItemStack to check + * @return true if it matches the requirement + */ + boolean matches(ItemStack subject); + + /** + * Determine the minimum input stack size. + * + * @return input amount required + */ + int getAmount(); + + /** + * List all possible inputs (best effort). + *

+ * The stack size is undefined, use getAmount to get the correct one. + * + * @return list of inputs, may be incomplete + */ + List getInputs(); +} diff --git a/src/api/java/ic2/api/recipe/IScrapboxManager.java b/src/api/java/ic2/api/recipe/IScrapboxManager.java new file mode 100644 index 00000000..8ed3cc93 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IScrapboxManager.java @@ -0,0 +1,13 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraft.item.ItemStack; + +public interface IScrapboxManager { + void addDrop(ItemStack drop, float rawChance); + + ItemStack getDrop(ItemStack input, boolean adjustInput); + + Map getDrops(); +} diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java new file mode 100644 index 00000000..64634f3c --- /dev/null +++ b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java @@ -0,0 +1,32 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; + + +public interface ISemiFluidFuelManager extends ILiquidAcceptManager { + /** + * Add a new fluid to the semi fluid generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param power amount of energy generated per tick + */ + void addFluid(String fluidName, int amount, double power); + + BurnProperty getBurnProperty(Fluid fluid); + + Map getBurnProperties(); + + + public static class BurnProperty { + public BurnProperty(int amount1, double power1) { + this.amount = amount1; + this.power = power1; + } + + public final int amount; + public final double power; + } +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java new file mode 100644 index 00000000..764ea698 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -0,0 +1,54 @@ +package ic2.api.recipe; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeInputFluidContainer implements IRecipeInput { + public RecipeInputFluidContainer(Fluid fluid) { + this(fluid, FluidContainerRegistry.BUCKET_VOLUME); + } + + public RecipeInputFluidContainer(Fluid fluid, int amount) { + this.fluid = fluid; + this.amount = amount; + } + + @Override + public boolean matches(ItemStack subject) { + FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); + if (fs == null) return false; + + return fs.getFluid() == fluid; + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + List ret = new ArrayList(); + + for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); + } + + return ret; + } + + @Override + public String toString() { + return "RInputFluidContainer<" + amount + "x" + fluid.getName() + ">"; + } + + public final Fluid fluid; + public final int amount; +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java new file mode 100644 index 00000000..22a809d5 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -0,0 +1,46 @@ +package ic2.api.recipe; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeInputItemStack implements IRecipeInput { + public RecipeInputItemStack(ItemStack aInput) { + this(aInput, aInput.stackSize); + } + + public RecipeInputItemStack(ItemStack aInput, int aAmount) { + if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); + + input = aInput.copy(); // Never forget to copy. + amount = aAmount; + } + + @Override + public boolean matches(ItemStack subject) { + return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + return Arrays.asList(input); + } + + @Override + public String toString() { + ItemStack stack = input.copy(); + input.stackSize = amount; + return "RInputItemStack<" + stack + ">"; + } + + public final ItemStack input; + public final int amount; +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java new file mode 100644 index 00000000..4d7d3d12 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -0,0 +1,71 @@ +package ic2.api.recipe; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeInputOreDict implements IRecipeInput { + public RecipeInputOreDict(String input1) { + this(input1, 1); + } + + public RecipeInputOreDict(String input1, int amount1) { + this(input1, amount1, null); + } + + public RecipeInputOreDict(String input1, int amount1, Integer meta) { + this.input = input1; + this.amount = amount1; + this.meta = meta; + } + + @Override + public boolean matches(ItemStack subject) { + List inputs = OreDictionary.getOres(input); + + for (ItemStack input1 : inputs) { + if (input1.getItem() == null) continue; // ignore invalid + int metaRequired = meta == null ? input1.getItemDamage() : meta; + + if (subject.getItem() == input1.getItem() && + (subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { + return true; + } + } + + return false; + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + List ores = OreDictionary.getOres(input); + List ret = new ArrayList(ores.size()); + + for (ItemStack stack : ores) { + if (stack.getItem() != null) ret.add(stack); // ignore invalid + } + + return ret; + } + + @Override + public String toString() { + if (meta == null) { + return "RInputOreDict<" + amount + "x" + input + ">"; + } else { + return "RInputOreDict<" + amount + "x" + input + "@" + meta + ">"; + } + } + + public final String input; + public final int amount; + public final Integer meta; +} diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java new file mode 100644 index 00000000..9020f892 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -0,0 +1,28 @@ +package ic2.api.recipe; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public final class RecipeOutput { + public RecipeOutput(NBTTagCompound metadata1, List items1) { + assert !items1.contains(null); + + this.metadata = metadata1; + this.items = items1; + } + + public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { + this(metadata1, Arrays.asList(items1)); + } + + @Override + public String toString() { + return "ROutput<" + items + "," + metadata + ">"; + } + + public final List items; + public final NBTTagCompound metadata; +} diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java new file mode 100644 index 00000000..fae2cd68 --- /dev/null +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -0,0 +1,60 @@ +package ic2.api.recipe; + + +/** + * General recipe registry. + * + * @author Richard + */ +public class Recipes { + public static IMachineRecipeManager macerator; + public static IMachineRecipeManager extractor; + public static IMachineRecipeManager compressor; + public static IMachineRecipeManager centrifuge; + public static IMachineRecipeManager blockcutter; + public static IMachineRecipeManager blastfurance; + public static IMachineRecipeManager recycler; + public static IMachineRecipeManager metalformerExtruding; + public static IMachineRecipeManager metalformerCutting; + public static IMachineRecipeManager metalformerRolling; + public static IMachineRecipeManager oreWashing; + public static ICannerBottleRecipeManager cannerBottle; + public static ICannerEnrichRecipeManager cannerEnrich; + + /** + * Reference amplifier values: + *

+ * 5000: Scrap + * 45000: Scrapbox + *

+ * As Parameter for the Amplification Value you have to use the NBTTagCompound + *

+ * NBTTagCompound nbt = new NBTTagCompound(); + * nbt.setInteger("amplification", aValue); + * matterAmplifier.addRecipe(yourStack, nbt); + */ + public static IMachineRecipeManager matterAmplifier; + /** + * Reference scrap box chance values: + *

+ * 0.1: Diamond + * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore + * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone + * 1.5: Apple, Bread + * 2.0: Netherrack, Rotten Flesh + * 3.0: Grass, Gravel + * 4.0: Stick + * 5.0: Dirt, Wooden Hoe + */ + public static IScrapboxManager scrapboxDrops; + public static IListRecipeManager recyclerBlacklist; + /** + * Do not add anything to this Whitelist. This is for Configuration only. + * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List + */ + public static IListRecipeManager recyclerWhitelist; + public static ICraftingRecipeManager advRecipes; + + public static ISemiFluidFuelManager semiFluidGenerator; + public static IFluidHeatManager FluidHeatGenerator; +} diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java new file mode 100644 index 00000000..7526ce32 --- /dev/null +++ b/src/api/java/ic2/api/recipe/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.recipe; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/api/java/ic2/api/tile/ExplosionWhitelist.java new file mode 100644 index 00000000..ade0e197 --- /dev/null +++ b/src/api/java/ic2/api/tile/ExplosionWhitelist.java @@ -0,0 +1,47 @@ +package ic2.api.tile; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; + +/** + * Blocks on this whitelist will not resist an explosion but won't be destroyed. + *

+ * The explosion code by default ignores blocks which absorb more than 1000 explosion power to + * prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and + * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get + * destroyed. + */ +public final class ExplosionWhitelist { + /** + * Add a block to the whitelist. + * + * @param block block to add + */ + public static void addWhitelistedBlock(Block block) { + whitelist.add(block); + } + + /** + * Remove a block from the whitelist. + * + * @param block block to remove + */ + public static void removeWhitelistedBlock(Block block) { + whitelist.remove(block); + } + + /** + * Check if a block is on the whitelist. + * + * @param block block to check if whitelisted + * @return Whether the block is whitelisted + */ + public static boolean isBlockWhitelisted(Block block) { + return whitelist.contains(block); + } + + private static Set whitelist = new HashSet(); +} + diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.java b/src/api/java/ic2/api/tile/IEnergyStorage.java new file mode 100644 index 00000000..bf80b004 --- /dev/null +++ b/src/api/java/ic2/api/tile/IEnergyStorage.java @@ -0,0 +1,61 @@ +package ic2.api.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Interface implemented by the tile entity of energy storage blocks. + */ +public interface IEnergyStorage { + /** + * Get the amount of energy currently stored in the block. + * + * @return Energy stored in the block + */ + public int getStored(); + + /** + * Set the amount of energy currently stored in the block. + * + * @param energy stored energy + */ + public void setStored(int energy); + + /** + * Add the specified amount of energy. + *

+ * Use negative values to decrease. + * + * @param amount of energy to add + * @return Energy stored in the block after adding the specified amount + */ + public int addEnergy(int amount); + + /** + * Get the maximum amount of energy the block can store. + * + * @return Maximum energy stored + */ + public int getCapacity(); + + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public int getOutput(); + + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public double getOutputEnergyUnitsPerTick(); + + /** + * Get whether this block can have its energy used by an adjacent teleporter. + * + * @param side side the teleporter is draining energy from + * @return Whether the block is teleporter compatible + */ + public boolean isTeleporterCompatible(ForgeDirection side); +} diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java new file mode 100644 index 00000000..0cbaba64 --- /dev/null +++ b/src/api/java/ic2/api/tile/IWrenchable.java @@ -0,0 +1,61 @@ +package ic2.api.tile; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Allows a tile entity to make use of the wrench's removal and rotation functions. + */ +public interface IWrenchable { + /** + * Determine if the wrench can be used to set the block's facing. + * Called before wrenchCanRemove(). + * + * @param entityPlayer player using the wrench, may be null + * @param side block's side the wrench was clicked on + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); + + /** + * Get the block's facing. + * + * @return Block facing + */ + short getFacing(); + + /** + * Set the block's facing + * + * @param facing facing to set the block to + */ + void setFacing(short facing); + + /** + * Determine if the wrench can be used to remove the block. + * Called if wrenchSetFacing fails. + * + * @param entityPlayer player using the wrench, may be null + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanRemove(EntityPlayer entityPlayer); + + /** + * Determine the probability to drop the block as it is. + * The first entry in getDrops will be replaced by blockid:meta if the drop is successful. + * + * @return Probability from 0 to 1 + */ + float getWrenchDropRate(); + + /** + * Determine the item the block will drop when the wrenching is successful. + *

+ * The ItemStack will be copied before creating the EntityItem. + * + * @param entityPlayer player using the wrench, may be null + * @return ItemStack to drop, may be null + */ + ItemStack getWrenchDrop(EntityPlayer entityPlayer); +} + diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java new file mode 100644 index 00000000..08fa88b2 --- /dev/null +++ b/src/api/java/ic2/api/tile/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.tile; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/util/IKeyboard.java b/src/api/java/ic2/api/util/IKeyboard.java new file mode 100644 index 00000000..a5a77d66 --- /dev/null +++ b/src/api/java/ic2/api/util/IKeyboard.java @@ -0,0 +1,21 @@ +package ic2.api.util; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IKeyboard { + boolean isAltKeyDown(EntityPlayer player); + + boolean isBoostKeyDown(EntityPlayer player); + + boolean isForwardKeyDown(EntityPlayer player); + + boolean isJumpKeyDown(EntityPlayer player); + + boolean isModeSwitchKeyDown(EntityPlayer player); + + boolean isSideinventoryKeyDown(EntityPlayer player); + + boolean isHudModeKeyDown(EntityPlayer player); + + boolean isSneakKeyDown(EntityPlayer player); +} diff --git a/src/api/java/ic2/api/util/Keys.java b/src/api/java/ic2/api/util/Keys.java new file mode 100644 index 00000000..1db739bf --- /dev/null +++ b/src/api/java/ic2/api/util/Keys.java @@ -0,0 +1,6 @@ +package ic2.api.util; + + +public class Keys { + public static IKeyboard instance; +} \ No newline at end of file diff --git a/src/api/java/ic2/api/util/package-info.java b/src/api/java/ic2/api/util/package-info.java new file mode 100644 index 00000000..b0141815 --- /dev/null +++ b/src/api/java/ic2/api/util/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.util; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/Direction.java b/src/main/java/ic2/api/Direction.java deleted file mode 100644 index cc41aea0..00000000 --- a/src/main/java/ic2/api/Direction.java +++ /dev/null @@ -1,108 +0,0 @@ -package ic2.api; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - - -/** - * Represents the 6 possible directions along the axis of a block. - */ -public enum Direction { - /** - * -X - */ - XN(0), - /** - * +X - */ - XP(1), - - /** - * -Y - */ - YN(2), //MC-Code starts with 0 here - /** - * +Y - */ - YP(3), // 1... - - /** - * -Z - */ - ZN(4), - /** - * +Z - */ - ZP(5); - - Direction(int dir) { - this.dir = dir; - } - - /*public CoordinateTuple ApplyToCoordinates(CoordinateTuple coordinates) { - CoordinateTuple ret = new CoordinateTuple(coordinates); - - ret.coords[dir/2] += GetSign(); - - return ret; - }*/ - - /** - * Get the tile entity next to a tile entity following this direction. - * - * @param tileEntity tile entity to check - * @return Adjacent tile entity or null if none exists - */ - public TileEntity applyToTileEntity(TileEntity tileEntity) { - int coords[] = { tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord }; - - coords[dir/2] += getSign(); - - if (tileEntity.getWorldObj() != null && tileEntity.getWorldObj().blockExists(coords[0], coords[1], coords[2])) { - return tileEntity.getWorldObj().getTileEntity(coords[0], coords[1], coords[2]); - } else { - return null; - } - } - - /** - * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) - * - * @return Inverse direction - */ - public Direction getInverse() { - int inverseDir = dir - getSign(); - - for (Direction direction : directions) { - if (direction.dir == inverseDir) return direction; - } - - return this; - } - - /** - * Convert this direction to a Minecraft side value. - * - * @return Minecraft side value - */ - public int toSideValue() { - return (dir + 4) % 6; - } - - /** - * Determine direction sign (N for negative or P for positive). - * - * @return -1 if the direction is negative, +1 if the direction is positive - */ - private int getSign() { - return (dir % 2) * 2 - 1; - } - - public ForgeDirection toForgeDirection() { - return ForgeDirection.getOrientation(toSideValue()); - } - - private int dir; - public static final Direction[] directions = Direction.values(); -} - diff --git a/src/main/java/ic2/api/crops/BaseSeed.java b/src/main/java/ic2/api/crops/BaseSeed.java deleted file mode 100644 index 11286b4b..00000000 --- a/src/main/java/ic2/api/crops/BaseSeed.java +++ /dev/null @@ -1,56 +0,0 @@ -package ic2.api.crops; - -/** - * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. - */ -public class BaseSeed { - /** - * Plant ID. - */ - public int id; - - /** - * Plant size. - */ - public int size; - - /** - * Plant growth stat. - */ - public int statGrowth; - - /** - * Plant gain stat. - */ - public int statGain; - - /** - * Plant resistance stat. - */ - public int statResistance; - - /** - * For internal usage only. - */ - public int stackSize; - - /** - * Create a BaseSeed object. - * - * @param id plant ID - * @param size plant size - * @param statGrowth plant growth stat - * @param statGain plant gain stat - * @param statResistance plant resistance stat - * @param stackSize for internal usage only - */ - public BaseSeed(int id, int size, int statGrowth, int statGain, int statResistance, int stackSize) { - super(); - this.id = id; - this.size = size; - this.statGrowth = statGrowth; - this.statGain = statGain; - this.statResistance = statResistance; - this.stackSize = stackSize; - } -} diff --git a/src/main/java/ic2/api/crops/CropCard.java b/src/main/java/ic2/api/crops/CropCard.java deleted file mode 100644 index bfc08ee7..00000000 --- a/src/main/java/ic2/api/crops/CropCard.java +++ /dev/null @@ -1,366 +0,0 @@ -package ic2.api.crops; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -/** - * Base agriculture crop. - * - * Any crop extending this can be registered using registerCrop to be added into the game. - */ -public abstract class CropCard -{ - /** - * Plant name. Will be displayed to the player. - * - * @return Plant name - */ - public abstract String name(); - - /** - * Your name here, will be shown in "Discovered by:" when analyzing seeds. - * - * @return Your name - */ - public String discoveredBy() {return "Alblaka";} - - /** - * Description of your plant. Keep it short, a few characters per line for up to two lines. - * Default is showing attributes of your plant, 2 per line. - * - * @param i line to get, starting from 0 - * @return The line - */ - public String desc(int i) - { - String[] att = attributes(); - if (att == null || att.length==0) return ""; - if (i == 0) - { - String s = att[0]; - if (att.length >= 2) - { - s+=", "+att[1]; - if (att.length >= 3) s+=","; - } - return s; - } - else - { - if (att.length < 3) return ""; - String s = att[2]; - if (att.length >= 4) s+=", "+att[3]; - return s; - } - } - - /** - * Tier of the plant. Ranges from 1 to 16, 0 is Weed. - * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. - * - * @return Tier - */ - public abstract int tier(); - - /** - * Describe the plant through a set of stats, influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - * - * Stats: - * - 0: Chemistry (Industrial uses based on chemical plant components) - * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) - * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) - * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) - * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) - * - * @param n index of the requested stat - * @return The requested value of the stats - */ - public abstract int stat(int n); - - /** - * Additional attributes of the plant, also influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - * - * @return Attributes as an array of strings - */ - public abstract String[] attributes(); - - /** - * Determine the max crop size. - * - * Currently only used for texture allocation. - */ - public abstract int maxSize(); - - /** - * Instantiate your Icons here. - * - * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public void registerSprites(IIconRegister iconRegister) { - textures = new IIcon[maxSize()]; - - for (int i = 1; i <= textures.length; i++) { - textures[i-1] = iconRegister.registerIcon("ic2:crop/blockCrop."+name()+"."+i); - } - } - - /** - * Sprite the crop is meant to be rendered with. - * - * @param crop reference to ICropTile - * @return 0-255, representing the sprite index on the crop's spritesheet. - */ - @SideOnly(Side.CLIENT) - public IIcon getSprite(ICropTile crop) { - if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; - - return textures[crop.getSize() - 1]; - } - - /** - * Get the crop's spritesheet. - * Per default crops_0.png of ic2-sprites - * @return Texture file path - */ - public String getTextureFile() { - return "/ic2/sprites/crops_0.png"; - } - - /** - * Amount of growth points needed to increase the plant's size. - * Default is 200 * tier. - */ - public int growthDuration(ICropTile crop) - { - return tier()*200; - } - - /** - * Check whether the plant can grow further. - * - * Consider: - * - Humidity, nutrients and air quality - * - Current size - * - Light level - * - Special biomes or conditions, accessible through crop.worldObj - * - * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. - * - * @param crop reference to ICropTile - * @return Whether the crop can grow - */ - public abstract boolean canGrow(ICropTile crop); - - /** - * Calculate the influence for the plant to grow based on humidity, nutrients and air. - * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. - * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) - * - * Default is humidity + nutrients + air (no factors). - * - * @param crop reference to ICropTile - * @param humidity ground humidity, influenced by hydration - * @param nutrients nutrient quality in ground, based on fertilizers - * @param air air quality, influences by open gardens and less crops surrounding this one - * @return 0-30 - */ - public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) - { - return (int) (humidity+nutrients+air); - } - - /** - * Used to determine whether the plant can crossbreed with another crop. - * Default is allow crossbreeding if the size is greater or equal than 3. - * - * @param crop crop to crossbreed with - */ - public boolean canCross(ICropTile crop) - { - return crop.getSize() >= 3; - } - - - /** - * Called when the plant is rightclicked by a player. - * Default action is harvesting. - * - * @param crop reference to ICropTile - * @param player player rightclicking the crop - * @return Whether the plant has changed - */ - public boolean rightclick(ICropTile crop, EntityPlayer player) - { - return crop.harvest(true); - } - - /** - * Check whether the crop can be harvested. - * - * @param crop reference to ICropTile - * @return Whether the crop can be harvested in its current state. - */ - public abstract boolean canBeHarvested(ICropTile crop); - - /** - * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. - * Default is 0.95^tier. - * - * @return Chance to drop the gains - */ - public float dropGainChance() - { - float base = 1F; - for (int i = 0; i < tier(); i++) {base*=0.95;} - return base; - } - - /** - * Item obtained from harvesting the plant. - * - * @param crop reference to ICropTile - * @return Item obtained - */ - public abstract ItemStack getGain(ICropTile crop); - - /** - * Get the size of the plant after harvesting. - * Default is 1. - * - * @param crop reference to ICropTile - * @return Plant size after harvesting - */ - public byte getSizeAfterHarvest(ICropTile crop) {return 1;} - - - /** - * Called when the plant is leftclicked by a player. - * Default action is picking the plant. - * - * @param crop reference to ICropTile - * @param player player leftclicked the crop - * @return Whether the plant has changed - */ - public boolean leftclick(ICropTile crop, EntityPlayer player) - { - return crop.pick(true); - } - - /** - * Base chance for dropping seeds when the plant is picked. - * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. - * - * @param crop reference to ICropTile - * @return Chance to drop the seeds - */ - public float dropSeedChance(ICropTile crop) - { - if (crop.getSize() == 1) return 0; - float base = 0.5F; - if (crop.getSize() == 2) base/=2F; - for (int i = 0; i < tier(); i++) {base*=0.8;} - return base; - } - - /** - * Obtain seeds dropped when the plant is picked. - * Multiple drops of the returned ItemStack can occur. - * Default action is generating a seed from this crop. - * - * @param crop reference to ICropTile - * @return Seeds - */ - public ItemStack getSeeds(ICropTile crop) - { - return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); - } - - /** - * Called when a neighbor block to the crop has changed. - * - * @param crop reference to ICropTile - */ - public void onNeighbourChange(ICropTile crop){} - - /** - * Check if the crop should emit redstone. - * - * @return Whether the crop should emit redstone - */ - public int emitRedstone(ICropTile crop){return 0;} - - /** - * Called when the crop is destroyed. - * - * @param crop reference to ICropTile - */ - public void onBlockDestroyed(ICropTile crop){} - - /** - * Get the light value emitted by the plant. - * - * @param crop reference to ICropTile - * @return Light value emitted - */ - public int getEmittedLight(ICropTile crop) {return 0;} - - /** - * Default is true if the entity is an EntityLiving in jumping or sprinting state. - * - * @param crop reference to ICropTile - * @param entity entity colliding - * @return Whether trampling calculation should happen, return false if the plant is no longer valid. - */ - public boolean onEntityCollision(ICropTile crop, Entity entity) - { - if (entity instanceof EntityLivingBase) - { - return ((EntityLivingBase)entity).isSprinting(); - } - return false; - } - - - /** - * Called every time the crop ticks. - * Should be called every 256 ticks or around 13 seconds. - * - * @param crop reference to ICropTile - */ - public void tick(ICropTile crop) {} - - /** - * Check whether this plant spreads weed to surrounding tiles. - * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. - * - * @param crop reference to ICropTile - * @return Whether the plant spreads weed - */ - public boolean isWeed(ICropTile crop) - { - return crop.getSize()>=2 && (crop.getID()==0 || crop.getGrowth()>=24); - } - - - /** - * Get this plant's ID. - * - * @return ID of this CropCard or -1 if it's not registered - */ - public final int getId() - { - return Crops.instance.getIdFor(this); - } - - @SideOnly(Side.CLIENT) - protected IIcon textures[]; -} diff --git a/src/main/java/ic2/api/crops/Crops.java b/src/main/java/ic2/api/crops/Crops.java deleted file mode 100644 index a133f1f6..00000000 --- a/src/main/java/ic2/api/crops/Crops.java +++ /dev/null @@ -1,103 +0,0 @@ -package ic2.api.crops; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.world.biome.BiomeGenBase; - -/** - * General management of the crop system. - */ -public abstract class Crops { - public static Crops instance; - - /** - * Adds a crop humidity and nutrient biome bonus. - * - * 0 indicates no bonus and negative values indicate a penalty. - * - * @param biome Biome to apply the bonus in - * @param humidityBonus Humidity stat bonus - * @param nutrientsBonus Nutrient stat bonus - */ - public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); - - /** - * Gets the humidity bonus for a biome. - * - * @param biome Biome to check - * @return Humidity bonus or 0 if none - */ - public abstract int getHumidityBiomeBonus(BiomeGenBase biome); - - /** - * Gets the nutrient bonus for a biome. - * - * @param biome Biome to check - * @return Nutrient bonus or 0 if none - */ - public abstract int getNutrientBiomeBonus(BiomeGenBase biome); - - /** - * Returns the list of registered crops. - * - * @return Registered crops by ID - */ - public abstract CropCard[] getCropList(); - - /** - * Auto-assign an ID to a plant and register it. - * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. - * - * @param crop plant to register - * @return The ID assigned to the plant - */ - public abstract short registerCrop(CropCard crop); - - /** - * Attempt to register a plant to an ID. - * If the ID is taken, the crop will not be registered and a console print will notify the user. - * - * @param crop plant to register - * @param i ID to register the plant to - * @return Whether the crop was registered - */ - public abstract boolean registerCrop(CropCard crop, int i); - - /** - * Registers a base seed, an item used to plant a crop. - * - * @param stack item - * @param id plant ID - * @param size initial size - * @param growth initial growth stat - * @param gain initial gain stat - * @param resistance initial resistance stat - * @return True if successful - */ - public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); - - /** - * Finds a base seed from the given item. - * - * @return Base seed or null if none found - */ - public abstract BaseSeed getBaseSeed(ItemStack stack); - - /** - * Execute registerSprites for all registered crop cards. - * - * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public abstract void startSpriteRegistration(IIconRegister iconRegister); - - /** - * Returns the ID for the given crop. - * - * @param crop Crop to look up - * @return ID, or -1 if not found - */ - public abstract int getIdFor(CropCard crop); -} diff --git a/src/main/java/ic2/api/crops/ICropTile.java b/src/main/java/ic2/api/crops/ICropTile.java deleted file mode 100644 index 4084c500..00000000 --- a/src/main/java/ic2/api/crops/ICropTile.java +++ /dev/null @@ -1,253 +0,0 @@ -package ic2.api.crops; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - -/** - * Interface implemented by the crop tile entity. - */ -public interface ICropTile { - /** - * Get the crop's plant ID. - * - * @return Plant ID, or -1 if there is no plant currently on the crop - */ - public short getID(); - - /** - * Set the crop's plant ID. - * - * @param id Plant ID, or -1 for no plant - */ - public void setID(short id); - - /** - * Get the crop's plant size. - * - * @return Plant size, starting with 1 and maximum varies depending on plant - */ - public byte getSize(); - - /** - * Set the crop's plant size. - * - * @param size Plant size - */ - public void setSize(byte size); - - /** - * Get the crop's plant growth stat. - * Higher values indicate faster growth. - * - * @return Plant growth stat - */ - public byte getGrowth(); - - /** - * Set the crop's plant growth stat. - * - * @param growth Plant growth stat - */ - public void setGrowth(byte growth); - - /** - * Get the crop's plant gain stat. - * Higher values indicate more drops. - * - * @return Plant gain stat - */ - public byte getGain(); - - /** - * Set the crop's plant gain stat. - * - * @param gain Plant gain stat - */ - public void setGain(byte gain); - - /** - * Get the crop's plant resistance stat. - * Higher values indicate more resistance against trampling. - * - * @return Plant resistance stat - */ - public byte getResistance(); - - /** - * Set the crop's plant resistance stat. - * - * @param resistance Plant resistance stat - */ - public void setResistance(byte resistance); - - /** - * Get the crop's plant scan level. - * Increases every time the seed is analyzed. - * - * @return Plant scan level - */ - public byte getScanLevel(); - - /** - * Set the crop's plant scan level. - * - * @param scanLevel Plant scan level - */ - public void setScanLevel(byte scanLevel); - - /** - * Get the crop's plant custom data, stored alongside the crop. - * Can be modified in place. - * - * @return Plant custom data - */ - public NBTTagCompound getCustomData(); - - /** - * Get the crop's nutrient storage. - * Ranges from 0 to 100. - * - * @return Crop nutrient storage - */ - public int getNutrientStorage(); - - /** - * Set the crop's nutrient storage. - * - * @param nutrientStorage Crop nutrient storage - */ - public void setNutrientStorage(int nutrientStorage); - - /** - * Get the crop's hydration storage. - * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. - * - * @return Crop hydration storage - */ - public int getHydrationStorage(); - - /** - * Set the crop's hydration storage. - * - * @param hydrationStorage Crop hydration storage - */ - public void setHydrationStorage(int hydrationStorage); - - /** - * Get the crop's Weed-Ex storage. - * - * @return Crop Weed-Ex storage - */ - public int getWeedExStorage(); - - /** - * Set the crop's Weed-Ex storage. - * - * @param weedExStorage Crop Weed-Ex storage - */ - public void setWeedExStorage(int weedExStorage); - - /** - * Get the crop's humidity. - * Ranges from 0 (dry) to 10 (humid). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop humidity level - */ - public byte getHumidity(); - - /** - * Get the crop's nutrient level. - * Ranges from 0 (empty) to 10 (full). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop nutrient level - */ - public byte getNutrients(); - - /** - * Get the crop's air quality. - * Ranges from 0 (cluttered) to 10 (fresh). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop air quality - */ - public byte getAirQuality(); - - /** - * Get the crop's world. - * - * @return Crop world - */ - public World getWorld(); - - /** - * Get the crop's location. - * - * @return Crop location - */ - public ChunkCoordinates getLocation(); - - /** - * Get the crop's light level. - * - * @return Crop light level - */ - public int getLightLevel(); - - /** - * Pick the crop, removing and giving seeds for the plant. - * - * @param manual whether it was done by hand (not automated) - * @return true if successfully picked - */ - public boolean pick(boolean manual); - - /** - * Harvest the crop, turning it into gain and resetting its size. - * - * @param manual whether it one by hand (not automated) - * @return true if successfully harvested - */ - public boolean harvest(boolean manual); - - /** - * Fully clears the crop without dropping anything. - */ - public void reset(); - - /** - * Request a texture and lighting update. - */ - public void updateState(); - - /** - * Check if a block is under the farmland containing the crop. - * Searches up to 2 blocks below the farmland or an air space, whichever appears first. - * - * @param block block to search - * @return Whether the block was found - */ - public boolean isBlockBelow(Block block); - - /** - * Generate plant seeds with the given parameters. - * - * @param plant plant ID - * @param growth plant growth stat - * @param gain plant gain stat - * @param resis plant resistance stat - * @param scan plant scan level - * @return Plant seed item - */ - public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); -} diff --git a/src/main/java/ic2/api/energy/EnergyNet.java b/src/main/java/ic2/api/energy/EnergyNet.java deleted file mode 100644 index 724aa9bc..00000000 --- a/src/main/java/ic2/api/energy/EnergyNet.java +++ /dev/null @@ -1,175 +0,0 @@ -package ic2.api.energy; - -import java.lang.reflect.Method; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import ic2.api.energy.tile.IEnergySource; - -/** - * Provides access to the energy network. - */ -public final class EnergyNet { - /** - * Gets the EnergyNet instance for the specified world. - * - * @param world world - * @return EnergyNet instance for the world - */ - public static EnergyNet getForWorld(World world) { - try { - if (EnergyNet_getForWorld == null) EnergyNet_getForWorld = Class.forName(getPackage() + ".core.EnergyNet").getMethod("getForWorld", World.class); - - return new EnergyNet(EnergyNet_getForWorld.invoke(null, world)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private EnergyNet(Object energyNetInstance) { - this.energyNetInstance = energyNetInstance; - } - - /** - * Add a tile entity to the energy network. - * The tile entity has to be valid and initialized. - * - * @param addedTileEntity tile entity to add - * - * @deprecated use EnergyTileLoadEvent instead - */ - @Deprecated - public void addTileEntity(TileEntity addedTileEntity) { - try { - if (EnergyNet_addTileEntity == null) EnergyNet_addTileEntity = Class.forName(getPackage() + ".core.EnergyNet").getMethod("addTileEntity", TileEntity.class); - - EnergyNet_addTileEntity.invoke(energyNetInstance, addedTileEntity); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Removes a tile entity from the energy network. - * The tile entity has to be still valid. - * - * @param removedTileEntity tile entity to remove - * - * @deprecated use EnergyTileUnloadEvent instead - */ - @Deprecated - public void removeTileEntity(TileEntity removedTileEntity) { - try { - if (EnergyNet_removeTileEntity == null) EnergyNet_removeTileEntity = Class.forName(getPackage() + ".core.EnergyNet").getMethod("removeTileEntity", TileEntity.class); - - EnergyNet_removeTileEntity.invoke(energyNetInstance, removedTileEntity); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Emit energy from an energy source to the energy network. - * - * @param energySource energy source to emit energy from - * @param amount amount of energy to emit in EU - * @return Leftover (unused) power - * - * @deprecated use EnergyTileSourceEvent instead - */ - @Deprecated - public int emitEnergyFrom(IEnergySource energySource, int amount) { - try { - if (EnergyNet_emitEnergyFrom == null) EnergyNet_emitEnergyFrom = Class.forName(getPackage() + ".core.EnergyNet").getMethod("emitEnergyFrom", IEnergySource.class, Integer.TYPE); - - return ((Integer) EnergyNet_emitEnergyFrom.invoke(energyNetInstance, energySource, amount)).intValue(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get the amount of energy currently being conducted by a conductor. - * Call this twice with a delay to get the average conducted power by doing (call2 - call1) / 2. - * - * @param tileEntity conductor - * - * @deprecated use getTotalEnergyEmitted and getTotalEnergySunken instead - */ - @Deprecated - public long getTotalEnergyConducted(TileEntity tileEntity) { - try { - if (EnergyNet_getTotalEnergyConducted == null) EnergyNet_getTotalEnergyConducted = Class.forName(getPackage() + ".core.EnergyNet").getMethod("getTotalEnergyConducted", TileEntity.class); - - return ((Long) EnergyNet_getTotalEnergyConducted.invoke(energyNetInstance, tileEntity)).longValue(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * determine how much energy has been emitted by the EnergyEmitter specified - * - * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick - * - * @param tileEntity energy emitter - */ - public long getTotalEnergyEmitted(TileEntity tileEntity) { - try { - if (EnergyNet_getTotalEnergyEmitted == null) EnergyNet_getTotalEnergyEmitted = Class.forName(getPackage() + ".core.EnergyNet").getMethod("getTotalEnergyEmitted", TileEntity.class); - - return ((Long) EnergyNet_getTotalEnergyEmitted.invoke(energyNetInstance, tileEntity)).longValue(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * determine how much energy has been sunken by the EnergySink specified - * - * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick - * - * @param tileEntity energy emitter - */ - public long getTotalEnergySunken(TileEntity tileEntity) { - try { - if (EnergyNet_getTotalEnergySunken == null) EnergyNet_getTotalEnergySunken = Class.forName(getPackage() + ".core.EnergyNet").getMethod("getTotalEnergySunken", TileEntity.class); - - return ((Long) EnergyNet_getTotalEnergySunken.invoke(energyNetInstance, tileEntity)).longValue(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = EnergyNet.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.energy".length()); - } - - return "ic2"; - } - - /** - * Instance of the energy network. - */ - Object energyNetInstance; - - private static Method EnergyNet_getForWorld; - private static Method EnergyNet_addTileEntity; - private static Method EnergyNet_removeTileEntity; - private static Method EnergyNet_emitEnergyFrom; - private static Method EnergyNet_getTotalEnergyConducted; - private static Method EnergyNet_getTotalEnergyEmitted; - private static Method EnergyNet_getTotalEnergySunken; -} - diff --git a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileEvent.java deleted file mode 100644 index 47765d8e..00000000 --- a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package ic2.api.energy.event; - -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.event.world.WorldEvent; - -import ic2.api.energy.tile.IEnergyTile; - -public class EnergyTileEvent extends WorldEvent { - public final IEnergyTile energyTile; - - public EnergyTileEvent(IEnergyTile energyTile) { - super(((TileEntity) energyTile).getWorldObj()); - - this.energyTile = energyTile; - } -} - diff --git a/src/main/java/ic2/api/energy/event/EnergyTileSourceEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileSourceEvent.java deleted file mode 100644 index 80c230c3..00000000 --- a/src/main/java/ic2/api/energy/event/EnergyTileSourceEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package ic2.api.energy.event; - -import ic2.api.energy.tile.IEnergySource; - -/** - * Event announcing an energy source operation. - * - * This event notifies subscribers of energy sources trying to push energy into - * an energy grid. - * - * The amount field indicates the maximum amount of energy left to be - * distributed. You have to substract the amount of energy you accepted from - * 'amount'. - * - * The IEnergySource posting this event has to check 'amount' to see how much - * energy has not been used up and adjust its output buffer accordingly - * (usually buffer -= 'initial amount' - 'amount after posting the event') - */ -public class EnergyTileSourceEvent extends EnergyTileEvent { - /** - * Amount of energy provided by the energy source. - * - * amount needs to be adjusted to show the remaining unused energy. - */ - public int amount; - - public EnergyTileSourceEvent(IEnergySource energySource, int amount) { - super(energySource); - - this.amount = amount; - } -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java deleted file mode 100644 index d4f80db5..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java +++ /dev/null @@ -1,22 +0,0 @@ -package ic2.api.energy.tile; - -import net.minecraft.tileentity.TileEntity; - -import ic2.api.Direction; - -/** - * For internal usage only. - * - * @see ic2.api.energy.tile.IEnergySink - * @see IEnergyConductor - */ -public interface IEnergyAcceptor extends IEnergyTile { - /** - * Determine if this acceptor can accept current from an adjacent emitter in a direction. - * - * @param emitter energy emitter - * @param direction direction the energy is being received from - */ - boolean acceptsEnergyFrom(TileEntity emitter, Direction direction); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyConductor.java b/src/main/java/ic2/api/energy/tile/IEnergyConductor.java deleted file mode 100644 index 2bfc8b6c..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyConductor.java +++ /dev/null @@ -1,51 +0,0 @@ -package ic2.api.energy.tile; - -/** - * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this - * interface. - */ -public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { - /** - * Energy loss for the conductor in EU per block. - * - * @return Energy loss - */ - double getConductionLoss(); - - /** - * Amount of energy the insulation will handle before shocking nearby players and mobs. - * - * @return Insulation energy absorption in EU - */ - int getInsulationEnergyAbsorption(); - - /** - * Amount of energy the insulation will handle before it is destroyed. - * Ensure that this value is greater than the insulation energy absorption + 64. - * - * @return Insulation-destroying energy in EU - */ - int getInsulationBreakdownEnergy(); - - /** - * Amount of energy the conductor will handle before it melts. - * - * @return Conductor-destroying energy in EU - */ - int getConductorBreakdownEnergy(); - - /** - * Remove the conductor's insulation if the insulation breakdown energy was exceeded. - * - * @see #getInsulationBreakdownEnergy() - */ - void removeInsulation(); - - /** - * Remove the conductor if the conductor breakdown energy was exceeded. - * - * @see #getConductorBreakdownEnergy() - */ - void removeConductor(); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java deleted file mode 100644 index 0ed0d065..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java +++ /dev/null @@ -1,23 +0,0 @@ -package ic2.api.energy.tile; - -import net.minecraft.tileentity.TileEntity; - -import ic2.api.Direction; - -/** - * For internal usage only. - * - * @see ic2.api.energy.tile.IEnergySource - * @see IEnergyConductor - */ -public interface IEnergyEmitter extends IEnergyTile { - /** - * Determine if this emitter can emit energy to an adjacent receiver. - * - * @param receiver receiver - * @param direction direction the receiver is from the emitter - * @return Whether energy should be emitted - */ - boolean emitsEnergyTo(TileEntity receiver, Direction direction); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergySink.java b/src/main/java/ic2/api/energy/tile/IEnergySink.java deleted file mode 100644 index 19013c1b..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergySink.java +++ /dev/null @@ -1,41 +0,0 @@ -package ic2.api.energy.tile; - -import ic2.api.Direction; - -/** - * Allows a tile entity (mostly a machine) to receive energy. - */ -public interface IEnergySink extends IEnergyAcceptor { - /** - * Determine how much energy the sink accepts. - * - * This value is unrelated to getMaxSafeInput(). - * - * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. - * - * @return max accepted input in eu - */ - int demandsEnergy(); - - /** - * Transfer energy to the sink. - * - * @param directionFrom direction from which the energy comes from - * @param amount energy to be transferred - * @return Energy not consumed (leftover) - */ - int injectEnergy(Direction directionFrom, int amount); - - /** - * Determine the amount of eu which can be safely injected into the specific energy sink without exploding. - * - * Typical values are 32 for LV, 128 for MV, 512 for HV and 2048 for EV. A value of Integer.MAX_VALUE indicates no - * limit. - * - * This value is unrelated to demandsEnergy(). - * - * @return max safe input in eu - */ - int getMaxSafeInput(); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergySource.java b/src/main/java/ic2/api/energy/tile/IEnergySource.java deleted file mode 100644 index d0086488..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergySource.java +++ /dev/null @@ -1,15 +0,0 @@ -package ic2.api.energy.tile; - -/** - * Allows a tile entity (mostly a generator) to emit energy. - */ -public interface IEnergySource extends IEnergyEmitter { - /** - * Maximum energy output provided by the source. - * If unsure, use Integer.MAX_VALUE. - * - * @return Maximum energy output - */ - int getMaxEnergyOutput(); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyTile.java b/src/main/java/ic2/api/energy/tile/IEnergyTile.java deleted file mode 100644 index dbf19d57..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyTile.java +++ /dev/null @@ -1,18 +0,0 @@ -package ic2.api.energy.tile; - -/** - * For internal usage only. - * - * @see ic2.api.energy.tile.IEnergySink - * @see IEnergySource - * @see IEnergyConductor - */ -public interface IEnergyTile { - /** - * Determine if this tile entity has been added to the energy network - * - * @return Whether the tile entity has been added - */ - boolean isAddedToEnergyNet(); -} - diff --git a/src/main/java/ic2/api/event/PaintEvent.java b/src/main/java/ic2/api/event/PaintEvent.java deleted file mode 100644 index 898a96b2..00000000 --- a/src/main/java/ic2/api/event/PaintEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -package ic2.api.event; - -import net.minecraft.world.World; -import net.minecraftforge.event.world.WorldEvent; - - -public class PaintEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; - - // color to paint the block - public final int color; - - // set to true to confirm the operation - public boolean painted = false; - - public PaintEvent(World world, int x, int y, int z, int side, int color) { - super(world); - - this.x = x; - this.y = y; - this.z = z; - this.side = side; - this.color = color; - } -} diff --git a/src/main/java/ic2/api/event/RetextureEvent.java b/src/main/java/ic2/api/event/RetextureEvent.java deleted file mode 100644 index 8abf0bcd..00000000 --- a/src/main/java/ic2/api/event/RetextureEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package ic2.api.event; - -import net.minecraft.world.World; -import net.minecraftforge.event.world.WorldEvent; - - -public class RetextureEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; - - // referenced block (to grab the texture from) - public final int referencedBlockId; - public final int referencedMeta; - public final int referencedSide; - - // set to true to confirm the operation - public boolean applied = false; - - public RetextureEvent(World world, int x, int y, int z, int side, int referencedBlockId, int referencedMeta, int referencedSide) { - super(world); - - this.x = x; - this.y = y; - this.z = z; - this.side = side; - this.referencedBlockId = referencedBlockId; - this.referencedMeta = referencedMeta; - this.referencedSide = referencedSide; - } -} diff --git a/src/main/java/ic2/api/info/IEnergyValueProvider.java b/src/main/java/ic2/api/info/IEnergyValueProvider.java deleted file mode 100644 index 50e84e6e..00000000 --- a/src/main/java/ic2/api/info/IEnergyValueProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package ic2.api.info; - -import net.minecraft.item.ItemStack; - -public interface IEnergyValueProvider { - /** - * Determine the energy value for a single item in the supplied stack. - * The value is used by most machines in the discharge slot. - * - * @param itemStack ItemStack containing the item to evaluate. - * @return energy in EU - */ - int getEnergyValue(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/info/IFuelValueProvider.java b/src/main/java/ic2/api/info/IFuelValueProvider.java deleted file mode 100644 index 7c7fe0f4..00000000 --- a/src/main/java/ic2/api/info/IFuelValueProvider.java +++ /dev/null @@ -1,15 +0,0 @@ -package ic2.api.info; - -import net.minecraft.item.ItemStack; - -public interface IFuelValueProvider { - /** - * Determine the fuel value for a single item in the supplied stack. - * The information currently applies to Generators and the Iron Furnace. - * - * @param itemStack ItemStack containing the item to evaluate. - * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. - * @return fuel value - */ - int getFuelValue(ItemStack itemStack, boolean allowLava); -} diff --git a/src/main/java/ic2/api/info/Info.java b/src/main/java/ic2/api/info/Info.java deleted file mode 100644 index 48b85d7e..00000000 --- a/src/main/java/ic2/api/info/Info.java +++ /dev/null @@ -1,6 +0,0 @@ -package ic2.api.info; - -public class Info { - public static IEnergyValueProvider itemEnergy; - public static IFuelValueProvider itemFuel; -} diff --git a/src/main/java/ic2/api/item/ElectricItem.java b/src/main/java/ic2/api/item/ElectricItem.java deleted file mode 100644 index 511220fd..00000000 --- a/src/main/java/ic2/api/item/ElectricItem.java +++ /dev/null @@ -1,108 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Allows for charging, discharging and using electric items (IElectricItem). - * - * The charge or remaining capacity of an item can be determined by calling charge/discharge with - * ignoreTransferLimit and simulate set to true. - */ -public final class ElectricItem { - /** - * IElectricItemManager to use for interacting with IElectricItem ItemStacks. - * - * This manager will act as a gateway and delegate the tasks to the final implementation - * (rawManager or a custom one) as necessary. - */ - public static IElectricItemManager manager; - - /** - * Standard IElectricItemManager implementation, only call it directly from another - * IElectricItemManager. Use manager instead. - */ - public static IElectricItemManager rawManager; - - /** - * Charge an item with a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - * - * @deprecated use manager.charge() instead - */ - @Deprecated - public static int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - return manager.charge(itemStack, amount, tier, ignoreTransferLimit, simulate); - } - - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - * - * @deprecated use manager.discharge() instead - */ - @Deprecated - public static int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - return manager.discharge(itemStack, amount, tier, ignoreTransferLimit, simulate); - } - - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - * - * @deprecated use manager.canUse() instead - */ - @Deprecated - public static boolean canUse(ItemStack itemStack, int amount) { - return manager.canUse(itemStack, amount); - } - - /** - * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param player player holding the item - * @return true if the operation succeeded - * - * @deprecated use manager.use() instead - */ - @Deprecated - public static boolean use(ItemStack itemStack, int amount, EntityPlayer player) { - return manager.use(itemStack, amount, player); - } - - /** - * Charge an item from the BatPack a player is wearing. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * use() already contains this functionality. - * - * @param itemStack electric item's stack - * @param player player holding the item - * - * @deprecated use manager.chargeFromArmor() instead - */ - @Deprecated - public static void chargeFromArmor(ItemStack itemStack, EntityPlayer player) { - manager.chargeFromArmor(itemStack, player); - } -} - diff --git a/src/main/java/ic2/api/item/IBoxable.java b/src/main/java/ic2/api/item/IBoxable.java deleted file mode 100644 index deb9f485..00000000 --- a/src/main/java/ic2/api/item/IBoxable.java +++ /dev/null @@ -1,18 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -/** - * Provides custom toolbox storage behavior for items. - * - * The normal condition for storing an item in a toolbox is having a maximum stack size of 1. - */ -public interface IBoxable { - /** - * Determine whether an item can be stored in a toolbox or not. - * - * @param itemstack item to be stored - * @return Whether to store the item in the toolbox or not - */ - public abstract boolean canBeStoredInToolbox(ItemStack itemstack); -} diff --git a/src/main/java/ic2/api/item/ICustomElectricItem.java b/src/main/java/ic2/api/item/ICustomElectricItem.java deleted file mode 100644 index 9f4b1a68..00000000 --- a/src/main/java/ic2/api/item/ICustomElectricItem.java +++ /dev/null @@ -1,67 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -/** - * Provides the ability to store energy on the implementing item. - * - * This interface is a special version of IElectricItem which delegates the implementation of - * charge(), discharge() and canUse() to the implementing Item. - * - * The default implementation (when not using ICustomElectricItem) does the following: - * - store and retrieve the charge - * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account - * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) - * - update and manage the damage value for the visual charge indicator - * - * @note ICustomElectricItem must not call the ElectricItem methods charge, discharge or canUse - * - * @deprecated Use ISpecialElectricItem instead. - */ -@Deprecated -public interface ICustomElectricItem extends IElectricItem { - /** - * Charge an item with a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - */ - public int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); - - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - */ - public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); - - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - */ - public boolean canUse(ItemStack itemStack, int amount); - - /** - * Determine whether to show the charge tool tip with NEI or other means. - * - * Return false if IC2's handler is incompatible, you want to implement your own or you don't - * want to display the charge at all. - * - * @return true to show the tool tip (x/y EU) - */ - public boolean canShowChargeToolTip(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/item/IElectricItem.java b/src/main/java/ic2/api/item/IElectricItem.java deleted file mode 100644 index adaf3b76..00000000 --- a/src/main/java/ic2/api/item/IElectricItem.java +++ /dev/null @@ -1,54 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -/** - * Provides the ability to store energy on the implementing item. - * - * The item should have a maximum damage of 13. - */ -public interface IElectricItem { - /** - * Determine if the item can be used in a machine or as an armor part to supply energy. - * - * @return Whether the item can supply energy - */ - boolean canProvideEnergy(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy greater than 0. - * - * @return Item ID to use - */ - int getChargedItemId(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy of 0. - * - * @return Item ID to use - */ - int getEmptyItemId(ItemStack itemStack); - - /** - * Get the item's maximum charge energy in EU. - * - * @return Maximum charge energy - */ - int getMaxCharge(ItemStack itemStack); - - /** - * Get the item's tier, lower tiers can't send energy to higher ones. - * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. - * - * @return Item's tier - */ - int getTier(ItemStack itemStack); - - /** - * Get the item's transfer limit in EU per transfer operation. - * - * @return Transfer limit - */ - int getTransferLimit(ItemStack itemStack); -} - diff --git a/src/main/java/ic2/api/item/IElectricItemManager.java b/src/main/java/ic2/api/item/IElectricItemManager.java deleted file mode 100644 index 88eab750..00000000 --- a/src/main/java/ic2/api/item/IElectricItemManager.java +++ /dev/null @@ -1,92 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; - -/** - * This interface specifies a manager to handle the various tasks for electric items. - * - * The default implementation does the following: - * - store and retrieve the charge - * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account - * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) - * - update and manage the damage value for the visual charge indicator - * - * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the - * default implementations through ElectricItem.rawManager. The default implementation is designed - * to minimize its dependency on its own constraints/structure and delegates most work back to the - * more atomic features in the gateway manager. - */ -public interface IElectricItemManager { - /** - * Charge an item with a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - */ - int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); - - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - */ - int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); - - /** - * Determine the charge level for the specified item - * - * @param itemStack ItemStack containing the electric item - * @return charge level in EU - */ - int getCharge(ItemStack itemStack); - - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - */ - boolean canUse(ItemStack itemStack, int amount); - - /** - * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param entity entity holding the item - * @return true if the operation succeeded - */ - boolean use(ItemStack itemStack, int amount, EntityLivingBase entity); - - /** - * Charge an item from the BatPack a player is wearing. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * use() already contains this functionality. - * - * @param itemStack electric item's stack - * @param entity entity holding the item - */ - void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity); - - /** - * Get the tool tip to display for electric items. - * - * @param itemStack ItemStack to determine the tooltip for - * @return tool tip string or null for none - */ - String getToolTip(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/item/IMetalArmor.java b/src/main/java/ic2/api/item/IMetalArmor.java deleted file mode 100644 index 16ffd24e..00000000 --- a/src/main/java/ic2/api/item/IMetalArmor.java +++ /dev/null @@ -1,20 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Armor items implementing this can be considered metal armor. - * - * Currently used for determining which boots can be used to slide up a magnetic pole. - */ -public interface IMetalArmor { - /** - * Determine if the given armor piece is metal armor. - * - * @param itemstack Armor piece as worn by the player - * @param player The player - * @return Whether the armor piece is metal armor - */ - public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); -} diff --git a/src/main/java/ic2/api/item/ISpecialElectricItem.java b/src/main/java/ic2/api/item/ISpecialElectricItem.java deleted file mode 100644 index a7302f53..00000000 --- a/src/main/java/ic2/api/item/ISpecialElectricItem.java +++ /dev/null @@ -1,13 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -public interface ISpecialElectricItem extends IElectricItem { - /** - * Supply a custom IElectricItemManager. - * - * @param itemStack ItemStack to get the manager for - * @return IElectricItemManager instance - */ - IElectricItemManager getManager(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/item/ITerraformingBP.java b/src/main/java/ic2/api/item/ITerraformingBP.java deleted file mode 100644 index 58f7e2fe..00000000 --- a/src/main/java/ic2/api/item/ITerraformingBP.java +++ /dev/null @@ -1,35 +0,0 @@ -package ic2.api.item; - -import net.minecraft.world.World; - -/** - * Allows an item to act as a terraformer blueprint. - */ -public interface ITerraformingBP -{ - /** - * Get the energy consumption per operation of the blueprint. - * - * @return Energy consumption in EU - */ - public abstract int getConsume(); - - /** - * Get the maximum range of the blueprint. - * Should be a divisor of 5. - * - * @return Maximum range in blocks - */ - public abstract int getRange(); - - /** - * Perform the terraforming operation. - * - * @param world world to terraform - * @param x X position to terraform - * @param z Z position to terraform - * @param yCoord Y position of the terraformer - * @return Whether the operation was successful and the terraformer should consume energy. - */ - public abstract boolean terraform(World world, int x, int z, int yCoord); -} diff --git a/src/main/java/ic2/api/item/ItemWrapper.java b/src/main/java/ic2/api/item/ItemWrapper.java deleted file mode 100644 index 58f80734..00000000 --- a/src/main/java/ic2/api/item/ItemWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - -/** - * Wrapper for inserting interfaces into items you don't own. - * - * @author Richard - */ -public class ItemWrapper { - private static final Multimap boxableItems = ArrayListMultimap.create(); - private static final Multimap metalArmorItems = ArrayListMultimap.create(); - - public static void registerBoxable(Item item, IBoxable boxable) { - boxableItems.put(item, boxable); - } - - public static boolean canBeStoredInToolbox(ItemStack stack) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IBoxable boxable : boxableItems.get(item)) { - if (boxable.canBeStoredInToolbox(stack)) return true; - } - - if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; - - return false; - } - - public static void registerMetalArmor(Item item, IMetalArmor armor) { - metalArmorItems.put(item, armor); - } - - public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IMetalArmor metalArmor : metalArmorItems.get(item)) { - if (metalArmor.isMetalArmor(stack, player)) return true; - } - - if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; - - return false; - } -} diff --git a/src/main/java/ic2/api/item/Items.java b/src/main/java/ic2/api/item/Items.java deleted file mode 100644 index 0d3f7534..00000000 --- a/src/main/java/ic2/api/item/Items.java +++ /dev/null @@ -1,407 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -/** - * Provides access to IC2 blocks and items. - * - * Some items can be acquired through the ore dictionary which is the recommended way. - * The items are initialized while IC2 is being loaded - try to use ModsLoaded() or load your mod after IC2. - * Some blocks/items can be disabled by a config setting, so it's recommended to check if they're null first. - * - * Getting the associated Block/Item for an ItemStack x: - * Blocks: Block.blocksList[x.itemID] - * Items: x.getItem() - */ -public final class Items { - /** - * Get an ItemStack for a specific item name, example: Items.getItem("resin") - * See the list below for item names. - * Make sure to copy() the ItemStack if you want to modify it. - * - * @param name item name - * @return The item or null if the item does not exist or an error occurred - */ - public static ItemStack getItem(String name) { - try { - if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); - - Object ret = Ic2Items.getField(name).get(null); - - if (ret instanceof ItemStack) { - return (ItemStack) ret; - } else { - return null; - } - } catch (Exception e) { - System.out.println("IC2 API: Call getItem failed for "+name); - - return null; - } - } - - /* Possible values: - - ----- blocks ----- - - ores - copperOre Copper Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreCopper, null with enableWorldGenOreCopper=false - tinOre Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreTin, null with enableWorldGenOreTin=false - uraniumOre Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreUranium, null with enableWorldGenOreUranium=false - - rubber related - Rubber wood block, meta reflects the state, meta in ItemStack set to 0, ore dictionary: woodRubber (with meta 0), null with enableWorldGenTreeRubber=false - dropped (as an item) -> metadata 0 - block, no resin spot -> metadata 0 or 1 - block, wet resin spot -> metadata 2-5 (according to the side) - block, dry resin spot -> metadata 8-11 (wet state + 6) - - rubberWood - rubberLeaves Rubber Leaves block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false - rubberSapling Rubber Sapling block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false - resinSheet Resin Sheet block, currently not meta sensitive - rubberTrampoline Rubber Trampoline block, meta reflects internal state, meta in ItemStack set to 0 - - building/storage - ironFence Iron Fence block, currently not meta sensitive - - reinforcedStone Reinforced Stone block, currently not meta sensitive - reinforcedGlass Reinforced Glass block, currently not meta sensitive - reinforcedDoorBlock Reinforced Door block, meta reflects the state (see vanilla doors), meta in ItemStack set to 0 - - constructionFoam Construction Foam block, currently not meta sensitive - constructionFoamWall Construction Foam Wall block, meta = color, implements IPaintableBlock - scaffold Scaffold block, meta reflects internal physical model data - - bronzeBlock Bronze block, meta sensitive - copperBlock Copper block, meta sensitive - tinBlock Tin block, meta sensitive - uraniumBlock Uranium block, meta sensitive - - cables (when placed as a block, inventory items are different TE implements IEnergyConductor) - copperCableBlock Copper Cable block, meta sensitive - insulatedCopperCableBlock Insulated Copper Cable block, meta sensitive - - goldCableBlock Gold Cable block, meta sensitive - insulatedGoldCableBlock Insulated Gold Cable block, meta sensitive - doubleInsulatedGoldCableBlock Double Insulated Gold Cable block, meta sensitive - - ironCableBlock Iron Cable block, meta sensitive - insulatedIronCableBlock Insulated Iron Cable block, meta sensitive - doubleInsulatedIronCableBlock Double Insulated Iron Cable block, meta sensitive - trippleInsulatedIronCableBlock Tripple Insulated Iron Cable block, meta sensitive - - glassFiberCableBlock Glass Fiber Cable block, meta sensitive - - tinCableBlock Tin Cable block, meta sensitive - - detectorCableBlock Detector Cable block, meta sensitive - splitterCableBlock Splitter Cable block, meta sensitive - - generators + related (TE implements IEnergySource ex. reactorChamber) - generator Generator block, meta sensitive - geothermalGenerator Geothermal Generator block, meta sensitive - waterMill Water Mill block, meta sensitive - solarPanel Solar Panel block, meta sensitive - windMill Wind Mill block, meta sensitive - nuclearReactor Nuclear Reactor block, meta sensitive - reactorChamber Reactor Chamber block, currently not meta sensitive - - energy storages (TE implements IEnergySource and IEnergyConductor) - batBox BatBox block, meta sensitive - mfeUnit MFE Unit block, meta sensitive - mfsUnit MFS Unit block, meta sensitive - - transformers (TE implements IEnergySource and IEnergyConductor) - lvTransformer LV Transformer block, meta sensitive - mvTransformer MV Transformer block, meta sensitive - hvTransformer HV Transformer block, meta sensitive - - machines + related (TE implements IEnergySink ex. machine, miningPipe, miningPipeTip) - machine Machine block, meta sensitive - advancedMachine Advanced Machine block, meta sensitive - - ironFurnace Iron Furnace block, meta sensitive - electroFurnace Electro Furnace block, meta sensitive - macerator Macerator block, meta sensitive - extractor Extractor block, meta sensitive - compressor Compressor block, meta sensitive - canner Canner block, meta sensitive - miner Miner block, meta sensitive - pump Pump block, meta sensitive - magnetizer Magnetizer block, meta sensitive - electrolyzer Electrolyzer block, meta sensitive - recycler Recycler block, meta sensitive - inductionFurnace Induction Furnace block, meta sensitive - massFabricator Mass Fabricator block, meta sensitive - terraformer Terraformer block, meta sensitive - teleporter Teleporter block, meta sensitive - teslaCoil Tesla Coil block, meta sensitive - luminator Passive (dark) Luminator block, meta = facing - activeLuminator Active (bright) Luminator block, meta = facing - - miningPipe Mining Pipe block, currently not meta sensitive, meta in ItemStack set to 0 - miningPipeTip Mining Pipe Tip block, currently not meta sensitive, meta in ItemStack set to 0 - - personal blocks - personalSafe Personal Safe block, meta sensitive - tradeOMat Trade-O-Mat block, meta sensitive - energyOMat Energy-O-Mat block, meta sensitive - - explosives - industrialTnt Industrial TNT block, currently not meta sensitive - nuke Nuke block, currently not meta sensitive - dynamiteStick Dynamite Stick block, meta = placement, meta in ItemStack set to 0 - dynamiteStickWithRemote Dynamite Stick with Remote block, meta = placement, meta in ItemStack set to 0 - - Agriculture Stuff - crop Crop Block, empty, not meta sensitive - - - ----- items ----- - - rubber + related - resin Resin item, currently not meta sensitive - rubber Rubber item, currently not meta sensitive, ore dictionary: itemRubber - - ore drops - uraniumDrop Uranium Drop item, currently not meta sensitive, ore dictionary: itemDropUranium - - dusts - bronzeDust Bronze Dust item, currently not meta sensitive - clayDust Clay Dust item, currently not meta sensitive - coalDust Coal Dust item, currently not meta sensitive - copperDust Copper Dust item, currently not meta sensitive - goldDust Gold Dust item, currently not meta sensitive - ironDust Iron Dust item, currently not meta sensitive - silverDust Silver Dust item, currently not meta sensitive - smallIronDust Small Iron Dust item, currently not meta sensitive - tinDust Tin Dust item, currently not meta sensitive - hydratedCoalDust Hydrated Coal Dust item, currently not meta sensitive - - ingots - refinedIronIngot Refined Iron Ingot item, currently not meta sensitive, ore dictionary: ingotRefinedIron - copperIngot Copper Ingot item, currently not meta sensitive, ore dictionary: ingotCopper - tinIngot Tin Ingot item, currently not meta sensitive, ore dictionary: ingotTin - bronzeIngot Bronze Ingot item, currently not meta sensitive, ore dictionary: ingotBronze - mixedMetalIngot Mixed Metal Ingot item, currently not meta sensitive - uraniumIngot Uranium Ingot item, currently not meta sensitive, ore dictionary: ingotUranium - - tools/weapons (without electric tools) - treetap Treetap item, meta = damage value - wrench Wrench item, meta = damage value - cutter Insulation Cutter item, meta = damage value - constructionFoamSprayer Construction Foam Sprayer item, meta = charges (as of v1.45) - - bronzePickaxe Bronze Pickaxe item, meta = damage value - bronzeAxe Bronze Axe item, meta = damage value - bronzeSword Bronze Sword item, meta = damage value - bronzeShovel Bronze Shovel item, meta = damage value - bronzeHoe Bronze Hoe item, meta = damage value - - el. tools/devices/weapons - miningDrill Mining Drill item, meta = visual charge indicator, implements IElectricItem - diamondDrill Diamond Tipped Mining Drill item, meta = visual charge indicator, implements IElectricItem - chainsaw Chainsaw item, meta = visual charge indicator, implements IElectricItem - electricWrench Electric Wrench item, meta = visual charge indicator, implements IElectricItem - electricTreetap Electric Treetap item, meta = visual charge indicator, implements IElectricItem - miningLaser Mining Laser item, meta = visual charge indicator, implements IElectricItem - - ecMeter EC-Mater item, currently not meta sensitive - odScanner Ore Density Scanner item, meta = damage value for charge level, implements IElectricItem - ovScanner Ore Value Scanner item, meta = visual charge indicator, implements IElectricItem - - frequencyTransmitter Frequency Transmitter item, currently not meta sensitive - - nanoSaber Idle Nano Saber item, meta = visual charge indicator, implements IElectricItem - enabledNanoSaber Enabled Nano Saber item, meta = visual charge indicator, implements IElectricItem - - armor/wearable - rubberBoots Rubber Boots item, meta = damage value - - bronzeHelmet Bronze Helmet Armor item, meta = damage value - bronzeChestplate Bronze Chestplate Armor item, meta = damage value - bronzeLeggings Bronze Leggings Armor item, meta = damage value - bronzeBoots Bronze Boots Armor item, meta = damage value - - compositeArmor Composite Armor item, meta = damage value for charge level - - nanoHelmet Nano Helmet Armor item, meta = visual charge indicator, implements IElectricItem - nanoBodyarmor Nano Bodyarmor item, meta = visual charge indicator, implements IElectricItem - nanoLeggings Nano Leggings Armor item, meta = visual charge indicator, implements IElectricItem - nanoBoots Nano Boots Armor item, meta = visual charge indicator, implements IElectricItem - - quantumHelmet Quantum Helmet Armor item, meta = visual charge indicator, implements IElectricItem - quantumBodyarmor Quantum Bodyarmor item, meta = visual charge indicator, implements IElectricItem - quantumLeggings Quantum Leggings Armor item, meta = visual charge indicator, implements IElectricItem - quantumBoots Quantum Boots Armor item, meta = visual charge indicator, implements IElectricItem - - jetpack Jetpack item, meta = damage value for fuel level - electricJetpack Electric Jetpack item, meta = visual charge indicator, implements IElectricItem - - batPack BatPack item, meta = visual charge indicator, implements IElectricItem, can provide energy - lapPack LapPack item, meta = visual charge indicator, implements IElectricItem, can provide energy - - cfPack CF Pack item, meta = charges (as of v1.45) - - solarHelmet Solar Helmet item, currently not meta sensitive - staticBoots Static Boots item, currently not meta sensitive - - batteries - reBattery Empty RE Battery item, currently not meta sensitive, implements IElectricItem - chargedReBattery RE Battery item, meta = visual charge indicator, implements IElectricItem, can provide energy - energyCrystal Energy Crystal item, meta = visual charge indicator, implements IElectricItem, can provide energy - lapotronCrystal Lapotron Crystal item, meta = visual charge indicator, implements IElectricItem, can provide energy - suBattery SU Battery item, currently not meta sensitive - - cables - copperCableItem Copper Cable item, meta sensitive - insulatedCopperCableItem Insulated Copper Cable item, meta sensitive - - goldCableItem Gold Cable item, meta sensitive - insulatedGoldCableItem Insulated Gold Cable item, meta sensitive - doubleInsulatedGoldCableItem Double Insulated Gold Cable item, meta sensitive - - ironCableItem Iron Cable item, meta sensitive - insulatedIronCableItem Insulated Iron Cable item, meta sensitive - doubleInsulatedIronCableItem Double Insulated Iron Cable item, meta sensitive - trippleInsulatedIronCableItem Tripple Insulated Iron Cable item, meta sensitive - - glassFiberCableItem Glass Fiber Cable item, meta sensitive - - tinCableItem Tin Cable item, meta sensitive - - detectorCableItem Detector Cable item, meta sensitive - splitterCableItem Splitter Cable item, meta sensitive - - cells/containers (without reactor components) - cell Empty Cell item, currently not meta sensitive - lavaCell Lava Cell item, currently not meta sensitive - hydratedCoalCell Hydrated Coal Cell item, currently not meta sensitive - bioCell Bio Cell item, currently not meta sensitive - coalfuelCell Coalfuel Cell item, currently not meta sensitive - biofuelCell Biofuel Cell item, currently not meta sensitive - waterCell Water Cell item, currently not meta sensitive - electrolyzedWaterCell Electrolyzed Water Cell item, currently not meta sensitive - - fuelCan Empty Fuel Can item, currently not meta sensitive - filledFuelCan Fuel Can item, meta = fuel value (as of v1.45) - - tinCan Empty Tin Can item, currently not meta sensitive - filledTinCan Filled Tin Can item, currently not meta sensitive - - reactor components - uraniumCell Uranium Cell item, meta = damage value - coolingCell Cooling Cell item, meta = damage value - - depletedIsotopeCell Depleted Isotope Cell item, meta = damage value - reEnrichedUraniumCell Re-Enriched Uranium Cell item, currently not meta sensitive - nearDepletedUraniumCell Near-Depleted Uranium Cell item, currently not meta sensitive - - integratedReactorPlating Integrated Reactor Plating item, meta = damage value - integratedHeatDisperser Integrated Heat Disperser item, meta = damage value - - terraformer blueprints - terraformerBlueprint Empty Terraformer Blueprint item, currently not meta sensitive - cultivationTerraformerBlueprint Cultivation Terraformer Blueprint item, currently not meta sensitive - irrigationTerraformerBlueprint Irrigation Terraformer Blueprint item, currently not meta sensitive - chillingTerraformerBlueprint Chilling Terraformer Blueprint item, currently not meta sensitive - desertificationTerraformerBlueprint Desertification Terraformer Blueprint item, currently not meta sensitive - flatificatorTerraformerBlueprint Flatificator Terraformer Blueprint item, currently not meta sensitive - mushroomTerraformerBlueprint Mushroom Terraformer Blueprint item, currently not meta sensitive - - diamond chain - coalBall Coal Ball item, currently not meta sensitive - compressedCoalBall Compressed Coal Ball item, currently not meta sensitive - coalChunk Coal Chunk item, currently not meta sensitive - industrialDiamond Industrial Diamond item, currently not meta sensitive, DEPRECATED - - recycler chain - scrap Scrap item, currently not meta sensitive - scrapBox Scrap Box item, currently not meta sensitive - - fuel production chain - hydratedCoalClump Hydrated Coal Clump item, currently not meta sensitive - plantBall Plant Ball item, currently not meta sensitive - compressedPlantBall Compressed Plant Ball item, currently not meta sensitive - - painting - painter Painter item, currently not meta sensitive - - blackPainter Black Painter item, meta = damage value - redPainter Red Painter item, meta = damage value - greenPainter Green Painter item, meta = damage value - brownPainter Brown Painter item, meta = damage value - bluePainter Blue Painter item, meta = damage value - purplePainter Purple Painter item, meta = damage value - cyanPainter Cyan Painter item, meta = damage value - lightGreyPainter Light Grey Painter item, meta = damage value - darkGreyPainter Dark Grey Painter item, meta = damage value - pinkPainter Pink Painter item, meta = damage value - limePainter Lime Painter item, meta = damage value - yellowPainter Yellow Painter item, meta = damage value - cloudPainter Cloud Painter item, meta = damage value - magentaPainter Magenta Painter item, meta = damage value - orangePainter Orange Painter item, meta = damage value - whitePainter White Painter item, meta = damage value - - explosives + related - dynamite Throwable Dynamite item, currently not meta sensitive - stickyDynamite Throwable Sticky Dynamite item, currently not meta sensitive - - remote Dynamite Remote item, currently not meta sensitive - - misc intermediate recipe ingredients - electronicCircuit Electronic Circuit item, currently not meta sensitive - advancedCircuit Advanced Circuit item, currently not meta sensitive - - advancedAlloy Advanced Alloy item, currently not meta sensitive - - carbonFiber Raw Carbon Fiber item, currently not meta sensitive - carbonMesh Raw Carbon Mesh item, currently not meta sensitive - carbonPlate Carbon Plate item, currently not meta sensitive - - matter UU-Matter item, currently not meta sensitive - iridiumOre Iridium Ore item, currently not meta sensitive - iridiumPlate Iridium Plate item, currently not meta sensitive - - upgrade modules - overclockerUpgrade overclocker upgrade item, meta sensitive - transformerUpgrade transformer upgrade item, meta sensitive - energyStorageUpgrade energy storage upgrade item, meta sensitive - - misc - coin Coin item, currently not meta sensitive - reinforcedDoor Reinforced Door item, currently not meta sensitive - constructionFoamPellet Construction Foam Pellet item, currently not meta sensitive - cropSeed Crop seeds, stuff stored in NBT, don't use for crafting recipes! - cropnalyzer Cropnalyzer handheld device - fertilizer Basic IC2Item, used to provide nutrients toCropBlocks - hydratingCell Cell used to hydrate Crops, meta = Content, 0 = Full, 9999 = Near empty - electricHoe Electric Hoe, meta = charge level - solarHelmet Solar Helmet item, currently not meta sensitive - terraWart Terra Wart item, cures potion effects - weedEx Weed-EX can, meta = uses left - - */ - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = Items.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.item".length()); - } - - return "ic2"; - } - - private static Class Ic2Items; -} - diff --git a/src/main/java/ic2/api/network/INetworkItemEventListener.java b/src/main/java/ic2/api/network/INetworkItemEventListener.java deleted file mode 100644 index 02ce470d..00000000 --- a/src/main/java/ic2/api/network/INetworkItemEventListener.java +++ /dev/null @@ -1,18 +0,0 @@ -package ic2.api.network; - -import net.minecraft.entity.player.EntityPlayer; - -/** - * Allows an item to receive network events received from the server. - */ -public interface INetworkItemEventListener { - /** - * Called when a network event is received. - * - * @param metaData item metadata - * @param player player containing the item - * @param event event ID - */ - void onNetworkEvent(int metaData, EntityPlayer player, int event); -} - diff --git a/src/main/java/ic2/api/network/INetworkUpdateListener.java b/src/main/java/ic2/api/network/INetworkUpdateListener.java deleted file mode 100644 index 09414ae3..00000000 --- a/src/main/java/ic2/api/network/INetworkUpdateListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package ic2.api.network; - -/** - * Allows a tile entity to receive field sync updates received from the server. - */ -public interface INetworkUpdateListener { - /** - * Called when a field is synchronized. - * - * @param field field synchronized - */ - void onNetworkUpdate(String field); -} - diff --git a/src/main/java/ic2/api/network/NetworkHelper.java b/src/main/java/ic2/api/network/NetworkHelper.java deleted file mode 100644 index 48ecc2ad..00000000 --- a/src/main/java/ic2/api/network/NetworkHelper.java +++ /dev/null @@ -1,237 +0,0 @@ -package ic2.api.network; - -import java.lang.reflect.Method; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -/** - * Provides methods to initiate events and synchronize tile entity fields in SMP. - * - * The methods are transparent between singleplayer and multiplayer - if a method is called in - * singleplayer, the associated callback will be locally executed. The implementation is different - * between the client and server versions of IC2. - * - * You'll usually want to use the server->client methods defined here to synchronize information - * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or - * producing effects. Anything which is only visible inside the GUI should be synchronized through - * the Container class associated to the GUI in Container.updateProgressBar(). - */ -public final class NetworkHelper { - // server -> client - - - /** - * Schedule a TileEntity's field to be updated to the clients in range. - * - * The updater will query the field's value during the next update, updates happen usually - * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. - * - * IC2's network updates have to get triggered every time, it doesn't continuously poll/send - * the field value. Just call updateTileEntityField after every change to a field which needs - * network synchronization. - * - * The following field data types are currently supported: - * - int, int[], short, short[], byte, byte[], long, long[] - * - float, float[], double, double[] - * - boolean, boolean[] - * - String, String[] - * - ItemStack - * - NBTBase (includes NBTTagCompound) - * - Block, Item, Achievement, Potion, Enchantment - * - ChunkCoordinates, ChunkCoordIntPair - * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) - * - World (does not sync the actual world, instead looks up the world by its dimension ID) - * - * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- - * side TileEntity if it implements INetworkUpdateListener. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). - * - * @param te TileEntity to update - * @param field Name of the field to update - */ - public static void updateTileEntityField(TileEntity te, String field) { - try { - if (NetworkManager_updateTileEntityField == null) NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); - if (instance == null) instance = getInstance(); - - NetworkManager_updateTileEntityField.invoke(instance, te, field); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified TileEntity to the clients in range. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). - * - * @param te TileEntity to notify, should implement INetworkTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { - try { - if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified Item to the clients in range. - * - * The item should implement INetworkItemEventListener to receive the event. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkItemEventListener.onNetworkEvent (if implemented by the item). - * - * @param player EntityPlayer holding the item - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { - try { - if (NetworkManager_initiateItemEvent == null) NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Schedule a block update (re-render) on the clients in range. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just trigger the - * block update locally. - * - * @param world World containing the block - * @param x The block's x coordinate - * @param y The block's y coordinate - * @param z The block's z coordinate - */ - public static void announceBlockUpdate(World world, int x, int y, int z) { - try { - if (NetworkManager_announceBlockUpdate == null) NetworkManager_announceBlockUpdate = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("announceBlockUpdate", World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_announceBlockUpdate.invoke(instance, world, x, y, z); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - - // client -> server - - - /** - * Ask the server to send the values of the fields specified. - * - * See updateTileEntityField for the supported field types. - * - * The implementation is currently limited to TileEntitys as data providers. The tile entity - * has to be fully initialized when executing this method (i.e. valid worldObj+coords). - * - * This method doesn't do anything if executed on the server. - * - * @param dataProvider Object implementing the INetworkDataProvider interface - * - * @deprecated no need to call this anymore, IC2 initiates it automatically - */ - @Deprecated - public static void requestInitialData(INetworkDataProvider dataProvider) { - } - - /** - * Immediately send an event for the specified TileEntity to the server. - * - * This method doesn't do anything if executed on the server. - * - * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientTileEntityEvent(TileEntity te, int event) { - try { - if (NetworkManager_initiateClientTileEntityEvent == null) NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified Item to the clients in range. - * - * The item should implement INetworkItemEventListener to receive the event. - * - * This method doesn't do anything if executed on the server. - * - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientItemEvent(ItemStack itemStack, int event) { - try { - if (NetworkManager_initiateClientItemEvent == null) NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = NetworkHelper.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.network".length()); - } - - return "ic2"; - } - - /** - * Get the NetworkManager instance, used internally. - * - * @return NetworkManager instance - */ - private static Object getInstance() { - try { - return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - - private static Object instance; - private static Method NetworkManager_updateTileEntityField; - private static Method NetworkManager_initiateTileEntityEvent; - private static Method NetworkManager_initiateItemEvent; - private static Method NetworkManager_announceBlockUpdate; - private static Method NetworkManager_initiateClientTileEntityEvent; - private static Method NetworkManager_initiateClientItemEvent; -} - diff --git a/src/main/java/ic2/api/reactor/IC2Reactor.java b/src/main/java/ic2/api/reactor/IC2Reactor.java deleted file mode 100644 index 512c4ff0..00000000 --- a/src/main/java/ic2/api/reactor/IC2Reactor.java +++ /dev/null @@ -1,34 +0,0 @@ -package ic2.api.reactor; - -import java.lang.reflect.Field; - -public class IC2Reactor { - private static Field energyGeneratorNuclear; - - public static int getEUOutput() { - try { - if (energyGeneratorNuclear == null) energyGeneratorNuclear = Class.forName(getPackage() + ".core.IC2").getDeclaredField("energyGeneratorNuclear"); - - return energyGeneratorNuclear.getInt(null); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = IC2Reactor.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.reactor".length()); - } - - return "ic2"; - } -} diff --git a/src/main/java/ic2/api/reactor/IReactor.java b/src/main/java/ic2/api/reactor/IReactor.java deleted file mode 100644 index 7fcbd699..00000000 --- a/src/main/java/ic2/api/reactor/IReactor.java +++ /dev/null @@ -1,140 +0,0 @@ -package ic2.api.reactor; - -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Interface implemented by the tile entity of nuclear reactors. - */ -public interface IReactor { - /** - * Get the reactor's position in the world. - * - * @return Position of the reactor - */ - public ChunkCoordinates getPosition(); - - /** - * Get the reactor's corresponding world. - * - * @return The reactor's world - */ - public World getWorld(); - - /** - * Get the reactor's heat. - * - * @return The reactor's heat - */ - public int getHeat(); - - /** - * Set the reactor's heat. - * - * @param heat reactor heat - */ - public void setHeat(int heat); - - /** - * Increase the reactor's heat. - * - * Use negative values to decrease. - * - * @param amount amount of heat to add - * @return The reactor's heat after adding the specified amount - */ - public int addHeat(int amount); - - /** - * Get the reactor's maximum heat before exploding. - * - * @return Maximum heat value - */ - public int getMaxHeat(); - - /** - * Set the reactor's stored maxHeat variable. - * Used by plating to increase the reactors MaxHeat capacity. - * Needs to be called during each cycle process. - */ - public void setMaxHeat(int newMaxHeat); - - /** - * Get's the reactor's HEM (Heat Effect Modifier) - * Basic value is 1.0F. - * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors - * (F.e. water evaporation, melting, damaging entitys, etc) - * - * @return HEM - */ - public float getHeatEffectModifier(); - - /** - * Set's the reactor's HEM - * Needs to be called during each cycle process. - */ - public void setHeatEffectModifier(float newHEM); - - /** - * Get the reactor's energy output. - * - * @return Energy output, not multiplied by the base EU/t value - */ - public int getOutput(); - - /** - * Add's the given amount of energy to the Reactor's output. - * - * @return Energy output after adding the value, not multiplied by the base EU/t value - */ - public float addOutput(float energy); - - /** - * Deprecated to avoid immediate API breaking. Don't use. - */ - @Deprecated - public int addOutput(int energy); - - /** - * Replaced by IC2Reactor.getEUOutput() - stays at the universal output value of 1 for compatibility - */ - @Deprecated - public int getPulsePower(); - - /** - * Get the item at the specified grid coordinates. - * - * @param x X position of the item - * @param y Y position of the item - * @return The item or null if there is no item - */ - public ItemStack getItemAt(int x, int y); - - /** - * Set the item at the specified grid coordinates. - * - * @param x X position of the item - * @param y Y position of the item - * @param item The item to set. - */ - public void setItemAt(int x, int y, ItemStack item); - - /** - * Explode the reactor. - */ - public void explode(); - - /** - * Get the reactor's tick rate (game ticks per reactor tick). - * - * @return Tick rate - */ - public int getTickRate(); - - /** - * Get whether the reactor is active and supposed to produce energy - * @return Whether the reactor is active - */ - public boolean produceEnergy(); -} diff --git a/src/main/java/ic2/api/reactor/IReactorChamber.java b/src/main/java/ic2/api/reactor/IReactorChamber.java deleted file mode 100644 index 1b9f2c9f..00000000 --- a/src/main/java/ic2/api/reactor/IReactorChamber.java +++ /dev/null @@ -1,13 +0,0 @@ -package ic2.api.reactor; - -/** - * Interface implemented by the reactor chamber tile entity. - */ -public interface IReactorChamber { - /** - * Get the chamber's reactor. - * - * @return The reactor - */ - public IReactor getReactor(); -} diff --git a/src/main/java/ic2/api/reactor/IReactorComponent.java b/src/main/java/ic2/api/reactor/IReactorComponent.java deleted file mode 100644 index 5170e94d..00000000 --- a/src/main/java/ic2/api/reactor/IReactorComponent.java +++ /dev/null @@ -1,97 +0,0 @@ -package ic2.api.reactor; - -import net.minecraft.item.ItemStack; - -/** - * Design custom Reactor components by implementing this Interface - * Items implementing the interface will not be ejected from Reactors in their clean-up - * and can/will be interacted with by other elements, f.e. Uranium Cells. - * - * All IC2 ReactorComponents implement and use this Interface - * - */ -public interface IReactorComponent -{ - /** - * Called by reactor upon iterating through it's inventory (every cycle). - * Perform all necessary calculation/interaction here - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - */ - public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. - * Uranium-Uranium interaction (f.e.) uses this method. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of called ItemStack - * @param pulsingStack Reference to the specific instance of pulsing ItemStack - * @param youX X-coordinate of your stack in the grid - * @param youY Y-coordinate of your stack in the grid - * @param pulseX X-coordinate of pulsing stack in the grid - * @param pulseY Y-coordinate of pulsing stack in the grid - * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) - */ - public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY); - - /** - * Called by components to determine whether your component can be heated. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return true if your component can take heat - */ - public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the maximum capacity of your heat-containing component here. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Maximum heat - */ - public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the current amount of heat stored in this component - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Current Heat - */ - public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by components to distribute heat to your component. - * Perform heating-calculations and increase your heat (dmg) level accordingly. - * This method will as well be called to REDUCE heat, by providing a negative amount. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @param heat Amount of heat to be added (may be negative to subtract heat) - * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) - */ - public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); - - /** - * Called upon reactor explosion - * Alter the explosion size. - * Returning a float 0 < f < 1 will be counted as multiplier. - * Anything else will be counted as a flat addition (in case of <0 = reduction). - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @return your explosion modifier - */ - public float influenceExplosion(IReactor reactor, ItemStack yourStack); -} diff --git a/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java deleted file mode 100644 index 756eaf63..00000000 --- a/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java +++ /dev/null @@ -1,26 +0,0 @@ -package ic2.api.recipe; - -import net.minecraft.item.ItemStack; - -/** - * Recipe manager interface for crafting recipes. - * - * @author Richard - */ -public interface ICraftingRecipeManager { - /** - * Adds a shaped crafting recipe. - * - * @param output Recipe output - * @param input Recipe input format - */ - public void addRecipe(ItemStack output, Object... input); - - /** - * Adds a shapeless crafting recipe. - * - * @param output Recipe output - * @param input Recipe input - */ - public void addShapelessRecipe(ItemStack output, Object... input); -} diff --git a/src/main/java/ic2/api/recipe/IListRecipeManager.java b/src/main/java/ic2/api/recipe/IListRecipeManager.java deleted file mode 100644 index 5c0d3062..00000000 --- a/src/main/java/ic2/api/recipe/IListRecipeManager.java +++ /dev/null @@ -1,36 +0,0 @@ -package ic2.api.recipe; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * Recipe manager interface for basic lists. - * - * @author Richard - */ -public interface IListRecipeManager extends Iterable { - /** - * Adds a stack to the list. - * - * @param stack Stack to add - */ - public void add(ItemStack stack); - - /** - * Checks whether the specified stack is in the list. - * - * @param stack Stack to check - * @return Whether the stack is in the list - */ - public boolean contains(ItemStack stack); - - /** - * Gets the list of stacks. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of stacks - */ - public List getStacks(); -} diff --git a/src/main/java/ic2/api/recipe/IMachineRecipeManager.java b/src/main/java/ic2/api/recipe/IMachineRecipeManager.java deleted file mode 100644 index 9adaeb8d..00000000 --- a/src/main/java/ic2/api/recipe/IMachineRecipeManager.java +++ /dev/null @@ -1,37 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraft.item.ItemStack; - -/** - * Recipe manager interface for basic machines. - * - * @author Richard - */ -public interface IMachineRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param input Recipe input - * @param output Recipe output - */ - public void addRecipe(ItemStack input, V output); - - /** - * Gets the recipe output for the given input. - * - * @param input Recipe input - * @return Recipe output, or null if none - */ - public V getOutputFor(ItemStack input, boolean adjustInput); - - /** - * Gets a list of recipes. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); -} diff --git a/src/main/java/ic2/api/recipe/Recipes.java b/src/main/java/ic2/api/recipe/Recipes.java deleted file mode 100644 index 7c362376..00000000 --- a/src/main/java/ic2/api/recipe/Recipes.java +++ /dev/null @@ -1,38 +0,0 @@ -package ic2.api.recipe; - -import net.minecraft.item.ItemStack; - -/** - * General recipe registry. - * - * @author Richard - */ -public class Recipes { - public static IMachineRecipeManager macerator; - public static IMachineRecipeManager extractor; - public static IMachineRecipeManager compressor; - - /** - * Reference amplifier values: - * - * 5000: Scrap - * 45000: Scrapbox - */ - public static IMachineRecipeManager matterAmplifier; - /** - * Reference scrap box chance values: - * - * 0.1: Diamond - * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore - * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone - * 1.5: Apple, Bread - * 2.0: Netherrack, Rotten Flesh - * 3.0: Grass, Gravel - * 4.0: Stick - * 5.0: Dirt, Wooden Hoe - */ - public static IMachineRecipeManager scrapboxDrops; - public static IListRecipeManager recyclerBlacklist; - - public static ICraftingRecipeManager advRecipes; -} diff --git a/src/main/java/ic2/api/tile/ExplosionWhitelist.java b/src/main/java/ic2/api/tile/ExplosionWhitelist.java deleted file mode 100644 index 01322b6c..00000000 --- a/src/main/java/ic2/api/tile/ExplosionWhitelist.java +++ /dev/null @@ -1,46 +0,0 @@ -package ic2.api.tile; - -import java.util.*; - -import net.minecraft.block.Block; - -/** - * Blocks on this whitelist will not resist an explosion but won't be destroyed. - * - * The explosion code by default ignores blocks which absorb more than 1000 explosion power to - * prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and - * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get - * destroyed. - */ -public final class ExplosionWhitelist { - /** - * Add a block to the whitelist. - * - * @param block block to add - */ - public static void addWhitelistedBlock(Block block) { - whitelist.add(block); - } - - /** - * Remove a block from the whitelist. - * - * @param block block to remove - */ - public static void removeWhitelistedBlock(Block block) { - whitelist.remove(block); - } - - /** - * Check if a block is on the whitelist. - * - * @param block block to check if whitelisted - * @return Whether the block is whitelisted - */ - public static boolean isBlockWhitelisted(Block block) { - return whitelist.contains(block); - } - - private static Set whitelist = new HashSet(); -} - diff --git a/src/main/java/ic2/api/tile/IEnergyStorage.java b/src/main/java/ic2/api/tile/IEnergyStorage.java deleted file mode 100644 index 79f30113..00000000 --- a/src/main/java/ic2/api/tile/IEnergyStorage.java +++ /dev/null @@ -1,54 +0,0 @@ -package ic2.api.tile; - -import ic2.api.Direction; - -/** - * Interface implemented by the tile entity of energy storage blocks. - */ -public interface IEnergyStorage { - /** - * Get the amount of energy currently stored in the block. - * - * @return Energy stored in the block - */ - public int getStored(); - - /** - * Set the amount of energy currently stored in the block. - * - * @param energy stored energy - */ - public void setStored(int energy); - - /** - * Add the specified amount of energy. - * - * Use negative values to decrease. - * - * @param amount of energy to add - * @return Energy stored in the block after adding the specified amount - */ - public int addEnergy(int amount); - - /** - * Get the maximum amount of energy the block can store. - * - * @return Maximum energy stored - */ - public int getCapacity(); - - /** - * Get the block's energy output. - * - * @return Energy output in EU/t - */ - public int getOutput(); - - /** - * Get whether this block can have its energy used by an adjacent teleporter. - * - * @param side side the teleporter is draining energy from - * @return Whether the block is teleporter compatible - */ - public boolean isTeleporterCompatible(Direction side); -} diff --git a/src/main/java/ic2/api/tile/IWrenchable.java b/src/main/java/ic2/api/tile/IWrenchable.java deleted file mode 100644 index f0144169..00000000 --- a/src/main/java/ic2/api/tile/IWrenchable.java +++ /dev/null @@ -1,59 +0,0 @@ -package ic2.api.tile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Allows a tile entity to make use of the wrench's removal and rotation functions. - */ -public interface IWrenchable { - /** - * Determine if the wrench can be used to set the block's facing. - * Called before wrenchCanRemove(). - * - * @param entityPlayer player using the wrench, may be null - * @param side block's side the wrench was clicked on - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); - - /** - * Get the block's facing. - * - * @return Block facing - */ - short getFacing(); - - /** - * Set the block's facing - * - * @param facing facing to set the block to - */ - void setFacing(short facing); - - /** - * Determine if the wrench can be used to remove the block. - * Called if wrenchSetFacing fails. - * - * @param entityPlayer player using the wrench, may be null - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanRemove(EntityPlayer entityPlayer); - - /** - * Determine the probability to drop the block as it is. - * The first entry in getBlockDropped will be replaced by blockid:meta if the drop is successful. - * - * @return Probability from 0 to 1 - */ - float getWrenchDropRate(); - - /** - * Determine the item the block will drop when the wrenching is successful. - * - * @param entityPlayer player using the wrench, may be null - * @return Item to drop, may be null - */ - ItemStack getWrenchDrop(EntityPlayer entityPlayer); -} - diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index b67ba45c..5dd3adbf 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -23,12 +23,16 @@ import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyAcceptor; +import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -42,8 +46,11 @@ import thaumic.tinkerer.common.lib.LibFeatures; @Optional.InterfaceList({ @Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), - @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib")}) -public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IFluidHandler, IPowerReceptor, /*IEnergySink,*/ IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { + @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), + @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")}) + + +public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { private boolean addedToICEnergyNet = false; @@ -64,9 +71,9 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI return LibFeatures.INTERFACE_DISTANCE; } - /*@Override - public void invalidate() { - removeFromIC2EnergyNet(); + @Override + public void invalidate() { + removeFromIC2EnergyNet(); super.invalidate(); } @@ -77,10 +84,10 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI private void removeFromIC2EnergyNet() { if(addedToICEnergyNet && !worldObj.isRemote) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - addedToICEnergyNet = false; - } - }*/ + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) this)); + addedToICEnergyNet = false; + } + } @Override public void markDirty() { @@ -247,31 +254,32 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI return worldObj; } - /*@Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { - TileEntity tile = getTile(); - return tile instanceof IEnergySink ? ((IEnergySink) tile).acceptsEnergyFrom(emitter, direction) : false; - } + @Optional.Method(modid = "IC2") + @Override + public double getDemandedEnergy() { + TileEntity tile = getTile(); + return tile instanceof IEnergySink ? ((IEnergySink) tile).getDemandedEnergy() : 0; + } - @Override - public double demandedEnergyUnits() { - TileEntity tile = getTile(); - return tile instanceof IEnergySink ? ((IEnergySink) tile).demandedEnergyUnits() : 0; - } - @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) { - TileEntity tile = getTile(); - return tile instanceof IEnergySink ? ((IEnergySink) tile).injectEnergyUnits(directionFrom, amount) : 0; - } + @Optional.Method(modid = "IC2") + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { - @Override - public int getMaxSafeInput() { - TileEntity tile = getTile(); - return tile instanceof IEnergySink ? ((IEnergySink) tile).getMaxSafeInput() : 0; - } -*/ - @Override + TileEntity tile = getTile(); + return tile instanceof IEnergySink ? ((IEnergySink) tile).injectEnergy(directionFrom, amount, voltage) : 0; + } + + + @Optional.Method(modid = "IC2") + @Override + public int getSinkTier() { + TileEntity tile = getTile(); + return tile instanceof IEnergySink ? ((IEnergySink) tile).getSinkTier() : 0; + } + + + @Override @Optional.Method(modid = "CoFHLib") public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { TileEntity tile = getTile(); @@ -474,4 +482,9 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + TileEntity tile = getTile(); + return tile instanceof IEnergyAcceptor ? ((IEnergySink) tile).acceptsEnergyFrom(emitter, direction) : false; + } } \ No newline at end of file diff --git a/src/main/java/thaumic/tinkerer/common/peripheral/PeripheralTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/peripheral/PeripheralTransvectorInterface.java index 62aa4a8c..bffc746e 100644 --- a/src/main/java/thaumic/tinkerer/common/peripheral/PeripheralTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/peripheral/PeripheralTransvectorInterface.java @@ -15,7 +15,7 @@ package thaumic.tinkerer.common.peripheral; -import ic2.api.energy.tile.IEnergySink; +import IEnergySink; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.tileentity.TileEntity; From 9196916bd1e4042f40c2dd7189fa09819c88181d Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sun, 24 Aug 2014 17:53:26 -0400 Subject: [PATCH 07/26] Fixed XP Talisman recipe --- .../java/thaumic/tinkerer/common/item/ItemXPTalisman.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java b/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java index a073ed2e..f064160e 100644 --- a/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java +++ b/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java @@ -127,8 +127,8 @@ public class ItemXPTalisman extends ItemBase implements IBauble { @Override public ThaumicTinkererRecipe getRecipeItem() { return new ThaumicTinkererInfusionRecipe(LibResearch.KEY_XP_TALISMAN, new ItemStack(this), 6, new AspectList().add(Aspect.GREED, 20).add(Aspect.EXCHANGE, 10).add(Aspect.BEAST, 10).add(Aspect.MECHANISM, 5), new ItemStack(Items.gold_ingot), - new ItemStack(Items.quartz), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemDarkQuartz.class)), new ItemStack(ConfigItems.itemResource, 1, 5), new ItemStack(Items.diamond)); - } + new ItemStack(Items.quartz), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemDarkQuartz.class)), new ItemStack(ConfigItems.itemZombieBrain), new ItemStack(Items.diamond)); + } @Override @SideOnly(Side.CLIENT) From 2456f31f47c0335a9140a4ab64ca123169d0c35e Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Sun, 24 Aug 2014 18:00:03 -0400 Subject: [PATCH 08/26] Swaped dark quartz recipies to fix conflict with Botania --- .../thaumic/tinkerer/common/item/ItemXPTalisman.java | 2 +- .../tinkerer/common/item/quartz/ItemDarkQuartz.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java b/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java index f064160e..bce169ef 100644 --- a/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java +++ b/src/main/java/thaumic/tinkerer/common/item/ItemXPTalisman.java @@ -127,7 +127,7 @@ public class ItemXPTalisman extends ItemBase implements IBauble { @Override public ThaumicTinkererRecipe getRecipeItem() { return new ThaumicTinkererInfusionRecipe(LibResearch.KEY_XP_TALISMAN, new ItemStack(this), 6, new AspectList().add(Aspect.GREED, 20).add(Aspect.EXCHANGE, 10).add(Aspect.BEAST, 10).add(Aspect.MECHANISM, 5), new ItemStack(Items.gold_ingot), - new ItemStack(Items.quartz), new ItemStack(ThaumicTinkerer.registry.getFirstItemFromClass(ItemDarkQuartz.class)), new ItemStack(ConfigItems.itemZombieBrain), new ItemStack(Items.diamond)); + new ItemStack(Items.quartz), new ItemStack(Items.quartz), new ItemStack(ConfigItems.itemZombieBrain), new ItemStack(Items.diamond)); } @Override diff --git a/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java b/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java index c7f9ed46..71331a99 100644 --- a/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java +++ b/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java @@ -35,13 +35,13 @@ public class ItemDarkQuartz extends ItemBase { @Override public ThaumicTinkererRecipe getRecipeItem() { return new ThaumicTinkererRecipeMulti( - new ThaumicTinkererCraftingBenchRecipe(LibResearch.KEY_DARK_QUARTZ + 0, new ItemStack(this, 8), - "QQQ", "QCQ", "QQQ", - 'Q', Items.quartz, + new ThaumicTinkererCraftingBenchRecipe(LibResearch.KEY_DARK_QUARTZ + 0, new ItemStack(this, 4), + "Q Q", " C ", "Q Q", + 'Q', Items.quartz, 'C', Items.coal), - new ThaumicTinkererCraftingBenchRecipe(LibResearch.KEY_DARK_QUARTZ + 0, new ItemStack(this, 8), - "QQQ", "QCQ", "QQQ", - 'Q', Items.quartz, + new ThaumicTinkererCraftingBenchRecipe(LibResearch.KEY_DARK_QUARTZ + 0, new ItemStack(this, 4), + "Q Q", " C ", "Q Q", + 'Q', Items.quartz, 'C', new ItemStack(Items.coal, 1, 1)) ); } From 000652eaede9aac6980ec291b4853f064ff382a1 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Mon, 25 Aug 2014 13:02:24 -0400 Subject: [PATCH 09/26] Fixed #464 --- .../TileTransvectorDislocator.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java index 8af39e55..26e3bf60 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorDislocator.java @@ -73,7 +73,7 @@ public class TileTransvectorDislocator extends TileTransvector { } public void setTo(ChunkCoordinates coords) { - worldObj.setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 1 | 2); + worldObj.setBlock(coords.posX, coords.posY, coords.posZ, block, meta, 2); TileEntity tile = this.tile == null ? null : TileEntity.createAndLoadEntity(this.tile); @@ -86,13 +86,20 @@ public class TileTransvectorDislocator extends TileTransvector { tile.updateContainingBlockInfo(); } - if (block != null) - block.onNeighborBlockChange(worldObj, coords.posX, coords.posY, coords.posZ, ThaumicTinkerer.registry.getFirstBlockFromClass(BlockTransvectorDislocator.class)); + //if (block != null) + // block.onNeighborBlockChange(worldObj, coords.posX, coords.posY, coords.posZ, ThaumicTinkerer.registry.getFirstBlockFromClass(BlockTransvectorDislocator.class)); - worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, meta, 3); + worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, meta, 2); } - } + + public void notify(ChunkCoordinates coords) { + + if (block != null) + block.onNeighborBlockChange(worldObj, coords.posX, coords.posY, coords.posZ, ThaumicTinkerer.registry.getFirstBlockFromClass(BlockTransvectorDislocator.class)); + + } + } @Override public void updateEntity() { @@ -129,7 +136,10 @@ public class TileTransvectorDislocator extends TileTransvector { endData.setTo(targetCoords); targetData.setTo(endCoords); - } + + endData.notify(targetCoords); + targetData.notify(endCoords); + } } List entitiesAtEnd = getEntitiesAtPoint(endCoords); From 1e612d4281e31bef39c668ccf30b489f4c63ae5f Mon Sep 17 00:00:00 2001 From: nekosune Date: Mon, 25 Aug 2014 18:20:11 +0100 Subject: [PATCH 10/26] Fixed forge version --- build.gradle | 2 +- .../thaumic/tinkerer/common/item/foci/ItemFocusDislocation.java | 2 +- .../thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 4782763a..deb4b7de 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ group = "thaumic.tinkerer" // http://maven.apache.org/guides/mini/guide-naming-c archivesBaseName = "ThaumicTinkerer" minecraft { - version = "1.7.10-10.13.0.1187" + version = "1.7.10-10.13.0.1208" //minecraftVersion="1.7.2" runDir = "eclipse" replace '${version}', project.version diff --git a/src/main/java/thaumic/tinkerer/common/item/foci/ItemFocusDislocation.java b/src/main/java/thaumic/tinkerer/common/item/foci/ItemFocusDislocation.java index 9f79d463..658978fe 100644 --- a/src/main/java/thaumic/tinkerer/common/item/foci/ItemFocusDislocation.java +++ b/src/main/java/thaumic/tinkerer/common/item/foci/ItemFocusDislocation.java @@ -78,7 +78,7 @@ public class ItemFocusDislocation extends ItemModFocus { Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); int meta = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ); - TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ); + TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ); ItemWandCasting wand = (ItemWandCasting) itemstack.getItem(); if (player.canPlayerEdit(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, itemstack)) { diff --git a/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java b/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java index 71331a99..c19b862b 100644 --- a/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java +++ b/src/main/java/thaumic/tinkerer/common/item/quartz/ItemDarkQuartz.java @@ -2,6 +2,7 @@ package thaumic.tinkerer.common.item.quartz; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + import thaumcraft.api.aspects.AspectList; import thaumcraft.api.research.ResearchPage; import thaumic.tinkerer.common.lib.LibItemNames; From 5694358bef27f5f2d5f5e413a6538fb0adfd148e Mon Sep 17 00:00:00 2001 From: nekosune Date: Mon, 25 Aug 2014 18:47:33 +0100 Subject: [PATCH 11/26] Fixed #463 --- .../common/block/tile/tablet/TileAnimationTablet.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/tablet/TileAnimationTablet.java b/src/main/java/thaumic/tinkerer/common/block/tile/tablet/TileAnimationTablet.java index c570edc0..72cb37b2 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/tablet/TileAnimationTablet.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/tablet/TileAnimationTablet.java @@ -185,7 +185,7 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova } try { - ForgeEventFactory.onPlayerInteract(player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side); + ForgeEventFactory.onPlayerInteract(player, Action.RIGHT_CLICK_AIR, coords.posX, coords.posY, coords.posZ, side,worldObj); Entity entity = detectedEntities.isEmpty() ? null : detectedEntities.get(worldObj.rand.nextInt(detectedEntities.size())); done = entity != null && entity instanceof EntityLiving && (item.itemInteractionForEntity(stack, player, (EntityLivingBase) entity) || (!(entity instanceof EntityAnimal) || ((EntityAnimal) entity).interact(player))); @@ -214,7 +214,8 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova stack = player.getCurrentEquippedItem(); if (stack == null || stack.stackSize == 0) setInventorySlotContents(0, null); - + if(stack!=getStackInSlot(0)) + setInventorySlotContents(0,stack); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } markDirty(); @@ -232,7 +233,7 @@ public class TileAnimationTablet extends TileEntity implements IInventory, IMova int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal(); ChunkCoordinates coords = getTargetLoc(); - PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, coords.posX, coords.posY, coords.posZ, side); + PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, coords.posX, coords.posY, coords.posZ, side,worldObj); if (event.isCanceled()) { stopBreaking(); return; From a3fc6a13a598c688f71685fc00900b3f626d4822 Mon Sep 17 00:00:00 2001 From: nekosune Date: Mon, 25 Aug 2014 19:24:15 +0100 Subject: [PATCH 12/26] Minor IC2 api change --- .../common/block/tile/transvector/TileTransvectorInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 5dd3adbf..a9f4776c 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -47,7 +47,7 @@ import thaumic.tinkerer.common.lib.LibFeatures; @Optional.InterfaceList({ @Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), - @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")}) + @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API")}) public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { From 5d7bdd9f2a97f60b03d9649b9fb0a892e1b807b8 Mon Sep 17 00:00:00 2001 From: nekosune Date: Tue, 26 Aug 2014 22:25:34 +0100 Subject: [PATCH 13/26] Ic2 api change --- src/api/java/ic2/api/Direction.java | 192 +++--- src/api/java/ic2/api/crops/BaseSeed.java | 86 +-- src/api/java/ic2/api/crops/CropCard.java | 630 +++++++++--------- src/api/java/ic2/api/crops/Crops.java | 180 ++--- src/api/java/ic2/api/crops/ICropTile.java | 428 ++++++------ src/api/java/ic2/api/crops/package-info.java | 4 +- src/api/java/ic2/api/energy/EnergyNet.java | 12 +- src/api/java/ic2/api/energy/IEnergyNet.java | 124 ++-- src/api/java/ic2/api/energy/NodeStats.java | 25 + .../ic2/api/energy/event/EnergyTileEvent.java | 12 +- .../api/energy/event/EnergyTileLoadEvent.java | 14 +- .../energy/event/EnergyTileUnloadEvent.java | 14 +- .../ic2/api/energy/event/package-info.java | 4 +- src/api/java/ic2/api/energy/package-info.java | 4 +- .../java/ic2/api/energy/prefab/BasicSink.java | 556 ++++++++-------- .../ic2/api/energy/prefab/BasicSource.java | 551 +++++++-------- .../ic2/api/energy/prefab/package-info.java | 4 +- .../ic2/api/energy/tile/IEnergyAcceptor.java | 22 +- .../ic2/api/energy/tile/IEnergyConductor.java | 76 +-- .../ic2/api/energy/tile/IEnergyEmitter.java | 24 +- .../java/ic2/api/energy/tile/IEnergySink.java | 62 +- .../ic2/api/energy/tile/IEnergySource.java | 52 +- .../java/ic2/api/energy/tile/IEnergyTile.java | 4 +- .../java/ic2/api/energy/tile/IHeatSource.java | 18 +- .../ic2/api/energy/tile/IKineticSource.java | 12 +- .../ic2/api/energy/tile/IMetaDelegate.java | 25 +- .../ic2/api/energy/tile/package-info.java | 4 +- src/api/java/ic2/api/event/LaserEvent.java | 172 ++--- src/api/java/ic2/api/event/PaintEvent.java | 34 +- .../java/ic2/api/event/RetextureEvent.java | 42 +- src/api/java/ic2/api/event/package-info.java | 4 +- .../ic2/api/info/IEnergyValueProvider.java | 22 +- .../java/ic2/api/info/IFuelValueProvider.java | 18 +- src/api/java/ic2/api/info/Info.java | 34 +- src/api/java/ic2/api/info/package-info.java | 4 +- src/api/java/ic2/api/item/ElectricItem.java | 80 +-- .../api/item/IBackupElectricItemManager.java | 4 +- .../java/ic2/api/item/IBlockCuttingBlade.java | 2 +- src/api/java/ic2/api/item/IBoxable.java | 14 +- src/api/java/ic2/api/item/IC2Items.java | 78 +-- src/api/java/ic2/api/item/IElectricItem.java | 76 +-- .../ic2/api/item/IElectricItemManager.java | 136 ++-- src/api/java/ic2/api/item/IItemHudInfo.java | 4 +- .../java/ic2/api/item/IKineticWindRotor.java | 10 +- src/api/java/ic2/api/item/IMetalArmor.java | 18 +- .../ic2/api/item/ISpecialElectricItem.java | 14 +- .../java/ic2/api/item/ITerraformingBP.java | 50 +- src/api/java/ic2/api/item/ItemWrapper.java | 70 +- src/api/java/ic2/api/item/package-info.java | 4 +- ...INetworkClientTileEntityEventListener.java | 14 +- .../ic2/api/network/INetworkDataProvider.java | 14 +- .../network/INetworkItemEventListener.java | 16 +- .../INetworkTileEntityEventListener.java | 12 +- .../api/network/INetworkUpdateListener.java | 14 +- .../java/ic2/api/network/NetworkHelper.java | 313 +++++---- .../java/ic2/api/network/package-info.java | 4 +- src/api/java/ic2/api/package-info.java | 4 +- src/api/java/ic2/api/reactor/IReactor.java | 248 +++---- .../java/ic2/api/reactor/IReactorChamber.java | 23 +- .../ic2/api/reactor/IReactorComponent.java | 163 +++-- .../java/ic2/api/reactor/package-info.java | 4 +- .../recipe/ICannerBottleRecipeManager.java | 74 +- .../recipe/ICannerEnrichRecipeManager.java | 76 +-- .../api/recipe/ICraftingRecipeManager.java | 32 +- .../ic2/api/recipe/IFluidHeatManager.java | 36 +- .../ic2/api/recipe/ILiquidAcceptManager.java | 5 +- .../ic2/api/recipe/IListRecipeManager.java | 52 +- .../ic2/api/recipe/IMachineRecipeManager.java | 57 +- .../java/ic2/api/recipe/IPatternStorage.java | 4 +- src/api/java/ic2/api/recipe/IRecipeInput.java | 42 +- .../java/ic2/api/recipe/IScrapboxManager.java | 6 +- .../ic2/api/recipe/ISemiFluidFuelManager.java | 36 +- .../api/recipe/RecipeInputFluidContainer.java | 62 +- .../ic2/api/recipe/RecipeInputItemStack.java | 56 +- .../ic2/api/recipe/RecipeInputOreDict.java | 96 +-- src/api/java/ic2/api/recipe/RecipeOutput.java | 28 +- src/api/java/ic2/api/recipe/Recipes.java | 98 +-- src/api/java/ic2/api/recipe/package-info.java | 4 +- .../java/ic2/api/tile/ExplosionWhitelist.java | 58 +- src/api/java/ic2/api/tile/IEnergyStorage.java | 92 +-- src/api/java/ic2/api/tile/IWrenchable.java | 90 +-- src/api/java/ic2/api/tile/package-info.java | 4 +- src/api/java/ic2/api/util/IKeyboard.java | 23 +- src/api/java/ic2/api/util/Keys.java | 2 +- src/api/java/ic2/api/util/package-info.java | 4 +- 85 files changed, 2979 insertions(+), 2916 deletions(-) create mode 100644 src/api/java/ic2/api/energy/NodeStats.java diff --git a/src/api/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java index ecfdee2d..894e8979 100644 --- a/src/api/java/ic2/api/Direction.java +++ b/src/api/java/ic2/api/Direction.java @@ -9,118 +9,120 @@ import net.minecraftforge.common.util.ForgeDirection; * Represents the 6 possible directions along the axis of a block. */ public enum Direction { - /** - * -X - */ - XN(0), - /** - * +X - */ - XP(1), + /** + * -X + */ + XN(0), + /** + * +X + */ + XP(1), - /** - * -Y - */ - YN(2), //MC-Code starts with 0 here - /** - * +Y - */ - YP(3), // 1... + /** + * -Y + */ + YN(2), //MC-Code starts with 0 here + /** + * +Y + */ + YP(3), // 1... - /** - * -Z - */ - ZN(4), - /** - * +Z - */ - ZP(5); + /** + * -Z + */ + ZN(4), + /** + * +Z + */ + ZP(5); - Direction(int dir1) { - this.dir = dir1; - } + public static Direction fromSideValue(int side) { + return directions[(side + 2) % 6]; + } - /*public CoordinateTuple ApplyToCoordinates(CoordinateTuple coordinates) { - CoordinateTuple ret = new CoordinateTuple(coordinates); + public static Direction fromForgeDirection(ForgeDirection dir) { + if (dir == ForgeDirection.UNKNOWN) return null; - ret.coords[dir/2] += GetSign(); + return fromSideValue(dir.ordinal()); + } - return ret; - }*/ + private Direction(int dir1) { + this.dir = dir1; + } - /** - * Get the tile entity next to a tile entity following this direction. - * - * @param tileEntity tile entity to check - * @return Adjacent tile entity or null if none exists - */ - public TileEntity applyToTileEntity(TileEntity te) { - return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); - } + /** + * Get the tile entity next to a tile entity following this direction. + * + * @param tileEntity tile entity to check + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyToTileEntity(TileEntity te) { + return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); + } - /** - * Get the tile entity next to a position following this direction. - * - * @param world World to check - * @param x X coordinate to check from - * @param y Y coordinate to check from - * @param z Z coordinate to check from - * @return Adjacent tile entity or null if none exists - */ - public TileEntity applyTo(World world, int x, int y, int z) { - int coords[] = {x, y, z}; + /** + * Get the tile entity next to a position following this direction. + * + * @param world World to check + * @param x X coordinate to check from + * @param y Y coordinate to check from + * @param z Z coordinate to check from + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyTo(World world, int x, int y, int z) { + int coords[] = { x, y, z }; - coords[dir / 2] += getSign(); + coords[dir/2] += getSign(); - if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { - try { - return world.getTileEntity(coords[0], coords[1], coords[2]); - } catch (Exception e) { - throw new RuntimeException("error getting TileEntity at dim " + world.provider.dimensionId + " " + coords[0] + "/" + coords[1] + "/" + coords[2]); - } - } + if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { + try { + return world.getTileEntity(coords[0], coords[1], coords[2]); + } catch (Exception e) { + throw new RuntimeException("error getting TileEntity at dim "+world.provider.dimensionId+" "+coords[0]+"/"+coords[1]+"/"+coords[2]); + } + } - return null; - } + return null; + } - /** - * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) - * - * @return Inverse direction - */ - public Direction getInverse() { - int inverseDir = dir - getSign(); + /** + * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) + * + * @return Inverse direction + */ + public Direction getInverse() { + int inverseDir = dir - getSign(); - for (Direction direction : directions) { - if (direction.dir == inverseDir) return direction; - } + for (Direction direction : directions) { + if (direction.dir == inverseDir) return direction; + } - return this; - } + return this; + } - /** - * Convert this direction to a Minecraft side value. - * - * @return Minecraft side value - */ - public int toSideValue() { - return (dir + 4) % 6; - } + /** + * Convert this direction to a Minecraft side value. + * + * @return Minecraft side value + */ + public int toSideValue() { + return (dir + 4) % 6; + } - /** - * Determine direction sign (N for negative or P for positive). - * - * @return -1 if the direction is negative, +1 if the direction is positive - */ - private int getSign() { - return (dir % 2) * 2 - 1; - } + /** + * Determine direction sign (N for negative or P for positive). + * + * @return -1 if the direction is negative, +1 if the direction is positive + */ + private int getSign() { + return (dir % 2) * 2 - 1; + } - public ForgeDirection toForgeDirection() { - return ForgeDirection.getOrientation(toSideValue()); - } + public ForgeDirection toForgeDirection() { + return ForgeDirection.getOrientation(toSideValue()); + } - private int dir; - public static final Direction[] directions = Direction.values(); + private int dir; + public static final Direction[] directions = Direction.values(); } diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java index 38a1a216..de6296b3 100644 --- a/src/api/java/ic2/api/crops/BaseSeed.java +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -4,53 +4,53 @@ package ic2.api.crops; * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. */ public class BaseSeed { - /** - * Plant ID. - */ - public int id; + /** + * Plant ID. + */ + public int id; - /** - * Plant size. - */ - public int size; + /** + * Plant size. + */ + public int size; - /** - * Plant growth stat. - */ - public int statGrowth; + /** + * Plant growth stat. + */ + public int statGrowth; - /** - * Plant gain stat. - */ - public int statGain; + /** + * Plant gain stat. + */ + public int statGain; - /** - * Plant resistance stat. - */ - public int statResistance; + /** + * Plant resistance stat. + */ + public int statResistance; - /** - * For internal usage only. - */ - public int stackSize; + /** + * For internal usage only. + */ + public int stackSize; - /** - * Create a BaseSeed object. - * - * @param id1 plant ID - * @param size1 plant size - * @param statGrowth1 plant growth stat - * @param statGain1 plant gain stat - * @param statResistance1 plant resistance stat - * @param stackSize1 for internal usage only - */ - public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) { - super(); - this.id = id1; - this.size = size1; - this.statGrowth = statGrowth1; - this.statGain = statGain1; - this.statResistance = statResistance1; - this.stackSize = stackSize1; - } + /** + * Create a BaseSeed object. + * + * @param id1 plant ID + * @param size1 plant size + * @param statGrowth1 plant growth stat + * @param statGain1 plant gain stat + * @param statResistance1 plant resistance stat + * @param stackSize1 for internal usage only + */ + public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) { + super(); + this.id = id1; + this.size = size1; + this.statGrowth = statGrowth1; + this.statGain = statGain1; + this.statResistance = statResistance1; + this.stackSize = stackSize1; + } } diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java index 0df1b512..e8237bc4 100644 --- a/src/api/java/ic2/api/crops/CropCard.java +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -12,360 +12,356 @@ import cpw.mods.fml.relauncher.SideOnly; /** * Base agriculture crop. - *

+ * * Any crop extending this can be registered using registerCrop to be added into the game. */ public abstract class CropCard { - /** - * Plant name. Will be displayed to the player. - * - * @return Plant name - */ - public abstract String name(); + /** + * Plant name. Will be displayed to the player. + * + * @return Plant name + */ + public abstract String name(); - /** - * Your name here, will be shown in "Discovered by:" when analyzing seeds. - * - * @return Your name - */ - public String discoveredBy() { - return "Alblaka"; - } + /** + * Your name here, will be shown in "Discovered by:" when analyzing seeds. + * + * @return Your name + */ + public String discoveredBy() {return "IC2 Team";} - /** - * Description of your plant. Keep it short, a few characters per line for up to two lines. - * Default is showing attributes of your plant, 2 per line. - * - * @param i line to get, starting from 0 - * @return The line - */ - public String desc(int i) { - String[] att = attributes(); - if (att == null || att.length == 0) return ""; - if (i == 0) { - String s = att[0]; - if (att.length >= 2) { - s += ", " + att[1]; - if (att.length >= 3) s += ","; - } - return s; - } - if (att.length < 3) return ""; - String s = att[2]; - if (att.length >= 4) s += ", " + att[3]; - return s; - } + /** + * Description of your plant. Keep it short, a few characters per line for up to two lines. + * Default is showing attributes of your plant, 2 per line. + * + * @param i line to get, starting from 0 + * @return The line + */ + public String desc(int i) { + String[] att = attributes(); + if (att == null || att.length == 0) return ""; + if (i == 0) { + String s = att[0]; + if (att.length >= 2) { + s+=", "+att[1]; + if (att.length >= 3) s+=","; + } + return s; + } + if (att.length < 3) return ""; + String s = att[2]; + if (att.length >= 4) s+=", "+att[3]; + return s; + } - /** - * Tier of the plant. Ranges from 1 to 16, 0 is Weed. - * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. - * - * @return Tier - */ - public abstract int tier(); + /** + * Tier of the plant. Ranges from 1 to 16, 0 is Weed. + * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. + * + * @return Tier + */ + public abstract int tier(); - /** - * Describe the plant through a set of stats, influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - *

- * Stats: - * - 0: Chemistry (Industrial uses based on chemical plant components) - * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) - * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) - * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) - * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) - * - * @param n index of the requested stat - * @return The requested value of the stats - */ - public abstract int stat(int n); + /** + * Describe the plant through a set of stats, influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + * + * Stats: + * - 0: Chemistry (Industrial uses based on chemical plant components) + * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) + * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) + * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) + * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) + * + * @param n index of the requested stat + * @return The requested value of the stats + */ + public abstract int stat(int n); - /** - * Additional attributes of the plant, also influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - * - * @return Attributes as an array of strings - */ - public abstract String[] attributes(); + /** + * Additional attributes of the plant, also influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + * + * @return Attributes as an array of strings + */ + public abstract String[] attributes(); - /** - * Determine the max crop size. - *

- * Currently only used for texture allocation. - */ - public abstract int maxSize(); + /** + * Determine the max crop size. + * + * Currently only used for texture allocation. + */ + public abstract int maxSize(); - /** - * Instantiate your Icons here. - *

- * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public void registerSprites(IIconRegister iconRegister) { - textures = new IIcon[maxSize()]; + /** + * Instantiate your Icons here. + * + * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + textures = new IIcon[maxSize()]; - for (int i = 1; i <= textures.length; i++) { - textures[i - 1] = iconRegister.registerIcon("ic2:crop/blockCrop." + name() + "." + i); - } - } + for (int i = 1; i <= textures.length; i++) { + textures[i-1] = iconRegister.registerIcon("ic2:crop/blockCrop."+name()+"."+i); + } + } - /** - * Sprite the crop is meant to be rendered with. - * - * @param crop reference to ICropTile - * @return 0-255, representing the sprite index on the crop's spritesheet. - */ - @SideOnly(Side.CLIENT) - public IIcon getSprite(ICropTile crop) { - if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; + /** + * Sprite the crop is meant to be rendered with. + * + * @param crop reference to ICropTile + * @return 0-255, representing the sprite index on the crop's spritesheet. + */ + @SideOnly(Side.CLIENT) + public IIcon getSprite(ICropTile crop) { + if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; - return textures[crop.getSize() - 1]; - } + return textures[crop.getSize() - 1]; + } - /** - * Get the crop's spritesheet. - * Per default crops_0.png of ic2-sprites - * - * @return Texture file path - */ - public String getTextureFile() { - return "/ic2/sprites/crops_0.png"; - } + /** + * Get the crop's spritesheet. + * Per default crops_0.png of ic2-sprites + * @return Texture file path + */ + public String getTextureFile() { + return "/ic2/sprites/crops_0.png"; + } - /** - * Amount of growth points needed to increase the plant's size. - * Default is 200 * tier. - */ - public int growthDuration(ICropTile crop) { - return tier() * 200; - } + /** + * Amount of growth points needed to increase the plant's size. + * Default is 200 * tier. + */ + public int growthDuration(ICropTile crop) { + return tier()*200; + } - /** - * Check whether the plant can grow further. - *

- * Consider: - * - Humidity, nutrients and air quality - * - Current size - * - Light level - * - Special biomes or conditions, accessible through crop.worldObj - *

- * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. - * - * @param crop reference to ICropTile - * @return Whether the crop can grow - */ - public abstract boolean canGrow(ICropTile crop); + /** + * Check whether the plant can grow further. + * + * Consider: + * - Humidity, nutrients and air quality + * - Current size + * - Light level + * - Special biomes or conditions, accessible through crop.worldObj + * + * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. + * + * @param crop reference to ICropTile + * @return Whether the crop can grow + */ + public abstract boolean canGrow(ICropTile crop); - /** - * Calculate the influence for the plant to grow based on humidity, nutrients and air. - * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. - * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) - *

- * Default is humidity + nutrients + air (no factors). - * - * @param crop reference to ICropTile - * @param humidity ground humidity, influenced by hydration - * @param nutrients nutrient quality in ground, based on fertilizers - * @param air air quality, influences by open gardens and less crops surrounding this one - * @return 0-30 - */ - public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { - return (int) (humidity + nutrients + air); - } + /** + * Calculate the influence for the plant to grow based on humidity, nutrients and air. + * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. + * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) + * + * Default is humidity + nutrients + air (no factors). + * + * @param crop reference to ICropTile + * @param humidity ground humidity, influenced by hydration + * @param nutrients nutrient quality in ground, based on fertilizers + * @param air air quality, influences by open gardens and less crops surrounding this one + * @return 0-30 + */ + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) (humidity+nutrients+air); + } - /** - * Used to determine whether the plant can crossbreed with another crop. - * Default is allow crossbreeding if the size is greater or equal than 3. - * - * @param crop crop to crossbreed with - */ - public boolean canCross(ICropTile crop) { - return crop.getSize() >= 3; - } + /** + * Used to determine whether the plant can crossbreed with another crop. + * Default is allow crossbreeding if the size is greater or equal than 3. + * + * @param crop crop to crossbreed with + */ + public boolean canCross(ICropTile crop) { + return crop.getSize() >= 3; + } - /** - * Called when the plant is rightclicked by a player. - * Default action is harvesting. - *

- * Only called Serverside. - * - * @param crop reference to ICropTile - * @param player player rightclicking the crop - * @return Whether the plant has changed - */ - public boolean rightclick(ICropTile crop, EntityPlayer player) { - return crop.harvest(true); - } + /** + * Called when the plant is rightclicked by a player. + * Default action is harvesting. + * + * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player rightclicking the crop + * @return Whether the plant has changed + */ + public boolean rightclick(ICropTile crop, EntityPlayer player) { + return crop.harvest(true); + } - /** - * Check whether the crop can be harvested. - * - * @param crop reference to ICropTile - * @return Whether the crop can be harvested in its current state. - */ - public abstract boolean canBeHarvested(ICropTile crop); + /** + * Use in Crop Havester with insert Cropnalyzer to get best Output. + * + * @param crop reference to ICropTile + * @return need crop size for best output. + */ - /** - * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. - * Default is 0.95^tier. - * - * @return Chance to drop the gains - */ - public float dropGainChance() { - float base = 1F; - for (int i = 0; i < tier(); i++) { - base *= 0.95; - } - return base; - } + public abstract int getOptimalHavestSize(ICropTile crop); - /** - * Item obtained from harvesting the plant. - * - * @param crop reference to ICropTile - * @return Item obtained - */ - public abstract ItemStack getGain(ICropTile crop); + /** + * Check whether the crop can be harvested. + * + * @param crop reference to ICropTile + * @return Whether the crop can be harvested in its current state. + */ + public abstract boolean canBeHarvested(ICropTile crop); - /** - * Get the size of the plant after harvesting. - * Default is 1. - * - * @param crop reference to ICropTile - * @return Plant size after harvesting - */ - public byte getSizeAfterHarvest(ICropTile crop) { - return 1; - } + /** + * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. + * Default is 0.95^tier. + * + * @return Chance to drop the gains + */ + public float dropGainChance() { + float base = 1F; + for (int i = 0; i < tier(); i++) {base*=0.95;} + return base; + } + + /** + * Item obtained from harvesting the plant. + * + * @param crop reference to ICropTile + * @return Item obtained + */ + public abstract ItemStack getGain(ICropTile crop); + + /** + * Get the size of the plant after harvesting. + * Default is 1. + * + * @param crop reference to ICropTile + * @return Plant size after harvesting + */ + public byte getSizeAfterHarvest(ICropTile crop) {return 1;} - /** - * Called when the plant is leftclicked by a player. - * Default action is picking the plant. - *

- * Only called Serverside. - * - * @param crop reference to ICropTile - * @param player player leftclicked the crop - * @return Whether the plant has changed - */ - public boolean leftclick(ICropTile crop, EntityPlayer player) { - return crop.pick(true); - } + /** + * Called when the plant is leftclicked by a player. + * Default action is picking the plant. + * + * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player leftclicked the crop + * @return Whether the plant has changed + */ + public boolean leftclick(ICropTile crop, EntityPlayer player) { + return crop.pick(true); + } - /** - * Base chance for dropping seeds when the plant is picked. - * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. - * - * @param crop reference to ICropTile - * @return Chance to drop the seeds - */ - public float dropSeedChance(ICropTile crop) { - if (crop.getSize() == 1) return 0; - float base = 0.5F; - if (crop.getSize() == 2) base /= 2F; - for (int i = 0; i < tier(); i++) { - base *= 0.8; - } - return base; - } + /** + * Base chance for dropping seeds when the plant is picked. + * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. + * + * @param crop reference to ICropTile + * @return Chance to drop the seeds + */ + public float dropSeedChance(ICropTile crop) { + if (crop.getSize() == 1) return 0; + float base = 0.5F; + if (crop.getSize() == 2) base/=2F; + for (int i = 0; i < tier(); i++) {base*=0.8;} + return base; + } - /** - * Obtain seeds dropped when the plant is picked. - * Multiple drops of the returned ItemStack can occur. - * Default action is generating a seed from this crop. - * - * @param crop reference to ICropTile - * @return Seeds - */ - public ItemStack getSeeds(ICropTile crop) { - return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); - } + /** + * Obtain seeds dropped when the plant is picked. + * Multiple drops of the returned ItemStack can occur. + * Default action is generating a seed from this crop. + * + * @param crop reference to ICropTile + * @return Seeds + */ + public ItemStack getSeeds(ICropTile crop) { + return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); + } - /** - * Called when a neighbor block to the crop has changed. - * - * @param crop reference to ICropTile - */ - public void onNeighbourChange(ICropTile crop) { - // - } + /** + * Called when a neighbor block to the crop has changed. + * + * @param crop reference to ICropTile + */ + public void onNeighbourChange(ICropTile crop) { + // + } - /** - * Check if the crop should emit redstone. - * - * @return Whether the crop should emit redstone - */ - public int emitRedstone(ICropTile crop) { - return 0; - } + /** + * Check if the crop should emit redstone. + * + * @return Whether the crop should emit redstone + */ + public int emitRedstone(ICropTile crop) {return 0;} - /** - * Called when the crop is destroyed. - * - * @param crop reference to ICropTile - */ - public void onBlockDestroyed(ICropTile crop) { - // - } + /** + * Called when the crop is destroyed. + * + * @param crop reference to ICropTile + */ + public void onBlockDestroyed(ICropTile crop) { + // + } - /** - * Get the light value emitted by the plant. - * - * @param crop reference to ICropTile - * @return Light value emitted - */ - public int getEmittedLight(ICropTile crop) { - return 0; - } + /** + * Get the light value emitted by the plant. + * + * @param crop reference to ICropTile + * @return Light value emitted + */ + public int getEmittedLight(ICropTile crop) {return 0;} - /** - * Default is true if the entity is an EntityLiving in jumping or sprinting state. - * - * @param crop reference to ICropTile - * @param entity entity colliding - * @return Whether trampling calculation should happen, return false if the plant is no longer valid. - */ - public boolean onEntityCollision(ICropTile crop, Entity entity) { - if (entity instanceof EntityLivingBase) { - return ((EntityLivingBase) entity).isSprinting(); - } - return false; - } + /** + * Default is true if the entity is an EntityLiving in jumping or sprinting state. + * + * @param crop reference to ICropTile + * @param entity entity colliding + * @return Whether trampling calculation should happen, return false if the plant is no longer valid. + */ + public boolean onEntityCollision(ICropTile crop, Entity entity) { + if (entity instanceof EntityLivingBase) { + return ((EntityLivingBase) entity).isSprinting(); + } + return false; + } - /** - * Called every time the crop ticks. - * Should be called every 256 ticks or around 13 seconds. - * - * @param crop reference to ICropTile - */ - public void tick(ICropTile crop) { - // - } + /** + * Called every time the crop ticks. + * Should be called every 256 ticks or around 13 seconds. + * + * @param crop reference to ICropTile + */ + public void tick(ICropTile crop) { + // + } - /** - * Check whether this plant spreads weed to surrounding tiles. - * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. - * - * @param crop reference to ICropTile - * @return Whether the plant spreads weed - */ - public boolean isWeed(ICropTile crop) { - return crop.getSize() >= 2 && (crop.getID() == 0 || crop.getGrowth() >= 24); - } + /** + * Check whether this plant spreads weed to surrounding tiles. + * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. + * + * @param crop reference to ICropTile + * @return Whether the plant spreads weed + */ + public boolean isWeed(ICropTile crop) { + return crop.getSize() >= 2 && (crop.getID() == 0 || crop.getGrowth() >= 24); + } - /** - * Get this plant's ID. - * - * @return ID of this CropCard or -1 if it's not registered - */ - public final int getId() { - return Crops.instance.getIdFor(this); - } + /** + * Get this plant's ID. + * + * @return ID of this CropCard or -1 if it's not registered + */ + public final int getId() { + return Crops.instance.getIdFor(this); + } - @SideOnly(Side.CLIENT) - protected IIcon textures[]; + @SideOnly(Side.CLIENT) + protected IIcon textures[]; } diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/api/java/ic2/api/crops/Crops.java index 3f16665a..53cc3239 100644 --- a/src/api/java/ic2/api/crops/Crops.java +++ b/src/api/java/ic2/api/crops/Crops.java @@ -13,105 +13,105 @@ import net.minecraftforge.common.BiomeDictionary.Type; * General management of the crop system. */ public abstract class Crops { - public static Crops instance; + public static Crops instance; - /** - * Adds a crop humidity and nutrient biome bonus. - *

- * 0 indicates no bonus and negative values indicate a penalty. - * - * @param biome Biome to apply the bonus in - * @param humidityBonus Humidity stat bonus - * @param nutrientsBonus Nutrient stat bonus - */ - public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); + /** + * Adds a crop humidity and nutrient biome bonus. + * + * 0 indicates no bonus and negative values indicate a penalty. + * + * @param biome Biome to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); - /** - * Adds a crop humidity and nutrient biome bonus. - *

- * 0 indicates no bonus and negative values indicate a penalty. - * - * @param type Forge biome type to apply the bonus in - * @param humidityBonus Humidity stat bonus - * @param nutrientsBonus Nutrient stat bonus - */ - public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus); + /** + * Adds a crop humidity and nutrient biome bonus. + * + * 0 indicates no bonus and negative values indicate a penalty. + * + * @param type Forge biome type to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus); - /** - * Gets the humidity bonus for a biome. - * - * @param biome Biome to check - * @return Humidity bonus or 0 if none - */ - public abstract int getHumidityBiomeBonus(BiomeGenBase biome); + /** + * Gets the humidity bonus for a biome. + * + * @param biome Biome to check + * @return Humidity bonus or 0 if none + */ + public abstract int getHumidityBiomeBonus(BiomeGenBase biome); - /** - * Gets the nutrient bonus for a biome. - * - * @param biome Biome to check - * @return Nutrient bonus or 0 if none - */ - public abstract int getNutrientBiomeBonus(BiomeGenBase biome); + /** + * Gets the nutrient bonus for a biome. + * + * @param biome Biome to check + * @return Nutrient bonus or 0 if none + */ + public abstract int getNutrientBiomeBonus(BiomeGenBase biome); - /** - * Returns the list of registered crops. - * - * @return Registered crops by ID - */ - public abstract CropCard[] getCropList(); + /** + * Returns the list of registered crops. + * + * @return Registered crops by ID + */ + public abstract CropCard[] getCropList(); - /** - * Auto-assign an ID to a plant and register it. - * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. - * - * @param crop plant to register - * @return The ID assigned to the plant - */ - public abstract short registerCrop(CropCard crop); + /** + * Auto-assign an ID to a plant and register it. + * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. + * + * @param crop plant to register + * @return The ID assigned to the plant + */ + public abstract short registerCrop(CropCard crop); - /** - * Attempt to register a plant to an ID. - * If the ID is taken, the crop will not be registered and a console print will notify the user. - * - * @param crop plant to register - * @param i ID to register the plant to - * @return Whether the crop was registered - */ - public abstract boolean registerCrop(CropCard crop, int i); + /** + * Attempt to register a plant to an ID. + * If the ID is taken, the crop will not be registered and a console print will notify the user. + * + * @param crop plant to register + * @param i ID to register the plant to + * @return Whether the crop was registered + */ + public abstract boolean registerCrop(CropCard crop, int i); - /** - * Registers a base seed, an item used to plant a crop. - * - * @param stack item - * @param id plant ID - * @param size initial size - * @param growth initial growth stat - * @param gain initial gain stat - * @param resistance initial resistance stat - * @return True if successful - */ - public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); + /** + * Registers a base seed, an item used to plant a crop. + * + * @param stack item + * @param id plant ID + * @param size initial size + * @param growth initial growth stat + * @param gain initial gain stat + * @param resistance initial resistance stat + * @return True if successful + */ + public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); - /** - * Finds a base seed from the given item. - * - * @return Base seed or null if none found - */ - public abstract BaseSeed getBaseSeed(ItemStack stack); + /** + * Finds a base seed from the given item. + * + * @return Base seed or null if none found + */ + public abstract BaseSeed getBaseSeed(ItemStack stack); - /** - * Execute registerSprites for all registered crop cards. - *

- * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public abstract void startSpriteRegistration(IIconRegister iconRegister); + /** + * Execute registerSprites for all registered crop cards. + * + * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public abstract void startSpriteRegistration(IIconRegister iconRegister); - /** - * Returns the ID for the given crop. - * - * @param crop Crop to look up - * @return ID, or -1 if not found - */ - public abstract int getIdFor(CropCard crop); + /** + * Returns the ID for the given crop. + * + * @param crop Crop to look up + * @return ID, or -1 if not found + */ + public abstract int getIdFor(CropCard crop); } diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java index b85820f9..09b46d79 100644 --- a/src/api/java/ic2/api/crops/ICropTile.java +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -10,241 +10,255 @@ import net.minecraft.world.World; * Interface implemented by the crop tile entity. */ public interface ICropTile { - /** - * Get the crop's plant ID. - * - * @return Plant ID, or -1 if there is no plant currently on the crop - */ - public short getID(); + /** + * Get the crop's plant ID. + * + * @return Plant ID, or -1 if there is no plant currently on the crop + */ + public short getID(); - /** - * Set the crop's plant ID. - * - * @param id Plant ID, or -1 for no plant - */ - public void setID(short id); + /** + * Set the crop's plant ID. + * + * @param id Plant ID, or -1 for no plant + */ + public void setID(short id); - /** - * Get the crop's plant size. - * - * @return Plant size, starting with 1 and maximum varies depending on plant - */ - public byte getSize(); + /** + * Get the crop's plant size. + * + * @return Plant size, starting with 1 and maximum varies depending on plant + */ + public byte getSize(); - /** - * Set the crop's plant size. - * - * @param size Plant size - */ - public void setSize(byte size); + /** + * Set the crop's plant size. + * + * @param size Plant size + */ + public void setSize(byte size); - /** - * Get the crop's plant growth stat. - * Higher values indicate faster growth. - * - * @return Plant growth stat - */ - public byte getGrowth(); + /** + * Get the crop's plant growth stat. + * Higher values indicate faster growth. + * + * @return Plant growth stat + */ + public byte getGrowth(); - /** - * Set the crop's plant growth stat. - * - * @param growth Plant growth stat - */ - public void setGrowth(byte growth); + /** + * Set the crop's plant growth stat. + * + * @param growth Plant growth stat + */ + public void setGrowth(byte growth); - /** - * Get the crop's plant gain stat. - * Higher values indicate more drops. - * - * @return Plant gain stat - */ - public byte getGain(); + /** + * Get the crop's plant gain stat. + * Higher values indicate more drops. + * + * @return Plant gain stat + */ + public byte getGain(); - /** - * Set the crop's plant gain stat. - * - * @param gain Plant gain stat - */ - public void setGain(byte gain); + /** + * Set the crop's plant gain stat. + * + * @param gain Plant gain stat + */ + public void setGain(byte gain); - /** - * Get the crop's plant resistance stat. - * Higher values indicate more resistance against trampling. - * - * @return Plant resistance stat - */ - public byte getResistance(); + /** + * Get the crop's plant resistance stat. + * Higher values indicate more resistance against trampling. + * + * @return Plant resistance stat + */ + public byte getResistance(); - /** - * Set the crop's plant resistance stat. - * - * @param resistance Plant resistance stat - */ - public void setResistance(byte resistance); + /** + * Set the crop's plant resistance stat. + * + * @param resistance Plant resistance stat + */ + public void setResistance(byte resistance); - /** - * Get the crop's plant scan level. - * Increases every time the seed is analyzed. - * - * @return Plant scan level - */ - public byte getScanLevel(); + /** + * Get the crop's plant scan level. + * Increases every time the seed is analyzed. + * + * @return Plant scan level + */ + public byte getScanLevel(); - /** - * Set the crop's plant scan level. - * - * @param scanLevel Plant scan level - */ - public void setScanLevel(byte scanLevel); + /** + * Set the crop's plant scan level. + * + * @param scanLevel Plant scan level + */ + public void setScanLevel(byte scanLevel); - /** - * Get the crop's plant custom data, stored alongside the crop. - * Can be modified in place. - * - * @return Plant custom data - */ - public NBTTagCompound getCustomData(); + /** + * Get the crop's plant custom data, stored alongside the crop. + * Can be modified in place. + * + * @return Plant custom data + */ + public NBTTagCompound getCustomData(); - /** - * Get the crop's nutrient storage. - * Ranges from 0 to 100. - * - * @return Crop nutrient storage - */ - public int getNutrientStorage(); + /** + * Get the crop's nutrient storage. + * Ranges from 0 to 100. + * + * @return Crop nutrient storage + */ + public int getNutrientStorage(); - /** - * Set the crop's nutrient storage. - * - * @param nutrientStorage Crop nutrient storage - */ - public void setNutrientStorage(int nutrientStorage); + /** + * Set the crop's nutrient storage. + * + * @param nutrientStorage Crop nutrient storage + */ + public void setNutrientStorage(int nutrientStorage); - /** - * Get the crop's hydration storage. - * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. - * - * @return Crop hydration storage - */ - public int getHydrationStorage(); + /** + * Get the crop's hydration storage. + * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. + * + * @return Crop hydration storage + */ + public int getHydrationStorage(); - /** - * Set the crop's hydration storage. - * - * @param hydrationStorage Crop hydration storage - */ - public void setHydrationStorage(int hydrationStorage); + /** + * Set the crop's hydration storage. + * + * @param hydrationStorage Crop hydration storage + */ + public void setHydrationStorage(int hydrationStorage); - /** - * Get the crop's Weed-Ex storage. - * - * @return Crop Weed-Ex storage - */ - public int getWeedExStorage(); + /** + * Get the crop's Weed-Ex storage. + * + * @return Crop Weed-Ex storage + */ + public int getWeedExStorage(); - /** - * Set the crop's Weed-Ex storage. - * - * @param weedExStorage Crop Weed-Ex storage - */ - public void setWeedExStorage(int weedExStorage); + /** + * Set the crop's Weed-Ex storage. + * + * @param weedExStorage Crop Weed-Ex storage + */ + public void setWeedExStorage(int weedExStorage); - /** - * Get the crop's humidity. - * Ranges from 0 (dry) to 10 (humid). - * Updates every couple of seconds or when an update is requested. - * - * @return Crop humidity level - * @see #updateState() - */ - public byte getHumidity(); + /** + * Get the crop's humidity. + * Ranges from 0 (dry) to 10 (humid). + * Updates every couple of seconds or when an update is requested. + * + * @see #updateState() + * + * @return Crop humidity level + */ + public byte getHumidity(); - /** - * Get the crop's nutrient level. - * Ranges from 0 (empty) to 10 (full). - * Updates every couple of seconds or when an update is requested. - * - * @return Crop nutrient level - * @see #updateState() - */ - public byte getNutrients(); + /** + * Get the crop's nutrient level. + * Ranges from 0 (empty) to 10 (full). + * Updates every couple of seconds or when an update is requested. + * + * @see #updateState() + * + * @return Crop nutrient level + */ + public byte getNutrients(); - /** - * Get the crop's air quality. - * Ranges from 0 (cluttered) to 10 (fresh). - * Updates every couple of seconds or when an update is requested. - * - * @return Crop air quality - * @see #updateState() - */ - public byte getAirQuality(); + /** + * Get the crop's air quality. + * Ranges from 0 (cluttered) to 10 (fresh). + * Updates every couple of seconds or when an update is requested. + * + * @see #updateState() + * + * @return Crop air quality + */ + public byte getAirQuality(); - /** - * Get the crop's world. - * - * @return Crop world - */ - public World getWorld(); + /** + * Get the crop's world. + * + * @return Crop world + */ + public World getWorld(); - /** - * Get the crop's location. - * - * @return Crop location - */ - public ChunkCoordinates getLocation(); + /** + * Get the crop's location. + * + * @return Crop location + */ + public ChunkCoordinates getLocation(); - /** - * Get the crop's light level. - * - * @return Crop light level - */ - public int getLightLevel(); + /** + * Get the crop's light level. + * + * @return Crop light level + */ + public int getLightLevel(); - /** - * Pick the crop, removing and giving seeds for the plant. - * - * @param manual whether it was done by hand (not automated) - * @return true if successfully picked - */ - public boolean pick(boolean manual); + /** + * Pick the crop, removing and giving seeds for the plant. + * + * @param manual whether it was done by hand (not automated) + * @return true if successfully picked + */ + public boolean pick(boolean manual); - /** - * Harvest the crop, turning it into gain and resetting its size. - * - * @param manual whether it one by hand (not automated) - * @return true if successfully harvested - */ - public boolean harvest(boolean manual); + /** + * Harvest the crop, turning it into gain and resetting its size. + * drop output on ground + * @param manual + * @return true if successfully harvested + */ + public boolean harvest(boolean manual); - /** - * Fully clears the crop without dropping anything. - */ - public void reset(); + /** + * Harvest the crop, turning it into gain and resetting its size. + * drop output on ground + * @param Optimal force check getOptimalHavestSize() for harvest + * @return ItemStack[] of harvest output + */ - /** - * Request a texture and lighting update. - */ - public void updateState(); + ItemStack[] harvest_automated(boolean Optimal); + + /** + * Fully clears the crop without dropping anything. + */ + public void reset(); + + /** + * Request a texture and lighting update. + */ + public void updateState(); + + /** + * Check if a block is under the farmland containing the crop. + * Searches up to 2 blocks below the farmland or an air space, whichever appears first. + * + * @param block block to search + * @return Whether the block was found + */ + public boolean isBlockBelow(Block block); + + /** + * Generate plant seeds with the given parameters. + * + * @param plant plant ID + * @param growth plant growth stat + * @param gain plant gain stat + * @param resis plant resistance stat + * @param scan plant scan level + * @return Plant seed item + */ + public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); - /** - * Check if a block is under the farmland containing the crop. - * Searches up to 2 blocks below the farmland or an air space, whichever appears first. - * - * @param block block to search - * @return Whether the block was found - */ - public boolean isBlockBelow(Block block); - /** - * Generate plant seeds with the given parameters. - * - * @param plant plant ID - * @param growth plant growth stat - * @param gain plant gain stat - * @param resis plant resistance stat - * @param scan plant scan level - * @return Plant seed item - */ - public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); } diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/api/java/ic2/api/crops/package-info.java index f5041cdc..04b82539 100644 --- a/src/api/java/ic2/api/crops/package-info.java +++ b/src/api/java/ic2/api/crops/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.crops; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.crops; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/EnergyNet.java b/src/api/java/ic2/api/energy/EnergyNet.java index 9ddf6b86..822bfc29 100644 --- a/src/api/java/ic2/api/energy/EnergyNet.java +++ b/src/api/java/ic2/api/energy/EnergyNet.java @@ -3,16 +3,16 @@ package ic2.api.energy; /** * Provides access to the energy network. - *

+ * * The old EnergyNet methods missing in IEnergyNet have been migrated to events (load, unload) or * removed (tiles no longer emit energy actively, the energy net implementation requests it). - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public final class EnergyNet { - /** - * Instance of the global EnergyNet class. - */ - public static IEnergyNet instance; + /** + * Instance of the global EnergyNet class. + */ + public static IEnergyNet instance; } diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java index d24d3acf..8f656e50 100644 --- a/src/api/java/ic2/api/energy/IEnergyNet.java +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -7,68 +7,80 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Interface representing the methods provided by the global EnergyNet class. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyNet { - /** - * Get the EnergyNet-registered tile entity at the specified position. - *

- * This is not the same as World.getTileEntity(), it's possible to register delegate tile - * entities with the energy net which are different from what's actually in the world. Those - * delegates allow to use separate TileEntity objects just for the EnergyNet interfaces, - * simplifying cross-mod dependencies and multi-blocks. - * - * @param world World containing the tile entity - * @param x x-coordinate - * @param y y-coordinate - * @param z z-coordinate - * @return tile entity registered to the energy net or null if none is registered - */ - TileEntity getTileEntity(World world, int x, int y, int z); + /** + * Get the EnergyNet-registered tile entity at the specified position. + * + * This is not the same as World.getTileEntity(), it's possible to register delegate tile + * entities with the energy net which are different from what's actually in the world. Those + * delegates allow to use separate TileEntity objects just for the EnergyNet interfaces, + * simplifying cross-mod dependencies and multi-blocks. + * + * @param world World containing the tile entity + * @param x x-coordinate + * @param y y-coordinate + * @param z z-coordinate + * @return tile entity registered to the energy net or null if none is registered + */ + TileEntity getTileEntity(World world, int x, int y, int z); - /** - * Get the EnergyNet-registered neighbor tile entity at the specified position. - * - * @param te TileEntity indicating the world and position to search from - * @param dir direction the neighbor is to be found - * @return neighbor tile entity registered to the energy net or null if none is registered - */ - TileEntity getNeighbor(TileEntity te, ForgeDirection dir); + /** + * Get the EnergyNet-registered neighbor tile entity at the specified position. + * + * @param te TileEntity indicating the world and position to search from + * @param dir direction the neighbor is to be found + * @return neighbor tile entity registered to the energy net or null if none is registered + */ + TileEntity getNeighbor(TileEntity te, ForgeDirection dir); - /** - * determine how much energy has been emitted by the EnergyEmitter specified - * - * @param tileEntity energy emitter - * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick - * @deprecated Discontinued, use getNodeStats instead. - */ - @Deprecated - double getTotalEnergyEmitted(TileEntity tileEntity); + /** + * determine how much energy has been emitted by the EnergyEmitter specified + * + * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick + * + * @param tileEntity energy emitter + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergyEmitted(TileEntity tileEntity); - /** - * determine how much energy has been sunken by the EnergySink specified - * - * @param tileEntity energy emitter - * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick - * @deprecated Discontinued, use getNodeStats instead. - */ - @Deprecated - double getTotalEnergySunken(TileEntity tileEntity); + /** + * determine how much energy has been sunken by the EnergySink specified + * + * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick + * + * @param tileEntity energy emitter + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergySunken(TileEntity tileEntity); - /** - * Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2. - * - * @param tier tier - * @return power in eu/t - */ - double getPowerFromTier(int tier); + /** + * Retrieve statistics for the tile entity specified. + * + * The statistics apply to the last simulated tick. + * + * @param te Tile entity to check. + * @return Statistics for the tile entity. + */ + NodeStats getNodeStats(TileEntity te); - /** - * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. - * - * @param power in eu/t - * @return tier - */ - int getTierFromPower(double power); + /** + * Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2. + * + * @param tier tier + * @return power in eu/t + */ + double getPowerFromTier(int tier); + + /** + * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. + * + * @param power in eu/t + * @return tier + */ + int getTierFromPower(double power); } diff --git a/src/api/java/ic2/api/energy/NodeStats.java b/src/api/java/ic2/api/energy/NodeStats.java new file mode 100644 index 00000000..c55fd4e4 --- /dev/null +++ b/src/api/java/ic2/api/energy/NodeStats.java @@ -0,0 +1,25 @@ +package ic2.api.energy; + +public class NodeStats { + public NodeStats(double energyIn, double energyOut, double voltage) { + this.energyIn = energyIn; + this.energyOut = energyOut; + this.voltage = voltage; + } + + public double getEnergyIn() { + return energyIn; + } + + public double getEnergyOut() { + return energyOut; + } + + public double getVoltage() { + return voltage; + } + + private final double energyIn; + private final double energyOut; + private final double voltage; +} diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java index 1b824672..2182e497 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java @@ -8,16 +8,16 @@ import ic2.api.energy.tile.IEnergyTile; /** * Base class for energy net events, don't use it directly. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileEvent extends WorldEvent { - public final IEnergyTile energyTile; + public final IEnergyTile energyTile; - public EnergyTileEvent(IEnergyTile energyTile1) { - super(((TileEntity) energyTile1).getWorldObj()); + public EnergyTileEvent(IEnergyTile energyTile1) { + super(((TileEntity) energyTile1).getWorldObj()); - this.energyTile = energyTile1; - } + this.energyTile = energyTile1; + } } diff --git a/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java index d302f894..bf019ae3 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java @@ -4,23 +4,23 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing new energy tiles. - *

+ * * This event notifies subscribers of loaded energy tiles, e.g. after getting * loaded through the chunk they are in or after being placed down by the * player or another deployer mechanism. - *

+ * * Every energy tile which wants to get connected to the IC2 Energy Network has * to either post this event or alternatively call EnergyNet.addTileEntity(). - *

+ * * You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileLoadEvent extends EnergyTileEvent { - public EnergyTileLoadEvent(IEnergyTile energyTile1) { - super(energyTile1); - } + public EnergyTileLoadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java index 727c8a11..2b22ae31 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java @@ -4,24 +4,24 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing terminated energy tiles. - *

+ * * This event notifies subscribers of unloaded energy tiles, e.g. after getting * unloaded through the chunk they are in or after being destroyed by the * player or another block pick/destruction mechanism. - *

+ * * Every energy tile which wants to get disconnected from the IC2 Energy * Network has to either post this event or alternatively call * EnergyNet.removeTileEntity(). - *

+ * * You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileUnloadEvent extends EnergyTileEvent { - public EnergyTileUnloadEvent(IEnergyTile energyTile1) { - super(energyTile1); - } + public EnergyTileUnloadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java index f1cc9ea0..40db6f8a 100644 --- a/src/api/java/ic2/api/energy/event/package-info.java +++ b/src/api/java/ic2/api/energy/event/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.event; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.energy.event; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java index a92380fb..81d0bfed 100644 --- a/src/api/java/ic2/api/energy/package-info.java +++ b/src/api/java/ic2/api/energy/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.energy; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/api/java/ic2/api/energy/prefab/BasicSink.java index 461e6d04..48de0613 100644 --- a/src/api/java/ic2/api/energy/prefab/BasicSink.java +++ b/src/api/java/ic2/api/energy/prefab/BasicSink.java @@ -17,347 +17,357 @@ import ic2.api.item.ElectricItem; /** * BasicSink is a simple adapter to provide an ic2 energy sink. - *

+ * * It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a * one-time configurable input energy buffer, thus providing a common use case for machines. - *

+ * * Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended. * The delegate can be extended with additional functionality through a sub class though. - *

+ * * The constraints set by BasicSink like the strict tank-like energy buffering should provide a * more easy to use and stable interface than using IEnergySink directly while aiming for * optimal performance. - *

+ * * Using BasicSink involves the following steps: * - create a BasicSink instance in your TileEntity, typically in a field * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. * - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available - * without consuming the energy. + * without consuming the energy. * - optionally use getEnergyStored to display the output buffer charge level * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - *

- * Example implementation code: * - * @code{.java} public class SomeTileEntity extends TileEntity { - * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); - * @Override public void invalidate() { - * ic2EnergySink.invalidate(); // notify the energy sink - * ... - * super.invalidate(); // this is important for mc! - * } - * @Override public void onChunkUnload() { - * ic2EnergySink.onChunkUnload(); // notify the energy sink - * ... - * } - * @Override public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - *

- * ic2EnergySink.readFromNBT(tag); - * ... - * } - * @Override public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - *

- * ic2EnergySink.writeToNBT(tag); - * ... - * } - * @Override public void updateEntity() { - * ic2EnergySink.updateEntity(); // notify the energy sink - * ... - * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick - * ... // do something with the energy - * } - * ... - * } - *

- * ... + * Example implementation code: + * @code{.java} + * public class SomeTileEntity extends TileEntity { + * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); + * + * @Override + * public void invalidate() { + * ic2EnergySink.invalidate(); // notify the energy sink + * ... + * super.invalidate(); // this is important for mc! + * } + * + * @Override + * public void onChunkUnload() { + * ic2EnergySink.onChunkUnload(); // notify the energy sink + * ... + * } + * + * @Override + * public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + * + * ic2EnergySink.readFromNBT(tag); + * ... + * } + * + * @Override + * public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + * + * ic2EnergySink.writeToNBT(tag); + * ... + * } + * + * @Override + * public void updateEntity() { + * ic2EnergySink.updateEntity(); // notify the energy sink + * ... + * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick + * ... // do something with the energy + * } + * ... + * } + * + * ... * } * @endcode */ public class BasicSink extends TileEntity implements IEnergySink { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** + // ********************************** + // *** Methods for use by the mod *** + // ********************************** - /** - * Constructor for a new BasicSink delegate. - * - * @param parent1 TileEntity represented by this energy sink. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSink(TileEntity parent1, int capacity1, int tier1) { - this.parent = parent1; - this.capacity = capacity1; - this.tier = tier1; - } + /** + * Constructor for a new BasicSink delegate. + * + * @param parent1 TileEntity represented by this energy sink. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSink(TileEntity parent1, int capacity1, int tier1) { + this.parent = parent1; + this.capacity = capacity1; + this.tier = tier1; + } - // in-world te forwards >> + // in-world te forwards >> - /** - * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); - } + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } - /** - * Notification that the base TileEntity finished loaded, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { - worldObj = parent.getWorldObj(); - xCoord = parent.xCoord; - yCoord = parent.yCoord; - zCoord = parent.zCoord; + /** + * Notification that the base TileEntity finished loaded, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - addedToEnet = true; - } - } + addedToEnet = true; + } + } - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); - onChunkUnload(); - } + onChunkUnload(); + } - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - addedToEnet = false; - } - } + addedToEnet = false; + } + } - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); + NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); - energyStored = data.getDouble("energy"); - } + energyStored = data.getDouble("energy"); + } - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public void writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } - NBTTagCompound data = new NBTTagCompound(); + NBTTagCompound data = new NBTTagCompound(); - data.setDouble("energy", energyStored); + data.setDouble("energy", energyStored); - tag.setTag("IC2BasicSink", data); - } + tag.setTag("IC2BasicSink", data); + } - // << in-world te forwards - // methods for using this adapter >> + // << in-world te forwards + // methods for using this adapter >> - /** - * Get the maximum amount of energy this sink can hold in its buffer. - * - * @return Capacity in EU. - */ - public int getCapacity() { - return capacity; - } + /** + * Get the maximum amount of energy this sink can hold in its buffer. + * + * @return Capacity in EU. + */ + public int getCapacity() { + return capacity; + } - /** - * Set the maximum amount of energy this sink can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(int capacity1) { - this.capacity = capacity1; - } + /** + * Set the maximum amount of energy this sink can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(int capacity1) { + this.capacity = capacity1; + } - /** - * Get the IC2 energy tier for this sink. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } + /** + * Get the IC2 energy tier for this sink. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } - /** - * Set the IC2 energy tier for this sink. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - this.tier = tier1; - } + /** + * Set the IC2 energy tier for this sink. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + this.tier = tier1; + } - /** - * Determine the energy stored in the sink's input buffer. - * - * @return amount in EU, may be above capacity - */ - public double getEnergyStored() { - return energyStored; - } + /** + * Determine the energy stored in the sink's input buffer. + * + * @return amount in EU, may be above capacity + */ + public double getEnergyStored() { + return energyStored; + } - /** - * Set the stored energy to the specified amount. - *

- * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } + /** + * Set the stored energy to the specified amount. + * + * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } - /** - * Determine if the specified amount of energy is available. - * - * @param amount in EU - * @return true if the amount is available - */ - public boolean canUseEnergy(double amount) { - return energyStored >= amount; - } + /** + * Determine if the specified amount of energy is available. + * + * @param amount in EU + * @return true if the amount is available + */ + public boolean canUseEnergy(double amount) { + return energyStored >= amount; + } - /** - * Use the specified amount of energy, if available. - * - * @param amount amount to use - * @return true if the amount was available - */ - public boolean useEnergy(double amount) { - if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { - energyStored -= amount; + /** + * Use the specified amount of energy, if available. + * + * @param amount amount to use + * @return true if the amount was available + */ + public boolean useEnergy(double amount) { + if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { + energyStored -= amount; - return true; - } - return false; - } + return true; + } + return false; + } - /** - * Discharge the supplied ItemStack into this sink's energy buffer. - * - * @param stack ItemStack to discharge (null is ignored) - * @param limit Transfer limit, values <= 0 will use the battery's limit - * @return true if energy was transferred - */ - public boolean discharge(ItemStack stack, int limit) { - if (stack == null || !Info.isIc2Available()) return false; + /** + * Discharge the supplied ItemStack into this sink's energy buffer. + * + * @param stack ItemStack to discharge (null is ignored) + * @param limit Transfer limit, values <= 0 will use the battery's limit + * @return true if energy was transferred + */ + public boolean discharge(ItemStack stack, int limit) { + if (stack == null || !Info.isIc2Available()) return false; - double amount = capacity - energyStored; - if (amount <= 0) return false; + double amount = capacity - energyStored; + if (amount <= 0) return false; - if (limit > 0 && limit < amount) amount = limit; + if (limit > 0 && limit < amount) amount = limit; - amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); + amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); - energyStored += amount; + energyStored += amount; - return amount > 0; - } + return amount > 0; + } - // << methods for using this adapter + // << methods for using this adapter - // backwards compatibility (ignore these) >> + // backwards compatibility (ignore these) >> - @Deprecated - public void onUpdateEntity() { - updateEntity(); - } + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } - @Deprecated - public void onInvalidate() { - invalidate(); - } + @Deprecated + public void onInvalidate() { + invalidate(); + } - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } - // << backwards compatibility + // << backwards compatibility - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** - // energy net interface >> + // energy net interface >> - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { - return true; - } + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return true; + } - @Override - public double getDemandedEnergy() { - return Math.max(0, capacity - energyStored); - } + @Override + public double getDemandedEnergy() { + return Math.max(0, capacity - energyStored); + } - @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { - energyStored += amount; + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + energyStored += amount; - return 0; - } + return 0; + } - @Override - public int getSinkTier() { - return tier; - } + @Override + public int getSinkTier() { + return tier; + } - // << energy net interface + // << energy net interface - public final TileEntity parent; + public final TileEntity parent; - protected int capacity; - protected int tier; - protected double energyStored; - protected boolean addedToEnet; + protected int capacity; + protected int tier; + protected double energyStored; + protected boolean addedToEnet; } diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/api/java/ic2/api/energy/prefab/BasicSource.java index e5f74fa6..011e8cd3 100644 --- a/src/api/java/ic2/api/energy/prefab/BasicSource.java +++ b/src/api/java/ic2/api/energy/prefab/BasicSource.java @@ -18,347 +18,358 @@ import ic2.api.item.ElectricItem; /** * BasicSource is a simple adapter to provide an ic2 energy source. - *

+ * * It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a * one-time configurable output energy buffer, thus providing a common use case for generators. - *

+ * * Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended. * The delegate can be extended with additional functionality through a sub class though. - *

+ * * The constraints set by BasicSource like the strict tank-like energy buffering should provide a * more easy to use and stable interface than using IEnergySource directly while aiming for * optimal performance. - *

+ * * Using BasicSource involves the following steps: * - create a BasicSource instance in your TileEntity, typically in a field * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. * - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator - * should run + * should run * - optionally use getEnergyStored to display the output buffer charge level * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - *

- * Example implementation code: * - * @code{.java} public class SomeTileEntity extends TileEntity { - * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); - * @Override public void invalidate() { - * ic2EnergySource.invalidate(); // notify the energy source - * ... - * super.invalidate(); // this is important for mc! - * } - * @Override public void onChunkUnload() { - * ic2EnergySource.onChunkUnload(); // notify the energy source - * ... - * } - * @Override public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - *

- * ic2EnergySource.readFromNBT(tag); - * ... - * } - * @Override public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - *

- * ic2EnergySource.writeToNBT(tag); - * ... - * } - * @Override public void updateEntity() { - * ic2EnergySource.updateEntity(); // notify the energy source - * ... - * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick - * ... - * } - *

- * ... + * Example implementation code: + * @code{.java} + * public class SomeTileEntity extends TileEntity { + * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); + * + * @Override + * public void invalidate() { + * ic2EnergySource.invalidate(); // notify the energy source + * ... + * super.invalidate(); // this is important for mc! + * } + * + * @Override + * public void onChunkUnload() { + * ic2EnergySource.onChunkUnload(); // notify the energy source + * ... + * } + * + * @Override + * public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + * + * ic2EnergySource.readFromNBT(tag); + * ... + * } + * + * @Override + * public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + * + * ic2EnergySource.writeToNBT(tag); + * ... + * } + * + * @Override + * public void updateEntity() { + * ic2EnergySource.updateEntity(); // notify the energy source + * ... + * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick + * ... + * } + * + * ... * } * @endcode */ public class BasicSource extends TileEntity implements IEnergySource { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** + // ********************************** + // *** Methods for use by the mod *** + // ********************************** - /** - * Constructor for a new BasicSource delegate. - * - * @param parent1 Base TileEntity represented by this energy source. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSource(TileEntity parent1, double capacity1, int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); + /** + * Constructor for a new BasicSource delegate. + * + * @param parent1 Base TileEntity represented by this energy source. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSource(TileEntity parent1, double capacity1, int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); - this.parent = parent1; - this.capacity = capacity1 < power ? power : capacity1; - this.tier = tier1; - } + this.parent = parent1; + this.capacity = capacity1 < power ? power : capacity1; + this.tier = tier1; + this.power = power; + } - // in-world te forwards >> + // in-world te forwards >> - /** - * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); - } + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } - /** - * Notification that the base TileEntity finished loading, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { - worldObj = parent.getWorldObj(); - xCoord = parent.xCoord; - yCoord = parent.yCoord; - zCoord = parent.zCoord; + /** + * Notification that the base TileEntity finished loading, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - addedToEnet = true; - } - } + addedToEnet = true; + } + } - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); - onChunkUnload(); - } + onChunkUnload(); + } - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - addedToEnet = false; - } - } + addedToEnet = false; + } + } - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); + NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); - energyStored = data.getDouble("energy"); - } + energyStored = data.getDouble("energy"); + } - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public void writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } - NBTTagCompound data = new NBTTagCompound(); + NBTTagCompound data = new NBTTagCompound(); - data.setDouble("energy", energyStored); + data.setDouble("energy", energyStored); - tag.setTag("IC2BasicSource", data); - } + tag.setTag("IC2BasicSource", data); + } - // << in-world te forwards - // methods for using this adapter >> + // << in-world te forwards + // methods for using this adapter >> - /** - * Get the maximum amount of energy this source can hold in its buffer. - * - * @return Capacity in EU. - */ - public double getCapacity() { - return capacity; - } + /** + * Get the maximum amount of energy this source can hold in its buffer. + * + * @return Capacity in EU. + */ + public double getCapacity() { + return capacity; + } - /** - * Set the maximum amount of energy this source can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(double capacity1) { - double power = EnergyNet.instance.getPowerFromTier(tier); + /** + * Set the maximum amount of energy this source can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(double capacity1) { + if (capacity1 < power) capacity1 = power; - if (capacity1 < power) capacity1 = power; + this.capacity = capacity1; + } - this.capacity = capacity1; - } + /** + * Get the IC2 energy tier for this source. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } - /** - * Get the IC2 energy tier for this source. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } + /** + * Set the IC2 energy tier for this source. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); - /** - * Set the IC2 energy tier for this source. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); + if (capacity < power) capacity = power; - if (capacity < power) capacity = power; - - this.tier = tier1; - } + this.tier = tier1; + this.power = power; + } - /** - * Determine the energy stored in the source's output buffer. - * - * @return amount in EU - */ - public double getEnergyStored() { - return energyStored; - } + /** + * Determine the energy stored in the source's output buffer. + * + * @return amount in EU + */ + public double getEnergyStored() { + return energyStored; + } - /** - * Set the stored energy to the specified amount. - *

- * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } + /** + * Set the stored energy to the specified amount. + * + * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } - /** - * Determine the free capacity in the source's output buffer. - * - * @return amount in EU - */ - public double getFreeCapacity() { - return capacity - energyStored; - } + /** + * Determine the free capacity in the source's output buffer. + * + * @return amount in EU + */ + public double getFreeCapacity() { + return capacity - energyStored; + } - /** - * Add some energy to the output buffer. - * - * @param amount maximum amount of energy to add - * @return amount added/used, NOT remaining - */ - public double addEnergy(double amount) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; - if (amount > capacity - energyStored) amount = capacity - energyStored; + /** + * Add some energy to the output buffer. + * + * @param amount maximum amount of energy to add + * @return amount added/used, NOT remaining + */ + public double addEnergy(double amount) { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; + if (amount > capacity - energyStored) amount = capacity - energyStored; - energyStored += amount; + energyStored += amount; - return amount; - } + return amount; + } - /** - * Charge the supplied ItemStack from this source's energy buffer. - * - * @param stack ItemStack to charge (null is ignored) - * @return true if energy was transferred - */ - public boolean charge(ItemStack stack) { - if (stack == null || !Info.isIc2Available()) return false; + /** + * Charge the supplied ItemStack from this source's energy buffer. + * + * @param stack ItemStack to charge (null is ignored) + * @return true if energy was transferred + */ + public boolean charge(ItemStack stack) { + if (stack == null || !Info.isIc2Available()) return false; - double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); + double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); - energyStored -= amount; + energyStored -= amount; - return amount > 0; - } + return amount > 0; + } - // << methods for using this adapter + // << methods for using this adapter - // backwards compatibility (ignore these) >> + // backwards compatibility (ignore these) >> - @Deprecated - public void onUpdateEntity() { - updateEntity(); - } + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } - @Deprecated - public void onInvalidate() { - invalidate(); - } + @Deprecated + public void onInvalidate() { + invalidate(); + } - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } - // << backwards compatibility + // << backwards compatibility - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** - // energy net interface >> + // energy net interface >> - @Override - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { - return true; - } + @Override + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return true; + } - @Override - public double getOfferedEnergy() { - return energyStored; - } + @Override + public double getOfferedEnergy() { + return Math.min(energyStored, power); + } - @Override - public void drawEnergy(double amount) { - energyStored -= amount; - } + @Override + public void drawEnergy(double amount) { + energyStored -= amount; + } - @Override - public int getSourceTier() { - return tier; - } + @Override + public int getSourceTier() { + return tier; + } - // << energy net interface + // << energy net interface - public final TileEntity parent; + public final TileEntity parent; - protected double capacity; - protected int tier; - protected double energyStored; - protected boolean addedToEnet; + protected double capacity; + protected int tier; + protected double power; + protected double energyStored; + protected boolean addedToEnet; } diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/api/java/ic2/api/energy/prefab/package-info.java index b244b0ff..c38f7e0e 100644 --- a/src/api/java/ic2/api/energy/prefab/package-info.java +++ b/src/api/java/ic2/api/energy/prefab/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.prefab; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.energy.prefab; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java index 18b827c0..1735ff5e 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java @@ -9,19 +9,19 @@ import net.minecraftforge.common.util.ForgeDirection; * * @see IEnergySink * @see IEnergyConductor - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyAcceptor extends IEnergyTile { - /** - * Determine if this acceptor can accept current from an adjacent emitter in a direction. - *

- * The TileEntity in the emitter parameter is what was originally added to the energy net, - * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. - * - * @param emitter energy emitter, may also be null or an IMetaDelegate - * @param direction direction the energy is being received from - */ - boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); + /** + * Determine if this acceptor can accept current from an adjacent emitter in a direction. + * + * The TileEntity in the emitter parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param emitter energy emitter, may also be null or an IMetaDelegate + * @param direction direction the energy is being received from + */ + boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java index 6d917546..08dab889 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java @@ -3,51 +3,51 @@ package ic2.api.energy.tile; /** * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this * interface. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { - /** - * Energy loss for the conductor in EU per block. - * - * @return Energy loss - */ - double getConductionLoss(); + /** + * Energy loss for the conductor in EU per block. + * + * @return Energy loss + */ + double getConductionLoss(); - /** - * Amount of energy the insulation will handle before shocking nearby players and mobs. - * - * @return Insulation energy absorption in EU - */ - double getInsulationEnergyAbsorption(); + /** + * Amount of energy the insulation will handle before shocking nearby players and mobs. + * + * @return Insulation energy absorption in EU + */ + double getInsulationEnergyAbsorption(); - /** - * Amount of energy the insulation will handle before it is destroyed. - * Ensure that this value is greater than the insulation energy absorption + 64. - * - * @return Insulation-destroying energy in EU - */ - double getInsulationBreakdownEnergy(); + /** + * Amount of energy the insulation will handle before it is destroyed. + * Ensure that this value is greater than the insulation energy absorption + 64. + * + * @return Insulation-destroying energy in EU + */ + double getInsulationBreakdownEnergy(); - /** - * Amount of energy the conductor will handle before it melts. - * - * @return Conductor-destroying energy in EU - */ - double getConductorBreakdownEnergy(); + /** + * Amount of energy the conductor will handle before it melts. + * + * @return Conductor-destroying energy in EU + */ + double getConductorBreakdownEnergy(); - /** - * Remove the conductor's insulation if the insulation breakdown energy was exceeded. - * - * @see #getInsulationBreakdownEnergy() - */ - void removeInsulation(); + /** + * Remove the conductor's insulation if the insulation breakdown energy was exceeded. + * + * @see #getInsulationBreakdownEnergy() + */ + void removeInsulation(); - /** - * Remove the conductor if the conductor breakdown energy was exceeded. - * - * @see #getConductorBreakdownEnergy() - */ - void removeConductor(); + /** + * Remove the conductor if the conductor breakdown energy was exceeded. + * + * @see #getConductorBreakdownEnergy() + */ + void removeConductor(); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java index 5988db01..013865e3 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java @@ -9,20 +9,20 @@ import net.minecraftforge.common.util.ForgeDirection; * * @see IEnergySource * @see IEnergyConductor - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyEmitter extends IEnergyTile { - /** - * Determine if this emitter can emit energy to an adjacent receiver. - *

- * The TileEntity in the receiver parameter is what was originally added to the energy net, - * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. - * - * @param receiver receiver, may also be null or an IMetaDelegate - * @param direction direction the receiver is from the emitter - * @return Whether energy should be emitted - */ - boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); + /** + * Determine if this emitter can emit energy to an adjacent receiver. + * + * The TileEntity in the receiver parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param receiver receiver, may also be null or an IMetaDelegate + * @param direction direction the receiver is from the emitter + * @return Whether energy should be emitted + */ + boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java index 4a943f05..4ae8e795 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergySink.java +++ b/src/api/java/ic2/api/energy/tile/IEnergySink.java @@ -4,40 +4,42 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Allows a tile entity (mostly a machine) to receive energy. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergySink extends IEnergyAcceptor { - /** - * Determine how much energy the sink accepts. - *

- * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. - * - * @return max accepted input in eu - * @note Modifying the energy net from this method is disallowed. - */ - double getDemandedEnergy(); + /** + * Determine how much energy the sink accepts. + * + * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. + * + * @note Modifying the energy net from this method is disallowed. + * + * @return max accepted input in eu + */ + double getDemandedEnergy(); - /** - * Determine the tier of this energy sink. - * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * - * @return tier of this energy sink - * @note Modifying the energy net from this method is disallowed. - * @note Return Integer.MAX_VALUE to allow any voltage. - */ - int getSinkTier(); + /** + * Determine the tier of this energy sink. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @note Modifying the energy net from this method is disallowed. + * @note Return Integer.MAX_VALUE to allow any voltage. + * + * @return tier of this energy sink + */ + int getSinkTier(); - /** - * Transfer energy to the sink. - *

- * It's highly recommended to accept all energy by letting the internal buffer overflow to - * increase the performance and accuracy of the distribution simulation. - * - * @param directionFrom direction from which the energy comes from - * @param amount energy to be transferred - * @return Energy not consumed (leftover) - */ - double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); + /** + * Transfer energy to the sink. + * + * It's highly recommended to accept all energy by letting the internal buffer overflow to + * increase the performance and accuracy of the distribution simulation. + * + * @param directionFrom direction from which the energy comes from + * @param amount energy to be transferred + * @return Energy not consumed (leftover) + */ + double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergySource.java b/src/api/java/ic2/api/energy/tile/IEnergySource.java index 7964e682..44b952a5 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergySource.java +++ b/src/api/java/ic2/api/energy/tile/IEnergySource.java @@ -2,35 +2,37 @@ package ic2.api.energy.tile; /** * Allows a tile entity (mostly a generator) to emit energy. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergySource extends IEnergyEmitter { - /** - * Energy output provided by the source this tick. - * This is typically Math.min(stored energy, max output/tick). - * - * @return Energy offered this tick - * @note Modifying the energy net from this method is disallowed. - */ - double getOfferedEnergy(); + /** + * Energy output provided by the source this tick. + * This is typically Math.min(stored energy, max output/tick). + * + * @note Modifying the energy net from this method is disallowed. + * + * @return Energy offered this tick + */ + double getOfferedEnergy(); - /** - * Draw energy from this source's buffer. - *

- * If the source doesn't have a buffer, this is a no-op. - * - * @param amount amount of EU to draw, may be negative - */ - void drawEnergy(double amount); + /** + * Draw energy from this source's buffer. + * + * If the source doesn't have a buffer, this is a no-op. + * + * @param amount amount of EU to draw, may be negative + */ + void drawEnergy(double amount); - /** - * Determine the tier of this energy source. - * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * - * @return tier of this energy source - * @note Modifying the energy net from this method is disallowed. - */ - int getSourceTier(); + /** + * Determine the tier of this energy source. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @note Modifying the energy net from this method is disallowed. + * + * @return tier of this energy source + */ + int getSourceTier(); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergyTile.java b/src/api/java/ic2/api/energy/tile/IEnergyTile.java index 2c8973a5..3938190a 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyTile.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyTile.java @@ -6,10 +6,10 @@ package ic2.api.energy.tile; * @see IEnergySink * @see IEnergySource * @see IEnergyConductor - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyTile { - // + // } diff --git a/src/api/java/ic2/api/energy/tile/IHeatSource.java b/src/api/java/ic2/api/energy/tile/IHeatSource.java index f40ce755..2e5db411 100644 --- a/src/api/java/ic2/api/energy/tile/IHeatSource.java +++ b/src/api/java/ic2/api/energy/tile/IHeatSource.java @@ -3,14 +3,14 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; public interface IHeatSource { - - /* - * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) - */ - int maxrequestHeatTick(ForgeDirection directionFrom); - + /* - * @param requested amount of heat to transfer + * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestHeatTick(ForgeDirection directionFrom); + + /* + * @param requested amount of heat to transfer * * @return transmitted amount of heat * @@ -18,6 +18,6 @@ public interface IHeatSource { * * requestHeat(100) : return 50 : so 50 units of heat remove from HeatSource */ - - int requestHeat(ForgeDirection directionFrom, int requestheat); + + int requestHeat(ForgeDirection directionFrom, int requestheat); } diff --git a/src/api/java/ic2/api/energy/tile/IKineticSource.java b/src/api/java/ic2/api/energy/tile/IKineticSource.java index 2276f2c7..a6514087 100644 --- a/src/api/java/ic2/api/energy/tile/IKineticSource.java +++ b/src/api/java/ic2/api/energy/tile/IKineticSource.java @@ -3,13 +3,13 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; public interface IKineticSource { - /* - * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) - */ - int maxrequestkineticenergyTick(ForgeDirection directionFrom); + /* + * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestkineticenergyTick(ForgeDirection directionFrom); /* - * @param requested amount of kinetic energy to transfer + * @param requested amount of kinetic energy to transfer * * @return transmitted amount of kineticenergy * @@ -18,5 +18,5 @@ public interface IKineticSource { * requestkineticenergy(100) : return 50 : so 50 units of kinetic energy remove from KineticSource */ - int requestkineticenergy(ForgeDirection directionFrom, int requestkineticenergy); + int requestkineticenergy(ForgeDirection directionFrom, int requestkineticenergy); } diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java index a9525552..f7319d0e 100644 --- a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java +++ b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java @@ -6,28 +6,31 @@ import net.minecraft.tileentity.TileEntity; /** * Interface for grouping multi-block structures to a single energy net delegate. - *

+ * * The energy net uses TileEntity to refer to a specific xyz+world position. If multiple of those * positions should belong to the same functional structure, i.e. they consume or produce energy * only once for the whole multi-block instead of once per every single block, this interface * allows to do so. - *

+ * * The tile entity implementing IMetaDelegate has to be added/removed to/from the energy net * instead of every single sub-TileEntity. The energy net interaction will be handled by the * IMetaDelegate TileEntity as well. - *

+ * * The sub tile array TileEntity[] just provides optional connectivity (IEnergyAcceptor, * IEnergyEmitter) and mandatory position (x, y, z, World) data. * If the connectivity data on the sub tile is missing, the meta delegate is queried instead. - *

+ * * See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IMetaDelegate extends IEnergyTile { - /** - * Get the sub-TileEntities belonging to this Meta TileEntity. - * - * @return sub-TileEntity array - * @note the list has to be consistent between the EnergyNet Load and Unload events. - */ - List getSubTiles(); + /** + * Get the sub-TileEntities belonging to this Meta TileEntity. + * + * @note The list has to be consistent between the EnergyNet Load and Unload events. + * @note The list must have at least 1 element. + * @note The parent te implementing IMetaDelegate isn't automatically included. + * + * @return sub-TileEntity array + */ + List getSubTiles(); } diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java index a1667397..3c60323a 100644 --- a/src/api/java/ic2/api/energy/tile/package-info.java +++ b/src/api/java/ic2/api/energy/tile/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.tile; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.energy.tile; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/api/java/ic2/api/event/LaserEvent.java index 6c7e1777..6d5ea280 100644 --- a/src/api/java/ic2/api/event/LaserEvent.java +++ b/src/api/java/ic2/api/event/LaserEvent.java @@ -14,101 +14,101 @@ import net.minecraftforge.event.world.WorldEvent; */ @Cancelable public class LaserEvent extends WorldEvent { - // the Laser Entity - public final Entity lasershot; + // the Laser Entity + public final Entity lasershot; - // the following variables can be changed and the Laser will adjust to them + // the following variables can be changed and the Laser will adjust to them - // the Player firing the Laser. If the Laser gets "reflected" the Player could change. - public EntityLivingBase owner; - // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. - public float range, power; - public int blockBreaks; - // Determines whether the laser will explode upon hitting something - public boolean explosive, smelt; + // the Player firing the Laser. If the Laser gets "reflected" the Player could change. + public EntityLivingBase owner; + // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. + public float range, power; + public int blockBreaks; + // Determines whether the laser will explode upon hitting something + public boolean explosive, smelt; - public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { - super(world1); - this.lasershot = lasershot1; - this.owner = owner1; - this.range = range1; - this.power = power1; - this.blockBreaks = blockBreaks1; - this.explosive = explosive1; - this.smelt = smelt1; - } + public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { + super(world1); + this.lasershot = lasershot1; + this.owner = owner1; + this.range = range1; + this.power = power1; + this.blockBreaks = blockBreaks1; + this.explosive = explosive1; + this.smelt = smelt1; + } - /** - * Event when the Laser is getting shot by a Player. - *

- * The Item is the Laser Gun which the "Player" has shot - */ - public static class LaserShootEvent extends LaserEvent { - ItemStack laseritem; + /** + * Event when the Laser is getting shot by a Player. + * + * The Item is the Laser Gun which the "Player" has shot + */ + public static class LaserShootEvent extends LaserEvent { + ItemStack laseritem; - public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.laseritem = laseritem1; - } - } + public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.laseritem = laseritem1; + } + } - /** - * Event when the Laser is exploding for some Reason. - *

- * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. - */ - public static class LaserExplodesEvent extends LaserEvent { - // explosion strength, even that can be changed! - public float explosionpower, explosiondroprate, explosionentitydamage; + /** + * Event when the Laser is exploding for some Reason. + * + * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. + */ + public static class LaserExplodesEvent extends LaserEvent { + // explosion strength, even that can be changed! + public float explosionpower, explosiondroprate, explosionentitydamage; - public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.explosionpower = explosionpower1; - this.explosiondroprate = explosiondroprate1; - this.explosionentitydamage = explosionentitydamage1; - } - } + public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.explosionpower = explosionpower1; + this.explosiondroprate = explosiondroprate1; + this.explosionentitydamage = explosionentitydamage1; + } + } - /** - * Event when the Laser is hitting a Block - * x, y and z are the Coords of the Block. - *

- * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. - * Use lasershot.setDead() to remove the Shot entirely. - */ - public static class LaserHitsBlockEvent extends LaserEvent { - // targeted block, even that can be changed! - public int x, y, z; - public int side; - // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. - public boolean removeBlock, dropBlock; - public float dropChance; + /** + * Event when the Laser is hitting a Block + * x, y and z are the Coords of the Block. + * + * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsBlockEvent extends LaserEvent { + // targeted block, even that can be changed! + public int x, y, z; + public int side; + // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. + public boolean removeBlock, dropBlock; + public float dropChance; - public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.removeBlock = removeBlock1; - this.dropBlock = dropBlock1; - this.dropChance = dropChance1; - } - } + public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.removeBlock = removeBlock1; + this.dropBlock = dropBlock1; + this.dropChance = dropChance1; + } + } - /** - * Event when the Laser is getting at a Living Entity - *

- * Canceling this Event ignores the Entity - * Use lasershot.setDead() to remove the Shot entirely. - */ - public static class LaserHitsEntityEvent extends LaserEvent { - // the Entity which the Laser has shot at, even the target can be changed! - public Entity hitentity; + /** + * Event when the Laser is getting at a Living Entity + * + * Canceling this Event ignores the Entity + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsEntityEvent extends LaserEvent { + // the Entity which the Laser has shot at, even the target can be changed! + public Entity hitentity; - public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.hitentity = hitentity1; - } - } + public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.hitentity = hitentity1; + } + } } diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/api/java/ic2/api/event/PaintEvent.java index 88f07030..c6565c22 100644 --- a/src/api/java/ic2/api/event/PaintEvent.java +++ b/src/api/java/ic2/api/event/PaintEvent.java @@ -8,25 +8,25 @@ import net.minecraftforge.event.world.WorldEvent; @Cancelable public class PaintEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; + // target block + public final int x; + public final int y; + public final int z; + public final int side; - // color to paint the block - public final int color; + // color to paint the block + public final int color; - // set to true to confirm the operation - public boolean painted = false; + // set to true to confirm the operation + public boolean painted = false; - public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { - super(world1); + public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { + super(world1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.color = color1; - } + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.color = color1; + } } diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/api/java/ic2/api/event/RetextureEvent.java index 49ed9ac5..d530578c 100644 --- a/src/api/java/ic2/api/event/RetextureEvent.java +++ b/src/api/java/ic2/api/event/RetextureEvent.java @@ -9,29 +9,29 @@ import net.minecraftforge.event.world.WorldEvent; @Cancelable public class RetextureEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; + // target block + public final int x; + public final int y; + public final int z; + public final int side; - // referenced block (to grab the texture from) - public final Block referencedBlock; - public final int referencedMeta; - public final int referencedSide; + // referenced block (to grab the texture from) + public final Block referencedBlock; + public final int referencedMeta; + public final int referencedSide; - // set to true to confirm the operation - public boolean applied = false; + // set to true to confirm the operation + public boolean applied = false; - public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { - super(world1); + public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { + super(world1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.referencedBlock = referencedBlock; - this.referencedMeta = referencedMeta1; - this.referencedSide = referencedSide1; - } + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.referencedBlock = referencedBlock; + this.referencedMeta = referencedMeta1; + this.referencedSide = referencedSide1; + } } diff --git a/src/api/java/ic2/api/event/package-info.java b/src/api/java/ic2/api/event/package-info.java index 58e5bdf4..d331b924 100644 --- a/src/api/java/ic2/api/event/package-info.java +++ b/src/api/java/ic2/api/event/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.event; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.event; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java index 14a6db90..1e7b2cc5 100644 --- a/src/api/java/ic2/api/info/IEnergyValueProvider.java +++ b/src/api/java/ic2/api/info/IEnergyValueProvider.java @@ -3,15 +3,15 @@ package ic2.api.info; import net.minecraft.item.ItemStack; public interface IEnergyValueProvider { - /** - * Determine the energy value for a single item in the supplied stack. - * The value is used by most machines in the discharge slot. - *

- * This only applies to basic single use items, others are to be queried - * through e.g. ElectricItem.manager.getCharge(). - * - * @param itemStack ItemStack containing the item to evaluate. - * @return energy in EU - */ - double getEnergyValue(ItemStack itemStack); + /** + * Determine the energy value for a single item in the supplied stack. + * The value is used by most machines in the discharge slot. + * + * This only applies to basic single use items, others are to be queried + * through e.g. ElectricItem.manager.getCharge(). + * + * @param itemStack ItemStack containing the item to evaluate. + * @return energy in EU + */ + double getEnergyValue(ItemStack itemStack); } diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java index 21fee297..7c7fe0f4 100644 --- a/src/api/java/ic2/api/info/IFuelValueProvider.java +++ b/src/api/java/ic2/api/info/IFuelValueProvider.java @@ -3,13 +3,13 @@ package ic2.api.info; import net.minecraft.item.ItemStack; public interface IFuelValueProvider { - /** - * Determine the fuel value for a single item in the supplied stack. - * The information currently applies to Generators and the Iron Furnace. - * - * @param itemStack ItemStack containing the item to evaluate. - * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. - * @return fuel value - */ - int getFuelValue(ItemStack itemStack, boolean allowLava); + /** + * Determine the fuel value for a single item in the supplied stack. + * The information currently applies to Generators and the Iron Furnace. + * + * @param itemStack ItemStack containing the item to evaluate. + * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. + * @return fuel value + */ + int getFuelValue(ItemStack itemStack, boolean allowLava); } diff --git a/src/api/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java index 3c8a7146..3b5a5442 100644 --- a/src/api/java/ic2/api/info/Info.java +++ b/src/api/java/ic2/api/info/Info.java @@ -6,27 +6,27 @@ import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.LoaderState; public class Info { - public static IEnergyValueProvider itemEnergy; - public static IFuelValueProvider itemFuel; - public static Object ic2ModInstance; + public static IEnergyValueProvider itemEnergy; + public static IFuelValueProvider itemFuel; + public static Object ic2ModInstance; - /** - * Damage Sources used by IC2. - * Getting assigned in preload. - */ - public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; + /** + * Damage Sources used by IC2. + * Getting assigned in preload. + */ + public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; - public static boolean isIc2Available() { - if (ic2Available != null) return ic2Available; + public static boolean isIc2Available() { + if (ic2Available != null) return ic2Available; - boolean loaded = Loader.isModLoaded("IC2"); + boolean loaded = Loader.isModLoaded("IC2"); - if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { - ic2Available = loaded; - } + if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { + ic2Available = loaded; + } - return loaded; - } + return loaded; + } - private static Boolean ic2Available = null; + private static Boolean ic2Available = null; } \ No newline at end of file diff --git a/src/api/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java index 7714e222..59936e5e 100644 --- a/src/api/java/ic2/api/info/package-info.java +++ b/src/api/java/ic2/api/info/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.info; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.info; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/item/ElectricItem.java b/src/api/java/ic2/api/item/ElectricItem.java index cc2b959a..19e5fc1b 100644 --- a/src/api/java/ic2/api/item/ElectricItem.java +++ b/src/api/java/ic2/api/item/ElectricItem.java @@ -9,51 +9,51 @@ import net.minecraft.item.ItemStack; * Allows for charging, discharging and using electric items (IElectricItem). */ public final class ElectricItem { - /** - * IElectricItemManager to use for interacting with IElectricItem ItemStacks. - *

- * This manager will act as a gateway and delegate the tasks to the final implementation - * (rawManager or a custom one) as necessary. - */ - public static IElectricItemManager manager; + /** + * IElectricItemManager to use for interacting with IElectricItem ItemStacks. + * + * This manager will act as a gateway and delegate the tasks to the final implementation + * (rawManager or a custom one) as necessary. + */ + public static IElectricItemManager manager; - /** - * Standard IElectricItemManager implementation, only call it directly from another - * IElectricItemManager. Use manager instead. - */ - public static IElectricItemManager rawManager; + /** + * Standard IElectricItemManager implementation, only call it directly from another + * IElectricItemManager. Use manager instead. + */ + public static IElectricItemManager rawManager; - /** - * Register an electric item manager for items not implementing IElectricItem. - *

- * This method is only designed for special purposes, implementing IElectricItem or - * ISpecialElectricItem instead of using this is faster. - *

- * Managers used with ISpecialElectricItem shouldn't be registered. - * - * @param manager Manager to register. - */ - public static void registerBackupManager(IBackupElectricItemManager manager) { - backupManagers.add(manager); - } + /** + * Register an electric item manager for items not implementing IElectricItem. + * + * This method is only designed for special purposes, implementing IElectricItem or + * ISpecialElectricItem instead of using this is faster. + * + * Managers used with ISpecialElectricItem shouldn't be registered. + * + * @param manager Manager to register. + */ + public static void registerBackupManager(IBackupElectricItemManager manager) { + backupManagers.add(manager); + } - /** - * Get the electric item manager suitable for the supplied item stack. - *

- * This method is for internal use only. - * - * @param stack ItemStack to be handled. - * @return First suitable electric item manager. - */ - public static IBackupElectricItemManager getBackupManager(ItemStack stack) { - for (IBackupElectricItemManager manager : backupManagers) { - if (manager.handles(stack)) return manager; - } + /** + * Get the electric item manager suitable for the supplied item stack. + * + * This method is for internal use only. + * + * @param stack ItemStack to be handled. + * @return First suitable electric item manager. + */ + public static IBackupElectricItemManager getBackupManager(ItemStack stack) { + for (IBackupElectricItemManager manager : backupManagers) { + if (manager.handles(stack)) return manager; + } - return null; - } + return null; + } - private static final List backupManagers = new ArrayList(); + private static final List backupManagers = new ArrayList(); } diff --git a/src/api/java/ic2/api/item/IBackupElectricItemManager.java b/src/api/java/ic2/api/item/IBackupElectricItemManager.java index e3fa60d7..2ae254ac 100644 --- a/src/api/java/ic2/api/item/IBackupElectricItemManager.java +++ b/src/api/java/ic2/api/item/IBackupElectricItemManager.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * This interface specifies a manager applicable to items not implementing IElectricItem. - *

+ * * The manager implementing this has to be registered with ElectricItem.registerBackupManager(). */ public interface IBackupElectricItemManager extends IElectricItemManager { - boolean handles(ItemStack stack); + boolean handles(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.java b/src/api/java/ic2/api/item/IBlockCuttingBlade.java index b53c461c..24a8f00d 100644 --- a/src/api/java/ic2/api/item/IBlockCuttingBlade.java +++ b/src/api/java/ic2/api/item/IBlockCuttingBlade.java @@ -2,5 +2,5 @@ package ic2.api.item; public interface IBlockCuttingBlade { - int gethardness(); + int gethardness(); } diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/api/java/ic2/api/item/IBoxable.java index 7b268632..bca2cc0d 100644 --- a/src/api/java/ic2/api/item/IBoxable.java +++ b/src/api/java/ic2/api/item/IBoxable.java @@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack; public interface IBoxable { - /** - * Determine whether an item can be stored in a toolbox or not. - * - * @param itemstack item to be stored - * @return Whether to store the item in the toolbox or not - */ - public abstract boolean canBeStoredInToolbox(ItemStack itemstack); + /** + * Determine whether an item can be stored in a toolbox or not. + * + * @param itemstack item to be stored + * @return Whether to store the item in the toolbox or not + */ + public abstract boolean canBeStoredInToolbox(ItemStack itemstack); } diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java index bd9305af..9b8c7df3 100644 --- a/src/api/java/ic2/api/item/IC2Items.java +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -4,40 +4,40 @@ import net.minecraft.item.ItemStack; /** * Provides access to IC2 blocks and items. - *

+ * * Some items can be acquired through the ore dictionary which is the recommended way. * The items are initialized while IC2 is being loaded - try to use ModsLoaded() or load your mod after IC2. * Some blocks/items can be disabled by a config setting, so it's recommended to check if they're null first. - *

+ * * Getting the associated Block/Item for an ItemStack x: - * Blocks: Block.blocksList[x.itemID] - * Items: x.getItem() + * Blocks: Block.blocksList[x.itemID] + * Items: x.getItem() */ public final class IC2Items { - /** - * Get an ItemStack for a specific item name, example: Items.getItem("resin") - * See the list below for item names. - * Make sure to copy() the ItemStack if you want to modify it. - * - * @param name item name - * @return The item or null if the item does not exist or an error occurred - */ - public static ItemStack getItem(String name) { - try { - if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); + /** + * Get an ItemStack for a specific item name, example: Items.getItem("resin") + * See the list below for item names. + * Make sure to copy() the ItemStack if you want to modify it. + * + * @param name item name + * @return The item or null if the item does not exist or an error occurred + */ + public static ItemStack getItem(String name) { + try { + if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); - Object ret = Ic2Items.getField(name).get(null); + Object ret = Ic2Items.getField(name).get(null); - if (ret instanceof ItemStack) { - return (ItemStack) ret; - } - return null; - } catch (Exception e) { - System.out.println("IC2 API: Call getItem failed for " + name); + if (ret instanceof ItemStack) { + return (ItemStack) ret; + } + return null; + } catch (Exception e) { + System.out.println("IC2 API: Call getItem failed for "+name); - return null; - } - } + return null; + } + } /* Possible values: @@ -576,23 +576,23 @@ public final class IC2Items { */ - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = IC2Items.class.getPackage(); + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = IC2Items.class.getPackage(); - if (pkg != null) { - String packageName = pkg.getName(); + if (pkg != null) { + String packageName = pkg.getName(); - return packageName.substring(0, packageName.length() - ".api.item".length()); - } + return packageName.substring(0, packageName.length() - ".api.item".length()); + } - return "ic2"; - } + return "ic2"; + } - private static Class Ic2Items; + private static Class Ic2Items; } diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java index ceaa2606..5525e00f 100644 --- a/src/api/java/ic2/api/item/IElectricItem.java +++ b/src/api/java/ic2/api/item/IElectricItem.java @@ -5,51 +5,51 @@ import net.minecraft.item.ItemStack; /** * Provides the ability to store energy on the implementing item. - *

+ * * The item should have a maximum damage of 13. */ public interface IElectricItem { - /** - * Determine if the item can be used in a machine or as an armor part to supply energy. - * - * @return Whether the item can supply energy - */ - boolean canProvideEnergy(ItemStack itemStack); + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); - /** - * Get the item ID to use for a charge energy greater than 0. - * - * @return Item ID to use - */ - Item getChargedItem(ItemStack itemStack); + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); - /** - * Get the item ID to use for a charge energy of 0. - * - * @return Item ID to use - */ - Item getEmptyItem(ItemStack itemStack); + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); - /** - * Get the item's maximum charge energy in EU. - * - * @return Maximum charge energy - */ - double getMaxCharge(ItemStack itemStack); + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); - /** - * Get the item's tier, lower tiers can't send energy to higher ones. - * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. - * - * @return Item's tier - */ - int getTier(ItemStack itemStack); + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); - /** - * Get the item's transfer limit in EU per transfer operation. - * - * @return Transfer limit - */ - double getTransferLimit(ItemStack itemStack); + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); } diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java index ecae1459..dfadbb26 100644 --- a/src/api/java/ic2/api/item/IElectricItemManager.java +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -5,89 +5,89 @@ import net.minecraft.item.ItemStack; /** * This interface specifies a manager to handle the various tasks for electric items. - *

+ * * The default implementation does the following: * - store and retrieve the charge * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) * - update and manage the damage value for the visual charge indicator - * + * * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the * default implementations through ElectricItem.rawManager. The default implementation is designed * to minimize its dependency on its own constraints/structure and delegates most work back to the * more atomic features in the gateway manager. */ public interface IElectricItemManager { - /** - * Charge an item with a specified amount of energy. - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - */ - double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param externally use the supplied item externally, i.e. to power something else as if it was a battery - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - */ - double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); - /** - * Determine the charge level for the specified item. - * - * @param itemStack ItemStack containing the electric item - * @return charge level in EU - */ - double getCharge(ItemStack stack); + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - */ - boolean canUse(ItemStack stack, double amount); + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); - /** - * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param entity entity holding the item - * @return true if the operation succeeded - */ - boolean use(ItemStack stack, double amount, EntityLivingBase entity); + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); - /** - * Charge an item from the BatPack a player is wearing. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * use() already contains this functionality. - * - * @param itemStack electric item's stack - * @param entity entity holding the item - */ - void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); - /** - * Get the tool tip to display for electric items. - * - * @param itemStack ItemStack to determine the tooltip for - * @return tool tip string or null for none - */ - String getToolTip(ItemStack stack); + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java index 66e32bdf..da973187 100644 --- a/src/api/java/ic2/api/item/IItemHudInfo.java +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -5,7 +5,7 @@ import java.util.List; import net.minecraft.item.ItemStack; public interface IItemHudInfo { - /* + /* Add Info to Nano- and Quantum-Suit Helm Hud for itemStack @@ -20,5 +20,5 @@ public interface IItemHudInfo { */ - public List getHudInfo(ItemStack itemStack); + public List getHudInfo(ItemStack itemStack); } diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.java b/src/api/java/ic2/api/item/IKineticWindRotor.java index 90522808..62f1fdc3 100644 --- a/src/api/java/ic2/api/item/IKineticWindRotor.java +++ b/src/api/java/ic2/api/item/IKineticWindRotor.java @@ -3,13 +3,13 @@ package ic2.api.item; import net.minecraft.util.ResourceLocation; public interface IKineticWindRotor { - public int getDiameter(); + public int getDiameter(); - public ResourceLocation getRotorRenderTexture(); + public ResourceLocation getRotorRenderTexture(); - public float getefficiency(); + public float getefficiency(); - int getminWindStrength(); + int getminWindStrength(); - int getmaxWindStrength(); + int getmaxWindStrength(); } diff --git a/src/api/java/ic2/api/item/IMetalArmor.java b/src/api/java/ic2/api/item/IMetalArmor.java index e4a85db0..16ffd24e 100644 --- a/src/api/java/ic2/api/item/IMetalArmor.java +++ b/src/api/java/ic2/api/item/IMetalArmor.java @@ -5,16 +5,16 @@ import net.minecraft.item.ItemStack; /** * Armor items implementing this can be considered metal armor. - *

+ * * Currently used for determining which boots can be used to slide up a magnetic pole. */ public interface IMetalArmor { - /** - * Determine if the given armor piece is metal armor. - * - * @param itemstack Armor piece as worn by the player - * @param player The player - * @return Whether the armor piece is metal armor - */ - public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); + /** + * Determine if the given armor piece is metal armor. + * + * @param itemstack Armor piece as worn by the player + * @param player The player + * @return Whether the armor piece is metal armor + */ + public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); } diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java index d3497a76..a7302f53 100644 --- a/src/api/java/ic2/api/item/ISpecialElectricItem.java +++ b/src/api/java/ic2/api/item/ISpecialElectricItem.java @@ -3,11 +3,11 @@ package ic2.api.item; import net.minecraft.item.ItemStack; public interface ISpecialElectricItem extends IElectricItem { - /** - * Supply a custom IElectricItemManager. - * - * @param itemStack ItemStack to get the manager for - * @return IElectricItemManager instance - */ - IElectricItemManager getManager(ItemStack itemStack); + /** + * Supply a custom IElectricItemManager. + * + * @param itemStack ItemStack to get the manager for + * @return IElectricItemManager instance + */ + IElectricItemManager getManager(ItemStack itemStack); } diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/api/java/ic2/api/item/ITerraformingBP.java index 5c9bf7ca..59b46bae 100644 --- a/src/api/java/ic2/api/item/ITerraformingBP.java +++ b/src/api/java/ic2/api/item/ITerraformingBP.java @@ -6,29 +6,29 @@ import net.minecraft.world.World; * Allows an item to act as a terraformer blueprint. */ public interface ITerraformingBP { - /** - * Get the energy consumption per operation of the blueprint. - * - * @return Energy consumption in EU - */ - public abstract int getConsume(); - - /** - * Get the maximum range of the blueprint. - * Should be a divisor of 5. - * - * @return Maximum range in blocks - */ - public abstract int getRange(); - - /** - * Perform the terraforming operation. - * - * @param world world to terraform - * @param x X position to terraform - * @param z Z position to terraform - * @param yCoord Y position of the terraformer - * @return Whether the operation was successful and the terraformer should consume energy. - */ - public abstract boolean terraform(World world, int x, int z, int yCoord); + /** + * Get the energy consumption per operation of the blueprint. + * + * @return Energy consumption in EU + */ + public abstract int getConsume(); + + /** + * Get the maximum range of the blueprint. + * Should be a divisor of 5. + * + * @return Maximum range in blocks + */ + public abstract int getRange(); + + /** + * Perform the terraforming operation. + * + * @param world world to terraform + * @param x X position to terraform + * @param z Z position to terraform + * @param yCoord Y position of the terraformer + * @return Whether the operation was successful and the terraformer should consume energy. + */ + public abstract boolean terraform(World world, int x, int z, int yCoord); } diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/api/java/ic2/api/item/ItemWrapper.java index 593cd1dc..58f80734 100644 --- a/src/api/java/ic2/api/item/ItemWrapper.java +++ b/src/api/java/ic2/api/item/ItemWrapper.java @@ -9,42 +9,42 @@ import com.google.common.collect.Multimap; /** * Wrapper for inserting interfaces into items you don't own. - * + * * @author Richard */ public class ItemWrapper { - private static final Multimap boxableItems = ArrayListMultimap.create(); - private static final Multimap metalArmorItems = ArrayListMultimap.create(); - - public static void registerBoxable(Item item, IBoxable boxable) { - boxableItems.put(item, boxable); - } - - public static boolean canBeStoredInToolbox(ItemStack stack) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IBoxable boxable : boxableItems.get(item)) { - if (boxable.canBeStoredInToolbox(stack)) return true; - } - - if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; - - return false; - } - - public static void registerMetalArmor(Item item, IMetalArmor armor) { - metalArmorItems.put(item, armor); - } - - public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IMetalArmor metalArmor : metalArmorItems.get(item)) { - if (metalArmor.isMetalArmor(stack, player)) return true; - } - - if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; - - return false; - } + private static final Multimap boxableItems = ArrayListMultimap.create(); + private static final Multimap metalArmorItems = ArrayListMultimap.create(); + + public static void registerBoxable(Item item, IBoxable boxable) { + boxableItems.put(item, boxable); + } + + public static boolean canBeStoredInToolbox(ItemStack stack) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IBoxable boxable : boxableItems.get(item)) { + if (boxable.canBeStoredInToolbox(stack)) return true; + } + + if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; + + return false; + } + + public static void registerMetalArmor(Item item, IMetalArmor armor) { + metalArmorItems.put(item, armor); + } + + public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IMetalArmor metalArmor : metalArmorItems.get(item)) { + if (metalArmor.isMetalArmor(stack, player)) return true; + } + + if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; + + return false; + } } diff --git a/src/api/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java index d814f54b..44ecdce9 100644 --- a/src/api/java/ic2/api/item/package-info.java +++ b/src/api/java/ic2/api/item/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.item; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.item; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java index 53cca72a..ed3ea38f 100644 --- a/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java @@ -6,12 +6,12 @@ import net.minecraft.entity.player.EntityPlayer; * Allows a tile entity to receive network events received from clients. */ public interface INetworkClientTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param player client which sent the event - * @param event event ID - */ - void onNetworkEvent(EntityPlayer player, int event); + /** + * Called when a network event is received. + * + * @param player client which sent the event + * @param event event ID + */ + void onNetworkEvent(EntityPlayer player, int event); } diff --git a/src/api/java/ic2/api/network/INetworkDataProvider.java b/src/api/java/ic2/api/network/INetworkDataProvider.java index cc59205f..c3f283e5 100644 --- a/src/api/java/ic2/api/network/INetworkDataProvider.java +++ b/src/api/java/ic2/api/network/INetworkDataProvider.java @@ -4,15 +4,15 @@ import java.util.List; /** * Tile entities which want to synchronized specific fields between client and server have to implement this. - *

+ * * The fields don't update themselves, a field update must be sent every time a synchronized field changes. */ public interface INetworkDataProvider { - /** - * Get the list of synchronized fields. - * - * @return Names of the synchronized fields - */ - List getNetworkedFields(); + /** + * Get the list of synchronized fields. + * + * @return Names of the synchronized fields + */ + List getNetworkedFields(); } diff --git a/src/api/java/ic2/api/network/INetworkItemEventListener.java b/src/api/java/ic2/api/network/INetworkItemEventListener.java index 85ac2a99..5f3228ce 100644 --- a/src/api/java/ic2/api/network/INetworkItemEventListener.java +++ b/src/api/java/ic2/api/network/INetworkItemEventListener.java @@ -7,13 +7,13 @@ import net.minecraft.item.ItemStack; * Allows an item to receive network events received from the server. */ public interface INetworkItemEventListener { - /** - * Called when a network event is received. - * - * @param itemStack item stack - * @param player player containing the item - * @param event event ID - */ - void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); + /** + * Called when a network event is received. + * + * @param itemStack item stack + * @param player player containing the item + * @param event event ID + */ + void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); } diff --git a/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java index 23b11c5b..fbb4753c 100644 --- a/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java @@ -4,11 +4,11 @@ package ic2.api.network; * Allows a tile entity to receive network events received from the server. */ public interface INetworkTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param event Event ID - */ - void onNetworkEvent(int event); + /** + * Called when a network event is received. + * + * @param event Event ID + */ + void onNetworkEvent(int event); } diff --git a/src/api/java/ic2/api/network/INetworkUpdateListener.java b/src/api/java/ic2/api/network/INetworkUpdateListener.java index 05548dee..09414ae3 100644 --- a/src/api/java/ic2/api/network/INetworkUpdateListener.java +++ b/src/api/java/ic2/api/network/INetworkUpdateListener.java @@ -1,14 +1,14 @@ package ic2.api.network; /** - * Allows a tile entity to receive field sync updates received from the server. + * Allows a tile entity to receive field sync updates received from the server. */ public interface INetworkUpdateListener { - /** - * Called when a field is synchronized. - * - * @param field field synchronized - */ - void onNetworkUpdate(String field); + /** + * Called when a field is synchronized. + * + * @param field field synchronized + */ + void onNetworkUpdate(String field); } diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java index c0aea0fe..5f9138d3 100644 --- a/src/api/java/ic2/api/network/NetworkHelper.java +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -8,192 +8,187 @@ import net.minecraft.tileentity.TileEntity; /** * Provides methods to initiate events and synchronize tile entity fields in SMP. - *

+ * * The methods are transparent between singleplayer and multiplayer - if a method is called in * singleplayer, the associated callback will be locally executed. The implementation is different * between the client and server versions of IC2. - *

+ * * You'll usually want to use the server->client methods defined here to synchronize information * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or * producing effects. Anything which is only visible inside the GUI should be synchronized through * the Container class associated to the GUI in Container.updateProgressBar(). */ public final class NetworkHelper { - // server -> client + // server -> client - /** - * Schedule a TileEntity's field to be updated to the clients in range. - *

- * The updater will query the field's value during the next update, updates happen usually - * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. - *

- * IC2's network updates have to get triggered every time, it doesn't continuously poll/send - * the field value. Just call updateTileEntityField after every change to a field which needs - * network synchronization. - *

- * The following field data types are currently supported: - * - int, int[], short, short[], byte, byte[], long, long[] - * - float, float[], double, double[] - * - boolean, boolean[] - * - String, String[] - * - ItemStack - * - NBTBase (includes NBTTagCompound) - * - Block, Item, Achievement, Potion, Enchantment - * - ChunkCoordinates, ChunkCoordIntPair - * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) - * - World (does not sync the actual world, instead looks up the world by its dimension ID) - *

- * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- - * side TileEntity if it implements INetworkUpdateListener. - *

- * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). - * - * @param te TileEntity to update - * @param field Name of the field to update - */ - public static void updateTileEntityField(TileEntity te, String field) { - try { - if (NetworkManager_updateTileEntityField == null) - NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); - if (instance == null) instance = getInstance(); + /** + * Schedule a TileEntity's field to be updated to the clients in range. + * + * The updater will query the field's value during the next update, updates happen usually + * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. + * + * IC2's network updates have to get triggered every time, it doesn't continuously poll/send + * the field value. Just call updateTileEntityField after every change to a field which needs + * network synchronization. + * + * The following field data types are currently supported: + * - int, int[], short, short[], byte, byte[], long, long[] + * - float, float[], double, double[] + * - boolean, boolean[] + * - String, String[] + * - ItemStack + * - NBTBase (includes NBTTagCompound) + * - Block, Item, Achievement, Potion, Enchantment + * - ChunkCoordinates, ChunkCoordIntPair + * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) + * - World (does not sync the actual world, instead looks up the world by its dimension ID) + * + * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- + * side TileEntity if it implements INetworkUpdateListener. + * + * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). + * + * @param te TileEntity to update + * @param field Name of the field to update + */ + public static void updateTileEntityField(TileEntity te, String field) { + try { + if (NetworkManager_updateTileEntityField == null) NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); + if (instance == null) instance = getInstance(); - NetworkManager_updateTileEntityField.invoke(instance, te, field); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + NetworkManager_updateTileEntityField.invoke(instance, te, field); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - /** - * Immediately send an event for the specified TileEntity to the clients in range. - *

- * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). - * - * @param te TileEntity to notify, should implement INetworkTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { - try { - if (NetworkManager_initiateTileEntityEvent == null) - NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); + /** + * Immediately send an event for the specified TileEntity to the clients in range. + * + * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). + * + * @param te TileEntity to notify, should implement INetworkTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { + try { + if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); - NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - /** - * Immediately send an event for the specified Item to the clients in range. - *

- * The item should implement INetworkItemEventListener to receive the event. - *

- * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkItemEventListener.onNetworkEvent (if implemented by the item). - * - * @param player EntityPlayer holding the item - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { - try { - if (NetworkManager_initiateItemEvent == null) - NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); + /** + * Immediately send an event for the specified Item to the clients in range. + * + * The item should implement INetworkItemEventListener to receive the event. + * + * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkItemEventListener.onNetworkEvent (if implemented by the item). + * + * @param player EntityPlayer holding the item + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { + try { + if (NetworkManager_initiateItemEvent == null) NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); - NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - // client -> server + // client -> server - /** - * Immediately send an event for the specified TileEntity to the server. - *

- * This method doesn't do anything if executed on the server. - * - * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientTileEntityEvent(TileEntity te, int event) { - try { - if (NetworkManager_initiateClientTileEntityEvent == null) - NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); - if (instance == null) instance = getInstance(); + /** + * Immediately send an event for the specified TileEntity to the server. + * + * This method doesn't do anything if executed on the server. + * + * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientTileEntityEvent(TileEntity te, int event) { + try { + if (NetworkManager_initiateClientTileEntityEvent == null) NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); + if (instance == null) instance = getInstance(); - NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - /** - * Immediately send an event for the specified Item to the clients in range. - *

- * The item should implement INetworkItemEventListener to receive the event. - *

- * This method doesn't do anything if executed on the server. - * - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientItemEvent(ItemStack itemStack, int event) { - try { - if (NetworkManager_initiateClientItemEvent == null) - NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); - if (instance == null) instance = getInstance(); + /** + * Immediately send an event for the specified Item to the clients in range. + * + * The item should implement INetworkItemEventListener to receive the event. + * + * This method doesn't do anything if executed on the server. + * + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientItemEvent(ItemStack itemStack, int event) { + try { + if (NetworkManager_initiateClientItemEvent == null) NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); + if (instance == null) instance = getInstance(); - NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = NetworkHelper.class.getPackage(); + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = NetworkHelper.class.getPackage(); - if (pkg != null) { - String packageName = pkg.getName(); + if (pkg != null) { + String packageName = pkg.getName(); - return packageName.substring(0, packageName.length() - ".api.network".length()); - } + return packageName.substring(0, packageName.length() - ".api.network".length()); + } - return "ic2"; - } + return "ic2"; + } - /** - * Get the NetworkManager instance, used internally. - * - * @return NetworkManager instance - */ - private static Object getInstance() { - try { - return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } + /** + * Get the NetworkManager instance, used internally. + * + * @return NetworkManager instance + */ + private static Object getInstance() { + try { + return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } - private static Object instance; - private static Method NetworkManager_updateTileEntityField; - private static Method NetworkManager_initiateTileEntityEvent; - private static Method NetworkManager_initiateItemEvent; - private static Method NetworkManager_initiateClientTileEntityEvent; - private static Method NetworkManager_initiateClientItemEvent; + private static Object instance; + private static Method NetworkManager_updateTileEntityField; + private static Method NetworkManager_initiateTileEntityEvent; + private static Method NetworkManager_initiateItemEvent; + private static Method NetworkManager_initiateClientTileEntityEvent; + private static Method NetworkManager_initiateClientItemEvent; } diff --git a/src/api/java/ic2/api/network/package-info.java b/src/api/java/ic2/api/network/package-info.java index d925e4a3..25ea29e1 100644 --- a/src/api/java/ic2/api/network/package-info.java +++ b/src/api/java/ic2/api/network/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.network; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.network; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java index 3440426c..e6f15228 100644 --- a/src/api/java/ic2/api/package-info.java +++ b/src/api/java/ic2/api/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/api/java/ic2/api/reactor/IReactor.java index c7a7a609..55191ccf 100644 --- a/src/api/java/ic2/api/reactor/IReactor.java +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -8,151 +8,151 @@ import net.minecraft.world.World; * Interface implemented by the tile entity of nuclear reactors. */ public interface IReactor { - /** - * Get the reactor's position in the world. - * - * @return Position of the reactor - */ - public ChunkCoordinates getPosition(); + /** + * Get the reactor's position in the world. + * + * @return Position of the reactor + */ + public ChunkCoordinates getPosition(); - /** - * Get the reactor's corresponding world. - * - * @return The reactor's world - */ - public World getWorld(); + /** + * Get the reactor's corresponding world. + * + * @return The reactor's world + */ + public World getWorld(); - /** - * Get the reactor's heat. - * - * @return The reactor's heat - */ - public int getHeat(); + /** + * Get the reactor's heat. + * + * @return The reactor's heat + */ + public int getHeat(); - /** - * Set the reactor's heat. - * - * @param heat reactor heat - */ - public void setHeat(int heat); + /** + * Set the reactor's heat. + * + * @param heat reactor heat + */ + public void setHeat(int heat); - /** - * Increase the reactor's heat. - *

- * Use negative values to decrease. - * - * @param amount amount of heat to add - * @return The reactor's heat after adding the specified amount - */ - public int addHeat(int amount); + /** + * Increase the reactor's heat. + * + * Use negative values to decrease. + * + * @param amount amount of heat to add + * @return The reactor's heat after adding the specified amount + */ + public int addHeat(int amount); - /** - * Get the reactor's maximum heat before exploding. - * - * @return Maximum heat value - */ - public int getMaxHeat(); + /** + * Get the reactor's maximum heat before exploding. + * + * @return Maximum heat value + */ + public int getMaxHeat(); - /** - * Set the reactor's stored maxHeat variable. - * Used by plating to increase the reactors MaxHeat capacity. - * Needs to be called during each cycle process. - */ - public void setMaxHeat(int newMaxHeat); + /** + * Set the reactor's stored maxHeat variable. + * Used by plating to increase the reactors MaxHeat capacity. + * Needs to be called during each cycle process. + */ + public void setMaxHeat(int newMaxHeat); - /** - * add Heat to a EmitHeat Buffer - * for use in Reactor operation.. need to be use - * for all Componetents with self-cooling - * no more magic heat disappear - */ + /** + * add Heat to a EmitHeat Buffer + * for use in Reactor operation.. need to be use + * for all Componetents with self-cooling + * no more magic heat disappear + */ - public void addEmitHeat(int heat); + public void addEmitHeat(int heat); - /** - * Get's the reactor's HEM (Heat Effect Modifier) - * Basic value is 1.0F. - * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors - * (F.e. water evaporation, melting, damaging entitys, etc) - * - * @return HEM - */ - public float getHeatEffectModifier(); + /** + * Get's the reactor's HEM (Heat Effect Modifier) + * Basic value is 1.0F. + * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors + * (F.e. water evaporation, melting, damaging entitys, etc) + * + * @return HEM + */ + public float getHeatEffectModifier(); - /** - * Set's the reactor's HEM - * Needs to be called during each cycle process. - */ - public void setHeatEffectModifier(float newHEM); + /** + * Set's the reactor's HEM + * Needs to be called during each cycle process. + */ + public void setHeatEffectModifier(float newHEM); - /** - * Get the reactor's energy output. - * - * @return Energy output, not multiplied by the base EU/t value - */ - public float getReactorEnergyOutput(); + /** + * Get the reactor's energy output. + * + * @return Energy output, not multiplied by the base EU/t value + */ + public float getReactorEnergyOutput(); - /** - * Get the reactor's energy output. - * - * @return Energy output, multiplied with base EU/t value and MainConfig.get().getFloat("balance/energy/generator/nuclear") - */ - public double getReactorEUEnergyOutput(); + /** + * Get the reactor's energy output. + * + * @return Energy output, multiplied with base EU/t value and MainConfig.get().getFloat("balance/energy/generator/nuclear") + */ + public double getReactorEUEnergyOutput(); - /** - * Add's the given amount of energy to the Reactor's output. - * - * @return Energy output after adding the value, not multiplied by the base EU/t value - */ - public float addOutput(float energy); + /** + * Add's the given amount of energy to the Reactor's output. + * + * @return Energy output after adding the value, not multiplied by the base EU/t value + */ + public float addOutput(float energy); - /** - * Get the item at the specified grid coordinates. - * - * @param x X position of the item, out of bounds returns null - * @param y Y position of the item, out of bounds returns null - * @return The item or null if there is no item - */ - public ItemStack getItemAt(int x, int y); + /** + * Get the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds returns null + * @param y Y position of the item, out of bounds returns null + * @return The item or null if there is no item + */ + public ItemStack getItemAt(int x, int y); - /** - * Set the item at the specified grid coordinates. - * - * @param x X position of the item, out of bounds is a no-op - * @param y Y position of the item, out of bounds is a no-op - * @param item The item to set. - */ - public void setItemAt(int x, int y, ItemStack item); + /** + * Set the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds is a no-op + * @param y Y position of the item, out of bounds is a no-op + * @param item The item to set. + */ + public void setItemAt(int x, int y, ItemStack item); - /** - * Explode the reactor. - */ - public void explode(); + /** + * Explode the reactor. + */ + public void explode(); - /** - * Get the reactor's tick rate (game ticks per reactor tick). - * - * @return Tick rate - */ - public int getTickRate(); + /** + * Get the reactor's tick rate (game ticks per reactor tick). + * + * @return Tick rate + */ + public int getTickRate(); - /** - * Get whether the reactor is active and supposed to produce energy - * - * @return Whether the reactor is active - */ - public boolean produceEnergy(); + /** + * Get whether the reactor is active and supposed to produce energy + * @return Whether the reactor is active + */ + public boolean produceEnergy(); - /** - * Set Redstone Signal without direct contact - */ + /** + * Set Redstone Signal without direct contact + * + */ - public void setRedstoneSignal(boolean redstone); + public void setRedstoneSignal(boolean redstone); - /** - * @return true if the reactor is FluidCooled - */ + /** + * @return true if the reactor is FluidCooled + */ - public boolean isFluidCooled(); + public boolean isFluidCooled(); } diff --git a/src/api/java/ic2/api/reactor/IReactorChamber.java b/src/api/java/ic2/api/reactor/IReactorChamber.java index 7199c43b..4611a6af 100644 --- a/src/api/java/ic2/api/reactor/IReactorChamber.java +++ b/src/api/java/ic2/api/reactor/IReactorChamber.java @@ -4,16 +4,17 @@ package ic2.api.reactor; * Interface implemented by the reactor chamber tile entity. */ public interface IReactorChamber { - /** - * Get the chamber's reactor. - * - * @return The reactor - */ - public IReactor getReactor(); + /** + * Get the chamber's reactor. + * + * @return The reactor + */ + public IReactor getReactor(); - /** - * Set Redstone Signal without direct contact - */ - - public void setRedstoneSignal(boolean redstone); + /** + * Set Redstone Signal without direct contact + * + */ + + public void setRedstoneSignal(boolean redstone); } diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/api/java/ic2/api/reactor/IReactorComponent.java index 80bfa659..84e011c7 100644 --- a/src/api/java/ic2/api/reactor/IReactorComponent.java +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -6,96 +6,93 @@ import net.minecraft.item.ItemStack; * Design custom Reactor components by implementing this Interface * Items implementing the interface will not be ejected from Reactors in their clean-up * and can/will be interacted with by other elements, f.e. Uranium Cells. - *

+ * * All IC2 ReactorComponents implement and use this Interface + * */ public interface IReactorComponent { - /** - * Called by reactor upon iterating through it's inventory (every cycle). - * Perform all necessary calculation/interaction here - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @param heatrun every Stack will cycle 2 time (true, false) first run for heat, sec for Eu calculation - */ - public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun); + /** + * Called by reactor upon iterating through it's inventory (every cycle). + * Perform all necessary calculation/interaction here + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heatrun every Stack will cycle 2 time (true, false) first run for heat, sec for Eu calculation + */ + public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun); - /** - * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. - * Uranium-Uranium interaction (f.e.) uses this method. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of called ItemStack - * @param pulsingStack Reference to the specific instance of pulsing ItemStack - * @param youX X-coordinate of your stack in the grid - * @param youY Y-coordinate of your stack in the grid - * @param pulseX X-coordinate of pulsing stack in the grid - * @param pulseY Y-coordinate of pulsing stack in the grid - * @param heatrun true for only create heat not EU, false for only EU not heat - * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) - */ - public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); + /** + * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. + * Uranium-Uranium interaction (f.e.) uses this method. + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of called ItemStack + * @param pulsingStack Reference to the specific instance of pulsing ItemStack + * @param youX X-coordinate of your stack in the grid + * @param youY Y-coordinate of your stack in the grid + * @param pulseX X-coordinate of pulsing stack in the grid + * @param pulseY Y-coordinate of pulsing stack in the grid + * @param heatrun true for only create heat not EU, false for only EU not heat + * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) + */ + public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); - /** - * Called by components to determine whether your component can be heated. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return true if your component can take heat - */ - public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); + /** + * Called by components to determine whether your component can be heated. + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return true if your component can take heat + */ + public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the maximum capacity of your heat-containing component here. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Maximum heat - */ - public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the maximum capacity of your heat-containing component here. + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Maximum heat + */ + public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the current amount of heat stored in this component - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Current Heat - */ - public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the current amount of heat stored in this component + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Current Heat + */ + public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); - /** - * Called by components to distribute heat to your component. - * Perform heating-calculations and increase your heat (dmg) level accordingly. - * This method will as well be called to REDUCE heat, by providing a negative amount. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @param heat Amount of heat to be added (may be negative to subtract heat) - * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) - */ - public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); + /** + * Called by components to distribute heat to your component. + * Perform heating-calculations and increase your heat (dmg) level accordingly. + * This method will as well be called to REDUCE heat, by providing a negative amount. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heat Amount of heat to be added (may be negative to subtract heat) + * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) + */ + public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); - /** - * Called upon reactor explosion - * Alter the explosion size. - * Returning a float 0 < f < 1 will be counted as multiplier. - * Anything else will be counted as a flat addition (in case of <0 = reduction). - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @return your explosion modifier - */ - public float influenceExplosion(IReactor reactor, ItemStack yourStack); + /** + * Called upon reactor explosion + * Alter the explosion size. + * Returning a float 0 < f < 1 will be counted as multiplier. + * Anything else will be counted as a flat addition (in case of <0 = reduction). + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @return your explosion modifier + */ + public float influenceExplosion(IReactor reactor, ItemStack yourStack); } diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/api/java/ic2/api/reactor/package-info.java index 43a08227..5194aee0 100644 --- a/src/api/java/ic2/api/reactor/package-info.java +++ b/src/api/java/ic2/api/reactor/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.reactor; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.reactor; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java index f5934125..415b3c38 100644 --- a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java @@ -5,47 +5,47 @@ import java.util.Map; import net.minecraft.item.ItemStack; public interface ICannerBottleRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param container Container to be filled - * @param fill Item to fill into the container - * @param output Filled container - */ - public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output); + /** + * Adds a recipe to the machine. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param output Filled container + */ + public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output); - /** - * Gets the recipe output for the given input. - * - * @param container Container to be filled - * @param fill Item to fill into the container - * @param adjustInput modify the input according to the recipe's requirements - * @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe - * @return Recipe output, or null if none - */ - public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest); + /** + * Gets the recipe output for the given input. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest); - /** - * Gets a list of recipes. - *

- * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); + /** + * Gets a list of recipes. + * + * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); - public static class Input { - public Input(IRecipeInput container1, IRecipeInput fill1) { - this.container = container1; - this.fill = fill1; - } + public static class Input { + public Input(IRecipeInput container1, IRecipeInput fill1) { + this.container = container1; + this.fill = fill1; + } - public boolean matches(ItemStack container1, ItemStack fill1) { - return this.container.matches(container1) && this.fill.matches(fill1); - } + public boolean matches(ItemStack container1, ItemStack fill1) { + return this.container.matches(container1) && this.fill.matches(fill1); + } - public final IRecipeInput container; - public final IRecipeInput fill; - } + public final IRecipeInput container; + public final IRecipeInput fill; + } } diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java index d5df6755..5eba1b68 100644 --- a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java @@ -7,48 +7,48 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public interface ICannerEnrichRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param input Fluid input - * @param additive Item to enrich the fluid with - * @param output Output fluid - */ - public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output); + /** + * Adds a recipe to the machine. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param output Output fluid + */ + public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output); - /** - * Gets the recipe output for the given input. - * - * @param input Fluid input - * @param additive Item to enrich the fluid with - * @param adjustInput modify the input according to the recipe's requirements - * @param acceptTest allow input or additive to be null to see if either of them is part of a recipe - * @return Recipe output, or null if none, output fluid in nbt - */ - public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest); + /** + * Gets the recipe output for the given input. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow input or additive to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none, output fluid in nbt + */ + public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest); - /** - * Gets a list of recipes. - *

- * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); + /** + * Gets a list of recipes. + * + * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); - public static class Input { - public Input(FluidStack fluid1, IRecipeInput additive1) { - this.fluid = fluid1; - this.additive = additive1; - } + public static class Input { + public Input(FluidStack fluid1, IRecipeInput additive1) { + this.fluid = fluid1; + this.additive = additive1; + } - public boolean matches(FluidStack fluid1, ItemStack additive1) { - return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && - this.additive.matches(additive1); - } + public boolean matches(FluidStack fluid1, ItemStack additive1) { + return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && + this.additive.matches(additive1); + } - public final FluidStack fluid; - public final IRecipeInput additive; - } + public final FluidStack fluid; + public final IRecipeInput additive; + } } diff --git a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java index b70c7e1f..756eaf63 100644 --- a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java @@ -4,23 +4,23 @@ import net.minecraft.item.ItemStack; /** * Recipe manager interface for crafting recipes. - * + * * @author Richard */ public interface ICraftingRecipeManager { - /** - * Adds a shaped crafting recipe. - * - * @param output Recipe output - * @param input Recipe input format - */ - public void addRecipe(ItemStack output, Object... input); - - /** - * Adds a shapeless crafting recipe. - * - * @param output Recipe output - * @param input Recipe input - */ - public void addShapelessRecipe(ItemStack output, Object... input); + /** + * Adds a shaped crafting recipe. + * + * @param output Recipe output + * @param input Recipe input format + */ + public void addRecipe(ItemStack output, Object... input); + + /** + * Adds a shapeless crafting recipe. + * + * @param output Recipe output + * @param input Recipe input + */ + public void addShapelessRecipe(ItemStack output, Object... input); } diff --git a/src/api/java/ic2/api/recipe/IFluidHeatManager.java b/src/api/java/ic2/api/recipe/IFluidHeatManager.java index 7bfff1d2..7ddecdce 100644 --- a/src/api/java/ic2/api/recipe/IFluidHeatManager.java +++ b/src/api/java/ic2/api/recipe/IFluidHeatManager.java @@ -6,27 +6,27 @@ import net.minecraftforge.fluids.Fluid; public interface IFluidHeatManager extends ILiquidAcceptManager { - /** - * Add a new fluid to the Fluid Heat Generator. - * - * @param fluidName the fluid to burn - * @param amount amount of fluid to consume per tick - * @param heat amount of heat generated per tick - */ - void addFluid(String fluidName, int amount, int heat); + /** + * Add a new fluid to the Fluid Heat Generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param heat amount of heat generated per tick + */ + void addFluid(String fluidName, int amount, int heat); - BurnProperty getBurnProperty(Fluid fluid); + BurnProperty getBurnProperty(Fluid fluid); - Map getBurnProperties(); + Map getBurnProperties(); - public static class BurnProperty { - public BurnProperty(int amount1, int heat1) { - this.amount = amount1; - this.heat = heat1; - } + public static class BurnProperty { + public BurnProperty(int amount1, int heat1) { + this.amount = amount1; + this.heat = heat1; + } - public final int amount; - public final int heat; - } + public final int amount; + public final int heat; + } } diff --git a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java index 39459d27..4f377b90 100644 --- a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java +++ b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java @@ -5,7 +5,6 @@ import java.util.Set; import net.minecraftforge.fluids.Fluid; public interface ILiquidAcceptManager { - boolean acceptsFluid(Fluid fluid); - - Set getAcceptedFluids(); + boolean acceptsFluid(Fluid fluid); + Set getAcceptedFluids(); } diff --git a/src/api/java/ic2/api/recipe/IListRecipeManager.java b/src/api/java/ic2/api/recipe/IListRecipeManager.java index 4b5ab28d..adc22912 100644 --- a/src/api/java/ic2/api/recipe/IListRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IListRecipeManager.java @@ -6,36 +6,36 @@ import net.minecraft.item.ItemStack; /** * Recipe manager interface for basic lists. - * + * * @author Richard */ public interface IListRecipeManager extends Iterable { - /** - * Adds a stack to the list. - * - * @param stack Stack to add - */ - public void add(IRecipeInput input); + /** + * Adds a stack to the list. + * + * @param stack Stack to add + */ + public void add(IRecipeInput input); - /** - * Checks whether the specified stack is in the list. - * - * @param stack Stack to check - * @return Whether the stack is in the list - */ - public boolean contains(ItemStack stack); + /** + * Checks whether the specified stack is in the list. + * + * @param stack Stack to check + * @return Whether the stack is in the list + */ + public boolean contains(ItemStack stack); - /** - * @return if the List is Empty - */ - public boolean isEmpty(); + /** + * @return if the List is Empty + */ + public boolean isEmpty(); - /** - * Gets the list of stacks. - *

- * You're a mad evil scientist if you ever modify this. - * - * @return List of stacks - */ - public List getInputs(); + /** + * Gets the list of stacks. + * + * You're a mad evil scientist if you ever modify this. + * + * @return List of stacks + */ + public List getInputs(); } diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java index 9bc465c1..388e394a 100644 --- a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java @@ -7,37 +7,38 @@ import net.minecraft.nbt.NBTTagCompound; /** * Recipe manager interface for basic machines. - * + * * @author RichardG, Player */ public interface IMachineRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param input Recipe input - * @param metadata meta data for additional recipe properties, may be null - * @param outputs Recipe outputs, zero or more depending on the machine - *

- * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} - * For the ore washing plant @param metadata meta data {"amount": 1-8000} - */ - public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); + /** + * Adds a recipe to the machine. + * + * @param input Recipe input + * @param metadata meta data for additional recipe properties, may be null + * @param outputs Recipe outputs, zero or more depending on the machine + * + * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} + * For the ore washing plant @param metadata meta data {"amount": 1-8000} + * + */ + public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); - /** - * Gets the recipe output for the given input. - * - * @param input Recipe input - * @param adjustInput modify the input according to the recipe's requirements - * @return Recipe output, or null if none - */ - public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); + /** + * Gets the recipe output for the given input. + * + * @param input Recipe input + * @param adjustInput modify the input according to the recipe's requirements + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); - /** - * Gets a list of recipes. - *

- * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); + /** + * Gets a list of recipes. + * + * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); } diff --git a/src/api/java/ic2/api/recipe/IPatternStorage.java b/src/api/java/ic2/api/recipe/IPatternStorage.java index 02719342..c9dbd8d7 100644 --- a/src/api/java/ic2/api/recipe/IPatternStorage.java +++ b/src/api/java/ic2/api/recipe/IPatternStorage.java @@ -5,7 +5,7 @@ import java.util.List; import net.minecraft.item.ItemStack; public interface IPatternStorage { - boolean addPattern(ItemStack itemstack); + boolean addPattern(ItemStack itemstack); - List getPatterns(); + List getPatterns(); } diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java index 200d2428..0c842d63 100644 --- a/src/api/java/ic2/api/recipe/IRecipeInput.java +++ b/src/api/java/ic2/api/recipe/IRecipeInput.java @@ -5,27 +5,27 @@ import java.util.List; import net.minecraft.item.ItemStack; public interface IRecipeInput { - /** - * Check if subject matches this recipe input, ignoring the amount. - * - * @param subject ItemStack to check - * @return true if it matches the requirement - */ - boolean matches(ItemStack subject); + /** + * Check if subject matches this recipe input, ignoring the amount. + * + * @param subject ItemStack to check + * @return true if it matches the requirement + */ + boolean matches(ItemStack subject); - /** - * Determine the minimum input stack size. - * - * @return input amount required - */ - int getAmount(); + /** + * Determine the minimum input stack size. + * + * @return input amount required + */ + int getAmount(); - /** - * List all possible inputs (best effort). - *

- * The stack size is undefined, use getAmount to get the correct one. - * - * @return list of inputs, may be incomplete - */ - List getInputs(); + /** + * List all possible inputs (best effort). + * + * The stack size is undefined, use getAmount to get the correct one. + * + * @return list of inputs, may be incomplete + */ + List getInputs(); } diff --git a/src/api/java/ic2/api/recipe/IScrapboxManager.java b/src/api/java/ic2/api/recipe/IScrapboxManager.java index 8ed3cc93..41b694dc 100644 --- a/src/api/java/ic2/api/recipe/IScrapboxManager.java +++ b/src/api/java/ic2/api/recipe/IScrapboxManager.java @@ -5,9 +5,9 @@ import java.util.Map; import net.minecraft.item.ItemStack; public interface IScrapboxManager { - void addDrop(ItemStack drop, float rawChance); + void addDrop(ItemStack drop, float rawChance); - ItemStack getDrop(ItemStack input, boolean adjustInput); + ItemStack getDrop(ItemStack input, boolean adjustInput); - Map getDrops(); + Map getDrops(); } diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java index 64634f3c..87c34270 100644 --- a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java +++ b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java @@ -6,27 +6,27 @@ import net.minecraftforge.fluids.Fluid; public interface ISemiFluidFuelManager extends ILiquidAcceptManager { - /** - * Add a new fluid to the semi fluid generator. - * - * @param fluidName the fluid to burn - * @param amount amount of fluid to consume per tick - * @param power amount of energy generated per tick - */ - void addFluid(String fluidName, int amount, double power); + /** + * Add a new fluid to the semi fluid generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param power amount of energy generated per tick + */ + void addFluid(String fluidName, int amount, double power); - BurnProperty getBurnProperty(Fluid fluid); + BurnProperty getBurnProperty(Fluid fluid); - Map getBurnProperties(); + Map getBurnProperties(); - public static class BurnProperty { - public BurnProperty(int amount1, double power1) { - this.amount = amount1; - this.power = power1; - } + public static class BurnProperty { + public BurnProperty(int amount1, double power1) { + this.amount = amount1; + this.power = power1; + } - public final int amount; - public final double power; - } + public final int amount; + public final double power; + } } diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java index 764ea698..103d293e 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -11,44 +11,44 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidStack; public class RecipeInputFluidContainer implements IRecipeInput { - public RecipeInputFluidContainer(Fluid fluid) { - this(fluid, FluidContainerRegistry.BUCKET_VOLUME); - } + public RecipeInputFluidContainer(Fluid fluid) { + this(fluid, FluidContainerRegistry.BUCKET_VOLUME); + } - public RecipeInputFluidContainer(Fluid fluid, int amount) { - this.fluid = fluid; - this.amount = amount; - } + public RecipeInputFluidContainer(Fluid fluid, int amount) { + this.fluid = fluid; + this.amount = amount; + } - @Override - public boolean matches(ItemStack subject) { - FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); - if (fs == null) return false; + @Override + public boolean matches(ItemStack subject) { + FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); + if (fs == null) return false; - return fs.getFluid() == fluid; - } + return fs.getFluid() == fluid; + } - @Override - public int getAmount() { - return amount; - } + @Override + public int getAmount() { + return amount; + } - @Override - public List getInputs() { - List ret = new ArrayList(); + @Override + public List getInputs() { + List ret = new ArrayList(); - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); - } + for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); + } - return ret; - } + return ret; + } - @Override - public String toString() { - return "RInputFluidContainer<" + amount + "x" + fluid.getName() + ">"; - } + @Override + public String toString() { + return "RInputFluidContainer<"+amount+"x"+fluid.getName()+">"; + } - public final Fluid fluid; - public final int amount; + public final Fluid fluid; + public final int amount; } diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java index 22a809d5..e1b65f94 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -8,39 +8,39 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeInputItemStack implements IRecipeInput { - public RecipeInputItemStack(ItemStack aInput) { - this(aInput, aInput.stackSize); - } + public RecipeInputItemStack(ItemStack aInput) { + this(aInput, aInput.stackSize); + } - public RecipeInputItemStack(ItemStack aInput, int aAmount) { - if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); + public RecipeInputItemStack(ItemStack aInput, int aAmount) { + if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); - input = aInput.copy(); // Never forget to copy. - amount = aAmount; - } + input = aInput.copy(); // Never forget to copy. + amount = aAmount; + } - @Override - public boolean matches(ItemStack subject) { - return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); - } + @Override + public boolean matches(ItemStack subject) { + return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); + } - @Override - public int getAmount() { - return amount; - } + @Override + public int getAmount() { + return amount; + } - @Override - public List getInputs() { - return Arrays.asList(input); - } + @Override + public List getInputs() { + return Arrays.asList(input); + } - @Override - public String toString() { - ItemStack stack = input.copy(); - input.stackSize = amount; - return "RInputItemStack<" + stack + ">"; - } + @Override + public String toString() { + ItemStack stack = input.copy(); + input.stackSize = amount; + return "RInputItemStack<"+stack+">"; + } - public final ItemStack input; - public final int amount; + public final ItemStack input; + public final int amount; } diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java index 4d7d3d12..89f73dc2 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -8,64 +8,64 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class RecipeInputOreDict implements IRecipeInput { - public RecipeInputOreDict(String input1) { - this(input1, 1); - } + public RecipeInputOreDict(String input1) { + this(input1, 1); + } - public RecipeInputOreDict(String input1, int amount1) { - this(input1, amount1, null); - } + public RecipeInputOreDict(String input1, int amount1) { + this(input1, amount1, null); + } - public RecipeInputOreDict(String input1, int amount1, Integer meta) { - this.input = input1; - this.amount = amount1; - this.meta = meta; - } + public RecipeInputOreDict(String input1, int amount1, Integer meta) { + this.input = input1; + this.amount = amount1; + this.meta = meta; + } - @Override - public boolean matches(ItemStack subject) { - List inputs = OreDictionary.getOres(input); + @Override + public boolean matches(ItemStack subject) { + List inputs = OreDictionary.getOres(input); - for (ItemStack input1 : inputs) { - if (input1.getItem() == null) continue; // ignore invalid - int metaRequired = meta == null ? input1.getItemDamage() : meta; + for (ItemStack input1 : inputs) { + if (input1.getItem() == null) continue; // ignore invalid + int metaRequired = meta == null ? input1.getItemDamage() : meta; - if (subject.getItem() == input1.getItem() && - (subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { - return true; - } - } + if (subject.getItem() == input1.getItem() && + (subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { + return true; + } + } - return false; - } + return false; + } - @Override - public int getAmount() { - return amount; - } + @Override + public int getAmount() { + return amount; + } - @Override - public List getInputs() { - List ores = OreDictionary.getOres(input); - List ret = new ArrayList(ores.size()); + @Override + public List getInputs() { + List ores = OreDictionary.getOres(input); + List ret = new ArrayList(ores.size()); - for (ItemStack stack : ores) { - if (stack.getItem() != null) ret.add(stack); // ignore invalid - } + for (ItemStack stack : ores) { + if (stack.getItem() != null) ret.add(stack); // ignore invalid + } - return ret; - } + return ret; + } - @Override - public String toString() { - if (meta == null) { - return "RInputOreDict<" + amount + "x" + input + ">"; - } else { - return "RInputOreDict<" + amount + "x" + input + "@" + meta + ">"; - } - } + @Override + public String toString() { + if (meta == null) { + return "RInputOreDict<"+amount+"x"+input+">"; + } else { + return "RInputOreDict<"+amount+"x"+input+"@"+meta+">"; + } + } - public final String input; - public final int amount; - public final Integer meta; + public final String input; + public final int amount; + public final Integer meta; } diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java index 9020f892..867cfa25 100644 --- a/src/api/java/ic2/api/recipe/RecipeOutput.java +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -7,22 +7,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public final class RecipeOutput { - public RecipeOutput(NBTTagCompound metadata1, List items1) { - assert !items1.contains(null); + public RecipeOutput(NBTTagCompound metadata1, List items1) { + assert !items1.contains(null); - this.metadata = metadata1; - this.items = items1; - } + this.metadata = metadata1; + this.items = items1; + } - public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { - this(metadata1, Arrays.asList(items1)); - } + public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { + this(metadata1, Arrays.asList(items1)); + } - @Override - public String toString() { - return "ROutput<" + items + "," + metadata + ">"; - } + @Override + public String toString() { + return "ROutput<"+items+","+metadata+">"; + } - public final List items; - public final NBTTagCompound metadata; + public final List items; + public final NBTTagCompound metadata; } diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java index fae2cd68..4c125976 100644 --- a/src/api/java/ic2/api/recipe/Recipes.java +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -3,58 +3,58 @@ package ic2.api.recipe; /** * General recipe registry. - * + * * @author Richard */ public class Recipes { - public static IMachineRecipeManager macerator; - public static IMachineRecipeManager extractor; - public static IMachineRecipeManager compressor; - public static IMachineRecipeManager centrifuge; - public static IMachineRecipeManager blockcutter; - public static IMachineRecipeManager blastfurance; - public static IMachineRecipeManager recycler; - public static IMachineRecipeManager metalformerExtruding; - public static IMachineRecipeManager metalformerCutting; - public static IMachineRecipeManager metalformerRolling; - public static IMachineRecipeManager oreWashing; - public static ICannerBottleRecipeManager cannerBottle; - public static ICannerEnrichRecipeManager cannerEnrich; + public static IMachineRecipeManager macerator; + public static IMachineRecipeManager extractor; + public static IMachineRecipeManager compressor; + public static IMachineRecipeManager centrifuge; + public static IMachineRecipeManager blockcutter; + public static IMachineRecipeManager blastfurance; + public static IMachineRecipeManager recycler; + public static IMachineRecipeManager metalformerExtruding; + public static IMachineRecipeManager metalformerCutting; + public static IMachineRecipeManager metalformerRolling; + public static IMachineRecipeManager oreWashing; + public static ICannerBottleRecipeManager cannerBottle; + public static ICannerEnrichRecipeManager cannerEnrich; - /** - * Reference amplifier values: - *

- * 5000: Scrap - * 45000: Scrapbox - *

- * As Parameter for the Amplification Value you have to use the NBTTagCompound - *

- * NBTTagCompound nbt = new NBTTagCompound(); - * nbt.setInteger("amplification", aValue); - * matterAmplifier.addRecipe(yourStack, nbt); - */ - public static IMachineRecipeManager matterAmplifier; - /** - * Reference scrap box chance values: - *

- * 0.1: Diamond - * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore - * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone - * 1.5: Apple, Bread - * 2.0: Netherrack, Rotten Flesh - * 3.0: Grass, Gravel - * 4.0: Stick - * 5.0: Dirt, Wooden Hoe - */ - public static IScrapboxManager scrapboxDrops; - public static IListRecipeManager recyclerBlacklist; - /** - * Do not add anything to this Whitelist. This is for Configuration only. - * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List - */ - public static IListRecipeManager recyclerWhitelist; - public static ICraftingRecipeManager advRecipes; + /** + * Reference amplifier values: + * + * 5000: Scrap + * 45000: Scrapbox + * + * As Parameter for the Amplification Value you have to use the NBTTagCompound + * + * NBTTagCompound nbt = new NBTTagCompound(); + * nbt.setInteger("amplification", aValue); + * matterAmplifier.addRecipe(yourStack, nbt); + */ + public static IMachineRecipeManager matterAmplifier; + /** + * Reference scrap box chance values: + * + * 0.1: Diamond + * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore + * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone + * 1.5: Apple, Bread + * 2.0: Netherrack, Rotten Flesh + * 3.0: Grass, Gravel + * 4.0: Stick + * 5.0: Dirt, Wooden Hoe + */ + public static IScrapboxManager scrapboxDrops; + public static IListRecipeManager recyclerBlacklist; + /** + * Do not add anything to this Whitelist. This is for Configuration only. + * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List + */ + public static IListRecipeManager recyclerWhitelist; + public static ICraftingRecipeManager advRecipes; - public static ISemiFluidFuelManager semiFluidGenerator; - public static IFluidHeatManager FluidHeatGenerator; + public static ISemiFluidFuelManager semiFluidGenerator; + public static IFluidHeatManager FluidHeatGenerator; } diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java index 7526ce32..44e70e79 100644 --- a/src/api/java/ic2/api/recipe/package-info.java +++ b/src/api/java/ic2/api/recipe/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.recipe; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.recipe; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/api/java/ic2/api/tile/ExplosionWhitelist.java index ade0e197..fa4a474a 100644 --- a/src/api/java/ic2/api/tile/ExplosionWhitelist.java +++ b/src/api/java/ic2/api/tile/ExplosionWhitelist.java @@ -7,41 +7,41 @@ import net.minecraft.block.Block; /** * Blocks on this whitelist will not resist an explosion but won't be destroyed. - *

+ * * The explosion code by default ignores blocks which absorb more than 1000 explosion power to * prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get * destroyed. */ public final class ExplosionWhitelist { - /** - * Add a block to the whitelist. - * - * @param block block to add - */ - public static void addWhitelistedBlock(Block block) { - whitelist.add(block); - } + /** + * Add a block to the whitelist. + * + * @param block block to add + */ + public static void addWhitelistedBlock(Block block) { + whitelist.add(block); + } + + /** + * Remove a block from the whitelist. + * + * @param block block to remove + */ + public static void removeWhitelistedBlock(Block block) { + whitelist.remove(block); + } + + /** + * Check if a block is on the whitelist. + * + * @param block block to check if whitelisted + * @return Whether the block is whitelisted + */ + public static boolean isBlockWhitelisted(Block block) { + return whitelist.contains(block); + } - /** - * Remove a block from the whitelist. - * - * @param block block to remove - */ - public static void removeWhitelistedBlock(Block block) { - whitelist.remove(block); - } - - /** - * Check if a block is on the whitelist. - * - * @param block block to check if whitelisted - * @return Whether the block is whitelisted - */ - public static boolean isBlockWhitelisted(Block block) { - return whitelist.contains(block); - } - - private static Set whitelist = new HashSet(); + private static Set whitelist = new HashSet(); } diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.java b/src/api/java/ic2/api/tile/IEnergyStorage.java index bf80b004..68f42703 100644 --- a/src/api/java/ic2/api/tile/IEnergyStorage.java +++ b/src/api/java/ic2/api/tile/IEnergyStorage.java @@ -6,56 +6,56 @@ import net.minecraftforge.common.util.ForgeDirection; * Interface implemented by the tile entity of energy storage blocks. */ public interface IEnergyStorage { - /** - * Get the amount of energy currently stored in the block. - * - * @return Energy stored in the block - */ - public int getStored(); + /** + * Get the amount of energy currently stored in the block. + * + * @return Energy stored in the block + */ + public int getStored(); - /** - * Set the amount of energy currently stored in the block. - * - * @param energy stored energy - */ - public void setStored(int energy); + /** + * Set the amount of energy currently stored in the block. + * + * @param energy stored energy + */ + public void setStored(int energy); - /** - * Add the specified amount of energy. - *

- * Use negative values to decrease. - * - * @param amount of energy to add - * @return Energy stored in the block after adding the specified amount - */ - public int addEnergy(int amount); + /** + * Add the specified amount of energy. + * + * Use negative values to decrease. + * + * @param amount of energy to add + * @return Energy stored in the block after adding the specified amount + */ + public int addEnergy(int amount); - /** - * Get the maximum amount of energy the block can store. - * - * @return Maximum energy stored - */ - public int getCapacity(); + /** + * Get the maximum amount of energy the block can store. + * + * @return Maximum energy stored + */ + public int getCapacity(); - /** - * Get the block's energy output. - * - * @return Energy output in EU/t - */ - public int getOutput(); + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public int getOutput(); - /** - * Get the block's energy output. - * - * @return Energy output in EU/t - */ - public double getOutputEnergyUnitsPerTick(); + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public double getOutputEnergyUnitsPerTick(); - /** - * Get whether this block can have its energy used by an adjacent teleporter. - * - * @param side side the teleporter is draining energy from - * @return Whether the block is teleporter compatible - */ - public boolean isTeleporterCompatible(ForgeDirection side); + /** + * Get whether this block can have its energy used by an adjacent teleporter. + * + * @param side side the teleporter is draining energy from + * @return Whether the block is teleporter compatible + */ + public boolean isTeleporterCompatible(ForgeDirection side); } diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java index 0cbaba64..8fcbea59 100644 --- a/src/api/java/ic2/api/tile/IWrenchable.java +++ b/src/api/java/ic2/api/tile/IWrenchable.java @@ -7,55 +7,55 @@ import net.minecraft.item.ItemStack; * Allows a tile entity to make use of the wrench's removal and rotation functions. */ public interface IWrenchable { - /** - * Determine if the wrench can be used to set the block's facing. - * Called before wrenchCanRemove(). - * - * @param entityPlayer player using the wrench, may be null - * @param side block's side the wrench was clicked on - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); + /** + * Determine if the wrench can be used to set the block's facing. + * Called before wrenchCanRemove(). + * + * @param entityPlayer player using the wrench, may be null + * @param side block's side the wrench was clicked on + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); - /** - * Get the block's facing. - * - * @return Block facing - */ - short getFacing(); + /** + * Get the block's facing. + * + * @return Block facing + */ + short getFacing(); - /** - * Set the block's facing - * - * @param facing facing to set the block to - */ - void setFacing(short facing); + /** + * Set the block's facing + * + * @param facing facing to set the block to + */ + void setFacing(short facing); - /** - * Determine if the wrench can be used to remove the block. - * Called if wrenchSetFacing fails. - * - * @param entityPlayer player using the wrench, may be null - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanRemove(EntityPlayer entityPlayer); + /** + * Determine if the wrench can be used to remove the block. + * Called if wrenchSetFacing fails. + * + * @param entityPlayer player using the wrench, may be null + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanRemove(EntityPlayer entityPlayer); - /** - * Determine the probability to drop the block as it is. - * The first entry in getDrops will be replaced by blockid:meta if the drop is successful. - * - * @return Probability from 0 to 1 - */ - float getWrenchDropRate(); + /** + * Determine the probability to drop the block as it is. + * The first entry in getDrops will be replaced by blockid:meta if the drop is successful. + * + * @return Probability from 0 to 1 + */ + float getWrenchDropRate(); - /** - * Determine the item the block will drop when the wrenching is successful. - *

- * The ItemStack will be copied before creating the EntityItem. - * - * @param entityPlayer player using the wrench, may be null - * @return ItemStack to drop, may be null - */ - ItemStack getWrenchDrop(EntityPlayer entityPlayer); + /** + * Determine the item the block will drop when the wrenching is successful. + * + * The ItemStack will be copied before creating the EntityItem. + * + * @param entityPlayer player using the wrench, may be null + * @return ItemStack to drop, may be null + */ + ItemStack getWrenchDrop(EntityPlayer entityPlayer); } diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java index 08fa88b2..5ebc76e2 100644 --- a/src/api/java/ic2/api/tile/package-info.java +++ b/src/api/java/ic2/api/tile/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.tile; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.tile; import cpw.mods.fml.common.API; diff --git a/src/api/java/ic2/api/util/IKeyboard.java b/src/api/java/ic2/api/util/IKeyboard.java index a5a77d66..ff6eaea5 100644 --- a/src/api/java/ic2/api/util/IKeyboard.java +++ b/src/api/java/ic2/api/util/IKeyboard.java @@ -3,19 +3,12 @@ package ic2.api.util; import net.minecraft.entity.player.EntityPlayer; public interface IKeyboard { - boolean isAltKeyDown(EntityPlayer player); - - boolean isBoostKeyDown(EntityPlayer player); - - boolean isForwardKeyDown(EntityPlayer player); - - boolean isJumpKeyDown(EntityPlayer player); - - boolean isModeSwitchKeyDown(EntityPlayer player); - - boolean isSideinventoryKeyDown(EntityPlayer player); - - boolean isHudModeKeyDown(EntityPlayer player); - - boolean isSneakKeyDown(EntityPlayer player); + boolean isAltKeyDown(EntityPlayer player); + boolean isBoostKeyDown(EntityPlayer player); + boolean isForwardKeyDown(EntityPlayer player); + boolean isJumpKeyDown(EntityPlayer player); + boolean isModeSwitchKeyDown(EntityPlayer player); + boolean isSideinventoryKeyDown(EntityPlayer player); + boolean isHudModeKeyDown(EntityPlayer player); + boolean isSneakKeyDown(EntityPlayer player); } diff --git a/src/api/java/ic2/api/util/Keys.java b/src/api/java/ic2/api/util/Keys.java index 1db739bf..84d17567 100644 --- a/src/api/java/ic2/api/util/Keys.java +++ b/src/api/java/ic2/api/util/Keys.java @@ -2,5 +2,5 @@ package ic2.api.util; public class Keys { - public static IKeyboard instance; + public static IKeyboard instance; } \ No newline at end of file diff --git a/src/api/java/ic2/api/util/package-info.java b/src/api/java/ic2/api/util/package-info.java index b0141815..4dd2d93b 100644 --- a/src/api/java/ic2/api/util/package-info.java +++ b/src/api/java/ic2/api/util/package-info.java @@ -1,4 +1,4 @@ -@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.util; - +@API(apiVersion="1.0", owner="IC2", provides="IC2API") +package ic2.api.util; import cpw.mods.fml.common.API; From d748f5c32b7017b3ce493ca215392eeb08f76751 Mon Sep 17 00:00:00 2001 From: nekosune Date: Tue, 26 Aug 2014 22:42:37 +0100 Subject: [PATCH 14/26] Moved ic2 api back --- src/{api => main}/java/ic2/api/Direction.java | 0 src/{api => main}/java/ic2/api/crops/BaseSeed.java | 0 src/{api => main}/java/ic2/api/crops/CropCard.java | 0 src/{api => main}/java/ic2/api/crops/Crops.java | 0 src/{api => main}/java/ic2/api/crops/ICropTile.java | 0 src/{api => main}/java/ic2/api/crops/package-info.java | 0 src/{api => main}/java/ic2/api/energy/EnergyNet.java | 0 src/{api => main}/java/ic2/api/energy/IEnergyNet.java | 0 src/{api => main}/java/ic2/api/energy/NodeStats.java | 0 src/{api => main}/java/ic2/api/energy/event/EnergyTileEvent.java | 0 .../java/ic2/api/energy/event/EnergyTileLoadEvent.java | 0 .../java/ic2/api/energy/event/EnergyTileUnloadEvent.java | 0 src/{api => main}/java/ic2/api/energy/event/package-info.java | 0 src/{api => main}/java/ic2/api/energy/package-info.java | 0 src/{api => main}/java/ic2/api/energy/prefab/BasicSink.java | 0 src/{api => main}/java/ic2/api/energy/prefab/BasicSource.java | 0 src/{api => main}/java/ic2/api/energy/prefab/package-info.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergyAcceptor.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergyConductor.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergyEmitter.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergySink.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergySource.java | 0 src/{api => main}/java/ic2/api/energy/tile/IEnergyTile.java | 0 src/{api => main}/java/ic2/api/energy/tile/IHeatSource.java | 0 src/{api => main}/java/ic2/api/energy/tile/IKineticSource.java | 0 src/{api => main}/java/ic2/api/energy/tile/IMetaDelegate.java | 0 src/{api => main}/java/ic2/api/energy/tile/package-info.java | 0 src/{api => main}/java/ic2/api/energy/usage.txt | 0 src/{api => main}/java/ic2/api/event/LaserEvent.java | 0 src/{api => main}/java/ic2/api/event/PaintEvent.java | 0 src/{api => main}/java/ic2/api/event/RetextureEvent.java | 0 src/{api => main}/java/ic2/api/event/package-info.java | 0 src/{api => main}/java/ic2/api/info/IEnergyValueProvider.java | 0 src/{api => main}/java/ic2/api/info/IFuelValueProvider.java | 0 src/{api => main}/java/ic2/api/info/Info.java | 0 src/{api => main}/java/ic2/api/info/package-info.java | 0 src/{api => main}/java/ic2/api/item/ElectricItem.java | 0 .../java/ic2/api/item/IBackupElectricItemManager.java | 0 src/{api => main}/java/ic2/api/item/IBlockCuttingBlade.java | 0 src/{api => main}/java/ic2/api/item/IBoxable.java | 0 src/{api => main}/java/ic2/api/item/IC2Items.java | 0 src/{api => main}/java/ic2/api/item/IDebuggable.java | 0 src/{api => main}/java/ic2/api/item/IElectricItem.java | 0 src/{api => main}/java/ic2/api/item/IElectricItemManager.java | 0 src/{api => main}/java/ic2/api/item/IItemHudInfo.java | 0 src/{api => main}/java/ic2/api/item/IKineticWindRotor.java | 0 src/{api => main}/java/ic2/api/item/IMetalArmor.java | 0 src/{api => main}/java/ic2/api/item/ISpecialElectricItem.java | 0 src/{api => main}/java/ic2/api/item/ITerraformingBP.java | 0 src/{api => main}/java/ic2/api/item/ItemWrapper.java | 0 src/{api => main}/java/ic2/api/item/package-info.java | 0 .../ic2/api/network/INetworkClientTileEntityEventListener.java | 0 src/{api => main}/java/ic2/api/network/INetworkDataProvider.java | 0 .../java/ic2/api/network/INetworkItemEventListener.java | 0 .../java/ic2/api/network/INetworkTileEntityEventListener.java | 0 .../java/ic2/api/network/INetworkUpdateListener.java | 0 src/{api => main}/java/ic2/api/network/NetworkHelper.java | 0 src/{api => main}/java/ic2/api/network/package-info.java | 0 src/{api => main}/java/ic2/api/package-info.java | 0 src/{api => main}/java/ic2/api/reactor/IReactor.java | 0 src/{api => main}/java/ic2/api/reactor/IReactorChamber.java | 0 src/{api => main}/java/ic2/api/reactor/IReactorComponent.java | 0 src/{api => main}/java/ic2/api/reactor/package-info.java | 0 .../java/ic2/api/recipe/ICannerBottleRecipeManager.java | 0 .../java/ic2/api/recipe/ICannerEnrichRecipeManager.java | 0 src/{api => main}/java/ic2/api/recipe/ICraftingRecipeManager.java | 0 src/{api => main}/java/ic2/api/recipe/IFluidHeatManager.java | 0 src/{api => main}/java/ic2/api/recipe/ILiquidAcceptManager.java | 0 src/{api => main}/java/ic2/api/recipe/IListRecipeManager.java | 0 src/{api => main}/java/ic2/api/recipe/IMachineRecipeManager.java | 0 src/{api => main}/java/ic2/api/recipe/IPatternStorage.java | 0 src/{api => main}/java/ic2/api/recipe/IRecipeInput.java | 0 src/{api => main}/java/ic2/api/recipe/IScrapboxManager.java | 0 src/{api => main}/java/ic2/api/recipe/ISemiFluidFuelManager.java | 0 .../java/ic2/api/recipe/RecipeInputFluidContainer.java | 0 src/{api => main}/java/ic2/api/recipe/RecipeInputItemStack.java | 0 src/{api => main}/java/ic2/api/recipe/RecipeInputOreDict.java | 0 src/{api => main}/java/ic2/api/recipe/RecipeOutput.java | 0 src/{api => main}/java/ic2/api/recipe/Recipes.java | 0 src/{api => main}/java/ic2/api/recipe/package-info.java | 0 src/{api => main}/java/ic2/api/tile/ExplosionWhitelist.java | 0 src/{api => main}/java/ic2/api/tile/IEnergyStorage.java | 0 src/{api => main}/java/ic2/api/tile/IWrenchable.java | 0 src/{api => main}/java/ic2/api/tile/package-info.java | 0 src/{api => main}/java/ic2/api/util/IKeyboard.java | 0 src/{api => main}/java/ic2/api/util/Keys.java | 0 src/{api => main}/java/ic2/api/util/package-info.java | 0 87 files changed, 0 insertions(+), 0 deletions(-) rename src/{api => main}/java/ic2/api/Direction.java (100%) rename src/{api => main}/java/ic2/api/crops/BaseSeed.java (100%) rename src/{api => main}/java/ic2/api/crops/CropCard.java (100%) rename src/{api => main}/java/ic2/api/crops/Crops.java (100%) rename src/{api => main}/java/ic2/api/crops/ICropTile.java (100%) rename src/{api => main}/java/ic2/api/crops/package-info.java (100%) rename src/{api => main}/java/ic2/api/energy/EnergyNet.java (100%) rename src/{api => main}/java/ic2/api/energy/IEnergyNet.java (100%) rename src/{api => main}/java/ic2/api/energy/NodeStats.java (100%) rename src/{api => main}/java/ic2/api/energy/event/EnergyTileEvent.java (100%) rename src/{api => main}/java/ic2/api/energy/event/EnergyTileLoadEvent.java (100%) rename src/{api => main}/java/ic2/api/energy/event/EnergyTileUnloadEvent.java (100%) rename src/{api => main}/java/ic2/api/energy/event/package-info.java (100%) rename src/{api => main}/java/ic2/api/energy/package-info.java (100%) rename src/{api => main}/java/ic2/api/energy/prefab/BasicSink.java (100%) rename src/{api => main}/java/ic2/api/energy/prefab/BasicSource.java (100%) rename src/{api => main}/java/ic2/api/energy/prefab/package-info.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergyAcceptor.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergyConductor.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergyEmitter.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergySink.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergySource.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IEnergyTile.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IHeatSource.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IKineticSource.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/IMetaDelegate.java (100%) rename src/{api => main}/java/ic2/api/energy/tile/package-info.java (100%) rename src/{api => main}/java/ic2/api/energy/usage.txt (100%) rename src/{api => main}/java/ic2/api/event/LaserEvent.java (100%) rename src/{api => main}/java/ic2/api/event/PaintEvent.java (100%) rename src/{api => main}/java/ic2/api/event/RetextureEvent.java (100%) rename src/{api => main}/java/ic2/api/event/package-info.java (100%) rename src/{api => main}/java/ic2/api/info/IEnergyValueProvider.java (100%) rename src/{api => main}/java/ic2/api/info/IFuelValueProvider.java (100%) rename src/{api => main}/java/ic2/api/info/Info.java (100%) rename src/{api => main}/java/ic2/api/info/package-info.java (100%) rename src/{api => main}/java/ic2/api/item/ElectricItem.java (100%) rename src/{api => main}/java/ic2/api/item/IBackupElectricItemManager.java (100%) rename src/{api => main}/java/ic2/api/item/IBlockCuttingBlade.java (100%) rename src/{api => main}/java/ic2/api/item/IBoxable.java (100%) rename src/{api => main}/java/ic2/api/item/IC2Items.java (100%) rename src/{api => main}/java/ic2/api/item/IDebuggable.java (100%) rename src/{api => main}/java/ic2/api/item/IElectricItem.java (100%) rename src/{api => main}/java/ic2/api/item/IElectricItemManager.java (100%) rename src/{api => main}/java/ic2/api/item/IItemHudInfo.java (100%) rename src/{api => main}/java/ic2/api/item/IKineticWindRotor.java (100%) rename src/{api => main}/java/ic2/api/item/IMetalArmor.java (100%) rename src/{api => main}/java/ic2/api/item/ISpecialElectricItem.java (100%) rename src/{api => main}/java/ic2/api/item/ITerraformingBP.java (100%) rename src/{api => main}/java/ic2/api/item/ItemWrapper.java (100%) rename src/{api => main}/java/ic2/api/item/package-info.java (100%) rename src/{api => main}/java/ic2/api/network/INetworkClientTileEntityEventListener.java (100%) rename src/{api => main}/java/ic2/api/network/INetworkDataProvider.java (100%) rename src/{api => main}/java/ic2/api/network/INetworkItemEventListener.java (100%) rename src/{api => main}/java/ic2/api/network/INetworkTileEntityEventListener.java (100%) rename src/{api => main}/java/ic2/api/network/INetworkUpdateListener.java (100%) rename src/{api => main}/java/ic2/api/network/NetworkHelper.java (100%) rename src/{api => main}/java/ic2/api/network/package-info.java (100%) rename src/{api => main}/java/ic2/api/package-info.java (100%) rename src/{api => main}/java/ic2/api/reactor/IReactor.java (100%) rename src/{api => main}/java/ic2/api/reactor/IReactorChamber.java (100%) rename src/{api => main}/java/ic2/api/reactor/IReactorComponent.java (100%) rename src/{api => main}/java/ic2/api/reactor/package-info.java (100%) rename src/{api => main}/java/ic2/api/recipe/ICannerBottleRecipeManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/ICannerEnrichRecipeManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/ICraftingRecipeManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/IFluidHeatManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/ILiquidAcceptManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/IListRecipeManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/IMachineRecipeManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/IPatternStorage.java (100%) rename src/{api => main}/java/ic2/api/recipe/IRecipeInput.java (100%) rename src/{api => main}/java/ic2/api/recipe/IScrapboxManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/ISemiFluidFuelManager.java (100%) rename src/{api => main}/java/ic2/api/recipe/RecipeInputFluidContainer.java (100%) rename src/{api => main}/java/ic2/api/recipe/RecipeInputItemStack.java (100%) rename src/{api => main}/java/ic2/api/recipe/RecipeInputOreDict.java (100%) rename src/{api => main}/java/ic2/api/recipe/RecipeOutput.java (100%) rename src/{api => main}/java/ic2/api/recipe/Recipes.java (100%) rename src/{api => main}/java/ic2/api/recipe/package-info.java (100%) rename src/{api => main}/java/ic2/api/tile/ExplosionWhitelist.java (100%) rename src/{api => main}/java/ic2/api/tile/IEnergyStorage.java (100%) rename src/{api => main}/java/ic2/api/tile/IWrenchable.java (100%) rename src/{api => main}/java/ic2/api/tile/package-info.java (100%) rename src/{api => main}/java/ic2/api/util/IKeyboard.java (100%) rename src/{api => main}/java/ic2/api/util/Keys.java (100%) rename src/{api => main}/java/ic2/api/util/package-info.java (100%) diff --git a/src/api/java/ic2/api/Direction.java b/src/main/java/ic2/api/Direction.java similarity index 100% rename from src/api/java/ic2/api/Direction.java rename to src/main/java/ic2/api/Direction.java diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/main/java/ic2/api/crops/BaseSeed.java similarity index 100% rename from src/api/java/ic2/api/crops/BaseSeed.java rename to src/main/java/ic2/api/crops/BaseSeed.java diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/main/java/ic2/api/crops/CropCard.java similarity index 100% rename from src/api/java/ic2/api/crops/CropCard.java rename to src/main/java/ic2/api/crops/CropCard.java diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/main/java/ic2/api/crops/Crops.java similarity index 100% rename from src/api/java/ic2/api/crops/Crops.java rename to src/main/java/ic2/api/crops/Crops.java diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/main/java/ic2/api/crops/ICropTile.java similarity index 100% rename from src/api/java/ic2/api/crops/ICropTile.java rename to src/main/java/ic2/api/crops/ICropTile.java diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/main/java/ic2/api/crops/package-info.java similarity index 100% rename from src/api/java/ic2/api/crops/package-info.java rename to src/main/java/ic2/api/crops/package-info.java diff --git a/src/api/java/ic2/api/energy/EnergyNet.java b/src/main/java/ic2/api/energy/EnergyNet.java similarity index 100% rename from src/api/java/ic2/api/energy/EnergyNet.java rename to src/main/java/ic2/api/energy/EnergyNet.java diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/main/java/ic2/api/energy/IEnergyNet.java similarity index 100% rename from src/api/java/ic2/api/energy/IEnergyNet.java rename to src/main/java/ic2/api/energy/IEnergyNet.java diff --git a/src/api/java/ic2/api/energy/NodeStats.java b/src/main/java/ic2/api/energy/NodeStats.java similarity index 100% rename from src/api/java/ic2/api/energy/NodeStats.java rename to src/main/java/ic2/api/energy/NodeStats.java diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileEvent.java similarity index 100% rename from src/api/java/ic2/api/energy/event/EnergyTileEvent.java rename to src/main/java/ic2/api/energy/event/EnergyTileEvent.java diff --git a/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java similarity index 100% rename from src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java rename to src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java diff --git a/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java similarity index 100% rename from src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java rename to src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/main/java/ic2/api/energy/event/package-info.java similarity index 100% rename from src/api/java/ic2/api/energy/event/package-info.java rename to src/main/java/ic2/api/energy/event/package-info.java diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/main/java/ic2/api/energy/package-info.java similarity index 100% rename from src/api/java/ic2/api/energy/package-info.java rename to src/main/java/ic2/api/energy/package-info.java diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/main/java/ic2/api/energy/prefab/BasicSink.java similarity index 100% rename from src/api/java/ic2/api/energy/prefab/BasicSink.java rename to src/main/java/ic2/api/energy/prefab/BasicSink.java diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/main/java/ic2/api/energy/prefab/BasicSource.java similarity index 100% rename from src/api/java/ic2/api/energy/prefab/BasicSource.java rename to src/main/java/ic2/api/energy/prefab/BasicSource.java diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/main/java/ic2/api/energy/prefab/package-info.java similarity index 100% rename from src/api/java/ic2/api/energy/prefab/package-info.java rename to src/main/java/ic2/api/energy/prefab/package-info.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java rename to src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/main/java/ic2/api/energy/tile/IEnergyConductor.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergyConductor.java rename to src/main/java/ic2/api/energy/tile/IEnergyConductor.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergyEmitter.java rename to src/main/java/ic2/api/energy/tile/IEnergyEmitter.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/main/java/ic2/api/energy/tile/IEnergySink.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergySink.java rename to src/main/java/ic2/api/energy/tile/IEnergySink.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergySource.java b/src/main/java/ic2/api/energy/tile/IEnergySource.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergySource.java rename to src/main/java/ic2/api/energy/tile/IEnergySource.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergyTile.java b/src/main/java/ic2/api/energy/tile/IEnergyTile.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IEnergyTile.java rename to src/main/java/ic2/api/energy/tile/IEnergyTile.java diff --git a/src/api/java/ic2/api/energy/tile/IHeatSource.java b/src/main/java/ic2/api/energy/tile/IHeatSource.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IHeatSource.java rename to src/main/java/ic2/api/energy/tile/IHeatSource.java diff --git a/src/api/java/ic2/api/energy/tile/IKineticSource.java b/src/main/java/ic2/api/energy/tile/IKineticSource.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IKineticSource.java rename to src/main/java/ic2/api/energy/tile/IKineticSource.java diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java b/src/main/java/ic2/api/energy/tile/IMetaDelegate.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/IMetaDelegate.java rename to src/main/java/ic2/api/energy/tile/IMetaDelegate.java diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/main/java/ic2/api/energy/tile/package-info.java similarity index 100% rename from src/api/java/ic2/api/energy/tile/package-info.java rename to src/main/java/ic2/api/energy/tile/package-info.java diff --git a/src/api/java/ic2/api/energy/usage.txt b/src/main/java/ic2/api/energy/usage.txt similarity index 100% rename from src/api/java/ic2/api/energy/usage.txt rename to src/main/java/ic2/api/energy/usage.txt diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/main/java/ic2/api/event/LaserEvent.java similarity index 100% rename from src/api/java/ic2/api/event/LaserEvent.java rename to src/main/java/ic2/api/event/LaserEvent.java diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/main/java/ic2/api/event/PaintEvent.java similarity index 100% rename from src/api/java/ic2/api/event/PaintEvent.java rename to src/main/java/ic2/api/event/PaintEvent.java diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/main/java/ic2/api/event/RetextureEvent.java similarity index 100% rename from src/api/java/ic2/api/event/RetextureEvent.java rename to src/main/java/ic2/api/event/RetextureEvent.java diff --git a/src/api/java/ic2/api/event/package-info.java b/src/main/java/ic2/api/event/package-info.java similarity index 100% rename from src/api/java/ic2/api/event/package-info.java rename to src/main/java/ic2/api/event/package-info.java diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/main/java/ic2/api/info/IEnergyValueProvider.java similarity index 100% rename from src/api/java/ic2/api/info/IEnergyValueProvider.java rename to src/main/java/ic2/api/info/IEnergyValueProvider.java diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/main/java/ic2/api/info/IFuelValueProvider.java similarity index 100% rename from src/api/java/ic2/api/info/IFuelValueProvider.java rename to src/main/java/ic2/api/info/IFuelValueProvider.java diff --git a/src/api/java/ic2/api/info/Info.java b/src/main/java/ic2/api/info/Info.java similarity index 100% rename from src/api/java/ic2/api/info/Info.java rename to src/main/java/ic2/api/info/Info.java diff --git a/src/api/java/ic2/api/info/package-info.java b/src/main/java/ic2/api/info/package-info.java similarity index 100% rename from src/api/java/ic2/api/info/package-info.java rename to src/main/java/ic2/api/info/package-info.java diff --git a/src/api/java/ic2/api/item/ElectricItem.java b/src/main/java/ic2/api/item/ElectricItem.java similarity index 100% rename from src/api/java/ic2/api/item/ElectricItem.java rename to src/main/java/ic2/api/item/ElectricItem.java diff --git a/src/api/java/ic2/api/item/IBackupElectricItemManager.java b/src/main/java/ic2/api/item/IBackupElectricItemManager.java similarity index 100% rename from src/api/java/ic2/api/item/IBackupElectricItemManager.java rename to src/main/java/ic2/api/item/IBackupElectricItemManager.java diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.java b/src/main/java/ic2/api/item/IBlockCuttingBlade.java similarity index 100% rename from src/api/java/ic2/api/item/IBlockCuttingBlade.java rename to src/main/java/ic2/api/item/IBlockCuttingBlade.java diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/main/java/ic2/api/item/IBoxable.java similarity index 100% rename from src/api/java/ic2/api/item/IBoxable.java rename to src/main/java/ic2/api/item/IBoxable.java diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/main/java/ic2/api/item/IC2Items.java similarity index 100% rename from src/api/java/ic2/api/item/IC2Items.java rename to src/main/java/ic2/api/item/IC2Items.java diff --git a/src/api/java/ic2/api/item/IDebuggable.java b/src/main/java/ic2/api/item/IDebuggable.java similarity index 100% rename from src/api/java/ic2/api/item/IDebuggable.java rename to src/main/java/ic2/api/item/IDebuggable.java diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/main/java/ic2/api/item/IElectricItem.java similarity index 100% rename from src/api/java/ic2/api/item/IElectricItem.java rename to src/main/java/ic2/api/item/IElectricItem.java diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/main/java/ic2/api/item/IElectricItemManager.java similarity index 100% rename from src/api/java/ic2/api/item/IElectricItemManager.java rename to src/main/java/ic2/api/item/IElectricItemManager.java diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/main/java/ic2/api/item/IItemHudInfo.java similarity index 100% rename from src/api/java/ic2/api/item/IItemHudInfo.java rename to src/main/java/ic2/api/item/IItemHudInfo.java diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.java b/src/main/java/ic2/api/item/IKineticWindRotor.java similarity index 100% rename from src/api/java/ic2/api/item/IKineticWindRotor.java rename to src/main/java/ic2/api/item/IKineticWindRotor.java diff --git a/src/api/java/ic2/api/item/IMetalArmor.java b/src/main/java/ic2/api/item/IMetalArmor.java similarity index 100% rename from src/api/java/ic2/api/item/IMetalArmor.java rename to src/main/java/ic2/api/item/IMetalArmor.java diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/main/java/ic2/api/item/ISpecialElectricItem.java similarity index 100% rename from src/api/java/ic2/api/item/ISpecialElectricItem.java rename to src/main/java/ic2/api/item/ISpecialElectricItem.java diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/main/java/ic2/api/item/ITerraformingBP.java similarity index 100% rename from src/api/java/ic2/api/item/ITerraformingBP.java rename to src/main/java/ic2/api/item/ITerraformingBP.java diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/main/java/ic2/api/item/ItemWrapper.java similarity index 100% rename from src/api/java/ic2/api/item/ItemWrapper.java rename to src/main/java/ic2/api/item/ItemWrapper.java diff --git a/src/api/java/ic2/api/item/package-info.java b/src/main/java/ic2/api/item/package-info.java similarity index 100% rename from src/api/java/ic2/api/item/package-info.java rename to src/main/java/ic2/api/item/package-info.java diff --git a/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java b/src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java similarity index 100% rename from src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java rename to src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java diff --git a/src/api/java/ic2/api/network/INetworkDataProvider.java b/src/main/java/ic2/api/network/INetworkDataProvider.java similarity index 100% rename from src/api/java/ic2/api/network/INetworkDataProvider.java rename to src/main/java/ic2/api/network/INetworkDataProvider.java diff --git a/src/api/java/ic2/api/network/INetworkItemEventListener.java b/src/main/java/ic2/api/network/INetworkItemEventListener.java similarity index 100% rename from src/api/java/ic2/api/network/INetworkItemEventListener.java rename to src/main/java/ic2/api/network/INetworkItemEventListener.java diff --git a/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java b/src/main/java/ic2/api/network/INetworkTileEntityEventListener.java similarity index 100% rename from src/api/java/ic2/api/network/INetworkTileEntityEventListener.java rename to src/main/java/ic2/api/network/INetworkTileEntityEventListener.java diff --git a/src/api/java/ic2/api/network/INetworkUpdateListener.java b/src/main/java/ic2/api/network/INetworkUpdateListener.java similarity index 100% rename from src/api/java/ic2/api/network/INetworkUpdateListener.java rename to src/main/java/ic2/api/network/INetworkUpdateListener.java diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/main/java/ic2/api/network/NetworkHelper.java similarity index 100% rename from src/api/java/ic2/api/network/NetworkHelper.java rename to src/main/java/ic2/api/network/NetworkHelper.java diff --git a/src/api/java/ic2/api/network/package-info.java b/src/main/java/ic2/api/network/package-info.java similarity index 100% rename from src/api/java/ic2/api/network/package-info.java rename to src/main/java/ic2/api/network/package-info.java diff --git a/src/api/java/ic2/api/package-info.java b/src/main/java/ic2/api/package-info.java similarity index 100% rename from src/api/java/ic2/api/package-info.java rename to src/main/java/ic2/api/package-info.java diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/main/java/ic2/api/reactor/IReactor.java similarity index 100% rename from src/api/java/ic2/api/reactor/IReactor.java rename to src/main/java/ic2/api/reactor/IReactor.java diff --git a/src/api/java/ic2/api/reactor/IReactorChamber.java b/src/main/java/ic2/api/reactor/IReactorChamber.java similarity index 100% rename from src/api/java/ic2/api/reactor/IReactorChamber.java rename to src/main/java/ic2/api/reactor/IReactorChamber.java diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/main/java/ic2/api/reactor/IReactorComponent.java similarity index 100% rename from src/api/java/ic2/api/reactor/IReactorComponent.java rename to src/main/java/ic2/api/reactor/IReactorComponent.java diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/main/java/ic2/api/reactor/package-info.java similarity index 100% rename from src/api/java/ic2/api/reactor/package-info.java rename to src/main/java/ic2/api/reactor/package-info.java diff --git a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java rename to src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java rename to src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java diff --git a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/ICraftingRecipeManager.java rename to src/main/java/ic2/api/recipe/ICraftingRecipeManager.java diff --git a/src/api/java/ic2/api/recipe/IFluidHeatManager.java b/src/main/java/ic2/api/recipe/IFluidHeatManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/IFluidHeatManager.java rename to src/main/java/ic2/api/recipe/IFluidHeatManager.java diff --git a/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/main/java/ic2/api/recipe/ILiquidAcceptManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/ILiquidAcceptManager.java rename to src/main/java/ic2/api/recipe/ILiquidAcceptManager.java diff --git a/src/api/java/ic2/api/recipe/IListRecipeManager.java b/src/main/java/ic2/api/recipe/IListRecipeManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/IListRecipeManager.java rename to src/main/java/ic2/api/recipe/IListRecipeManager.java diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/main/java/ic2/api/recipe/IMachineRecipeManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/IMachineRecipeManager.java rename to src/main/java/ic2/api/recipe/IMachineRecipeManager.java diff --git a/src/api/java/ic2/api/recipe/IPatternStorage.java b/src/main/java/ic2/api/recipe/IPatternStorage.java similarity index 100% rename from src/api/java/ic2/api/recipe/IPatternStorage.java rename to src/main/java/ic2/api/recipe/IPatternStorage.java diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/main/java/ic2/api/recipe/IRecipeInput.java similarity index 100% rename from src/api/java/ic2/api/recipe/IRecipeInput.java rename to src/main/java/ic2/api/recipe/IRecipeInput.java diff --git a/src/api/java/ic2/api/recipe/IScrapboxManager.java b/src/main/java/ic2/api/recipe/IScrapboxManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/IScrapboxManager.java rename to src/main/java/ic2/api/recipe/IScrapboxManager.java diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java similarity index 100% rename from src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java rename to src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java similarity index 100% rename from src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java rename to src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/main/java/ic2/api/recipe/RecipeInputItemStack.java similarity index 100% rename from src/api/java/ic2/api/recipe/RecipeInputItemStack.java rename to src/main/java/ic2/api/recipe/RecipeInputItemStack.java diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/main/java/ic2/api/recipe/RecipeInputOreDict.java similarity index 100% rename from src/api/java/ic2/api/recipe/RecipeInputOreDict.java rename to src/main/java/ic2/api/recipe/RecipeInputOreDict.java diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/main/java/ic2/api/recipe/RecipeOutput.java similarity index 100% rename from src/api/java/ic2/api/recipe/RecipeOutput.java rename to src/main/java/ic2/api/recipe/RecipeOutput.java diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/main/java/ic2/api/recipe/Recipes.java similarity index 100% rename from src/api/java/ic2/api/recipe/Recipes.java rename to src/main/java/ic2/api/recipe/Recipes.java diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/main/java/ic2/api/recipe/package-info.java similarity index 100% rename from src/api/java/ic2/api/recipe/package-info.java rename to src/main/java/ic2/api/recipe/package-info.java diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/main/java/ic2/api/tile/ExplosionWhitelist.java similarity index 100% rename from src/api/java/ic2/api/tile/ExplosionWhitelist.java rename to src/main/java/ic2/api/tile/ExplosionWhitelist.java diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.java b/src/main/java/ic2/api/tile/IEnergyStorage.java similarity index 100% rename from src/api/java/ic2/api/tile/IEnergyStorage.java rename to src/main/java/ic2/api/tile/IEnergyStorage.java diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/main/java/ic2/api/tile/IWrenchable.java similarity index 100% rename from src/api/java/ic2/api/tile/IWrenchable.java rename to src/main/java/ic2/api/tile/IWrenchable.java diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/main/java/ic2/api/tile/package-info.java similarity index 100% rename from src/api/java/ic2/api/tile/package-info.java rename to src/main/java/ic2/api/tile/package-info.java diff --git a/src/api/java/ic2/api/util/IKeyboard.java b/src/main/java/ic2/api/util/IKeyboard.java similarity index 100% rename from src/api/java/ic2/api/util/IKeyboard.java rename to src/main/java/ic2/api/util/IKeyboard.java diff --git a/src/api/java/ic2/api/util/Keys.java b/src/main/java/ic2/api/util/Keys.java similarity index 100% rename from src/api/java/ic2/api/util/Keys.java rename to src/main/java/ic2/api/util/Keys.java diff --git a/src/api/java/ic2/api/util/package-info.java b/src/main/java/ic2/api/util/package-info.java similarity index 100% rename from src/api/java/ic2/api/util/package-info.java rename to src/main/java/ic2/api/util/package-info.java From 96263612a536c3af31e7c078d74dab8d020a3fdf Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 17:51:48 -0400 Subject: [PATCH 15/26] Attempt at adding additional check for IC2 api --- .../transvector/TileTransvectorInterface.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index a9f4776c..9f933c27 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -19,6 +19,7 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import cofh.api.energy.IEnergyHandler; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -73,16 +74,23 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void invalidate() { - removeFromIC2EnergyNet(); - super.invalidate(); + if (Loader.isModLoaded("IC2")) { + removeFromIC2EnergyNet(); + } + super.invalidate(); } @Override public void onChunkUnload() { - removeFromIC2EnergyNet(); - } - private void removeFromIC2EnergyNet() { + if (Loader.isModLoaded("IC2")) { + removeFromIC2EnergyNet(); + } + } + + + @Optional.Method(modid = "IC2") + private void removeFromIC2EnergyNet() { if(addedToICEnergyNet && !worldObj.isRemote) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) this)); addedToICEnergyNet = false; From b19b5fabcfffb021f43db745a14092aa7a53fbfb Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:01:45 -0400 Subject: [PATCH 16/26] Temporarily remove refrences to IC2 for testing --- .../transvector/TileTransvectorInterface.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 9f933c27..d4dbc7e9 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -74,28 +74,28 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void invalidate() { - if (Loader.isModLoaded("IC2")) { - removeFromIC2EnergyNet(); - } + //if (Loader.isModLoaded("IC2")) { + // removeFromIC2EnergyNet(); + //} super.invalidate(); } @Override public void onChunkUnload() { - if (Loader.isModLoaded("IC2")) { - removeFromIC2EnergyNet(); - } + //if (Loader.isModLoaded("IC2")) { + // removeFromIC2EnergyNet(); + //} } - @Optional.Method(modid = "IC2") - private void removeFromIC2EnergyNet() { - if(addedToICEnergyNet && !worldObj.isRemote) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) this)); - addedToICEnergyNet = false; - } - } + //@Optional.Method(modid = "IC2") + //private void removeFromIC2EnergyNet() { + // if(addedToICEnergyNet && !worldObj.isRemote) { + // MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) this)); + // addedToICEnergyNet = false; + // } + //} @Override public void markDirty() { From b7b64aebf68e443d8d55886bdbd2ddc9286bf5f4 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:13:23 -0400 Subject: [PATCH 17/26] Move IC2 refrences indo IndustrialcraftUnloadHelper --- .../transvector/TileTransvectorInterface.java | 24 +++++++------------ .../compat/IndustrialcraftUnloadHelper.java | 20 ++++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index d4dbc7e9..ea3b4a83 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -43,6 +43,7 @@ import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.IAspectContainer; import thaumcraft.api.aspects.IEssentiaTransport; +import thaumic.tinkerer.common.compat.IndustrialcraftUnloadHelper; import thaumic.tinkerer.common.lib.LibFeatures; @Optional.InterfaceList({ @Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), @@ -53,7 +54,7 @@ import thaumic.tinkerer.common.lib.LibFeatures; public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { - private boolean addedToICEnergyNet = false; + public boolean addedToICEnergyNet = false; @Override public void updateEntity() { @@ -74,29 +75,20 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void invalidate() { - //if (Loader.isModLoaded("IC2")) { - // removeFromIC2EnergyNet(); - //} + if (Loader.isModLoaded("IC2")) { + IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); + } super.invalidate(); } @Override public void onChunkUnload() { - //if (Loader.isModLoaded("IC2")) { - // removeFromIC2EnergyNet(); - //} + if (Loader.isModLoaded("IC2")) { + IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); + } } - - //@Optional.Method(modid = "IC2") - //private void removeFromIC2EnergyNet() { - // if(addedToICEnergyNet && !worldObj.isRemote) { - // MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) this)); - // addedToICEnergyNet = false; - // } - //} - @Override public void markDirty() { super.markDirty(); diff --git a/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java new file mode 100644 index 00000000..6e95db23 --- /dev/null +++ b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java @@ -0,0 +1,20 @@ +package thaumic.tinkerer.common.compat; + +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import thaumic.tinkerer.common.block.tile.transvector.TileTransvectorInterface; + +/** + * Created by pixlepix on 8/26/14. + */ +public class IndustrialcraftUnloadHelper { + + public static void removeFromIC2EnergyNet(TileTransvectorInterface tileEntity) { + if ((tileEntity.addedToICEnergyNet && !tileEntity.getWorldObj().isRemote)) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergySink) tileEntity)); + tileEntity.addedToICEnergyNet = false; + } + } +} From e0de7bafabd94f595c7f2209b7771f8d73e04ffa Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:14:11 -0400 Subject: [PATCH 18/26] Used "IC2API" instead of "IC2" --- .../tile/transvector/TileTransvectorInterface.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index ea3b4a83..e9a946fb 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -75,7 +75,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void invalidate() { - if (Loader.isModLoaded("IC2")) { + if (Loader.isModLoaded("IC2API")) { IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } super.invalidate(); @@ -84,7 +84,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void onChunkUnload() { - if (Loader.isModLoaded("IC2")) { + if (Loader.isModLoaded("IC2API")) { IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } } @@ -254,7 +254,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI return worldObj; } - @Optional.Method(modid = "IC2") + @Optional.Method(modid = "IC2API") @Override public double getDemandedEnergy() { TileEntity tile = getTile(); @@ -262,7 +262,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } - @Optional.Method(modid = "IC2") + @Optional.Method(modid = "IC2API") @Override public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { @@ -271,7 +271,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } - @Optional.Method(modid = "IC2") + @Optional.Method(modid = "IC2API") @Override public int getSinkTier() { TileEntity tile = getTile(); From 8818468461705bb1bf415b5739b967e0d1a87a7c Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:21:08 -0400 Subject: [PATCH 19/26] Moved IC2 back into /api for testing --- src/api/java/ic2/api/Direction.java | 127 ++++ src/api/java/ic2/api/crops/BaseSeed.java | 56 ++ src/api/java/ic2/api/crops/CropCard.java | 379 +++++++++++ src/api/java/ic2/api/crops/Crops.java | 115 ++++ src/api/java/ic2/api/crops/ICropTile.java | 263 ++++++++ src/api/java/ic2/api/crops/package-info.java | 4 + .../java/ic2/api/energy/EnergyNet.java | 12 +- src/api/java/ic2/api/energy/IEnergyNet.java | 83 +++ src/api/java/ic2/api/energy/NodeStats.java | 25 + .../ic2/api/energy/event/EnergyTileEvent.java | 18 +- .../api/energy/event/EnergyTileLoadEvent.java | 14 +- .../energy/event/EnergyTileUnloadEvent.java | 14 +- .../ic2/api/energy/event/package-info.java | 4 + src/api/java/ic2/api/energy/package-info.java | 4 + .../java/ic2/api/energy/prefab/BasicSink.java | 360 ++++++++++ .../ic2/api/energy/prefab/BasicSource.java | 362 ++++++++++ .../ic2/api/energy/prefab/package-info.java | 4 + .../ic2/api/energy/tile/IEnergyAcceptor.java | 26 + .../ic2/api/energy/tile/IEnergyConductor.java | 53 ++ .../ic2/api/energy/tile/IEnergyEmitter.java | 27 + .../java/ic2/api/energy/tile/IEnergySink.java | 43 ++ .../ic2/api/energy/tile/IEnergySource.java | 36 + .../java/ic2/api/energy/tile/IEnergyTile.java | 10 +- .../java/ic2/api/energy/tile/IHeatSource.java | 18 +- .../ic2/api/energy/tile/IKineticSource.java | 12 +- .../ic2/api/energy/tile/IMetaDelegate.java | 31 +- .../ic2/api/energy/tile/package-info.java | 4 + .../java/ic2/api/energy/usage.txt | 0 src/api/java/ic2/api/event/LaserEvent.java | 112 ++++ src/api/java/ic2/api/event/PaintEvent.java | 30 + .../java/ic2/api/event/RetextureEvent.java | 35 + src/api/java/ic2/api/event/package-info.java | 4 + .../ic2/api/info/IEnergyValueProvider.java | 17 + .../java/ic2/api/info/IFuelValueProvider.java | 15 + src/api/java/ic2/api/info/Info.java | 31 + src/api/java/ic2/api/info/package-info.java | 4 + src/api/java/ic2/api/item/ElectricItem.java | 59 ++ .../api/item/IBackupElectricItemManager.java | 4 +- .../java/ic2/api/item/IBlockCuttingBlade.java | 2 +- src/api/java/ic2/api/item/IBoxable.java | 14 + .../java/ic2/api/item/IC2Items.java | 78 +-- .../java/ic2/api/item/IDebuggable.java | 0 src/api/java/ic2/api/item/IElectricItem.java | 55 ++ .../ic2/api/item/IElectricItemManager.java | 93 +++ .../java/ic2/api/item/IItemHudInfo.java | 8 +- .../java/ic2/api/item/IKineticWindRotor.java | 15 + src/api/java/ic2/api/item/IMetalArmor.java | 20 + .../ic2/api/item/ISpecialElectricItem.java | 13 + .../java/ic2/api/item/ITerraformingBP.java | 34 + src/api/java/ic2/api/item/ItemWrapper.java | 49 ++ src/api/java/ic2/api/item/package-info.java | 4 + ...INetworkClientTileEntityEventListener.java | 14 +- .../ic2/api/network/INetworkDataProvider.java | 14 +- .../network/INetworkItemEventListener.java | 19 + .../INetworkTileEntityEventListener.java | 12 +- .../api/network/INetworkUpdateListener.java | 14 + .../java/ic2/api/network/NetworkHelper.java | 199 ++++++ .../java/ic2/api/network/package-info.java | 4 + src/api/java/ic2/api/package-info.java | 4 + src/api/java/ic2/api/reactor/IReactor.java | 158 +++++ .../java/ic2/api/reactor/IReactorChamber.java | 19 + .../ic2/api/reactor/IReactorComponent.java | 101 +++ .../java/ic2/api/reactor/package-info.java | 4 + .../recipe/ICannerBottleRecipeManager.java | 51 ++ .../recipe/ICannerEnrichRecipeManager.java | 53 ++ .../api/recipe/ICraftingRecipeManager.java | 26 + .../ic2/api/recipe/IFluidHeatManager.java | 32 + .../ic2/api/recipe/ILiquidAcceptManager.java | 9 +- .../ic2/api/recipe/IListRecipeManager.java | 41 ++ .../ic2/api/recipe/IMachineRecipeManager.java | 43 ++ .../java/ic2/api/recipe/IPatternStorage.java | 10 +- src/api/java/ic2/api/recipe/IRecipeInput.java | 31 + .../java/ic2/api/recipe/IScrapboxManager.java | 13 + .../ic2/api/recipe/ISemiFluidFuelManager.java | 32 + .../api/recipe/RecipeInputFluidContainer.java | 53 ++ .../ic2/api/recipe/RecipeInputItemStack.java | 45 ++ .../ic2/api/recipe/RecipeInputOreDict.java | 70 ++ src/api/java/ic2/api/recipe/RecipeOutput.java | 28 + src/api/java/ic2/api/recipe/Recipes.java | 60 ++ src/api/java/ic2/api/recipe/package-info.java | 4 + .../java/ic2/api/tile/ExplosionWhitelist.java | 47 ++ src/api/java/ic2/api/tile/IEnergyStorage.java | 61 ++ src/api/java/ic2/api/tile/IWrenchable.java | 61 ++ src/api/java/ic2/api/tile/package-info.java | 4 + src/api/java/ic2/api/util/IKeyboard.java | 21 + src/{main => api}/java/ic2/api/util/Keys.java | 2 +- src/api/java/ic2/api/util/package-info.java | 4 + src/main/java/ic2/api/Direction.java | 128 ---- src/main/java/ic2/api/crops/BaseSeed.java | 56 -- src/main/java/ic2/api/crops/CropCard.java | 367 ----------- src/main/java/ic2/api/crops/Crops.java | 117 ---- src/main/java/ic2/api/crops/ICropTile.java | 264 -------- src/main/java/ic2/api/crops/package-info.java | 4 - src/main/java/ic2/api/energy/IEnergyNet.java | 86 --- src/main/java/ic2/api/energy/NodeStats.java | 25 - .../ic2/api/energy/event/package-info.java | 4 - .../java/ic2/api/energy/package-info.java | 4 - .../java/ic2/api/energy/prefab/BasicSink.java | 373 ----------- .../ic2/api/energy/prefab/BasicSource.java | 375 ----------- .../ic2/api/energy/prefab/package-info.java | 4 - .../ic2/api/energy/tile/IEnergyAcceptor.java | 27 - .../ic2/api/energy/tile/IEnergyConductor.java | 53 -- .../ic2/api/energy/tile/IEnergyEmitter.java | 28 - .../java/ic2/api/energy/tile/IEnergySink.java | 45 -- .../ic2/api/energy/tile/IEnergySource.java | 38 -- .../ic2/api/energy/tile/package-info.java | 4 - src/main/java/ic2/api/event/LaserEvent.java | 114 ---- src/main/java/ic2/api/event/PaintEvent.java | 32 - .../java/ic2/api/event/RetextureEvent.java | 37 -- src/main/java/ic2/api/event/package-info.java | 4 - .../ic2/api/info/IEnergyValueProvider.java | 17 - .../java/ic2/api/info/IFuelValueProvider.java | 15 - src/main/java/ic2/api/info/Info.java | 32 - src/main/java/ic2/api/info/package-info.java | 4 - src/main/java/ic2/api/item/ElectricItem.java | 59 -- src/main/java/ic2/api/item/IBoxable.java | 14 - src/main/java/ic2/api/item/IElectricItem.java | 55 -- .../ic2/api/item/IElectricItemManager.java | 93 --- .../java/ic2/api/item/IKineticWindRotor.java | 15 - src/main/java/ic2/api/item/IMetalArmor.java | 20 - .../ic2/api/item/ISpecialElectricItem.java | 13 - .../java/ic2/api/item/ITerraformingBP.java | 34 - src/main/java/ic2/api/item/ItemWrapper.java | 50 -- src/main/java/ic2/api/item/package-info.java | 4 - .../network/INetworkItemEventListener.java | 19 - .../api/network/INetworkUpdateListener.java | 14 - .../java/ic2/api/network/NetworkHelper.java | 194 ------ .../java/ic2/api/network/package-info.java | 4 - src/main/java/ic2/api/package-info.java | 4 - src/main/java/ic2/api/reactor/IReactor.java | 158 ----- .../java/ic2/api/reactor/IReactorChamber.java | 20 - .../ic2/api/reactor/IReactorComponent.java | 98 --- .../java/ic2/api/reactor/package-info.java | 4 - .../recipe/ICannerBottleRecipeManager.java | 51 -- .../recipe/ICannerEnrichRecipeManager.java | 54 -- .../api/recipe/ICraftingRecipeManager.java | 26 - .../ic2/api/recipe/IFluidHeatManager.java | 32 - .../ic2/api/recipe/IListRecipeManager.java | 41 -- .../ic2/api/recipe/IMachineRecipeManager.java | 44 -- .../java/ic2/api/recipe/IRecipeInput.java | 31 - .../java/ic2/api/recipe/IScrapboxManager.java | 13 - .../ic2/api/recipe/ISemiFluidFuelManager.java | 32 - .../api/recipe/RecipeInputFluidContainer.java | 54 -- .../ic2/api/recipe/RecipeInputItemStack.java | 46 -- .../ic2/api/recipe/RecipeInputOreDict.java | 71 -- .../java/ic2/api/recipe/RecipeOutput.java | 28 - src/main/java/ic2/api/recipe/Recipes.java | 60 -- .../java/ic2/api/recipe/package-info.java | 4 - .../java/ic2/api/tile/ExplosionWhitelist.java | 47 -- .../java/ic2/api/tile/IEnergyStorage.java | 61 -- src/main/java/ic2/api/tile/IWrenchable.java | 61 -- src/main/java/ic2/api/tile/package-info.java | 4 - src/main/java/ic2/api/util/IKeyboard.java | 14 - src/main/java/ic2/api/util/package-info.java | 4 - .../transvector/TileTransvectorInterface.java | 620 +++++++++--------- .../compat/IndustrialcraftUnloadHelper.java | 1 - 156 files changed, 4330 insertions(+), 4361 deletions(-) create mode 100644 src/api/java/ic2/api/Direction.java create mode 100644 src/api/java/ic2/api/crops/BaseSeed.java create mode 100644 src/api/java/ic2/api/crops/CropCard.java create mode 100644 src/api/java/ic2/api/crops/Crops.java create mode 100644 src/api/java/ic2/api/crops/ICropTile.java create mode 100644 src/api/java/ic2/api/crops/package-info.java rename src/{main => api}/java/ic2/api/energy/EnergyNet.java (76%) create mode 100644 src/api/java/ic2/api/energy/IEnergyNet.java create mode 100644 src/api/java/ic2/api/energy/NodeStats.java rename src/{main => api}/java/ic2/api/energy/event/EnergyTileEvent.java (64%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileLoadEvent.java (86%) rename src/{main => api}/java/ic2/api/energy/event/EnergyTileUnloadEvent.java (87%) create mode 100644 src/api/java/ic2/api/energy/event/package-info.java create mode 100644 src/api/java/ic2/api/energy/package-info.java create mode 100644 src/api/java/ic2/api/energy/prefab/BasicSink.java create mode 100644 src/api/java/ic2/api/energy/prefab/BasicSource.java create mode 100644 src/api/java/ic2/api/energy/prefab/package-info.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyConductor.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyEmitter.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergySink.java create mode 100644 src/api/java/ic2/api/energy/tile/IEnergySource.java rename src/{main => api}/java/ic2/api/energy/tile/IEnergyTile.java (60%) rename src/{main => api}/java/ic2/api/energy/tile/IHeatSource.java (54%) rename src/{main => api}/java/ic2/api/energy/tile/IKineticSource.java (53%) rename src/{main => api}/java/ic2/api/energy/tile/IMetaDelegate.java (72%) create mode 100644 src/api/java/ic2/api/energy/tile/package-info.java rename src/{main => api}/java/ic2/api/energy/usage.txt (100%) create mode 100644 src/api/java/ic2/api/event/LaserEvent.java create mode 100644 src/api/java/ic2/api/event/PaintEvent.java create mode 100644 src/api/java/ic2/api/event/RetextureEvent.java create mode 100644 src/api/java/ic2/api/event/package-info.java create mode 100644 src/api/java/ic2/api/info/IEnergyValueProvider.java create mode 100644 src/api/java/ic2/api/info/IFuelValueProvider.java create mode 100644 src/api/java/ic2/api/info/Info.java create mode 100644 src/api/java/ic2/api/info/package-info.java create mode 100644 src/api/java/ic2/api/item/ElectricItem.java rename src/{main => api}/java/ic2/api/item/IBackupElectricItemManager.java (87%) rename src/{main => api}/java/ic2/api/item/IBlockCuttingBlade.java (73%) create mode 100644 src/api/java/ic2/api/item/IBoxable.java rename src/{main => api}/java/ic2/api/item/IC2Items.java (95%) rename src/{main => api}/java/ic2/api/item/IDebuggable.java (100%) create mode 100644 src/api/java/ic2/api/item/IElectricItem.java create mode 100644 src/api/java/ic2/api/item/IElectricItemManager.java rename src/{main => api}/java/ic2/api/item/IItemHudInfo.java (87%) create mode 100644 src/api/java/ic2/api/item/IKineticWindRotor.java create mode 100644 src/api/java/ic2/api/item/IMetalArmor.java create mode 100644 src/api/java/ic2/api/item/ISpecialElectricItem.java create mode 100644 src/api/java/ic2/api/item/ITerraformingBP.java create mode 100644 src/api/java/ic2/api/item/ItemWrapper.java create mode 100644 src/api/java/ic2/api/item/package-info.java rename src/{main => api}/java/ic2/api/network/INetworkClientTileEntityEventListener.java (51%) rename src/{main => api}/java/ic2/api/network/INetworkDataProvider.java (66%) create mode 100644 src/api/java/ic2/api/network/INetworkItemEventListener.java rename src/{main => api}/java/ic2/api/network/INetworkTileEntityEventListener.java (54%) create mode 100644 src/api/java/ic2/api/network/INetworkUpdateListener.java create mode 100644 src/api/java/ic2/api/network/NetworkHelper.java create mode 100644 src/api/java/ic2/api/network/package-info.java create mode 100644 src/api/java/ic2/api/package-info.java create mode 100644 src/api/java/ic2/api/reactor/IReactor.java create mode 100644 src/api/java/ic2/api/reactor/IReactorChamber.java create mode 100644 src/api/java/ic2/api/reactor/IReactorComponent.java create mode 100644 src/api/java/ic2/api/reactor/package-info.java create mode 100644 src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/ICraftingRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/IFluidHeatManager.java rename src/{main => api}/java/ic2/api/recipe/ILiquidAcceptManager.java (63%) create mode 100644 src/api/java/ic2/api/recipe/IListRecipeManager.java create mode 100644 src/api/java/ic2/api/recipe/IMachineRecipeManager.java rename src/{main => api}/java/ic2/api/recipe/IPatternStorage.java (60%) create mode 100644 src/api/java/ic2/api/recipe/IRecipeInput.java create mode 100644 src/api/java/ic2/api/recipe/IScrapboxManager.java create mode 100644 src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputItemStack.java create mode 100644 src/api/java/ic2/api/recipe/RecipeInputOreDict.java create mode 100644 src/api/java/ic2/api/recipe/RecipeOutput.java create mode 100644 src/api/java/ic2/api/recipe/Recipes.java create mode 100644 src/api/java/ic2/api/recipe/package-info.java create mode 100644 src/api/java/ic2/api/tile/ExplosionWhitelist.java create mode 100644 src/api/java/ic2/api/tile/IEnergyStorage.java create mode 100644 src/api/java/ic2/api/tile/IWrenchable.java create mode 100644 src/api/java/ic2/api/tile/package-info.java create mode 100644 src/api/java/ic2/api/util/IKeyboard.java rename src/{main => api}/java/ic2/api/util/Keys.java (54%) create mode 100644 src/api/java/ic2/api/util/package-info.java delete mode 100644 src/main/java/ic2/api/Direction.java delete mode 100644 src/main/java/ic2/api/crops/BaseSeed.java delete mode 100644 src/main/java/ic2/api/crops/CropCard.java delete mode 100644 src/main/java/ic2/api/crops/Crops.java delete mode 100644 src/main/java/ic2/api/crops/ICropTile.java delete mode 100644 src/main/java/ic2/api/crops/package-info.java delete mode 100644 src/main/java/ic2/api/energy/IEnergyNet.java delete mode 100644 src/main/java/ic2/api/energy/NodeStats.java delete mode 100644 src/main/java/ic2/api/energy/event/package-info.java delete mode 100644 src/main/java/ic2/api/energy/package-info.java delete mode 100644 src/main/java/ic2/api/energy/prefab/BasicSink.java delete mode 100644 src/main/java/ic2/api/energy/prefab/BasicSource.java delete mode 100644 src/main/java/ic2/api/energy/prefab/package-info.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyConductor.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergyEmitter.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergySink.java delete mode 100644 src/main/java/ic2/api/energy/tile/IEnergySource.java delete mode 100644 src/main/java/ic2/api/energy/tile/package-info.java delete mode 100644 src/main/java/ic2/api/event/LaserEvent.java delete mode 100644 src/main/java/ic2/api/event/PaintEvent.java delete mode 100644 src/main/java/ic2/api/event/RetextureEvent.java delete mode 100644 src/main/java/ic2/api/event/package-info.java delete mode 100644 src/main/java/ic2/api/info/IEnergyValueProvider.java delete mode 100644 src/main/java/ic2/api/info/IFuelValueProvider.java delete mode 100644 src/main/java/ic2/api/info/Info.java delete mode 100644 src/main/java/ic2/api/info/package-info.java delete mode 100644 src/main/java/ic2/api/item/ElectricItem.java delete mode 100644 src/main/java/ic2/api/item/IBoxable.java delete mode 100644 src/main/java/ic2/api/item/IElectricItem.java delete mode 100644 src/main/java/ic2/api/item/IElectricItemManager.java delete mode 100644 src/main/java/ic2/api/item/IKineticWindRotor.java delete mode 100644 src/main/java/ic2/api/item/IMetalArmor.java delete mode 100644 src/main/java/ic2/api/item/ISpecialElectricItem.java delete mode 100644 src/main/java/ic2/api/item/ITerraformingBP.java delete mode 100644 src/main/java/ic2/api/item/ItemWrapper.java delete mode 100644 src/main/java/ic2/api/item/package-info.java delete mode 100644 src/main/java/ic2/api/network/INetworkItemEventListener.java delete mode 100644 src/main/java/ic2/api/network/INetworkUpdateListener.java delete mode 100644 src/main/java/ic2/api/network/NetworkHelper.java delete mode 100644 src/main/java/ic2/api/network/package-info.java delete mode 100644 src/main/java/ic2/api/package-info.java delete mode 100644 src/main/java/ic2/api/reactor/IReactor.java delete mode 100644 src/main/java/ic2/api/reactor/IReactorChamber.java delete mode 100644 src/main/java/ic2/api/reactor/IReactorComponent.java delete mode 100644 src/main/java/ic2/api/reactor/package-info.java delete mode 100644 src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/ICraftingRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/IFluidHeatManager.java delete mode 100644 src/main/java/ic2/api/recipe/IListRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/IMachineRecipeManager.java delete mode 100644 src/main/java/ic2/api/recipe/IRecipeInput.java delete mode 100644 src/main/java/ic2/api/recipe/IScrapboxManager.java delete mode 100644 src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java delete mode 100644 src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java delete mode 100644 src/main/java/ic2/api/recipe/RecipeInputItemStack.java delete mode 100644 src/main/java/ic2/api/recipe/RecipeInputOreDict.java delete mode 100644 src/main/java/ic2/api/recipe/RecipeOutput.java delete mode 100644 src/main/java/ic2/api/recipe/Recipes.java delete mode 100644 src/main/java/ic2/api/recipe/package-info.java delete mode 100644 src/main/java/ic2/api/tile/ExplosionWhitelist.java delete mode 100644 src/main/java/ic2/api/tile/IEnergyStorage.java delete mode 100644 src/main/java/ic2/api/tile/IWrenchable.java delete mode 100644 src/main/java/ic2/api/tile/package-info.java delete mode 100644 src/main/java/ic2/api/util/IKeyboard.java delete mode 100644 src/main/java/ic2/api/util/package-info.java diff --git a/src/api/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java new file mode 100644 index 00000000..53a59b58 --- /dev/null +++ b/src/api/java/ic2/api/Direction.java @@ -0,0 +1,127 @@ +package ic2.api; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Represents the 6 possible directions along the axis of a block. + */ +public enum Direction { + /** + * -X + */ + XN(0), + /** + * +X + */ + XP(1), + + /** + * -Y + */ + YN(2), //MC-Code starts with 0 here + /** + * +Y + */ + YP(3), // 1... + + /** + * -Z + */ + ZN(4), + /** + * +Z + */ + ZP(5); + + public static Direction fromSideValue(int side) { + return directions[(side + 2) % 6]; + } + + public static Direction fromForgeDirection(ForgeDirection dir) { + if (dir == ForgeDirection.UNKNOWN) return null; + + return fromSideValue(dir.ordinal()); + } + + private Direction(int dir1) { + this.dir = dir1; + } + + /** + * Get the tile entity next to a tile entity following this direction. + * + * @param tileEntity tile entity to check + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyToTileEntity(TileEntity te) { + return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); + } + + /** + * Get the tile entity next to a position following this direction. + * + * @param world World to check + * @param x X coordinate to check from + * @param y Y coordinate to check from + * @param z Z coordinate to check from + * @return Adjacent tile entity or null if none exists + */ + public TileEntity applyTo(World world, int x, int y, int z) { + int coords[] = {x, y, z}; + + coords[dir / 2] += getSign(); + + if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { + try { + return world.getTileEntity(coords[0], coords[1], coords[2]); + } catch (Exception e) { + throw new RuntimeException("error getting TileEntity at dim " + world.provider.dimensionId + " " + coords[0] + "/" + coords[1] + "/" + coords[2]); + } + } + + return null; + } + + /** + * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) + * + * @return Inverse direction + */ + public Direction getInverse() { + int inverseDir = dir - getSign(); + + for (Direction direction : directions) { + if (direction.dir == inverseDir) return direction; + } + + return this; + } + + /** + * Convert this direction to a Minecraft side value. + * + * @return Minecraft side value + */ + public int toSideValue() { + return (dir + 4) % 6; + } + + /** + * Determine direction sign (N for negative or P for positive). + * + * @return -1 if the direction is negative, +1 if the direction is positive + */ + private int getSign() { + return (dir % 2) * 2 - 1; + } + + public ForgeDirection toForgeDirection() { + return ForgeDirection.getOrientation(toSideValue()); + } + + private int dir; + public static final Direction[] directions = Direction.values(); +} + diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java new file mode 100644 index 00000000..38a1a216 --- /dev/null +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -0,0 +1,56 @@ +package ic2.api.crops; + +/** + * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. + */ +public class BaseSeed { + /** + * Plant ID. + */ + public int id; + + /** + * Plant size. + */ + public int size; + + /** + * Plant growth stat. + */ + public int statGrowth; + + /** + * Plant gain stat. + */ + public int statGain; + + /** + * Plant resistance stat. + */ + public int statResistance; + + /** + * For internal usage only. + */ + public int stackSize; + + /** + * Create a BaseSeed object. + * + * @param id1 plant ID + * @param size1 plant size + * @param statGrowth1 plant growth stat + * @param statGain1 plant gain stat + * @param statResistance1 plant resistance stat + * @param stackSize1 for internal usage only + */ + public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) { + super(); + this.id = id1; + this.size = size1; + this.statGrowth = statGrowth1; + this.statGain = statGain1; + this.statResistance = statResistance1; + this.stackSize = stackSize1; + } +} diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java new file mode 100644 index 00000000..c8eff3c5 --- /dev/null +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -0,0 +1,379 @@ +package ic2.api.crops; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +/** + * Base agriculture crop. + *

+ * Any crop extending this can be registered using registerCrop to be added into the game. + */ +public abstract class CropCard { + /** + * Plant name. Will be displayed to the player. + * + * @return Plant name + */ + public abstract String name(); + + /** + * Your name here, will be shown in "Discovered by:" when analyzing seeds. + * + * @return Your name + */ + public String discoveredBy() { + return "IC2 Team"; + } + + /** + * Description of your plant. Keep it short, a few characters per line for up to two lines. + * Default is showing attributes of your plant, 2 per line. + * + * @param i line to get, starting from 0 + * @return The line + */ + public String desc(int i) { + String[] att = attributes(); + if (att == null || att.length == 0) return ""; + if (i == 0) { + String s = att[0]; + if (att.length >= 2) { + s += ", " + att[1]; + if (att.length >= 3) s += ","; + } + return s; + } + if (att.length < 3) return ""; + String s = att[2]; + if (att.length >= 4) s += ", " + att[3]; + return s; + } + + /** + * Tier of the plant. Ranges from 1 to 16, 0 is Weed. + * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. + * + * @return Tier + */ + public abstract int tier(); + + /** + * Describe the plant through a set of stats, influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + *

+ * Stats: + * - 0: Chemistry (Industrial uses based on chemical plant components) + * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) + * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) + * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) + * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) + * + * @param n index of the requested stat + * @return The requested value of the stats + */ + public abstract int stat(int n); + + /** + * Additional attributes of the plant, also influencing breeding. + * Plants sharing stats and attributes will tend to cross-breed more often. + * + * @return Attributes as an array of strings + */ + public abstract String[] attributes(); + + /** + * Determine the max crop size. + *

+ * Currently only used for texture allocation. + */ + public abstract int maxSize(); + + /** + * Instantiate your Icons here. + *

+ * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + textures = new IIcon[maxSize()]; + + for (int i = 1; i <= textures.length; i++) { + textures[i - 1] = iconRegister.registerIcon("ic2:crop/blockCrop." + name() + "." + i); + } + } + + /** + * Sprite the crop is meant to be rendered with. + * + * @param crop reference to ICropTile + * @return 0-255, representing the sprite index on the crop's spritesheet. + */ + @SideOnly(Side.CLIENT) + public IIcon getSprite(ICropTile crop) { + if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; + + return textures[crop.getSize() - 1]; + } + + /** + * Get the crop's spritesheet. + * Per default crops_0.png of ic2-sprites + * + * @return Texture file path + */ + public String getTextureFile() { + return "/ic2/sprites/crops_0.png"; + } + + /** + * Amount of growth points needed to increase the plant's size. + * Default is 200 * tier. + */ + public int growthDuration(ICropTile crop) { + return tier() * 200; + } + + /** + * Check whether the plant can grow further. + *

+ * Consider: + * - Humidity, nutrients and air quality + * - Current size + * - Light level + * - Special biomes or conditions, accessible through crop.worldObj + *

+ * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. + * + * @param crop reference to ICropTile + * @return Whether the crop can grow + */ + public abstract boolean canGrow(ICropTile crop); + + /** + * Calculate the influence for the plant to grow based on humidity, nutrients and air. + * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. + * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) + *

+ * Default is humidity + nutrients + air (no factors). + * + * @param crop reference to ICropTile + * @param humidity ground humidity, influenced by hydration + * @param nutrients nutrient quality in ground, based on fertilizers + * @param air air quality, influences by open gardens and less crops surrounding this one + * @return 0-30 + */ + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) (humidity + nutrients + air); + } + + /** + * Used to determine whether the plant can crossbreed with another crop. + * Default is allow crossbreeding if the size is greater or equal than 3. + * + * @param crop crop to crossbreed with + */ + public boolean canCross(ICropTile crop) { + return crop.getSize() >= 3; + } + + + /** + * Called when the plant is rightclicked by a player. + * Default action is harvesting. + *

+ * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player rightclicking the crop + * @return Whether the plant has changed + */ + public boolean rightclick(ICropTile crop, EntityPlayer player) { + return crop.harvest(true); + } + + /** + * Use in Crop Havester with insert Cropnalyzer to get best Output. + * + * @param crop reference to ICropTile + * @return need crop size for best output. + */ + + public abstract int getOptimalHavestSize(ICropTile crop); + + /** + * Check whether the crop can be harvested. + * + * @param crop reference to ICropTile + * @return Whether the crop can be harvested in its current state. + */ + public abstract boolean canBeHarvested(ICropTile crop); + + /** + * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. + * Default is 0.95^tier. + * + * @return Chance to drop the gains + */ + public float dropGainChance() { + float base = 1F; + for (int i = 0; i < tier(); i++) { + base *= 0.95; + } + return base; + } + + /** + * Item obtained from harvesting the plant. + * + * @param crop reference to ICropTile + * @return Item obtained + */ + public abstract ItemStack getGain(ICropTile crop); + + /** + * Get the size of the plant after harvesting. + * Default is 1. + * + * @param crop reference to ICropTile + * @return Plant size after harvesting + */ + public byte getSizeAfterHarvest(ICropTile crop) { + return 1; + } + + + /** + * Called when the plant is leftclicked by a player. + * Default action is picking the plant. + *

+ * Only called Serverside. + * + * @param crop reference to ICropTile + * @param player player leftclicked the crop + * @return Whether the plant has changed + */ + public boolean leftclick(ICropTile crop, EntityPlayer player) { + return crop.pick(true); + } + + /** + * Base chance for dropping seeds when the plant is picked. + * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. + * + * @param crop reference to ICropTile + * @return Chance to drop the seeds + */ + public float dropSeedChance(ICropTile crop) { + if (crop.getSize() == 1) return 0; + float base = 0.5F; + if (crop.getSize() == 2) base /= 2F; + for (int i = 0; i < tier(); i++) { + base *= 0.8; + } + return base; + } + + /** + * Obtain seeds dropped when the plant is picked. + * Multiple drops of the returned ItemStack can occur. + * Default action is generating a seed from this crop. + * + * @param crop reference to ICropTile + * @return Seeds + */ + public ItemStack getSeeds(ICropTile crop) { + return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); + } + + /** + * Called when a neighbor block to the crop has changed. + * + * @param crop reference to ICropTile + */ + public void onNeighbourChange(ICropTile crop) { + // + } + + /** + * Check if the crop should emit redstone. + * + * @return Whether the crop should emit redstone + */ + public int emitRedstone(ICropTile crop) { + return 0; + } + + /** + * Called when the crop is destroyed. + * + * @param crop reference to ICropTile + */ + public void onBlockDestroyed(ICropTile crop) { + // + } + + /** + * Get the light value emitted by the plant. + * + * @param crop reference to ICropTile + * @return Light value emitted + */ + public int getEmittedLight(ICropTile crop) { + return 0; + } + + /** + * Default is true if the entity is an EntityLiving in jumping or sprinting state. + * + * @param crop reference to ICropTile + * @param entity entity colliding + * @return Whether trampling calculation should happen, return false if the plant is no longer valid. + */ + public boolean onEntityCollision(ICropTile crop, Entity entity) { + if (entity instanceof EntityLivingBase) { + return ((EntityLivingBase) entity).isSprinting(); + } + return false; + } + + + /** + * Called every time the crop ticks. + * Should be called every 256 ticks or around 13 seconds. + * + * @param crop reference to ICropTile + */ + public void tick(ICropTile crop) { + // + } + + /** + * Check whether this plant spreads weed to surrounding tiles. + * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. + * + * @param crop reference to ICropTile + * @return Whether the plant spreads weed + */ + public boolean isWeed(ICropTile crop) { + return crop.getSize() >= 2 && (crop.getID() == 0 || crop.getGrowth() >= 24); + } + + + /** + * Get this plant's ID. + * + * @return ID of this CropCard or -1 if it's not registered + */ + public final int getId() { + return Crops.instance.getIdFor(this); + } + + @SideOnly(Side.CLIENT) + protected IIcon textures[]; +} diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/api/java/ic2/api/crops/Crops.java new file mode 100644 index 00000000..d41e1287 --- /dev/null +++ b/src/api/java/ic2/api/crops/Crops.java @@ -0,0 +1,115 @@ +package ic2.api.crops; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary.Type; + +/** + * General management of the crop system. + */ +public abstract class Crops { + public static Crops instance; + + /** + * Adds a crop humidity and nutrient biome bonus. + *

+ * 0 indicates no bonus and negative values indicate a penalty. + * + * @param biome Biome to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); + + /** + * Adds a crop humidity and nutrient biome bonus. + *

+ * 0 indicates no bonus and negative values indicate a penalty. + * + * @param type Forge biome type to apply the bonus in + * @param humidityBonus Humidity stat bonus + * @param nutrientsBonus Nutrient stat bonus + */ + public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus); + + /** + * Gets the humidity bonus for a biome. + * + * @param biome Biome to check + * @return Humidity bonus or 0 if none + */ + public abstract int getHumidityBiomeBonus(BiomeGenBase biome); + + /** + * Gets the nutrient bonus for a biome. + * + * @param biome Biome to check + * @return Nutrient bonus or 0 if none + */ + public abstract int getNutrientBiomeBonus(BiomeGenBase biome); + + /** + * Returns the list of registered crops. + * + * @return Registered crops by ID + */ + public abstract CropCard[] getCropList(); + + /** + * Auto-assign an ID to a plant and register it. + * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. + * + * @param crop plant to register + * @return The ID assigned to the plant + */ + public abstract short registerCrop(CropCard crop); + + /** + * Attempt to register a plant to an ID. + * If the ID is taken, the crop will not be registered and a console print will notify the user. + * + * @param crop plant to register + * @param i ID to register the plant to + * @return Whether the crop was registered + */ + public abstract boolean registerCrop(CropCard crop, int i); + + /** + * Registers a base seed, an item used to plant a crop. + * + * @param stack item + * @param id plant ID + * @param size initial size + * @param growth initial growth stat + * @param gain initial gain stat + * @param resistance initial resistance stat + * @return True if successful + */ + public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); + + /** + * Finds a base seed from the given item. + * + * @return Base seed or null if none found + */ + public abstract BaseSeed getBaseSeed(ItemStack stack); + + /** + * Execute registerSprites for all registered crop cards. + *

+ * This method will get called by IC2, don't call it yourself. + */ + @SideOnly(Side.CLIENT) + public abstract void startSpriteRegistration(IIconRegister iconRegister); + + /** + * Returns the ID for the given crop. + * + * @param crop Crop to look up + * @return ID, or -1 if not found + */ + public abstract int getIdFor(CropCard crop); +} diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java new file mode 100644 index 00000000..1b37eeb5 --- /dev/null +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -0,0 +1,263 @@ +package ic2.api.crops; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +/** + * Interface implemented by the crop tile entity. + */ +public interface ICropTile { + /** + * Get the crop's plant ID. + * + * @return Plant ID, or -1 if there is no plant currently on the crop + */ + public short getID(); + + /** + * Set the crop's plant ID. + * + * @param id Plant ID, or -1 for no plant + */ + public void setID(short id); + + /** + * Get the crop's plant size. + * + * @return Plant size, starting with 1 and maximum varies depending on plant + */ + public byte getSize(); + + /** + * Set the crop's plant size. + * + * @param size Plant size + */ + public void setSize(byte size); + + /** + * Get the crop's plant growth stat. + * Higher values indicate faster growth. + * + * @return Plant growth stat + */ + public byte getGrowth(); + + /** + * Set the crop's plant growth stat. + * + * @param growth Plant growth stat + */ + public void setGrowth(byte growth); + + /** + * Get the crop's plant gain stat. + * Higher values indicate more drops. + * + * @return Plant gain stat + */ + public byte getGain(); + + /** + * Set the crop's plant gain stat. + * + * @param gain Plant gain stat + */ + public void setGain(byte gain); + + /** + * Get the crop's plant resistance stat. + * Higher values indicate more resistance against trampling. + * + * @return Plant resistance stat + */ + public byte getResistance(); + + /** + * Set the crop's plant resistance stat. + * + * @param resistance Plant resistance stat + */ + public void setResistance(byte resistance); + + /** + * Get the crop's plant scan level. + * Increases every time the seed is analyzed. + * + * @return Plant scan level + */ + public byte getScanLevel(); + + /** + * Set the crop's plant scan level. + * + * @param scanLevel Plant scan level + */ + public void setScanLevel(byte scanLevel); + + /** + * Get the crop's plant custom data, stored alongside the crop. + * Can be modified in place. + * + * @return Plant custom data + */ + public NBTTagCompound getCustomData(); + + /** + * Get the crop's nutrient storage. + * Ranges from 0 to 100. + * + * @return Crop nutrient storage + */ + public int getNutrientStorage(); + + /** + * Set the crop's nutrient storage. + * + * @param nutrientStorage Crop nutrient storage + */ + public void setNutrientStorage(int nutrientStorage); + + /** + * Get the crop's hydration storage. + * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. + * + * @return Crop hydration storage + */ + public int getHydrationStorage(); + + /** + * Set the crop's hydration storage. + * + * @param hydrationStorage Crop hydration storage + */ + public void setHydrationStorage(int hydrationStorage); + + /** + * Get the crop's Weed-Ex storage. + * + * @return Crop Weed-Ex storage + */ + public int getWeedExStorage(); + + /** + * Set the crop's Weed-Ex storage. + * + * @param weedExStorage Crop Weed-Ex storage + */ + public void setWeedExStorage(int weedExStorage); + + /** + * Get the crop's humidity. + * Ranges from 0 (dry) to 10 (humid). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop humidity level + * @see #updateState() + */ + public byte getHumidity(); + + /** + * Get the crop's nutrient level. + * Ranges from 0 (empty) to 10 (full). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop nutrient level + * @see #updateState() + */ + public byte getNutrients(); + + /** + * Get the crop's air quality. + * Ranges from 0 (cluttered) to 10 (fresh). + * Updates every couple of seconds or when an update is requested. + * + * @return Crop air quality + * @see #updateState() + */ + public byte getAirQuality(); + + /** + * Get the crop's world. + * + * @return Crop world + */ + public World getWorld(); + + /** + * Get the crop's location. + * + * @return Crop location + */ + public ChunkCoordinates getLocation(); + + /** + * Get the crop's light level. + * + * @return Crop light level + */ + public int getLightLevel(); + + /** + * Pick the crop, removing and giving seeds for the plant. + * + * @param manual whether it was done by hand (not automated) + * @return true if successfully picked + */ + public boolean pick(boolean manual); + + /** + * Harvest the crop, turning it into gain and resetting its size. + * drop output on ground + * + * @param manual + * @return true if successfully harvested + */ + public boolean harvest(boolean manual); + + /** + * Harvest the crop, turning it into gain and resetting its size. + * drop output on ground + * + * @param Optimal force check getOptimalHavestSize() for harvest + * @return ItemStack[] of harvest output + */ + + ItemStack[] harvest_automated(boolean Optimal); + + /** + * Fully clears the crop without dropping anything. + */ + public void reset(); + + /** + * Request a texture and lighting update. + */ + public void updateState(); + + /** + * Check if a block is under the farmland containing the crop. + * Searches up to 2 blocks below the farmland or an air space, whichever appears first. + * + * @param block block to search + * @return Whether the block was found + */ + public boolean isBlockBelow(Block block); + + /** + * Generate plant seeds with the given parameters. + * + * @param plant plant ID + * @param growth plant growth stat + * @param gain plant gain stat + * @param resis plant resistance stat + * @param scan plant scan level + * @return Plant seed item + */ + public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); + + +} diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/api/java/ic2/api/crops/package-info.java new file mode 100644 index 00000000..f5041cdc --- /dev/null +++ b/src/api/java/ic2/api/crops/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.crops; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/energy/EnergyNet.java b/src/api/java/ic2/api/energy/EnergyNet.java similarity index 76% rename from src/main/java/ic2/api/energy/EnergyNet.java rename to src/api/java/ic2/api/energy/EnergyNet.java index 822bfc29..9ddf6b86 100644 --- a/src/main/java/ic2/api/energy/EnergyNet.java +++ b/src/api/java/ic2/api/energy/EnergyNet.java @@ -3,16 +3,16 @@ package ic2.api.energy; /** * Provides access to the energy network. - * + *

* The old EnergyNet methods missing in IEnergyNet have been migrated to events (load, unload) or * removed (tiles no longer emit energy actively, the energy net implementation requests it). - * + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public final class EnergyNet { - /** - * Instance of the global EnergyNet class. - */ - public static IEnergyNet instance; + /** + * Instance of the global EnergyNet class. + */ + public static IEnergyNet instance; } diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java new file mode 100644 index 00000000..c21241b4 --- /dev/null +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -0,0 +1,83 @@ +package ic2.api.energy; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Interface representing the methods provided by the global EnergyNet class. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyNet { + /** + * Get the EnergyNet-registered tile entity at the specified position. + *

+ * This is not the same as World.getTileEntity(), it's possible to register delegate tile + * entities with the energy net which are different from what's actually in the world. Those + * delegates allow to use separate TileEntity objects just for the EnergyNet interfaces, + * simplifying cross-mod dependencies and multi-blocks. + * + * @param world World containing the tile entity + * @param x x-coordinate + * @param y y-coordinate + * @param z z-coordinate + * @return tile entity registered to the energy net or null if none is registered + */ + TileEntity getTileEntity(World world, int x, int y, int z); + + /** + * Get the EnergyNet-registered neighbor tile entity at the specified position. + * + * @param te TileEntity indicating the world and position to search from + * @param dir direction the neighbor is to be found + * @return neighbor tile entity registered to the energy net or null if none is registered + */ + TileEntity getNeighbor(TileEntity te, ForgeDirection dir); + + /** + * determine how much energy has been emitted by the EnergyEmitter specified + * + * @param tileEntity energy emitter + * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergyEmitted(TileEntity tileEntity); + + /** + * determine how much energy has been sunken by the EnergySink specified + * + * @param tileEntity energy emitter + * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick + * @deprecated Discontinued, use getNodeStats instead. + */ + @Deprecated + double getTotalEnergySunken(TileEntity tileEntity); + + /** + * Retrieve statistics for the tile entity specified. + *

+ * The statistics apply to the last simulated tick. + * + * @param te Tile entity to check. + * @return Statistics for the tile entity. + */ + NodeStats getNodeStats(TileEntity te); + + /** + * Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2. + * + * @param tier tier + * @return power in eu/t + */ + double getPowerFromTier(int tier); + + /** + * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. + * + * @param power in eu/t + * @return tier + */ + int getTierFromPower(double power); +} diff --git a/src/api/java/ic2/api/energy/NodeStats.java b/src/api/java/ic2/api/energy/NodeStats.java new file mode 100644 index 00000000..11883685 --- /dev/null +++ b/src/api/java/ic2/api/energy/NodeStats.java @@ -0,0 +1,25 @@ +package ic2.api.energy; + +public class NodeStats { + public NodeStats(double energyIn, double energyOut, double voltage) { + this.energyIn = energyIn; + this.energyOut = energyOut; + this.voltage = voltage; + } + + public double getEnergyIn() { + return energyIn; + } + + public double getEnergyOut() { + return energyOut; + } + + public double getVoltage() { + return voltage; + } + + private final double energyIn; + private final double energyOut; + private final double voltage; +} diff --git a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java similarity index 64% rename from src/main/java/ic2/api/energy/event/EnergyTileEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileEvent.java index 2182e497..4979e4b0 100644 --- a/src/main/java/ic2/api/energy/event/EnergyTileEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java @@ -1,23 +1,21 @@ package ic2.api.energy.event; -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.event.world.WorldEvent; - import ic2.api.energy.tile.IEnergyTile; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.event.world.WorldEvent; /** * Base class for energy net events, don't use it directly. - * + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileEvent extends WorldEvent { - public final IEnergyTile energyTile; + public final IEnergyTile energyTile; - public EnergyTileEvent(IEnergyTile energyTile1) { - super(((TileEntity) energyTile1).getWorldObj()); + public EnergyTileEvent(IEnergyTile energyTile1) { + super(((TileEntity) energyTile1).getWorldObj()); - this.energyTile = energyTile1; - } + this.energyTile = energyTile1; + } } diff --git a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java similarity index 86% rename from src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java index bf019ae3..d302f894 100644 --- a/src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileLoadEvent.java @@ -4,23 +4,23 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing new energy tiles. - * + *

* This event notifies subscribers of loaded energy tiles, e.g. after getting * loaded through the chunk they are in or after being placed down by the * player or another deployer mechanism. - * + *

* Every energy tile which wants to get connected to the IC2 Energy Network has * to either post this event or alternatively call EnergyNet.addTileEntity(). - * + *

* You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. - * + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileLoadEvent extends EnergyTileEvent { - public EnergyTileLoadEvent(IEnergyTile energyTile1) { - super(energyTile1); - } + public EnergyTileLoadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java similarity index 87% rename from src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java rename to src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java index 2b22ae31..727c8a11 100644 --- a/src/main/java/ic2/api/energy/event/EnergyTileUnloadEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileUnloadEvent.java @@ -4,24 +4,24 @@ import ic2.api.energy.tile.IEnergyTile; /** * Event announcing terminated energy tiles. - * + *

* This event notifies subscribers of unloaded energy tiles, e.g. after getting * unloaded through the chunk they are in or after being destroyed by the * player or another block pick/destruction mechanism. - * + *

* Every energy tile which wants to get disconnected from the IC2 Energy * Network has to either post this event or alternatively call * EnergyNet.removeTileEntity(). - * + *

* You may use this event to build a static representation of energy tiles for * your own energy grid implementation if you need to. It's not required if you * always lookup energy paths on demand. - * + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public class EnergyTileUnloadEvent extends EnergyTileEvent { - public EnergyTileUnloadEvent(IEnergyTile energyTile1) { - super(energyTile1); - } + public EnergyTileUnloadEvent(IEnergyTile energyTile1) { + super(energyTile1); + } } diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java new file mode 100644 index 00000000..f1cc9ea0 --- /dev/null +++ b/src/api/java/ic2/api/energy/event/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.event; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java new file mode 100644 index 00000000..a92380fb --- /dev/null +++ b/src/api/java/ic2/api/energy/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/api/java/ic2/api/energy/prefab/BasicSink.java new file mode 100644 index 00000000..042f3688 --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSink.java @@ -0,0 +1,360 @@ +package ic2.api.energy.prefab; + +import cpw.mods.fml.common.FMLCommonHandler; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * BasicSink is a simple adapter to provide an ic2 energy sink. + *

+ * It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a + * one-time configurable input energy buffer, thus providing a common use case for machines. + *

+ * Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended. + * The delegate can be extended with additional functionality through a sub class though. + *

+ * The constraints set by BasicSink like the strict tank-like energy buffering should provide a + * more easy to use and stable interface than using IEnergySink directly while aiming for + * optimal performance. + *

+ * Using BasicSink involves the following steps: + * - create a BasicSink instance in your TileEntity, typically in a field + * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. + * - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available + * without consuming the energy. + * - optionally use getEnergyStored to display the output buffer charge level + * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) + *

+ * Example implementation code: + * + * @code{.java} public class SomeTileEntity extends TileEntity { + * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); + * @Override public void invalidate() { + * ic2EnergySink.invalidate(); // notify the energy sink + * ... + * super.invalidate(); // this is important for mc! + * } + * @Override public void onChunkUnload() { + * ic2EnergySink.onChunkUnload(); // notify the energy sink + * ... + * } + * @Override public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + *

+ * ic2EnergySink.readFromNBT(tag); + * ... + * } + * @Override public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + *

+ * ic2EnergySink.writeToNBT(tag); + * ... + * } + * @Override public void updateEntity() { + * ic2EnergySink.updateEntity(); // notify the energy sink + * ... + * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick + * ... // do something with the energy + * } + * ... + * } + *

+ * ... + * } + * @endcode + */ +public class BasicSink extends TileEntity implements IEnergySink { + // ********************************** + // *** Methods for use by the mod *** + // ********************************** + + /** + * Constructor for a new BasicSink delegate. + * + * @param parent1 TileEntity represented by this energy sink. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSink(TileEntity parent1, int capacity1, int tier1) { + this.parent = parent1; + this.capacity = capacity1; + this.tier = tier1; + } + + // in-world te forwards >> + + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } + + /** + * Notification that the base TileEntity finished loaded, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; + + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + + addedToEnet = true; + } + } + + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); + + onChunkUnload(); + } + + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + + addedToEnet = false; + } + } + + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + + NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); + + energyStored = data.getDouble("energy"); + } + + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } + + NBTTagCompound data = new NBTTagCompound(); + + data.setDouble("energy", energyStored); + + tag.setTag("IC2BasicSink", data); + } + + // << in-world te forwards + // methods for using this adapter >> + + /** + * Get the maximum amount of energy this sink can hold in its buffer. + * + * @return Capacity in EU. + */ + public int getCapacity() { + return capacity; + } + + /** + * Set the maximum amount of energy this sink can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(int capacity1) { + this.capacity = capacity1; + } + + /** + * Get the IC2 energy tier for this sink. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } + + /** + * Set the IC2 energy tier for this sink. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + this.tier = tier1; + } + + /** + * Determine the energy stored in the sink's input buffer. + * + * @return amount in EU, may be above capacity + */ + public double getEnergyStored() { + return energyStored; + } + + /** + * Set the stored energy to the specified amount. + *

+ * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } + + /** + * Determine if the specified amount of energy is available. + * + * @param amount in EU + * @return true if the amount is available + */ + public boolean canUseEnergy(double amount) { + return energyStored >= amount; + } + + /** + * Use the specified amount of energy, if available. + * + * @param amount amount to use + * @return true if the amount was available + */ + public boolean useEnergy(double amount) { + if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { + energyStored -= amount; + + return true; + } + return false; + } + + /** + * Discharge the supplied ItemStack into this sink's energy buffer. + * + * @param stack ItemStack to discharge (null is ignored) + * @param limit Transfer limit, values <= 0 will use the battery's limit + * @return true if energy was transferred + */ + public boolean discharge(ItemStack stack, int limit) { + if (stack == null || !Info.isIc2Available()) return false; + + double amount = capacity - energyStored; + if (amount <= 0) return false; + + if (limit > 0 && limit < amount) amount = limit; + + amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); + + energyStored += amount; + + return amount > 0; + } + + // << methods for using this adapter + + // backwards compatibility (ignore these) >> + + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } + + @Deprecated + public void onInvalidate() { + invalidate(); + } + + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } + + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } + + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } + + // << backwards compatibility + + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** + + // energy net interface >> + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return true; + } + + @Override + public double getDemandedEnergy() { + return Math.max(0, capacity - energyStored); + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + energyStored += amount; + + return 0; + } + + @Override + public int getSinkTier() { + return tier; + } + + // << energy net interface + + + public final TileEntity parent; + + protected int capacity; + protected int tier; + protected double energyStored; + protected boolean addedToEnet; +} diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/api/java/ic2/api/energy/prefab/BasicSource.java new file mode 100644 index 00000000..e78e48ba --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSource.java @@ -0,0 +1,362 @@ +package ic2.api.energy.prefab; + +import cpw.mods.fml.common.FMLCommonHandler; +import ic2.api.energy.EnergyNet; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySource; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * BasicSource is a simple adapter to provide an ic2 energy source. + *

+ * It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a + * one-time configurable output energy buffer, thus providing a common use case for generators. + *

+ * Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended. + * The delegate can be extended with additional functionality through a sub class though. + *

+ * The constraints set by BasicSource like the strict tank-like energy buffering should provide a + * more easy to use and stable interface than using IEnergySource directly while aiming for + * optimal performance. + *

+ * Using BasicSource involves the following steps: + * - create a BasicSource instance in your TileEntity, typically in a field + * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource + * instance. + * If you have other means of determining when the tile entity is fully loaded, notify onLoaded + * that way instead of forwarding updateEntity. + * - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator + * should run + * - optionally use getEnergyStored to display the output buffer charge level + * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) + *

+ * Example implementation code: + * + * @code{.java} public class SomeTileEntity extends TileEntity { + * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) + * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); + * @Override public void invalidate() { + * ic2EnergySource.invalidate(); // notify the energy source + * ... + * super.invalidate(); // this is important for mc! + * } + * @Override public void onChunkUnload() { + * ic2EnergySource.onChunkUnload(); // notify the energy source + * ... + * } + * @Override public void readFromNBT(NBTTagCompound tag) { + * super.readFromNBT(tag); + *

+ * ic2EnergySource.readFromNBT(tag); + * ... + * } + * @Override public void writeToNBT(NBTTagCompound tag) { + * super.writeToNBT(tag); + *

+ * ic2EnergySource.writeToNBT(tag); + * ... + * } + * @Override public void updateEntity() { + * ic2EnergySource.updateEntity(); // notify the energy source + * ... + * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick + * ... + * } + *

+ * ... + * } + * @endcode + */ +public class BasicSource extends TileEntity implements IEnergySource { + // ********************************** + // *** Methods for use by the mod *** + // ********************************** + + /** + * Constructor for a new BasicSource delegate. + * + * @param parent1 Base TileEntity represented by this energy source. + * @param capacity1 Maximum amount of eu to store. + * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... + */ + public BasicSource(TileEntity parent1, double capacity1, int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); + + this.parent = parent1; + this.capacity = capacity1 < power ? power : capacity1; + this.tier = tier1; + this.power = power; + } + + // in-world te forwards >> + + /** + * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void updateEntity() { + if (!addedToEnet) onLoaded(); + } + + /** + * Notification that the base TileEntity finished loading, for advanced uses. + * Either updateEntity or onLoaded have to be used. + */ + public void onLoaded() { + if (!addedToEnet && + !FMLCommonHandler.instance().getEffectiveSide().isClient() && + Info.isIc2Available()) { + worldObj = parent.getWorldObj(); + xCoord = parent.xCoord; + yCoord = parent.yCoord; + zCoord = parent.zCoord; + + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + + addedToEnet = true; + } + } + + /** + * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void invalidate() { + super.invalidate(); + + onChunkUnload(); + } + + /** + * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. + * Both invalidate and onChunkUnload have to be used. + */ + @Override + public void onChunkUnload() { + if (addedToEnet && + Info.isIc2Available()) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + + addedToEnet = false; + } + } + + /** + * Forward for the base TileEntity's readFromNBT(), used for loading the state. + * + * @param tag Compound tag as supplied by TileEntity.readFromNBT() + */ + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + + NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); + + energyStored = data.getDouble("energy"); + } + + /** + * Forward for the base TileEntity's writeToNBT(), used for saving the state. + * + * @param tag Compound tag as supplied by TileEntity.writeToNBT() + */ + @Override + public void writeToNBT(NBTTagCompound tag) { + try { + super.writeToNBT(tag); + } catch (RuntimeException e) { + // happens if this is a delegate, ignore + } + + NBTTagCompound data = new NBTTagCompound(); + + data.setDouble("energy", energyStored); + + tag.setTag("IC2BasicSource", data); + } + + // << in-world te forwards + // methods for using this adapter >> + + /** + * Get the maximum amount of energy this source can hold in its buffer. + * + * @return Capacity in EU. + */ + public double getCapacity() { + return capacity; + } + + /** + * Set the maximum amount of energy this source can hold in its buffer. + * + * @param capacity1 Capacity in EU. + */ + public void setCapacity(double capacity1) { + if (capacity1 < power) capacity1 = power; + + this.capacity = capacity1; + } + + /** + * Get the IC2 energy tier for this source. + * + * @return IC2 Tier. + */ + public int getTier() { + return tier; + } + + /** + * Set the IC2 energy tier for this source. + * + * @param tier1 IC2 Tier. + */ + public void setTier(int tier1) { + double power = EnergyNet.instance.getPowerFromTier(tier1); + + if (capacity < power) capacity = power; + + this.tier = tier1; + this.power = power; + } + + + /** + * Determine the energy stored in the source's output buffer. + * + * @return amount in EU + */ + public double getEnergyStored() { + return energyStored; + } + + /** + * Set the stored energy to the specified amount. + *

+ * This is intended for server -> client synchronization, e.g. to display the stored energy in + * a GUI through getEnergyStored(). + * + * @param amount + */ + public void setEnergyStored(double amount) { + energyStored = amount; + } + + /** + * Determine the free capacity in the source's output buffer. + * + * @return amount in EU + */ + public double getFreeCapacity() { + return capacity - energyStored; + } + + /** + * Add some energy to the output buffer. + * + * @param amount maximum amount of energy to add + * @return amount added/used, NOT remaining + */ + public double addEnergy(double amount) { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; + if (amount > capacity - energyStored) amount = capacity - energyStored; + + energyStored += amount; + + return amount; + } + + /** + * Charge the supplied ItemStack from this source's energy buffer. + * + * @param stack ItemStack to charge (null is ignored) + * @return true if energy was transferred + */ + public boolean charge(ItemStack stack) { + if (stack == null || !Info.isIc2Available()) return false; + + double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); + + energyStored -= amount; + + return amount > 0; + } + + // << methods for using this adapter + + // backwards compatibility (ignore these) >> + + @Deprecated + public void onUpdateEntity() { + updateEntity(); + } + + @Deprecated + public void onInvalidate() { + invalidate(); + } + + @Deprecated + public void onOnChunkUnload() { + onChunkUnload(); + } + + @Deprecated + public void onReadFromNbt(NBTTagCompound tag) { + readFromNBT(tag); + } + + @Deprecated + public void onWriteToNbt(NBTTagCompound tag) { + writeToNBT(tag); + } + + // << backwards compatibility + + // ****************************** + // *** Methods for use by ic2 *** + // ****************************** + + // energy net interface >> + + @Override + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return true; + } + + @Override + public double getOfferedEnergy() { + return Math.min(energyStored, power); + } + + @Override + public void drawEnergy(double amount) { + energyStored -= amount; + } + + @Override + public int getSourceTier() { + return tier; + } + + // << energy net interface + + + public final TileEntity parent; + + protected double capacity; + protected int tier; + protected double power; + protected double energyStored; + protected boolean addedToEnet; +} diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/api/java/ic2/api/energy/prefab/package-info.java new file mode 100644 index 00000000..b244b0ff --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.prefab; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java new file mode 100644 index 00000000..fa4f8d32 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java @@ -0,0 +1,26 @@ +package ic2.api.energy.tile; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * For internal/multi-block usage only. + * + * @see ic2.api.energy.tile.IEnergySink + * @see ic2.api.energy.tile.IEnergyConductor + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyAcceptor extends IEnergyTile { + /** + * Determine if this acceptor can accept current from an adjacent emitter in a direction. + *

+ * The TileEntity in the emitter parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param emitter energy emitter, may also be null or an IMetaDelegate + * @param direction direction the energy is being received from + */ + boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java new file mode 100644 index 00000000..6d917546 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java @@ -0,0 +1,53 @@ +package ic2.api.energy.tile; + +/** + * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this + * interface. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { + /** + * Energy loss for the conductor in EU per block. + * + * @return Energy loss + */ + double getConductionLoss(); + + /** + * Amount of energy the insulation will handle before shocking nearby players and mobs. + * + * @return Insulation energy absorption in EU + */ + double getInsulationEnergyAbsorption(); + + /** + * Amount of energy the insulation will handle before it is destroyed. + * Ensure that this value is greater than the insulation energy absorption + 64. + * + * @return Insulation-destroying energy in EU + */ + double getInsulationBreakdownEnergy(); + + /** + * Amount of energy the conductor will handle before it melts. + * + * @return Conductor-destroying energy in EU + */ + double getConductorBreakdownEnergy(); + + /** + * Remove the conductor's insulation if the insulation breakdown energy was exceeded. + * + * @see #getInsulationBreakdownEnergy() + */ + void removeInsulation(); + + /** + * Remove the conductor if the conductor breakdown energy was exceeded. + * + * @see #getConductorBreakdownEnergy() + */ + void removeConductor(); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java new file mode 100644 index 00000000..7357b69d --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java @@ -0,0 +1,27 @@ +package ic2.api.energy.tile; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * For internal/multi-block usage only. + * + * @see ic2.api.energy.tile.IEnergySource + * @see ic2.api.energy.tile.IEnergyConductor + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyEmitter extends IEnergyTile { + /** + * Determine if this emitter can emit energy to an adjacent receiver. + *

+ * The TileEntity in the receiver parameter is what was originally added to the energy net, + * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. + * + * @param receiver receiver, may also be null or an IMetaDelegate + * @param direction direction the receiver is from the emitter + * @return Whether energy should be emitted + */ + boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java new file mode 100644 index 00000000..4a943f05 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergySink.java @@ -0,0 +1,43 @@ +package ic2.api.energy.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Allows a tile entity (mostly a machine) to receive energy. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergySink extends IEnergyAcceptor { + /** + * Determine how much energy the sink accepts. + *

+ * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. + * + * @return max accepted input in eu + * @note Modifying the energy net from this method is disallowed. + */ + double getDemandedEnergy(); + + /** + * Determine the tier of this energy sink. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @return tier of this energy sink + * @note Modifying the energy net from this method is disallowed. + * @note Return Integer.MAX_VALUE to allow any voltage. + */ + int getSinkTier(); + + /** + * Transfer energy to the sink. + *

+ * It's highly recommended to accept all energy by letting the internal buffer overflow to + * increase the performance and accuracy of the distribution simulation. + * + * @param directionFrom direction from which the energy comes from + * @param amount energy to be transferred + * @return Energy not consumed (leftover) + */ + double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); +} + diff --git a/src/api/java/ic2/api/energy/tile/IEnergySource.java b/src/api/java/ic2/api/energy/tile/IEnergySource.java new file mode 100644 index 00000000..7964e682 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergySource.java @@ -0,0 +1,36 @@ +package ic2.api.energy.tile; + +/** + * Allows a tile entity (mostly a generator) to emit energy. + *

+ * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergySource extends IEnergyEmitter { + /** + * Energy output provided by the source this tick. + * This is typically Math.min(stored energy, max output/tick). + * + * @return Energy offered this tick + * @note Modifying the energy net from this method is disallowed. + */ + double getOfferedEnergy(); + + /** + * Draw energy from this source's buffer. + *

+ * If the source doesn't have a buffer, this is a no-op. + * + * @param amount amount of EU to draw, may be negative + */ + void drawEnergy(double amount); + + /** + * Determine the tier of this energy source. + * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. + * + * @return tier of this energy source + * @note Modifying the energy net from this method is disallowed. + */ + int getSourceTier(); +} + diff --git a/src/main/java/ic2/api/energy/tile/IEnergyTile.java b/src/api/java/ic2/api/energy/tile/IEnergyTile.java similarity index 60% rename from src/main/java/ic2/api/energy/tile/IEnergyTile.java rename to src/api/java/ic2/api/energy/tile/IEnergyTile.java index 3938190a..a7e473a4 100644 --- a/src/main/java/ic2/api/energy/tile/IEnergyTile.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyTile.java @@ -3,13 +3,13 @@ package ic2.api.energy.tile; /** * For internal usage only, base class for all energy tiles. * - * @see IEnergySink - * @see IEnergySource - * @see IEnergyConductor - * + * @see ic2.api.energy.tile.IEnergySink + * @see ic2.api.energy.tile.IEnergySource + * @see ic2.api.energy.tile.IEnergyConductor + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IEnergyTile { - // + // } diff --git a/src/main/java/ic2/api/energy/tile/IHeatSource.java b/src/api/java/ic2/api/energy/tile/IHeatSource.java similarity index 54% rename from src/main/java/ic2/api/energy/tile/IHeatSource.java rename to src/api/java/ic2/api/energy/tile/IHeatSource.java index 2e5db411..f40ce755 100644 --- a/src/main/java/ic2/api/energy/tile/IHeatSource.java +++ b/src/api/java/ic2/api/energy/tile/IHeatSource.java @@ -3,14 +3,14 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; public interface IHeatSource { - + + /* + * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestHeatTick(ForgeDirection directionFrom); + /* - * Return max heat transmission peer Tick (only theoretical bandwidth not available amount) - */ - int maxrequestHeatTick(ForgeDirection directionFrom); - - /* - * @param requested amount of heat to transfer + * @param requested amount of heat to transfer * * @return transmitted amount of heat * @@ -18,6 +18,6 @@ public interface IHeatSource { * * requestHeat(100) : return 50 : so 50 units of heat remove from HeatSource */ - - int requestHeat(ForgeDirection directionFrom, int requestheat); + + int requestHeat(ForgeDirection directionFrom, int requestheat); } diff --git a/src/main/java/ic2/api/energy/tile/IKineticSource.java b/src/api/java/ic2/api/energy/tile/IKineticSource.java similarity index 53% rename from src/main/java/ic2/api/energy/tile/IKineticSource.java rename to src/api/java/ic2/api/energy/tile/IKineticSource.java index a6514087..2276f2c7 100644 --- a/src/main/java/ic2/api/energy/tile/IKineticSource.java +++ b/src/api/java/ic2/api/energy/tile/IKineticSource.java @@ -3,13 +3,13 @@ package ic2.api.energy.tile; import net.minecraftforge.common.util.ForgeDirection; public interface IKineticSource { - /* - * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) - */ - int maxrequestkineticenergyTick(ForgeDirection directionFrom); + /* + * Return max kinetic energy transmission peer Tick (only theoretical bandwidth not available amount) + */ + int maxrequestkineticenergyTick(ForgeDirection directionFrom); /* - * @param requested amount of kinetic energy to transfer + * @param requested amount of kinetic energy to transfer * * @return transmitted amount of kineticenergy * @@ -18,5 +18,5 @@ public interface IKineticSource { * requestkineticenergy(100) : return 50 : so 50 units of kinetic energy remove from KineticSource */ - int requestkineticenergy(ForgeDirection directionFrom, int requestkineticenergy); + int requestkineticenergy(ForgeDirection directionFrom, int requestkineticenergy); } diff --git a/src/main/java/ic2/api/energy/tile/IMetaDelegate.java b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java similarity index 72% rename from src/main/java/ic2/api/energy/tile/IMetaDelegate.java rename to src/api/java/ic2/api/energy/tile/IMetaDelegate.java index f7319d0e..a79cd9bb 100644 --- a/src/main/java/ic2/api/energy/tile/IMetaDelegate.java +++ b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java @@ -1,36 +1,35 @@ package ic2.api.energy.tile; -import java.util.List; - import net.minecraft.tileentity.TileEntity; +import java.util.List; + /** * Interface for grouping multi-block structures to a single energy net delegate. - * + *

* The energy net uses TileEntity to refer to a specific xyz+world position. If multiple of those * positions should belong to the same functional structure, i.e. they consume or produce energy * only once for the whole multi-block instead of once per every single block, this interface * allows to do so. - * + *

* The tile entity implementing IMetaDelegate has to be added/removed to/from the energy net * instead of every single sub-TileEntity. The energy net interaction will be handled by the * IMetaDelegate TileEntity as well. - * + *

* The sub tile array TileEntity[] just provides optional connectivity (IEnergyAcceptor, * IEnergyEmitter) and mandatory position (x, y, z, World) data. * If the connectivity data on the sub tile is missing, the meta delegate is queried instead. - * + *

* See ic2/api/energy/usage.txt for an overall description of the energy net api. */ public interface IMetaDelegate extends IEnergyTile { - /** - * Get the sub-TileEntities belonging to this Meta TileEntity. - * - * @note The list has to be consistent between the EnergyNet Load and Unload events. - * @note The list must have at least 1 element. - * @note The parent te implementing IMetaDelegate isn't automatically included. - * - * @return sub-TileEntity array - */ - List getSubTiles(); + /** + * Get the sub-TileEntities belonging to this Meta TileEntity. + * + * @return sub-TileEntity array + * @note The list has to be consistent between the EnergyNet Load and Unload events. + * @note The list must have at least 1 element. + * @note The parent te implementing IMetaDelegate isn't automatically included. + */ + List getSubTiles(); } diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java new file mode 100644 index 00000000..a1667397 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.energy.tile; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/energy/usage.txt b/src/api/java/ic2/api/energy/usage.txt similarity index 100% rename from src/main/java/ic2/api/energy/usage.txt rename to src/api/java/ic2/api/energy/usage.txt diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/api/java/ic2/api/event/LaserEvent.java new file mode 100644 index 00000000..7d83d57b --- /dev/null +++ b/src/api/java/ic2/api/event/LaserEvent.java @@ -0,0 +1,112 @@ +package ic2.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; + +/** + * A bunch of Events to handle the power of the Mining Laser. + */ +@Cancelable +public class LaserEvent extends WorldEvent { + // the Laser Entity + public final Entity lasershot; + + // the following variables can be changed and the Laser will adjust to them + + // the Player firing the Laser. If the Laser gets "reflected" the Player could change. + public EntityLivingBase owner; + // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. + public float range, power; + public int blockBreaks; + // Determines whether the laser will explode upon hitting something + public boolean explosive, smelt; + + public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { + super(world1); + this.lasershot = lasershot1; + this.owner = owner1; + this.range = range1; + this.power = power1; + this.blockBreaks = blockBreaks1; + this.explosive = explosive1; + this.smelt = smelt1; + } + + /** + * Event when the Laser is getting shot by a Player. + *

+ * The Item is the Laser Gun which the "Player" has shot + */ + public static class LaserShootEvent extends LaserEvent { + ItemStack laseritem; + + public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.laseritem = laseritem1; + } + } + + /** + * Event when the Laser is exploding for some Reason. + *

+ * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. + */ + public static class LaserExplodesEvent extends LaserEvent { + // explosion strength, even that can be changed! + public float explosionpower, explosiondroprate, explosionentitydamage; + + public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.explosionpower = explosionpower1; + this.explosiondroprate = explosiondroprate1; + this.explosionentitydamage = explosionentitydamage1; + } + } + + /** + * Event when the Laser is hitting a Block + * x, y and z are the Coords of the Block. + *

+ * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsBlockEvent extends LaserEvent { + // targeted block, even that can be changed! + public int x, y, z; + public int side; + // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. + public boolean removeBlock, dropBlock; + public float dropChance; + + public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.removeBlock = removeBlock1; + this.dropBlock = dropBlock1; + this.dropChance = dropChance1; + } + } + + /** + * Event when the Laser is getting at a Living Entity + *

+ * Canceling this Event ignores the Entity + * Use lasershot.setDead() to remove the Shot entirely. + */ + public static class LaserHitsEntityEvent extends LaserEvent { + // the Entity which the Laser has shot at, even the target can be changed! + public Entity hitentity; + + public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { + super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); + this.hitentity = hitentity1; + } + } +} diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/api/java/ic2/api/event/PaintEvent.java new file mode 100644 index 00000000..a5b32f2e --- /dev/null +++ b/src/api/java/ic2/api/event/PaintEvent.java @@ -0,0 +1,30 @@ +package ic2.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; + +@Cancelable +public class PaintEvent extends WorldEvent { + // target block + public final int x; + public final int y; + public final int z; + public final int side; + + // color to paint the block + public final int color; + + // set to true to confirm the operation + public boolean painted = false; + + public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { + super(world1); + + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.color = color1; + } +} diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/api/java/ic2/api/event/RetextureEvent.java new file mode 100644 index 00000000..221438e5 --- /dev/null +++ b/src/api/java/ic2/api/event/RetextureEvent.java @@ -0,0 +1,35 @@ +package ic2.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; + +@Cancelable +public class RetextureEvent extends WorldEvent { + // target block + public final int x; + public final int y; + public final int z; + public final int side; + + // referenced block (to grab the texture from) + public final Block referencedBlock; + public final int referencedMeta; + public final int referencedSide; + + // set to true to confirm the operation + public boolean applied = false; + + public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { + super(world1); + + this.x = x1; + this.y = y1; + this.z = z1; + this.side = side1; + this.referencedBlock = referencedBlock; + this.referencedMeta = referencedMeta1; + this.referencedSide = referencedSide1; + } +} diff --git a/src/api/java/ic2/api/event/package-info.java b/src/api/java/ic2/api/event/package-info.java new file mode 100644 index 00000000..58e5bdf4 --- /dev/null +++ b/src/api/java/ic2/api/event/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.event; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java new file mode 100644 index 00000000..14a6db90 --- /dev/null +++ b/src/api/java/ic2/api/info/IEnergyValueProvider.java @@ -0,0 +1,17 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IEnergyValueProvider { + /** + * Determine the energy value for a single item in the supplied stack. + * The value is used by most machines in the discharge slot. + *

+ * This only applies to basic single use items, others are to be queried + * through e.g. ElectricItem.manager.getCharge(). + * + * @param itemStack ItemStack containing the item to evaluate. + * @return energy in EU + */ + double getEnergyValue(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java new file mode 100644 index 00000000..21fee297 --- /dev/null +++ b/src/api/java/ic2/api/info/IFuelValueProvider.java @@ -0,0 +1,15 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IFuelValueProvider { + /** + * Determine the fuel value for a single item in the supplied stack. + * The information currently applies to Generators and the Iron Furnace. + * + * @param itemStack ItemStack containing the item to evaluate. + * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. + * @return fuel value + */ + int getFuelValue(ItemStack itemStack, boolean allowLava); +} diff --git a/src/api/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java new file mode 100644 index 00000000..da25567d --- /dev/null +++ b/src/api/java/ic2/api/info/Info.java @@ -0,0 +1,31 @@ +package ic2.api.info; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState; +import net.minecraft.util.DamageSource; + +public class Info { + public static IEnergyValueProvider itemEnergy; + public static IFuelValueProvider itemFuel; + public static Object ic2ModInstance; + + /** + * Damage Sources used by IC2. + * Getting assigned in preload. + */ + public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; + + public static boolean isIc2Available() { + if (ic2Available != null) return ic2Available; + + boolean loaded = Loader.isModLoaded("IC2"); + + if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { + ic2Available = loaded; + } + + return loaded; + } + + private static Boolean ic2Available = null; +} \ No newline at end of file diff --git a/src/api/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java new file mode 100644 index 00000000..7714e222 --- /dev/null +++ b/src/api/java/ic2/api/info/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.info; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/item/ElectricItem.java b/src/api/java/ic2/api/item/ElectricItem.java new file mode 100644 index 00000000..f865862c --- /dev/null +++ b/src/api/java/ic2/api/item/ElectricItem.java @@ -0,0 +1,59 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +/** + * Allows for charging, discharging and using electric items (IElectricItem). + */ +public final class ElectricItem { + /** + * IElectricItemManager to use for interacting with IElectricItem ItemStacks. + *

+ * This manager will act as a gateway and delegate the tasks to the final implementation + * (rawManager or a custom one) as necessary. + */ + public static IElectricItemManager manager; + + /** + * Standard IElectricItemManager implementation, only call it directly from another + * IElectricItemManager. Use manager instead. + */ + public static IElectricItemManager rawManager; + + /** + * Register an electric item manager for items not implementing IElectricItem. + *

+ * This method is only designed for special purposes, implementing IElectricItem or + * ISpecialElectricItem instead of using this is faster. + *

+ * Managers used with ISpecialElectricItem shouldn't be registered. + * + * @param manager Manager to register. + */ + public static void registerBackupManager(IBackupElectricItemManager manager) { + backupManagers.add(manager); + } + + /** + * Get the electric item manager suitable for the supplied item stack. + *

+ * This method is for internal use only. + * + * @param stack ItemStack to be handled. + * @return First suitable electric item manager. + */ + public static IBackupElectricItemManager getBackupManager(ItemStack stack) { + for (IBackupElectricItemManager manager : backupManagers) { + if (manager.handles(stack)) return manager; + } + + return null; + } + + + private static final List backupManagers = new ArrayList(); +} + diff --git a/src/main/java/ic2/api/item/IBackupElectricItemManager.java b/src/api/java/ic2/api/item/IBackupElectricItemManager.java similarity index 87% rename from src/main/java/ic2/api/item/IBackupElectricItemManager.java rename to src/api/java/ic2/api/item/IBackupElectricItemManager.java index 2ae254ac..e3fa60d7 100644 --- a/src/main/java/ic2/api/item/IBackupElectricItemManager.java +++ b/src/api/java/ic2/api/item/IBackupElectricItemManager.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * This interface specifies a manager applicable to items not implementing IElectricItem. - * + *

* The manager implementing this has to be registered with ElectricItem.registerBackupManager(). */ public interface IBackupElectricItemManager extends IElectricItemManager { - boolean handles(ItemStack stack); + boolean handles(ItemStack stack); } diff --git a/src/main/java/ic2/api/item/IBlockCuttingBlade.java b/src/api/java/ic2/api/item/IBlockCuttingBlade.java similarity index 73% rename from src/main/java/ic2/api/item/IBlockCuttingBlade.java rename to src/api/java/ic2/api/item/IBlockCuttingBlade.java index 24a8f00d..b53c461c 100644 --- a/src/main/java/ic2/api/item/IBlockCuttingBlade.java +++ b/src/api/java/ic2/api/item/IBlockCuttingBlade.java @@ -2,5 +2,5 @@ package ic2.api.item; public interface IBlockCuttingBlade { - int gethardness(); + int gethardness(); } diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/api/java/ic2/api/item/IBoxable.java new file mode 100644 index 00000000..7b268632 --- /dev/null +++ b/src/api/java/ic2/api/item/IBoxable.java @@ -0,0 +1,14 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + + +public interface IBoxable { + /** + * Determine whether an item can be stored in a toolbox or not. + * + * @param itemstack item to be stored + * @return Whether to store the item in the toolbox or not + */ + public abstract boolean canBeStoredInToolbox(ItemStack itemstack); +} diff --git a/src/main/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java similarity index 95% rename from src/main/java/ic2/api/item/IC2Items.java rename to src/api/java/ic2/api/item/IC2Items.java index 9b8c7df3..bd9305af 100644 --- a/src/main/java/ic2/api/item/IC2Items.java +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -4,40 +4,40 @@ import net.minecraft.item.ItemStack; /** * Provides access to IC2 blocks and items. - * + *

* Some items can be acquired through the ore dictionary which is the recommended way. * The items are initialized while IC2 is being loaded - try to use ModsLoaded() or load your mod after IC2. * Some blocks/items can be disabled by a config setting, so it's recommended to check if they're null first. - * + *

* Getting the associated Block/Item for an ItemStack x: - * Blocks: Block.blocksList[x.itemID] - * Items: x.getItem() + * Blocks: Block.blocksList[x.itemID] + * Items: x.getItem() */ public final class IC2Items { - /** - * Get an ItemStack for a specific item name, example: Items.getItem("resin") - * See the list below for item names. - * Make sure to copy() the ItemStack if you want to modify it. - * - * @param name item name - * @return The item or null if the item does not exist or an error occurred - */ - public static ItemStack getItem(String name) { - try { - if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); + /** + * Get an ItemStack for a specific item name, example: Items.getItem("resin") + * See the list below for item names. + * Make sure to copy() the ItemStack if you want to modify it. + * + * @param name item name + * @return The item or null if the item does not exist or an error occurred + */ + public static ItemStack getItem(String name) { + try { + if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items"); - Object ret = Ic2Items.getField(name).get(null); + Object ret = Ic2Items.getField(name).get(null); - if (ret instanceof ItemStack) { - return (ItemStack) ret; - } - return null; - } catch (Exception e) { - System.out.println("IC2 API: Call getItem failed for "+name); + if (ret instanceof ItemStack) { + return (ItemStack) ret; + } + return null; + } catch (Exception e) { + System.out.println("IC2 API: Call getItem failed for " + name); - return null; - } - } + return null; + } + } /* Possible values: @@ -576,23 +576,23 @@ public final class IC2Items { */ - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = IC2Items.class.getPackage(); + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = IC2Items.class.getPackage(); - if (pkg != null) { - String packageName = pkg.getName(); + if (pkg != null) { + String packageName = pkg.getName(); - return packageName.substring(0, packageName.length() - ".api.item".length()); - } + return packageName.substring(0, packageName.length() - ".api.item".length()); + } - return "ic2"; - } + return "ic2"; + } - private static Class Ic2Items; + private static Class Ic2Items; } diff --git a/src/main/java/ic2/api/item/IDebuggable.java b/src/api/java/ic2/api/item/IDebuggable.java similarity index 100% rename from src/main/java/ic2/api/item/IDebuggable.java rename to src/api/java/ic2/api/item/IDebuggable.java diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java new file mode 100644 index 00000000..ceaa2606 --- /dev/null +++ b/src/api/java/ic2/api/item/IElectricItem.java @@ -0,0 +1,55 @@ +package ic2.api.item; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Provides the ability to store energy on the implementing item. + *

+ * The item should have a maximum damage of 13. + */ +public interface IElectricItem { + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); + + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); + + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); + + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); +} + diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java new file mode 100644 index 00000000..ecae1459 --- /dev/null +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -0,0 +1,93 @@ +package ic2.api.item; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + *

+ * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * more atomic features in the gateway manager. + */ +public interface IElectricItemManager { + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); + + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); + + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); + + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); +} diff --git a/src/main/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java similarity index 87% rename from src/main/java/ic2/api/item/IItemHudInfo.java rename to src/api/java/ic2/api/item/IItemHudInfo.java index da973187..177a7ff7 100644 --- a/src/main/java/ic2/api/item/IItemHudInfo.java +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -1,11 +1,11 @@ package ic2.api.item; -import java.util.List; - import net.minecraft.item.ItemStack; +import java.util.List; + public interface IItemHudInfo { - /* + /* Add Info to Nano- and Quantum-Suit Helm Hud for itemStack @@ -20,5 +20,5 @@ public interface IItemHudInfo { */ - public List getHudInfo(ItemStack itemStack); + public List getHudInfo(ItemStack itemStack); } diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.java b/src/api/java/ic2/api/item/IKineticWindRotor.java new file mode 100644 index 00000000..90522808 --- /dev/null +++ b/src/api/java/ic2/api/item/IKineticWindRotor.java @@ -0,0 +1,15 @@ +package ic2.api.item; + +import net.minecraft.util.ResourceLocation; + +public interface IKineticWindRotor { + public int getDiameter(); + + public ResourceLocation getRotorRenderTexture(); + + public float getefficiency(); + + int getminWindStrength(); + + int getmaxWindStrength(); +} diff --git a/src/api/java/ic2/api/item/IMetalArmor.java b/src/api/java/ic2/api/item/IMetalArmor.java new file mode 100644 index 00000000..e4a85db0 --- /dev/null +++ b/src/api/java/ic2/api/item/IMetalArmor.java @@ -0,0 +1,20 @@ +package ic2.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Armor items implementing this can be considered metal armor. + *

+ * Currently used for determining which boots can be used to slide up a magnetic pole. + */ +public interface IMetalArmor { + /** + * Determine if the given armor piece is metal armor. + * + * @param itemstack Armor piece as worn by the player + * @param player The player + * @return Whether the armor piece is metal armor + */ + public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); +} diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java new file mode 100644 index 00000000..d3497a76 --- /dev/null +++ b/src/api/java/ic2/api/item/ISpecialElectricItem.java @@ -0,0 +1,13 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +public interface ISpecialElectricItem extends IElectricItem { + /** + * Supply a custom IElectricItemManager. + * + * @param itemStack ItemStack to get the manager for + * @return IElectricItemManager instance + */ + IElectricItemManager getManager(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/api/java/ic2/api/item/ITerraformingBP.java new file mode 100644 index 00000000..5c9bf7ca --- /dev/null +++ b/src/api/java/ic2/api/item/ITerraformingBP.java @@ -0,0 +1,34 @@ +package ic2.api.item; + +import net.minecraft.world.World; + +/** + * Allows an item to act as a terraformer blueprint. + */ +public interface ITerraformingBP { + /** + * Get the energy consumption per operation of the blueprint. + * + * @return Energy consumption in EU + */ + public abstract int getConsume(); + + /** + * Get the maximum range of the blueprint. + * Should be a divisor of 5. + * + * @return Maximum range in blocks + */ + public abstract int getRange(); + + /** + * Perform the terraforming operation. + * + * @param world world to terraform + * @param x X position to terraform + * @param z Z position to terraform + * @param yCoord Y position of the terraformer + * @return Whether the operation was successful and the terraformer should consume energy. + */ + public abstract boolean terraform(World world, int x, int z, int yCoord); +} diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/api/java/ic2/api/item/ItemWrapper.java new file mode 100644 index 00000000..31ae9c17 --- /dev/null +++ b/src/api/java/ic2/api/item/ItemWrapper.java @@ -0,0 +1,49 @@ +package ic2.api.item; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Wrapper for inserting interfaces into items you don't own. + * + * @author Richard + */ +public class ItemWrapper { + private static final Multimap boxableItems = ArrayListMultimap.create(); + private static final Multimap metalArmorItems = ArrayListMultimap.create(); + + public static void registerBoxable(Item item, IBoxable boxable) { + boxableItems.put(item, boxable); + } + + public static boolean canBeStoredInToolbox(ItemStack stack) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IBoxable boxable : boxableItems.get(item)) { + if (boxable.canBeStoredInToolbox(stack)) return true; + } + + if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; + + return false; + } + + public static void registerMetalArmor(Item item, IMetalArmor armor) { + metalArmorItems.put(item, armor); + } + + public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { + Item item = stack.getItem(); + // use customs first to allow for overriding behavior + for (IMetalArmor metalArmor : metalArmorItems.get(item)) { + if (metalArmor.isMetalArmor(stack, player)) return true; + } + + if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; + + return false; + } +} diff --git a/src/api/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java new file mode 100644 index 00000000..d814f54b --- /dev/null +++ b/src/api/java/ic2/api/item/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.item; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java similarity index 51% rename from src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java rename to src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java index ed3ea38f..53cca72a 100644 --- a/src/main/java/ic2/api/network/INetworkClientTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkClientTileEntityEventListener.java @@ -6,12 +6,12 @@ import net.minecraft.entity.player.EntityPlayer; * Allows a tile entity to receive network events received from clients. */ public interface INetworkClientTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param player client which sent the event - * @param event event ID - */ - void onNetworkEvent(EntityPlayer player, int event); + /** + * Called when a network event is received. + * + * @param player client which sent the event + * @param event event ID + */ + void onNetworkEvent(EntityPlayer player, int event); } diff --git a/src/main/java/ic2/api/network/INetworkDataProvider.java b/src/api/java/ic2/api/network/INetworkDataProvider.java similarity index 66% rename from src/main/java/ic2/api/network/INetworkDataProvider.java rename to src/api/java/ic2/api/network/INetworkDataProvider.java index c3f283e5..cc59205f 100644 --- a/src/main/java/ic2/api/network/INetworkDataProvider.java +++ b/src/api/java/ic2/api/network/INetworkDataProvider.java @@ -4,15 +4,15 @@ import java.util.List; /** * Tile entities which want to synchronized specific fields between client and server have to implement this. - * + *

* The fields don't update themselves, a field update must be sent every time a synchronized field changes. */ public interface INetworkDataProvider { - /** - * Get the list of synchronized fields. - * - * @return Names of the synchronized fields - */ - List getNetworkedFields(); + /** + * Get the list of synchronized fields. + * + * @return Names of the synchronized fields + */ + List getNetworkedFields(); } diff --git a/src/api/java/ic2/api/network/INetworkItemEventListener.java b/src/api/java/ic2/api/network/INetworkItemEventListener.java new file mode 100644 index 00000000..85ac2a99 --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkItemEventListener.java @@ -0,0 +1,19 @@ +package ic2.api.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Allows an item to receive network events received from the server. + */ +public interface INetworkItemEventListener { + /** + * Called when a network event is received. + * + * @param itemStack item stack + * @param player player containing the item + * @param event event ID + */ + void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); +} + diff --git a/src/main/java/ic2/api/network/INetworkTileEntityEventListener.java b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java similarity index 54% rename from src/main/java/ic2/api/network/INetworkTileEntityEventListener.java rename to src/api/java/ic2/api/network/INetworkTileEntityEventListener.java index fbb4753c..23b11c5b 100644 --- a/src/main/java/ic2/api/network/INetworkTileEntityEventListener.java +++ b/src/api/java/ic2/api/network/INetworkTileEntityEventListener.java @@ -4,11 +4,11 @@ package ic2.api.network; * Allows a tile entity to receive network events received from the server. */ public interface INetworkTileEntityEventListener { - /** - * Called when a network event is received. - * - * @param event Event ID - */ - void onNetworkEvent(int event); + /** + * Called when a network event is received. + * + * @param event Event ID + */ + void onNetworkEvent(int event); } diff --git a/src/api/java/ic2/api/network/INetworkUpdateListener.java b/src/api/java/ic2/api/network/INetworkUpdateListener.java new file mode 100644 index 00000000..05548dee --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkUpdateListener.java @@ -0,0 +1,14 @@ +package ic2.api.network; + +/** + * Allows a tile entity to receive field sync updates received from the server. + */ +public interface INetworkUpdateListener { + /** + * Called when a field is synchronized. + * + * @param field field synchronized + */ + void onNetworkUpdate(String field); +} + diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java new file mode 100644 index 00000000..150e0465 --- /dev/null +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -0,0 +1,199 @@ +package ic2.api.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +import java.lang.reflect.Method; + +/** + * Provides methods to initiate events and synchronize tile entity fields in SMP. + *

+ * The methods are transparent between singleplayer and multiplayer - if a method is called in + * singleplayer, the associated callback will be locally executed. The implementation is different + * between the client and server versions of IC2. + *

+ * You'll usually want to use the server->client methods defined here to synchronize information + * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or + * producing effects. Anything which is only visible inside the GUI should be synchronized through + * the Container class associated to the GUI in Container.updateProgressBar(). + */ +public final class NetworkHelper { + // server -> client + + + /** + * Schedule a TileEntity's field to be updated to the clients in range. + *

+ * The updater will query the field's value during the next update, updates happen usually + * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. + *

+ * IC2's network updates have to get triggered every time, it doesn't continuously poll/send + * the field value. Just call updateTileEntityField after every change to a field which needs + * network synchronization. + *

+ * The following field data types are currently supported: + * - int, int[], short, short[], byte, byte[], long, long[] + * - float, float[], double, double[] + * - boolean, boolean[] + * - String, String[] + * - ItemStack + * - NBTBase (includes NBTTagCompound) + * - Block, Item, Achievement, Potion, Enchantment + * - ChunkCoordinates, ChunkCoordIntPair + * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) + * - World (does not sync the actual world, instead looks up the world by its dimension ID) + *

+ * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- + * side TileEntity if it implements INetworkUpdateListener. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). + * + * @param te TileEntity to update + * @param field Name of the field to update + */ + public static void updateTileEntityField(TileEntity te, String field) { + try { + if (NetworkManager_updateTileEntityField == null) + NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); + if (instance == null) instance = getInstance(); + + NetworkManager_updateTileEntityField.invoke(instance, te, field); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified TileEntity to the clients in range. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). + * + * @param te TileEntity to notify, should implement INetworkTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { + try { + if (NetworkManager_initiateTileEntityEvent == null) + NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified Item to the clients in range. + *

+ * The item should implement INetworkItemEventListener to receive the event. + *

+ * If this method is being executed on the client (i.e. Singleplayer), it'll just call + * INetworkItemEventListener.onNetworkEvent (if implemented by the item). + * + * @param player EntityPlayer holding the item + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + * @param limitRange Limit the notification range to (currently) 20 blocks instead of the + * tracking distance if true + */ + public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { + try { + if (NetworkManager_initiateItemEvent == null) + NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + // client -> server + + /** + * Immediately send an event for the specified TileEntity to the server. + *

+ * This method doesn't do anything if executed on the server. + * + * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientTileEntityEvent(TileEntity te, int event) { + try { + if (NetworkManager_initiateClientTileEntityEvent == null) + NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Immediately send an event for the specified Item to the clients in range. + *

+ * The item should implement INetworkItemEventListener to receive the event. + *

+ * This method doesn't do anything if executed on the server. + * + * @param itemStack ItemStack containing the item + * @param event Arbitrary integer to represent the event, choosing the values is up to you + */ + public static void initiateClientItemEvent(ItemStack itemStack, int event) { + try { + if (NetworkManager_initiateClientItemEvent == null) + NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); + if (instance == null) instance = getInstance(); + + NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = NetworkHelper.class.getPackage(); + + if (pkg != null) { + String packageName = pkg.getName(); + + return packageName.substring(0, packageName.length() - ".api.network".length()); + } + + return "ic2"; + } + + /** + * Get the NetworkManager instance, used internally. + * + * @return NetworkManager instance + */ + private static Object getInstance() { + try { + return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + private static Object instance; + private static Method NetworkManager_updateTileEntityField; + private static Method NetworkManager_initiateTileEntityEvent; + private static Method NetworkManager_initiateItemEvent; + private static Method NetworkManager_initiateClientTileEntityEvent; + private static Method NetworkManager_initiateClientItemEvent; +} + diff --git a/src/api/java/ic2/api/network/package-info.java b/src/api/java/ic2/api/network/package-info.java new file mode 100644 index 00000000..d925e4a3 --- /dev/null +++ b/src/api/java/ic2/api/network/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.network; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java new file mode 100644 index 00000000..3440426c --- /dev/null +++ b/src/api/java/ic2/api/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/api/java/ic2/api/reactor/IReactor.java new file mode 100644 index 00000000..c7a7a609 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -0,0 +1,158 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +/** + * Interface implemented by the tile entity of nuclear reactors. + */ +public interface IReactor { + /** + * Get the reactor's position in the world. + * + * @return Position of the reactor + */ + public ChunkCoordinates getPosition(); + + /** + * Get the reactor's corresponding world. + * + * @return The reactor's world + */ + public World getWorld(); + + /** + * Get the reactor's heat. + * + * @return The reactor's heat + */ + public int getHeat(); + + /** + * Set the reactor's heat. + * + * @param heat reactor heat + */ + public void setHeat(int heat); + + /** + * Increase the reactor's heat. + *

+ * Use negative values to decrease. + * + * @param amount amount of heat to add + * @return The reactor's heat after adding the specified amount + */ + public int addHeat(int amount); + + /** + * Get the reactor's maximum heat before exploding. + * + * @return Maximum heat value + */ + public int getMaxHeat(); + + /** + * Set the reactor's stored maxHeat variable. + * Used by plating to increase the reactors MaxHeat capacity. + * Needs to be called during each cycle process. + */ + public void setMaxHeat(int newMaxHeat); + + /** + * add Heat to a EmitHeat Buffer + * for use in Reactor operation.. need to be use + * for all Componetents with self-cooling + * no more magic heat disappear + */ + + + public void addEmitHeat(int heat); + + /** + * Get's the reactor's HEM (Heat Effect Modifier) + * Basic value is 1.0F. + * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors + * (F.e. water evaporation, melting, damaging entitys, etc) + * + * @return HEM + */ + public float getHeatEffectModifier(); + + /** + * Set's the reactor's HEM + * Needs to be called during each cycle process. + */ + public void setHeatEffectModifier(float newHEM); + + /** + * Get the reactor's energy output. + * + * @return Energy output, not multiplied by the base EU/t value + */ + public float getReactorEnergyOutput(); + + /** + * Get the reactor's energy output. + * + * @return Energy output, multiplied with base EU/t value and MainConfig.get().getFloat("balance/energy/generator/nuclear") + */ + public double getReactorEUEnergyOutput(); + + /** + * Add's the given amount of energy to the Reactor's output. + * + * @return Energy output after adding the value, not multiplied by the base EU/t value + */ + public float addOutput(float energy); + + /** + * Get the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds returns null + * @param y Y position of the item, out of bounds returns null + * @return The item or null if there is no item + */ + public ItemStack getItemAt(int x, int y); + + /** + * Set the item at the specified grid coordinates. + * + * @param x X position of the item, out of bounds is a no-op + * @param y Y position of the item, out of bounds is a no-op + * @param item The item to set. + */ + public void setItemAt(int x, int y, ItemStack item); + + /** + * Explode the reactor. + */ + public void explode(); + + /** + * Get the reactor's tick rate (game ticks per reactor tick). + * + * @return Tick rate + */ + public int getTickRate(); + + /** + * Get whether the reactor is active and supposed to produce energy + * + * @return Whether the reactor is active + */ + public boolean produceEnergy(); + + /** + * Set Redstone Signal without direct contact + */ + + public void setRedstoneSignal(boolean redstone); + + /** + * @return true if the reactor is FluidCooled + */ + + public boolean isFluidCooled(); +} diff --git a/src/api/java/ic2/api/reactor/IReactorChamber.java b/src/api/java/ic2/api/reactor/IReactorChamber.java new file mode 100644 index 00000000..7199c43b --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactorChamber.java @@ -0,0 +1,19 @@ +package ic2.api.reactor; + +/** + * Interface implemented by the reactor chamber tile entity. + */ +public interface IReactorChamber { + /** + * Get the chamber's reactor. + * + * @return The reactor + */ + public IReactor getReactor(); + + /** + * Set Redstone Signal without direct contact + */ + + public void setRedstoneSignal(boolean redstone); +} diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/api/java/ic2/api/reactor/IReactorComponent.java new file mode 100644 index 00000000..80bfa659 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -0,0 +1,101 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; + +/** + * Design custom Reactor components by implementing this Interface + * Items implementing the interface will not be ejected from Reactors in their clean-up + * and can/will be interacted with by other elements, f.e. Uranium Cells. + *

+ * All IC2 ReactorComponents implement and use this Interface + */ +public interface IReactorComponent { + /** + * Called by reactor upon iterating through it's inventory (every cycle). + * Perform all necessary calculation/interaction here + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heatrun every Stack will cycle 2 time (true, false) first run for heat, sec for Eu calculation + */ + public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun); + + /** + * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. + * Uranium-Uranium interaction (f.e.) uses this method. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of called ItemStack + * @param pulsingStack Reference to the specific instance of pulsing ItemStack + * @param youX X-coordinate of your stack in the grid + * @param youY Y-coordinate of your stack in the grid + * @param pulseX X-coordinate of pulsing stack in the grid + * @param pulseY Y-coordinate of pulsing stack in the grid + * @param heatrun true for only create heat not EU, false for only EU not heat + * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) + */ + public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); + + /** + * Called by components to determine whether your component can be heated. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return true if your component can take heat + */ + public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the maximum capacity of your heat-containing component here. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Maximum heat + */ + public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by heat-switches to determine how much heat to distribute into which direction. + * Please return the current amount of heat stored in this component + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @return Current Heat + */ + public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); + + /** + * Called by components to distribute heat to your component. + * Perform heating-calculations and increase your heat (dmg) level accordingly. + * This method will as well be called to REDUCE heat, by providing a negative amount. + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @param x X-coordinate of the stack in the grid + * @param y Y-coordinate of the stack in the grid + * @param heat Amount of heat to be added (may be negative to subtract heat) + * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) + */ + public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); + + /** + * Called upon reactor explosion + * Alter the explosion size. + * Returning a float 0 < f < 1 will be counted as multiplier. + * Anything else will be counted as a flat addition (in case of <0 = reduction). + * + * @param reactor Reference to the Reactor + * @param yourStack Reference to the specific instance of iterated ItemStack + * @return your explosion modifier + */ + public float influenceExplosion(IReactor reactor, ItemStack yourStack); +} diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/api/java/ic2/api/reactor/package-info.java new file mode 100644 index 00000000..43a08227 --- /dev/null +++ b/src/api/java/ic2/api/reactor/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.reactor; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java new file mode 100644 index 00000000..45c84447 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICannerBottleRecipeManager.java @@ -0,0 +1,51 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.Map; + +public interface ICannerBottleRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param output Filled container + */ + public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output); + + /** + * Gets the recipe output for the given input. + * + * @param container Container to be filled + * @param fill Item to fill into the container + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); + + + public static class Input { + public Input(IRecipeInput container1, IRecipeInput fill1) { + this.container = container1; + this.fill = fill1; + } + + public boolean matches(ItemStack container1, ItemStack fill1) { + return this.container.matches(container1) && this.fill.matches(fill1); + } + + public final IRecipeInput container; + public final IRecipeInput fill; + } +} diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java new file mode 100644 index 00000000..cbd4f9c7 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java @@ -0,0 +1,53 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.Map; + +public interface ICannerEnrichRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param output Output fluid + */ + public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output); + + /** + * Gets the recipe output for the given input. + * + * @param input Fluid input + * @param additive Item to enrich the fluid with + * @param adjustInput modify the input according to the recipe's requirements + * @param acceptTest allow input or additive to be null to see if either of them is part of a recipe + * @return Recipe output, or null if none, output fluid in nbt + */ + public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); + + + public static class Input { + public Input(FluidStack fluid1, IRecipeInput additive1) { + this.fluid = fluid1; + this.additive = additive1; + } + + public boolean matches(FluidStack fluid1, ItemStack additive1) { + return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && + this.additive.matches(additive1); + } + + public final FluidStack fluid; + public final IRecipeInput additive; + } +} diff --git a/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java new file mode 100644 index 00000000..b70c7e1f --- /dev/null +++ b/src/api/java/ic2/api/recipe/ICraftingRecipeManager.java @@ -0,0 +1,26 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +/** + * Recipe manager interface for crafting recipes. + * + * @author Richard + */ +public interface ICraftingRecipeManager { + /** + * Adds a shaped crafting recipe. + * + * @param output Recipe output + * @param input Recipe input format + */ + public void addRecipe(ItemStack output, Object... input); + + /** + * Adds a shapeless crafting recipe. + * + * @param output Recipe output + * @param input Recipe input + */ + public void addShapelessRecipe(ItemStack output, Object... input); +} diff --git a/src/api/java/ic2/api/recipe/IFluidHeatManager.java b/src/api/java/ic2/api/recipe/IFluidHeatManager.java new file mode 100644 index 00000000..fa439805 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IFluidHeatManager.java @@ -0,0 +1,32 @@ +package ic2.api.recipe; + +import net.minecraftforge.fluids.Fluid; + +import java.util.Map; + + +public interface IFluidHeatManager extends ILiquidAcceptManager { + /** + * Add a new fluid to the Fluid Heat Generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param heat amount of heat generated per tick + */ + void addFluid(String fluidName, int amount, int heat); + + BurnProperty getBurnProperty(Fluid fluid); + + Map getBurnProperties(); + + + public static class BurnProperty { + public BurnProperty(int amount1, int heat1) { + this.amount = amount1; + this.heat = heat1; + } + + public final int amount; + public final int heat; + } +} diff --git a/src/main/java/ic2/api/recipe/ILiquidAcceptManager.java b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java similarity index 63% rename from src/main/java/ic2/api/recipe/ILiquidAcceptManager.java rename to src/api/java/ic2/api/recipe/ILiquidAcceptManager.java index 4f377b90..c2212c21 100644 --- a/src/main/java/ic2/api/recipe/ILiquidAcceptManager.java +++ b/src/api/java/ic2/api/recipe/ILiquidAcceptManager.java @@ -1,10 +1,11 @@ package ic2.api.recipe; -import java.util.Set; - import net.minecraftforge.fluids.Fluid; +import java.util.Set; + public interface ILiquidAcceptManager { - boolean acceptsFluid(Fluid fluid); - Set getAcceptedFluids(); + boolean acceptsFluid(Fluid fluid); + + Set getAcceptedFluids(); } diff --git a/src/api/java/ic2/api/recipe/IListRecipeManager.java b/src/api/java/ic2/api/recipe/IListRecipeManager.java new file mode 100644 index 00000000..f00dcad3 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IListRecipeManager.java @@ -0,0 +1,41 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Recipe manager interface for basic lists. + * + * @author Richard + */ +public interface IListRecipeManager extends Iterable { + /** + * Adds a stack to the list. + * + * @param stack Stack to add + */ + public void add(IRecipeInput input); + + /** + * Checks whether the specified stack is in the list. + * + * @param stack Stack to check + * @return Whether the stack is in the list + */ + public boolean contains(ItemStack stack); + + /** + * @return if the List is Empty + */ + public boolean isEmpty(); + + /** + * Gets the list of stacks. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of stacks + */ + public List getInputs(); +} diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java new file mode 100644 index 00000000..b0800fe0 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java @@ -0,0 +1,43 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.Map; + +/** + * Recipe manager interface for basic machines. + * + * @author RichardG, Player + */ +public interface IMachineRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param input Recipe input + * @param metadata meta data for additional recipe properties, may be null + * @param outputs Recipe outputs, zero or more depending on the machine + *

+ * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} + * For the ore washing plant @param metadata meta data {"amount": 1-8000} + */ + public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); + + /** + * Gets the recipe output for the given input. + * + * @param input Recipe input + * @param adjustInput modify the input according to the recipe's requirements + * @return Recipe output, or null if none + */ + public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); + + /** + * Gets a list of recipes. + *

+ * You're a mad evil scientist if you ever modify this. + * + * @return List of recipes + */ + public Map getRecipes(); +} diff --git a/src/main/java/ic2/api/recipe/IPatternStorage.java b/src/api/java/ic2/api/recipe/IPatternStorage.java similarity index 60% rename from src/main/java/ic2/api/recipe/IPatternStorage.java rename to src/api/java/ic2/api/recipe/IPatternStorage.java index c9dbd8d7..1632052a 100644 --- a/src/main/java/ic2/api/recipe/IPatternStorage.java +++ b/src/api/java/ic2/api/recipe/IPatternStorage.java @@ -1,11 +1,11 @@ package ic2.api.recipe; -import java.util.List; - import net.minecraft.item.ItemStack; -public interface IPatternStorage { - boolean addPattern(ItemStack itemstack); +import java.util.List; - List getPatterns(); +public interface IPatternStorage { + boolean addPattern(ItemStack itemstack); + + List getPatterns(); } diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java new file mode 100644 index 00000000..61c193c2 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IRecipeInput.java @@ -0,0 +1,31 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +public interface IRecipeInput { + /** + * Check if subject matches this recipe input, ignoring the amount. + * + * @param subject ItemStack to check + * @return true if it matches the requirement + */ + boolean matches(ItemStack subject); + + /** + * Determine the minimum input stack size. + * + * @return input amount required + */ + int getAmount(); + + /** + * List all possible inputs (best effort). + *

+ * The stack size is undefined, use getAmount to get the correct one. + * + * @return list of inputs, may be incomplete + */ + List getInputs(); +} diff --git a/src/api/java/ic2/api/recipe/IScrapboxManager.java b/src/api/java/ic2/api/recipe/IScrapboxManager.java new file mode 100644 index 00000000..d37d0a4d --- /dev/null +++ b/src/api/java/ic2/api/recipe/IScrapboxManager.java @@ -0,0 +1,13 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +import java.util.Map; + +public interface IScrapboxManager { + void addDrop(ItemStack drop, float rawChance); + + ItemStack getDrop(ItemStack input, boolean adjustInput); + + Map getDrops(); +} diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java new file mode 100644 index 00000000..ac132299 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java @@ -0,0 +1,32 @@ +package ic2.api.recipe; + +import net.minecraftforge.fluids.Fluid; + +import java.util.Map; + + +public interface ISemiFluidFuelManager extends ILiquidAcceptManager { + /** + * Add a new fluid to the semi fluid generator. + * + * @param fluidName the fluid to burn + * @param amount amount of fluid to consume per tick + * @param power amount of energy generated per tick + */ + void addFluid(String fluidName, int amount, double power); + + BurnProperty getBurnProperty(Fluid fluid); + + Map getBurnProperties(); + + + public static class BurnProperty { + public BurnProperty(int amount1, double power1) { + this.amount = amount1; + this.power = power1; + } + + public final int amount; + public final double power; + } +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java new file mode 100644 index 00000000..10b45f0a --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -0,0 +1,53 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.List; + +public class RecipeInputFluidContainer implements IRecipeInput { + public RecipeInputFluidContainer(Fluid fluid) { + this(fluid, FluidContainerRegistry.BUCKET_VOLUME); + } + + public RecipeInputFluidContainer(Fluid fluid, int amount) { + this.fluid = fluid; + this.amount = amount; + } + + @Override + public boolean matches(ItemStack subject) { + FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); + if (fs == null) return false; + + return fs.getFluid() == fluid; + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + List ret = new ArrayList(); + + for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); + } + + return ret; + } + + @Override + public String toString() { + return "RInputFluidContainer<" + amount + "x" + fluid.getName() + ">"; + } + + public final Fluid fluid; + public final int amount; +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java new file mode 100644 index 00000000..1e05691a --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -0,0 +1,45 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.Arrays; +import java.util.List; + +public class RecipeInputItemStack implements IRecipeInput { + public RecipeInputItemStack(ItemStack aInput) { + this(aInput, aInput.stackSize); + } + + public RecipeInputItemStack(ItemStack aInput, int aAmount) { + if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); + + input = aInput.copy(); // Never forget to copy. + amount = aAmount; + } + + @Override + public boolean matches(ItemStack subject) { + return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + return Arrays.asList(input); + } + + @Override + public String toString() { + ItemStack stack = input.copy(); + input.stackSize = amount; + return "RInputItemStack<" + stack + ">"; + } + + public final ItemStack input; + public final int amount; +} diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java new file mode 100644 index 00000000..cda49984 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -0,0 +1,70 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; +import java.util.List; + +public class RecipeInputOreDict implements IRecipeInput { + public RecipeInputOreDict(String input1) { + this(input1, 1); + } + + public RecipeInputOreDict(String input1, int amount1) { + this(input1, amount1, null); + } + + public RecipeInputOreDict(String input1, int amount1, Integer meta) { + this.input = input1; + this.amount = amount1; + this.meta = meta; + } + + @Override + public boolean matches(ItemStack subject) { + List inputs = OreDictionary.getOres(input); + + for (ItemStack input1 : inputs) { + if (input1.getItem() == null) continue; // ignore invalid + int metaRequired = meta == null ? input1.getItemDamage() : meta; + + if (subject.getItem() == input1.getItem() && + (subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { + return true; + } + } + + return false; + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + List ores = OreDictionary.getOres(input); + List ret = new ArrayList(ores.size()); + + for (ItemStack stack : ores) { + if (stack.getItem() != null) ret.add(stack); // ignore invalid + } + + return ret; + } + + @Override + public String toString() { + if (meta == null) { + return "RInputOreDict<" + amount + "x" + input + ">"; + } else { + return "RInputOreDict<" + amount + "x" + input + "@" + meta + ">"; + } + } + + public final String input; + public final int amount; + public final Integer meta; +} diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java new file mode 100644 index 00000000..51ea33bc --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -0,0 +1,28 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.Arrays; +import java.util.List; + +public final class RecipeOutput { + public RecipeOutput(NBTTagCompound metadata1, List items1) { + assert !items1.contains(null); + + this.metadata = metadata1; + this.items = items1; + } + + public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { + this(metadata1, Arrays.asList(items1)); + } + + @Override + public String toString() { + return "ROutput<" + items + "," + metadata + ">"; + } + + public final List items; + public final NBTTagCompound metadata; +} diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java new file mode 100644 index 00000000..fae2cd68 --- /dev/null +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -0,0 +1,60 @@ +package ic2.api.recipe; + + +/** + * General recipe registry. + * + * @author Richard + */ +public class Recipes { + public static IMachineRecipeManager macerator; + public static IMachineRecipeManager extractor; + public static IMachineRecipeManager compressor; + public static IMachineRecipeManager centrifuge; + public static IMachineRecipeManager blockcutter; + public static IMachineRecipeManager blastfurance; + public static IMachineRecipeManager recycler; + public static IMachineRecipeManager metalformerExtruding; + public static IMachineRecipeManager metalformerCutting; + public static IMachineRecipeManager metalformerRolling; + public static IMachineRecipeManager oreWashing; + public static ICannerBottleRecipeManager cannerBottle; + public static ICannerEnrichRecipeManager cannerEnrich; + + /** + * Reference amplifier values: + *

+ * 5000: Scrap + * 45000: Scrapbox + *

+ * As Parameter for the Amplification Value you have to use the NBTTagCompound + *

+ * NBTTagCompound nbt = new NBTTagCompound(); + * nbt.setInteger("amplification", aValue); + * matterAmplifier.addRecipe(yourStack, nbt); + */ + public static IMachineRecipeManager matterAmplifier; + /** + * Reference scrap box chance values: + *

+ * 0.1: Diamond + * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore + * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone + * 1.5: Apple, Bread + * 2.0: Netherrack, Rotten Flesh + * 3.0: Grass, Gravel + * 4.0: Stick + * 5.0: Dirt, Wooden Hoe + */ + public static IScrapboxManager scrapboxDrops; + public static IListRecipeManager recyclerBlacklist; + /** + * Do not add anything to this Whitelist. This is for Configuration only. + * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List + */ + public static IListRecipeManager recyclerWhitelist; + public static ICraftingRecipeManager advRecipes; + + public static ISemiFluidFuelManager semiFluidGenerator; + public static IFluidHeatManager FluidHeatGenerator; +} diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java new file mode 100644 index 00000000..7526ce32 --- /dev/null +++ b/src/api/java/ic2/api/recipe/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.recipe; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/api/java/ic2/api/tile/ExplosionWhitelist.java new file mode 100644 index 00000000..d1f8a454 --- /dev/null +++ b/src/api/java/ic2/api/tile/ExplosionWhitelist.java @@ -0,0 +1,47 @@ +package ic2.api.tile; + +import net.minecraft.block.Block; + +import java.util.HashSet; +import java.util.Set; + +/** + * Blocks on this whitelist will not resist an explosion but won't be destroyed. + *

+ * The explosion code by default ignores blocks which absorb more than 1000 explosion power to + * prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and + * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get + * destroyed. + */ +public final class ExplosionWhitelist { + /** + * Add a block to the whitelist. + * + * @param block block to add + */ + public static void addWhitelistedBlock(Block block) { + whitelist.add(block); + } + + /** + * Remove a block from the whitelist. + * + * @param block block to remove + */ + public static void removeWhitelistedBlock(Block block) { + whitelist.remove(block); + } + + /** + * Check if a block is on the whitelist. + * + * @param block block to check if whitelisted + * @return Whether the block is whitelisted + */ + public static boolean isBlockWhitelisted(Block block) { + return whitelist.contains(block); + } + + private static Set whitelist = new HashSet(); +} + diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.java b/src/api/java/ic2/api/tile/IEnergyStorage.java new file mode 100644 index 00000000..bf80b004 --- /dev/null +++ b/src/api/java/ic2/api/tile/IEnergyStorage.java @@ -0,0 +1,61 @@ +package ic2.api.tile; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Interface implemented by the tile entity of energy storage blocks. + */ +public interface IEnergyStorage { + /** + * Get the amount of energy currently stored in the block. + * + * @return Energy stored in the block + */ + public int getStored(); + + /** + * Set the amount of energy currently stored in the block. + * + * @param energy stored energy + */ + public void setStored(int energy); + + /** + * Add the specified amount of energy. + *

+ * Use negative values to decrease. + * + * @param amount of energy to add + * @return Energy stored in the block after adding the specified amount + */ + public int addEnergy(int amount); + + /** + * Get the maximum amount of energy the block can store. + * + * @return Maximum energy stored + */ + public int getCapacity(); + + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public int getOutput(); + + /** + * Get the block's energy output. + * + * @return Energy output in EU/t + */ + public double getOutputEnergyUnitsPerTick(); + + /** + * Get whether this block can have its energy used by an adjacent teleporter. + * + * @param side side the teleporter is draining energy from + * @return Whether the block is teleporter compatible + */ + public boolean isTeleporterCompatible(ForgeDirection side); +} diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java new file mode 100644 index 00000000..0cbaba64 --- /dev/null +++ b/src/api/java/ic2/api/tile/IWrenchable.java @@ -0,0 +1,61 @@ +package ic2.api.tile; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Allows a tile entity to make use of the wrench's removal and rotation functions. + */ +public interface IWrenchable { + /** + * Determine if the wrench can be used to set the block's facing. + * Called before wrenchCanRemove(). + * + * @param entityPlayer player using the wrench, may be null + * @param side block's side the wrench was clicked on + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); + + /** + * Get the block's facing. + * + * @return Block facing + */ + short getFacing(); + + /** + * Set the block's facing + * + * @param facing facing to set the block to + */ + void setFacing(short facing); + + /** + * Determine if the wrench can be used to remove the block. + * Called if wrenchSetFacing fails. + * + * @param entityPlayer player using the wrench, may be null + * @return Whether the wrenching was done and the wrench should be damaged + */ + boolean wrenchCanRemove(EntityPlayer entityPlayer); + + /** + * Determine the probability to drop the block as it is. + * The first entry in getDrops will be replaced by blockid:meta if the drop is successful. + * + * @return Probability from 0 to 1 + */ + float getWrenchDropRate(); + + /** + * Determine the item the block will drop when the wrenching is successful. + *

+ * The ItemStack will be copied before creating the EntityItem. + * + * @param entityPlayer player using the wrench, may be null + * @return ItemStack to drop, may be null + */ + ItemStack getWrenchDrop(EntityPlayer entityPlayer); +} + diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java new file mode 100644 index 00000000..08fa88b2 --- /dev/null +++ b/src/api/java/ic2/api/tile/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.tile; + +import cpw.mods.fml.common.API; + diff --git a/src/api/java/ic2/api/util/IKeyboard.java b/src/api/java/ic2/api/util/IKeyboard.java new file mode 100644 index 00000000..a5a77d66 --- /dev/null +++ b/src/api/java/ic2/api/util/IKeyboard.java @@ -0,0 +1,21 @@ +package ic2.api.util; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IKeyboard { + boolean isAltKeyDown(EntityPlayer player); + + boolean isBoostKeyDown(EntityPlayer player); + + boolean isForwardKeyDown(EntityPlayer player); + + boolean isJumpKeyDown(EntityPlayer player); + + boolean isModeSwitchKeyDown(EntityPlayer player); + + boolean isSideinventoryKeyDown(EntityPlayer player); + + boolean isHudModeKeyDown(EntityPlayer player); + + boolean isSneakKeyDown(EntityPlayer player); +} diff --git a/src/main/java/ic2/api/util/Keys.java b/src/api/java/ic2/api/util/Keys.java similarity index 54% rename from src/main/java/ic2/api/util/Keys.java rename to src/api/java/ic2/api/util/Keys.java index 84d17567..1db739bf 100644 --- a/src/main/java/ic2/api/util/Keys.java +++ b/src/api/java/ic2/api/util/Keys.java @@ -2,5 +2,5 @@ package ic2.api.util; public class Keys { - public static IKeyboard instance; + public static IKeyboard instance; } \ No newline at end of file diff --git a/src/api/java/ic2/api/util/package-info.java b/src/api/java/ic2/api/util/package-info.java new file mode 100644 index 00000000..b0141815 --- /dev/null +++ b/src/api/java/ic2/api/util/package-info.java @@ -0,0 +1,4 @@ +@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.util; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ic2/api/Direction.java b/src/main/java/ic2/api/Direction.java deleted file mode 100644 index 894e8979..00000000 --- a/src/main/java/ic2/api/Direction.java +++ /dev/null @@ -1,128 +0,0 @@ -package ic2.api; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Represents the 6 possible directions along the axis of a block. - */ -public enum Direction { - /** - * -X - */ - XN(0), - /** - * +X - */ - XP(1), - - /** - * -Y - */ - YN(2), //MC-Code starts with 0 here - /** - * +Y - */ - YP(3), // 1... - - /** - * -Z - */ - ZN(4), - /** - * +Z - */ - ZP(5); - - public static Direction fromSideValue(int side) { - return directions[(side + 2) % 6]; - } - - public static Direction fromForgeDirection(ForgeDirection dir) { - if (dir == ForgeDirection.UNKNOWN) return null; - - return fromSideValue(dir.ordinal()); - } - - private Direction(int dir1) { - this.dir = dir1; - } - - /** - * Get the tile entity next to a tile entity following this direction. - * - * @param tileEntity tile entity to check - * @return Adjacent tile entity or null if none exists - */ - public TileEntity applyToTileEntity(TileEntity te) { - return applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); - } - - /** - * Get the tile entity next to a position following this direction. - * - * @param world World to check - * @param x X coordinate to check from - * @param y Y coordinate to check from - * @param z Z coordinate to check from - * @return Adjacent tile entity or null if none exists - */ - public TileEntity applyTo(World world, int x, int y, int z) { - int coords[] = { x, y, z }; - - coords[dir/2] += getSign(); - - if (world != null && world.blockExists(coords[0], coords[1], coords[2])) { - try { - return world.getTileEntity(coords[0], coords[1], coords[2]); - } catch (Exception e) { - throw new RuntimeException("error getting TileEntity at dim "+world.provider.dimensionId+" "+coords[0]+"/"+coords[1]+"/"+coords[2]); - } - } - - return null; - } - - /** - * Get the inverse of this direction (XN -> XP, XP -> XN, etc.) - * - * @return Inverse direction - */ - public Direction getInverse() { - int inverseDir = dir - getSign(); - - for (Direction direction : directions) { - if (direction.dir == inverseDir) return direction; - } - - return this; - } - - /** - * Convert this direction to a Minecraft side value. - * - * @return Minecraft side value - */ - public int toSideValue() { - return (dir + 4) % 6; - } - - /** - * Determine direction sign (N for negative or P for positive). - * - * @return -1 if the direction is negative, +1 if the direction is positive - */ - private int getSign() { - return (dir % 2) * 2 - 1; - } - - public ForgeDirection toForgeDirection() { - return ForgeDirection.getOrientation(toSideValue()); - } - - private int dir; - public static final Direction[] directions = Direction.values(); -} - diff --git a/src/main/java/ic2/api/crops/BaseSeed.java b/src/main/java/ic2/api/crops/BaseSeed.java deleted file mode 100644 index de6296b3..00000000 --- a/src/main/java/ic2/api/crops/BaseSeed.java +++ /dev/null @@ -1,56 +0,0 @@ -package ic2.api.crops; - -/** - * Base agriculture seed. Used to determine the state of a plant once it is planted from an item. - */ -public class BaseSeed { - /** - * Plant ID. - */ - public int id; - - /** - * Plant size. - */ - public int size; - - /** - * Plant growth stat. - */ - public int statGrowth; - - /** - * Plant gain stat. - */ - public int statGain; - - /** - * Plant resistance stat. - */ - public int statResistance; - - /** - * For internal usage only. - */ - public int stackSize; - - /** - * Create a BaseSeed object. - * - * @param id1 plant ID - * @param size1 plant size - * @param statGrowth1 plant growth stat - * @param statGain1 plant gain stat - * @param statResistance1 plant resistance stat - * @param stackSize1 for internal usage only - */ - public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) { - super(); - this.id = id1; - this.size = size1; - this.statGrowth = statGrowth1; - this.statGain = statGain1; - this.statResistance = statResistance1; - this.stackSize = stackSize1; - } -} diff --git a/src/main/java/ic2/api/crops/CropCard.java b/src/main/java/ic2/api/crops/CropCard.java deleted file mode 100644 index e8237bc4..00000000 --- a/src/main/java/ic2/api/crops/CropCard.java +++ /dev/null @@ -1,367 +0,0 @@ -package ic2.api.crops; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Base agriculture crop. - * - * Any crop extending this can be registered using registerCrop to be added into the game. - */ -public abstract class CropCard { - /** - * Plant name. Will be displayed to the player. - * - * @return Plant name - */ - public abstract String name(); - - /** - * Your name here, will be shown in "Discovered by:" when analyzing seeds. - * - * @return Your name - */ - public String discoveredBy() {return "IC2 Team";} - - /** - * Description of your plant. Keep it short, a few characters per line for up to two lines. - * Default is showing attributes of your plant, 2 per line. - * - * @param i line to get, starting from 0 - * @return The line - */ - public String desc(int i) { - String[] att = attributes(); - if (att == null || att.length == 0) return ""; - if (i == 0) { - String s = att[0]; - if (att.length >= 2) { - s+=", "+att[1]; - if (att.length >= 3) s+=","; - } - return s; - } - if (att.length < 3) return ""; - String s = att[2]; - if (att.length >= 4) s+=", "+att[3]; - return s; - } - - /** - * Tier of the plant. Ranges from 1 to 16, 0 is Weed. - * Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers. - * - * @return Tier - */ - public abstract int tier(); - - /** - * Describe the plant through a set of stats, influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - * - * Stats: - * - 0: Chemistry (Industrial uses based on chemical plant components) - * - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) - * - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) - * - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) - * - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) - * - * @param n index of the requested stat - * @return The requested value of the stats - */ - public abstract int stat(int n); - - /** - * Additional attributes of the plant, also influencing breeding. - * Plants sharing stats and attributes will tend to cross-breed more often. - * - * @return Attributes as an array of strings - */ - public abstract String[] attributes(); - - /** - * Determine the max crop size. - * - * Currently only used for texture allocation. - */ - public abstract int maxSize(); - - /** - * Instantiate your Icons here. - * - * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public void registerSprites(IIconRegister iconRegister) { - textures = new IIcon[maxSize()]; - - for (int i = 1; i <= textures.length; i++) { - textures[i-1] = iconRegister.registerIcon("ic2:crop/blockCrop."+name()+"."+i); - } - } - - /** - * Sprite the crop is meant to be rendered with. - * - * @param crop reference to ICropTile - * @return 0-255, representing the sprite index on the crop's spritesheet. - */ - @SideOnly(Side.CLIENT) - public IIcon getSprite(ICropTile crop) { - if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null; - - return textures[crop.getSize() - 1]; - } - - /** - * Get the crop's spritesheet. - * Per default crops_0.png of ic2-sprites - * @return Texture file path - */ - public String getTextureFile() { - return "/ic2/sprites/crops_0.png"; - } - - /** - * Amount of growth points needed to increase the plant's size. - * Default is 200 * tier. - */ - public int growthDuration(ICropTile crop) { - return tier()*200; - } - - /** - * Check whether the plant can grow further. - * - * Consider: - * - Humidity, nutrients and air quality - * - Current size - * - Light level - * - Special biomes or conditions, accessible through crop.worldObj - * - * This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real. - * - * @param crop reference to ICropTile - * @return Whether the crop can grow - */ - public abstract boolean canGrow(ICropTile crop); - - /** - * Calculate the influence for the plant to grow based on humidity, nutrients and air. - * Normal behavior is rating the three stats "normal", with each of them ranging from 0-30. - * Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4) - * - * Default is humidity + nutrients + air (no factors). - * - * @param crop reference to ICropTile - * @param humidity ground humidity, influenced by hydration - * @param nutrients nutrient quality in ground, based on fertilizers - * @param air air quality, influences by open gardens and less crops surrounding this one - * @return 0-30 - */ - public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { - return (int) (humidity+nutrients+air); - } - - /** - * Used to determine whether the plant can crossbreed with another crop. - * Default is allow crossbreeding if the size is greater or equal than 3. - * - * @param crop crop to crossbreed with - */ - public boolean canCross(ICropTile crop) { - return crop.getSize() >= 3; - } - - - /** - * Called when the plant is rightclicked by a player. - * Default action is harvesting. - * - * Only called Serverside. - * - * @param crop reference to ICropTile - * @param player player rightclicking the crop - * @return Whether the plant has changed - */ - public boolean rightclick(ICropTile crop, EntityPlayer player) { - return crop.harvest(true); - } - - /** - * Use in Crop Havester with insert Cropnalyzer to get best Output. - * - * @param crop reference to ICropTile - * @return need crop size for best output. - */ - - public abstract int getOptimalHavestSize(ICropTile crop); - - /** - * Check whether the crop can be harvested. - * - * @param crop reference to ICropTile - * @return Whether the crop can be harvested in its current state. - */ - public abstract boolean canBeHarvested(ICropTile crop); - - /** - * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. - * Default is 0.95^tier. - * - * @return Chance to drop the gains - */ - public float dropGainChance() { - float base = 1F; - for (int i = 0; i < tier(); i++) {base*=0.95;} - return base; - } - - /** - * Item obtained from harvesting the plant. - * - * @param crop reference to ICropTile - * @return Item obtained - */ - public abstract ItemStack getGain(ICropTile crop); - - /** - * Get the size of the plant after harvesting. - * Default is 1. - * - * @param crop reference to ICropTile - * @return Plant size after harvesting - */ - public byte getSizeAfterHarvest(ICropTile crop) {return 1;} - - - /** - * Called when the plant is leftclicked by a player. - * Default action is picking the plant. - * - * Only called Serverside. - * - * @param crop reference to ICropTile - * @param player player leftclicked the crop - * @return Whether the plant has changed - */ - public boolean leftclick(ICropTile crop, EntityPlayer player) { - return crop.pick(true); - } - - /** - * Base chance for dropping seeds when the plant is picked. - * Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0. - * - * @param crop reference to ICropTile - * @return Chance to drop the seeds - */ - public float dropSeedChance(ICropTile crop) { - if (crop.getSize() == 1) return 0; - float base = 0.5F; - if (crop.getSize() == 2) base/=2F; - for (int i = 0; i < tier(); i++) {base*=0.8;} - return base; - } - - /** - * Obtain seeds dropped when the plant is picked. - * Multiple drops of the returned ItemStack can occur. - * Default action is generating a seed from this crop. - * - * @param crop reference to ICropTile - * @return Seeds - */ - public ItemStack getSeeds(ICropTile crop) { - return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); - } - - /** - * Called when a neighbor block to the crop has changed. - * - * @param crop reference to ICropTile - */ - public void onNeighbourChange(ICropTile crop) { - // - } - - /** - * Check if the crop should emit redstone. - * - * @return Whether the crop should emit redstone - */ - public int emitRedstone(ICropTile crop) {return 0;} - - /** - * Called when the crop is destroyed. - * - * @param crop reference to ICropTile - */ - public void onBlockDestroyed(ICropTile crop) { - // - } - - /** - * Get the light value emitted by the plant. - * - * @param crop reference to ICropTile - * @return Light value emitted - */ - public int getEmittedLight(ICropTile crop) {return 0;} - - /** - * Default is true if the entity is an EntityLiving in jumping or sprinting state. - * - * @param crop reference to ICropTile - * @param entity entity colliding - * @return Whether trampling calculation should happen, return false if the plant is no longer valid. - */ - public boolean onEntityCollision(ICropTile crop, Entity entity) { - if (entity instanceof EntityLivingBase) { - return ((EntityLivingBase) entity).isSprinting(); - } - return false; - } - - - /** - * Called every time the crop ticks. - * Should be called every 256 ticks or around 13 seconds. - * - * @param crop reference to ICropTile - */ - public void tick(ICropTile crop) { - // - } - - /** - * Check whether this plant spreads weed to surrounding tiles. - * Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2. - * - * @param crop reference to ICropTile - * @return Whether the plant spreads weed - */ - public boolean isWeed(ICropTile crop) { - return crop.getSize() >= 2 && (crop.getID() == 0 || crop.getGrowth() >= 24); - } - - - /** - * Get this plant's ID. - * - * @return ID of this CropCard or -1 if it's not registered - */ - public final int getId() { - return Crops.instance.getIdFor(this); - } - - @SideOnly(Side.CLIENT) - protected IIcon textures[]; -} diff --git a/src/main/java/ic2/api/crops/Crops.java b/src/main/java/ic2/api/crops/Crops.java deleted file mode 100644 index 53cc3239..00000000 --- a/src/main/java/ic2/api/crops/Crops.java +++ /dev/null @@ -1,117 +0,0 @@ -package ic2.api.crops; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.world.biome.BiomeGenBase; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraftforge.common.BiomeDictionary.Type; - -/** - * General management of the crop system. - */ -public abstract class Crops { - public static Crops instance; - - /** - * Adds a crop humidity and nutrient biome bonus. - * - * 0 indicates no bonus and negative values indicate a penalty. - * - * @param biome Biome to apply the bonus in - * @param humidityBonus Humidity stat bonus - * @param nutrientsBonus Nutrient stat bonus - */ - public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); - - /** - * Adds a crop humidity and nutrient biome bonus. - * - * 0 indicates no bonus and negative values indicate a penalty. - * - * @param type Forge biome type to apply the bonus in - * @param humidityBonus Humidity stat bonus - * @param nutrientsBonus Nutrient stat bonus - */ - public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus); - - /** - * Gets the humidity bonus for a biome. - * - * @param biome Biome to check - * @return Humidity bonus or 0 if none - */ - public abstract int getHumidityBiomeBonus(BiomeGenBase biome); - - /** - * Gets the nutrient bonus for a biome. - * - * @param biome Biome to check - * @return Nutrient bonus or 0 if none - */ - public abstract int getNutrientBiomeBonus(BiomeGenBase biome); - - /** - * Returns the list of registered crops. - * - * @return Registered crops by ID - */ - public abstract CropCard[] getCropList(); - - /** - * Auto-assign an ID to a plant and register it. - * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. - * - * @param crop plant to register - * @return The ID assigned to the plant - */ - public abstract short registerCrop(CropCard crop); - - /** - * Attempt to register a plant to an ID. - * If the ID is taken, the crop will not be registered and a console print will notify the user. - * - * @param crop plant to register - * @param i ID to register the plant to - * @return Whether the crop was registered - */ - public abstract boolean registerCrop(CropCard crop, int i); - - /** - * Registers a base seed, an item used to plant a crop. - * - * @param stack item - * @param id plant ID - * @param size initial size - * @param growth initial growth stat - * @param gain initial gain stat - * @param resistance initial resistance stat - * @return True if successful - */ - public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); - - /** - * Finds a base seed from the given item. - * - * @return Base seed or null if none found - */ - public abstract BaseSeed getBaseSeed(ItemStack stack); - - /** - * Execute registerSprites for all registered crop cards. - * - * This method will get called by IC2, don't call it yourself. - */ - @SideOnly(Side.CLIENT) - public abstract void startSpriteRegistration(IIconRegister iconRegister); - - /** - * Returns the ID for the given crop. - * - * @param crop Crop to look up - * @return ID, or -1 if not found - */ - public abstract int getIdFor(CropCard crop); -} diff --git a/src/main/java/ic2/api/crops/ICropTile.java b/src/main/java/ic2/api/crops/ICropTile.java deleted file mode 100644 index 09b46d79..00000000 --- a/src/main/java/ic2/api/crops/ICropTile.java +++ /dev/null @@ -1,264 +0,0 @@ -package ic2.api.crops; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - -/** - * Interface implemented by the crop tile entity. - */ -public interface ICropTile { - /** - * Get the crop's plant ID. - * - * @return Plant ID, or -1 if there is no plant currently on the crop - */ - public short getID(); - - /** - * Set the crop's plant ID. - * - * @param id Plant ID, or -1 for no plant - */ - public void setID(short id); - - /** - * Get the crop's plant size. - * - * @return Plant size, starting with 1 and maximum varies depending on plant - */ - public byte getSize(); - - /** - * Set the crop's plant size. - * - * @param size Plant size - */ - public void setSize(byte size); - - /** - * Get the crop's plant growth stat. - * Higher values indicate faster growth. - * - * @return Plant growth stat - */ - public byte getGrowth(); - - /** - * Set the crop's plant growth stat. - * - * @param growth Plant growth stat - */ - public void setGrowth(byte growth); - - /** - * Get the crop's plant gain stat. - * Higher values indicate more drops. - * - * @return Plant gain stat - */ - public byte getGain(); - - /** - * Set the crop's plant gain stat. - * - * @param gain Plant gain stat - */ - public void setGain(byte gain); - - /** - * Get the crop's plant resistance stat. - * Higher values indicate more resistance against trampling. - * - * @return Plant resistance stat - */ - public byte getResistance(); - - /** - * Set the crop's plant resistance stat. - * - * @param resistance Plant resistance stat - */ - public void setResistance(byte resistance); - - /** - * Get the crop's plant scan level. - * Increases every time the seed is analyzed. - * - * @return Plant scan level - */ - public byte getScanLevel(); - - /** - * Set the crop's plant scan level. - * - * @param scanLevel Plant scan level - */ - public void setScanLevel(byte scanLevel); - - /** - * Get the crop's plant custom data, stored alongside the crop. - * Can be modified in place. - * - * @return Plant custom data - */ - public NBTTagCompound getCustomData(); - - /** - * Get the crop's nutrient storage. - * Ranges from 0 to 100. - * - * @return Crop nutrient storage - */ - public int getNutrientStorage(); - - /** - * Set the crop's nutrient storage. - * - * @param nutrientStorage Crop nutrient storage - */ - public void setNutrientStorage(int nutrientStorage); - - /** - * Get the crop's hydration storage. - * 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells. - * - * @return Crop hydration storage - */ - public int getHydrationStorage(); - - /** - * Set the crop's hydration storage. - * - * @param hydrationStorage Crop hydration storage - */ - public void setHydrationStorage(int hydrationStorage); - - /** - * Get the crop's Weed-Ex storage. - * - * @return Crop Weed-Ex storage - */ - public int getWeedExStorage(); - - /** - * Set the crop's Weed-Ex storage. - * - * @param weedExStorage Crop Weed-Ex storage - */ - public void setWeedExStorage(int weedExStorage); - - /** - * Get the crop's humidity. - * Ranges from 0 (dry) to 10 (humid). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop humidity level - */ - public byte getHumidity(); - - /** - * Get the crop's nutrient level. - * Ranges from 0 (empty) to 10 (full). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop nutrient level - */ - public byte getNutrients(); - - /** - * Get the crop's air quality. - * Ranges from 0 (cluttered) to 10 (fresh). - * Updates every couple of seconds or when an update is requested. - * - * @see #updateState() - * - * @return Crop air quality - */ - public byte getAirQuality(); - - /** - * Get the crop's world. - * - * @return Crop world - */ - public World getWorld(); - - /** - * Get the crop's location. - * - * @return Crop location - */ - public ChunkCoordinates getLocation(); - - /** - * Get the crop's light level. - * - * @return Crop light level - */ - public int getLightLevel(); - - /** - * Pick the crop, removing and giving seeds for the plant. - * - * @param manual whether it was done by hand (not automated) - * @return true if successfully picked - */ - public boolean pick(boolean manual); - - /** - * Harvest the crop, turning it into gain and resetting its size. - * drop output on ground - * @param manual - * @return true if successfully harvested - */ - public boolean harvest(boolean manual); - - /** - * Harvest the crop, turning it into gain and resetting its size. - * drop output on ground - * @param Optimal force check getOptimalHavestSize() for harvest - * @return ItemStack[] of harvest output - */ - - ItemStack[] harvest_automated(boolean Optimal); - - /** - * Fully clears the crop without dropping anything. - */ - public void reset(); - - /** - * Request a texture and lighting update. - */ - public void updateState(); - - /** - * Check if a block is under the farmland containing the crop. - * Searches up to 2 blocks below the farmland or an air space, whichever appears first. - * - * @param block block to search - * @return Whether the block was found - */ - public boolean isBlockBelow(Block block); - - /** - * Generate plant seeds with the given parameters. - * - * @param plant plant ID - * @param growth plant growth stat - * @param gain plant gain stat - * @param resis plant resistance stat - * @param scan plant scan level - * @return Plant seed item - */ - public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); - - -} diff --git a/src/main/java/ic2/api/crops/package-info.java b/src/main/java/ic2/api/crops/package-info.java deleted file mode 100644 index 04b82539..00000000 --- a/src/main/java/ic2/api/crops/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.crops; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/energy/IEnergyNet.java b/src/main/java/ic2/api/energy/IEnergyNet.java deleted file mode 100644 index 8f656e50..00000000 --- a/src/main/java/ic2/api/energy/IEnergyNet.java +++ /dev/null @@ -1,86 +0,0 @@ -package ic2.api.energy; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Interface representing the methods provided by the global EnergyNet class. - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergyNet { - /** - * Get the EnergyNet-registered tile entity at the specified position. - * - * This is not the same as World.getTileEntity(), it's possible to register delegate tile - * entities with the energy net which are different from what's actually in the world. Those - * delegates allow to use separate TileEntity objects just for the EnergyNet interfaces, - * simplifying cross-mod dependencies and multi-blocks. - * - * @param world World containing the tile entity - * @param x x-coordinate - * @param y y-coordinate - * @param z z-coordinate - * @return tile entity registered to the energy net or null if none is registered - */ - TileEntity getTileEntity(World world, int x, int y, int z); - - /** - * Get the EnergyNet-registered neighbor tile entity at the specified position. - * - * @param te TileEntity indicating the world and position to search from - * @param dir direction the neighbor is to be found - * @return neighbor tile entity registered to the energy net or null if none is registered - */ - TileEntity getNeighbor(TileEntity te, ForgeDirection dir); - - /** - * determine how much energy has been emitted by the EnergyEmitter specified - * - * @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick - * - * @param tileEntity energy emitter - * @deprecated Discontinued, use getNodeStats instead. - */ - @Deprecated - double getTotalEnergyEmitted(TileEntity tileEntity); - - /** - * determine how much energy has been sunken by the EnergySink specified - * - * @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick - * - * @param tileEntity energy emitter - * @deprecated Discontinued, use getNodeStats instead. - */ - @Deprecated - double getTotalEnergySunken(TileEntity tileEntity); - - /** - * Retrieve statistics for the tile entity specified. - * - * The statistics apply to the last simulated tick. - * - * @param te Tile entity to check. - * @return Statistics for the tile entity. - */ - NodeStats getNodeStats(TileEntity te); - - /** - * Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2. - * - * @param tier tier - * @return power in eu/t - */ - double getPowerFromTier(int tier); - - /** - * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. - * - * @param power in eu/t - * @return tier - */ - int getTierFromPower(double power); -} diff --git a/src/main/java/ic2/api/energy/NodeStats.java b/src/main/java/ic2/api/energy/NodeStats.java deleted file mode 100644 index c55fd4e4..00000000 --- a/src/main/java/ic2/api/energy/NodeStats.java +++ /dev/null @@ -1,25 +0,0 @@ -package ic2.api.energy; - -public class NodeStats { - public NodeStats(double energyIn, double energyOut, double voltage) { - this.energyIn = energyIn; - this.energyOut = energyOut; - this.voltage = voltage; - } - - public double getEnergyIn() { - return energyIn; - } - - public double getEnergyOut() { - return energyOut; - } - - public double getVoltage() { - return voltage; - } - - private final double energyIn; - private final double energyOut; - private final double voltage; -} diff --git a/src/main/java/ic2/api/energy/event/package-info.java b/src/main/java/ic2/api/energy/event/package-info.java deleted file mode 100644 index 40db6f8a..00000000 --- a/src/main/java/ic2/api/energy/event/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.event; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/energy/package-info.java b/src/main/java/ic2/api/energy/package-info.java deleted file mode 100644 index 81d0bfed..00000000 --- a/src/main/java/ic2/api/energy/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/energy/prefab/BasicSink.java b/src/main/java/ic2/api/energy/prefab/BasicSink.java deleted file mode 100644 index 48de0613..00000000 --- a/src/main/java/ic2/api/energy/prefab/BasicSink.java +++ /dev/null @@ -1,373 +0,0 @@ -package ic2.api.energy.prefab; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - -import cpw.mods.fml.common.FMLCommonHandler; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; - -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.info.Info; -import ic2.api.item.ElectricItem; - -/** - * BasicSink is a simple adapter to provide an ic2 energy sink. - * - * It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a - * one-time configurable input energy buffer, thus providing a common use case for machines. - * - * Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended. - * The delegate can be extended with additional functionality through a sub class though. - * - * The constraints set by BasicSink like the strict tank-like energy buffering should provide a - * more easy to use and stable interface than using IEnergySink directly while aiming for - * optimal performance. - * - * Using BasicSink involves the following steps: - * - create a BasicSink instance in your TileEntity, typically in a field - * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. - * - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available - * without consuming the energy. - * - optionally use getEnergyStored to display the output buffer charge level - * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - * - * Example implementation code: - * @code{.java} - * public class SomeTileEntity extends TileEntity { - * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); - * - * @Override - * public void invalidate() { - * ic2EnergySink.invalidate(); // notify the energy sink - * ... - * super.invalidate(); // this is important for mc! - * } - * - * @Override - * public void onChunkUnload() { - * ic2EnergySink.onChunkUnload(); // notify the energy sink - * ... - * } - * - * @Override - * public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - * - * ic2EnergySink.readFromNBT(tag); - * ... - * } - * - * @Override - * public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - * - * ic2EnergySink.writeToNBT(tag); - * ... - * } - * - * @Override - * public void updateEntity() { - * ic2EnergySink.updateEntity(); // notify the energy sink - * ... - * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick - * ... // do something with the energy - * } - * ... - * } - * - * ... - * } - * @endcode - */ -public class BasicSink extends TileEntity implements IEnergySink { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** - - /** - * Constructor for a new BasicSink delegate. - * - * @param parent1 TileEntity represented by this energy sink. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSink(TileEntity parent1, int capacity1, int tier1) { - this.parent = parent1; - this.capacity = capacity1; - this.tier = tier1; - } - - // in-world te forwards >> - - /** - * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); - } - - /** - * Notification that the base TileEntity finished loaded, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { - worldObj = parent.getWorldObj(); - xCoord = parent.xCoord; - yCoord = parent.yCoord; - zCoord = parent.zCoord; - - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - - addedToEnet = true; - } - } - - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); - - onChunkUnload(); - } - - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - - addedToEnet = false; - } - } - - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - - NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); - - energyStored = data.getDouble("energy"); - } - - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public void writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } - - NBTTagCompound data = new NBTTagCompound(); - - data.setDouble("energy", energyStored); - - tag.setTag("IC2BasicSink", data); - } - - // << in-world te forwards - // methods for using this adapter >> - - /** - * Get the maximum amount of energy this sink can hold in its buffer. - * - * @return Capacity in EU. - */ - public int getCapacity() { - return capacity; - } - - /** - * Set the maximum amount of energy this sink can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(int capacity1) { - this.capacity = capacity1; - } - - /** - * Get the IC2 energy tier for this sink. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } - - /** - * Set the IC2 energy tier for this sink. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - this.tier = tier1; - } - - /** - * Determine the energy stored in the sink's input buffer. - * - * @return amount in EU, may be above capacity - */ - public double getEnergyStored() { - return energyStored; - } - - /** - * Set the stored energy to the specified amount. - * - * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } - - /** - * Determine if the specified amount of energy is available. - * - * @param amount in EU - * @return true if the amount is available - */ - public boolean canUseEnergy(double amount) { - return energyStored >= amount; - } - - /** - * Use the specified amount of energy, if available. - * - * @param amount amount to use - * @return true if the amount was available - */ - public boolean useEnergy(double amount) { - if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { - energyStored -= amount; - - return true; - } - return false; - } - - /** - * Discharge the supplied ItemStack into this sink's energy buffer. - * - * @param stack ItemStack to discharge (null is ignored) - * @param limit Transfer limit, values <= 0 will use the battery's limit - * @return true if energy was transferred - */ - public boolean discharge(ItemStack stack, int limit) { - if (stack == null || !Info.isIc2Available()) return false; - - double amount = capacity - energyStored; - if (amount <= 0) return false; - - if (limit > 0 && limit < amount) amount = limit; - - amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); - - energyStored += amount; - - return amount > 0; - } - - // << methods for using this adapter - - // backwards compatibility (ignore these) >> - - @Deprecated - public void onUpdateEntity() { - updateEntity(); - } - - @Deprecated - public void onInvalidate() { - invalidate(); - } - - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } - - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } - - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } - - // << backwards compatibility - - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** - - // energy net interface >> - - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { - return true; - } - - @Override - public double getDemandedEnergy() { - return Math.max(0, capacity - energyStored); - } - - @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { - energyStored += amount; - - return 0; - } - - @Override - public int getSinkTier() { - return tier; - } - - // << energy net interface - - - public final TileEntity parent; - - protected int capacity; - protected int tier; - protected double energyStored; - protected boolean addedToEnet; -} diff --git a/src/main/java/ic2/api/energy/prefab/BasicSource.java b/src/main/java/ic2/api/energy/prefab/BasicSource.java deleted file mode 100644 index 011e8cd3..00000000 --- a/src/main/java/ic2/api/energy/prefab/BasicSource.java +++ /dev/null @@ -1,375 +0,0 @@ -package ic2.api.energy.prefab; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; - -import cpw.mods.fml.common.FMLCommonHandler; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; - -import ic2.api.energy.EnergyNet; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySource; -import ic2.api.info.Info; -import ic2.api.item.ElectricItem; - -/** - * BasicSource is a simple adapter to provide an ic2 energy source. - * - * It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a - * one-time configurable output energy buffer, thus providing a common use case for generators. - * - * Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended. - * The delegate can be extended with additional functionality through a sub class though. - * - * The constraints set by BasicSource like the strict tank-like energy buffering should provide a - * more easy to use and stable interface than using IEnergySource directly while aiming for - * optimal performance. - * - * Using BasicSource involves the following steps: - * - create a BasicSource instance in your TileEntity, typically in a field - * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. - * - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator - * should run - * - optionally use getEnergyStored to display the output buffer charge level - * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - * - * Example implementation code: - * @code{.java} - * public class SomeTileEntity extends TileEntity { - * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); - * - * @Override - * public void invalidate() { - * ic2EnergySource.invalidate(); // notify the energy source - * ... - * super.invalidate(); // this is important for mc! - * } - * - * @Override - * public void onChunkUnload() { - * ic2EnergySource.onChunkUnload(); // notify the energy source - * ... - * } - * - * @Override - * public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - * - * ic2EnergySource.readFromNBT(tag); - * ... - * } - * - * @Override - * public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - * - * ic2EnergySource.writeToNBT(tag); - * ... - * } - * - * @Override - * public void updateEntity() { - * ic2EnergySource.updateEntity(); // notify the energy source - * ... - * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick - * ... - * } - * - * ... - * } - * @endcode - */ -public class BasicSource extends TileEntity implements IEnergySource { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** - - /** - * Constructor for a new BasicSource delegate. - * - * @param parent1 Base TileEntity represented by this energy source. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSource(TileEntity parent1, double capacity1, int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); - - this.parent = parent1; - this.capacity = capacity1 < power ? power : capacity1; - this.tier = tier1; - this.power = power; - } - - // in-world te forwards >> - - /** - * Forward for the base TileEntity's updateEntity(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void updateEntity() { - if (!addedToEnet) onLoaded(); - } - - /** - * Notification that the base TileEntity finished loading, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !FMLCommonHandler.instance().getEffectiveSide().isClient() && - Info.isIc2Available()) { - worldObj = parent.getWorldObj(); - xCoord = parent.xCoord; - yCoord = parent.yCoord; - zCoord = parent.zCoord; - - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - - addedToEnet = true; - } - } - - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); - - onChunkUnload(); - } - - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - - addedToEnet = false; - } - } - - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - - NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); - - energyStored = data.getDouble("energy"); - } - - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public void writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } - - NBTTagCompound data = new NBTTagCompound(); - - data.setDouble("energy", energyStored); - - tag.setTag("IC2BasicSource", data); - } - - // << in-world te forwards - // methods for using this adapter >> - - /** - * Get the maximum amount of energy this source can hold in its buffer. - * - * @return Capacity in EU. - */ - public double getCapacity() { - return capacity; - } - - /** - * Set the maximum amount of energy this source can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(double capacity1) { - if (capacity1 < power) capacity1 = power; - - this.capacity = capacity1; - } - - /** - * Get the IC2 energy tier for this source. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } - - /** - * Set the IC2 energy tier for this source. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); - - if (capacity < power) capacity = power; - - this.tier = tier1; - this.power = power; - } - - - /** - * Determine the energy stored in the source's output buffer. - * - * @return amount in EU - */ - public double getEnergyStored() { - return energyStored; - } - - /** - * Set the stored energy to the specified amount. - * - * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } - - /** - * Determine the free capacity in the source's output buffer. - * - * @return amount in EU - */ - public double getFreeCapacity() { - return capacity - energyStored; - } - - /** - * Add some energy to the output buffer. - * - * @param amount maximum amount of energy to add - * @return amount added/used, NOT remaining - */ - public double addEnergy(double amount) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; - if (amount > capacity - energyStored) amount = capacity - energyStored; - - energyStored += amount; - - return amount; - } - - /** - * Charge the supplied ItemStack from this source's energy buffer. - * - * @param stack ItemStack to charge (null is ignored) - * @return true if energy was transferred - */ - public boolean charge(ItemStack stack) { - if (stack == null || !Info.isIc2Available()) return false; - - double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); - - energyStored -= amount; - - return amount > 0; - } - - // << methods for using this adapter - - // backwards compatibility (ignore these) >> - - @Deprecated - public void onUpdateEntity() { - updateEntity(); - } - - @Deprecated - public void onInvalidate() { - invalidate(); - } - - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } - - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } - - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } - - // << backwards compatibility - - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** - - // energy net interface >> - - @Override - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { - return true; - } - - @Override - public double getOfferedEnergy() { - return Math.min(energyStored, power); - } - - @Override - public void drawEnergy(double amount) { - energyStored -= amount; - } - - @Override - public int getSourceTier() { - return tier; - } - - // << energy net interface - - - public final TileEntity parent; - - protected double capacity; - protected int tier; - protected double power; - protected double energyStored; - protected boolean addedToEnet; -} diff --git a/src/main/java/ic2/api/energy/prefab/package-info.java b/src/main/java/ic2/api/energy/prefab/package-info.java deleted file mode 100644 index c38f7e0e..00000000 --- a/src/main/java/ic2/api/energy/prefab/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.prefab; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java deleted file mode 100644 index 1735ff5e..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java +++ /dev/null @@ -1,27 +0,0 @@ -package ic2.api.energy.tile; - -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * For internal/multi-block usage only. - * - * @see IEnergySink - * @see IEnergyConductor - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergyAcceptor extends IEnergyTile { - /** - * Determine if this acceptor can accept current from an adjacent emitter in a direction. - * - * The TileEntity in the emitter parameter is what was originally added to the energy net, - * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. - * - * @param emitter energy emitter, may also be null or an IMetaDelegate - * @param direction direction the energy is being received from - */ - boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyConductor.java b/src/main/java/ic2/api/energy/tile/IEnergyConductor.java deleted file mode 100644 index 08dab889..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyConductor.java +++ /dev/null @@ -1,53 +0,0 @@ -package ic2.api.energy.tile; - -/** - * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this - * interface. - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { - /** - * Energy loss for the conductor in EU per block. - * - * @return Energy loss - */ - double getConductionLoss(); - - /** - * Amount of energy the insulation will handle before shocking nearby players and mobs. - * - * @return Insulation energy absorption in EU - */ - double getInsulationEnergyAbsorption(); - - /** - * Amount of energy the insulation will handle before it is destroyed. - * Ensure that this value is greater than the insulation energy absorption + 64. - * - * @return Insulation-destroying energy in EU - */ - double getInsulationBreakdownEnergy(); - - /** - * Amount of energy the conductor will handle before it melts. - * - * @return Conductor-destroying energy in EU - */ - double getConductorBreakdownEnergy(); - - /** - * Remove the conductor's insulation if the insulation breakdown energy was exceeded. - * - * @see #getInsulationBreakdownEnergy() - */ - void removeInsulation(); - - /** - * Remove the conductor if the conductor breakdown energy was exceeded. - * - * @see #getConductorBreakdownEnergy() - */ - void removeConductor(); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java deleted file mode 100644 index 013865e3..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergyEmitter.java +++ /dev/null @@ -1,28 +0,0 @@ -package ic2.api.energy.tile; - -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * For internal/multi-block usage only. - * - * @see IEnergySource - * @see IEnergyConductor - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergyEmitter extends IEnergyTile { - /** - * Determine if this emitter can emit energy to an adjacent receiver. - * - * The TileEntity in the receiver parameter is what was originally added to the energy net, - * which may be normal in-world TileEntity, a delegate or an IMetaDelegate. - * - * @param receiver receiver, may also be null or an IMetaDelegate - * @param direction direction the receiver is from the emitter - * @return Whether energy should be emitted - */ - boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergySink.java b/src/main/java/ic2/api/energy/tile/IEnergySink.java deleted file mode 100644 index 4ae8e795..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergySink.java +++ /dev/null @@ -1,45 +0,0 @@ -package ic2.api.energy.tile; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Allows a tile entity (mostly a machine) to receive energy. - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergySink extends IEnergyAcceptor { - /** - * Determine how much energy the sink accepts. - * - * Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0. - * - * @note Modifying the energy net from this method is disallowed. - * - * @return max accepted input in eu - */ - double getDemandedEnergy(); - - /** - * Determine the tier of this energy sink. - * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * - * @note Modifying the energy net from this method is disallowed. - * @note Return Integer.MAX_VALUE to allow any voltage. - * - * @return tier of this energy sink - */ - int getSinkTier(); - - /** - * Transfer energy to the sink. - * - * It's highly recommended to accept all energy by letting the internal buffer overflow to - * increase the performance and accuracy of the distribution simulation. - * - * @param directionFrom direction from which the energy comes from - * @param amount energy to be transferred - * @return Energy not consumed (leftover) - */ - double injectEnergy(ForgeDirection directionFrom, double amount, double voltage); -} - diff --git a/src/main/java/ic2/api/energy/tile/IEnergySource.java b/src/main/java/ic2/api/energy/tile/IEnergySource.java deleted file mode 100644 index 44b952a5..00000000 --- a/src/main/java/ic2/api/energy/tile/IEnergySource.java +++ /dev/null @@ -1,38 +0,0 @@ -package ic2.api.energy.tile; - -/** - * Allows a tile entity (mostly a generator) to emit energy. - * - * See ic2/api/energy/usage.txt for an overall description of the energy net api. - */ -public interface IEnergySource extends IEnergyEmitter { - /** - * Energy output provided by the source this tick. - * This is typically Math.min(stored energy, max output/tick). - * - * @note Modifying the energy net from this method is disallowed. - * - * @return Energy offered this tick - */ - double getOfferedEnergy(); - - /** - * Draw energy from this source's buffer. - * - * If the source doesn't have a buffer, this is a no-op. - * - * @param amount amount of EU to draw, may be negative - */ - void drawEnergy(double amount); - - /** - * Determine the tier of this energy source. - * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. - * - * @note Modifying the energy net from this method is disallowed. - * - * @return tier of this energy source - */ - int getSourceTier(); -} - diff --git a/src/main/java/ic2/api/energy/tile/package-info.java b/src/main/java/ic2/api/energy/tile/package-info.java deleted file mode 100644 index 3c60323a..00000000 --- a/src/main/java/ic2/api/energy/tile/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.tile; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/event/LaserEvent.java b/src/main/java/ic2/api/event/LaserEvent.java deleted file mode 100644 index 6d5ea280..00000000 --- a/src/main/java/ic2/api/event/LaserEvent.java +++ /dev/null @@ -1,114 +0,0 @@ -package ic2.api.event; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - -import net.minecraftforge.event.world.WorldEvent; - -/** - * A bunch of Events to handle the power of the Mining Laser. - */ -@Cancelable -public class LaserEvent extends WorldEvent { - // the Laser Entity - public final Entity lasershot; - - // the following variables can be changed and the Laser will adjust to them - - // the Player firing the Laser. If the Laser gets "reflected" the Player could change. - public EntityLivingBase owner; - // Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range. - public float range, power; - public int blockBreaks; - // Determines whether the laser will explode upon hitting something - public boolean explosive, smelt; - - public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) { - super(world1); - this.lasershot = lasershot1; - this.owner = owner1; - this.range = range1; - this.power = power1; - this.blockBreaks = blockBreaks1; - this.explosive = explosive1; - this.smelt = smelt1; - } - - /** - * Event when the Laser is getting shot by a Player. - * - * The Item is the Laser Gun which the "Player" has shot - */ - public static class LaserShootEvent extends LaserEvent { - ItemStack laseritem; - - public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.laseritem = laseritem1; - } - } - - /** - * Event when the Laser is exploding for some Reason. - * - * The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired. - */ - public static class LaserExplodesEvent extends LaserEvent { - // explosion strength, even that can be changed! - public float explosionpower, explosiondroprate, explosionentitydamage; - - public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.explosionpower = explosionpower1; - this.explosiondroprate = explosiondroprate1; - this.explosionentitydamage = explosionentitydamage1; - } - } - - /** - * Event when the Laser is hitting a Block - * x, y and z are the Coords of the Block. - * - * Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass. - * Use lasershot.setDead() to remove the Shot entirely. - */ - public static class LaserHitsBlockEvent extends LaserEvent { - // targeted block, even that can be changed! - public int x, y, z; - public int side; - // removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something. - public boolean removeBlock, dropBlock; - public float dropChance; - - public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.removeBlock = removeBlock1; - this.dropBlock = dropBlock1; - this.dropChance = dropChance1; - } - } - - /** - * Event when the Laser is getting at a Living Entity - * - * Canceling this Event ignores the Entity - * Use lasershot.setDead() to remove the Shot entirely. - */ - public static class LaserHitsEntityEvent extends LaserEvent { - // the Entity which the Laser has shot at, even the target can be changed! - public Entity hitentity; - - public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) { - super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1); - this.hitentity = hitentity1; - } - } -} diff --git a/src/main/java/ic2/api/event/PaintEvent.java b/src/main/java/ic2/api/event/PaintEvent.java deleted file mode 100644 index c6565c22..00000000 --- a/src/main/java/ic2/api/event/PaintEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package ic2.api.event; - -import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - -import net.minecraftforge.event.world.WorldEvent; - -@Cancelable -public class PaintEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; - - // color to paint the block - public final int color; - - // set to true to confirm the operation - public boolean painted = false; - - public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) { - super(world1); - - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.color = color1; - } -} diff --git a/src/main/java/ic2/api/event/RetextureEvent.java b/src/main/java/ic2/api/event/RetextureEvent.java deleted file mode 100644 index d530578c..00000000 --- a/src/main/java/ic2/api/event/RetextureEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package ic2.api.event; - -import net.minecraft.block.Block; -import net.minecraft.world.World; - -import cpw.mods.fml.common.eventhandler.Cancelable; - -import net.minecraftforge.event.world.WorldEvent; - -@Cancelable -public class RetextureEvent extends WorldEvent { - // target block - public final int x; - public final int y; - public final int z; - public final int side; - - // referenced block (to grab the texture from) - public final Block referencedBlock; - public final int referencedMeta; - public final int referencedSide; - - // set to true to confirm the operation - public boolean applied = false; - - public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) { - super(world1); - - this.x = x1; - this.y = y1; - this.z = z1; - this.side = side1; - this.referencedBlock = referencedBlock; - this.referencedMeta = referencedMeta1; - this.referencedSide = referencedSide1; - } -} diff --git a/src/main/java/ic2/api/event/package-info.java b/src/main/java/ic2/api/event/package-info.java deleted file mode 100644 index d331b924..00000000 --- a/src/main/java/ic2/api/event/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.event; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/info/IEnergyValueProvider.java b/src/main/java/ic2/api/info/IEnergyValueProvider.java deleted file mode 100644 index 1e7b2cc5..00000000 --- a/src/main/java/ic2/api/info/IEnergyValueProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -package ic2.api.info; - -import net.minecraft.item.ItemStack; - -public interface IEnergyValueProvider { - /** - * Determine the energy value for a single item in the supplied stack. - * The value is used by most machines in the discharge slot. - * - * This only applies to basic single use items, others are to be queried - * through e.g. ElectricItem.manager.getCharge(). - * - * @param itemStack ItemStack containing the item to evaluate. - * @return energy in EU - */ - double getEnergyValue(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/info/IFuelValueProvider.java b/src/main/java/ic2/api/info/IFuelValueProvider.java deleted file mode 100644 index 7c7fe0f4..00000000 --- a/src/main/java/ic2/api/info/IFuelValueProvider.java +++ /dev/null @@ -1,15 +0,0 @@ -package ic2.api.info; - -import net.minecraft.item.ItemStack; - -public interface IFuelValueProvider { - /** - * Determine the fuel value for a single item in the supplied stack. - * The information currently applies to Generators and the Iron Furnace. - * - * @param itemStack ItemStack containing the item to evaluate. - * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. - * @return fuel value - */ - int getFuelValue(ItemStack itemStack, boolean allowLava); -} diff --git a/src/main/java/ic2/api/info/Info.java b/src/main/java/ic2/api/info/Info.java deleted file mode 100644 index 3b5a5442..00000000 --- a/src/main/java/ic2/api/info/Info.java +++ /dev/null @@ -1,32 +0,0 @@ -package ic2.api.info; - -import net.minecraft.util.DamageSource; - -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.LoaderState; - -public class Info { - public static IEnergyValueProvider itemEnergy; - public static IFuelValueProvider itemFuel; - public static Object ic2ModInstance; - - /** - * Damage Sources used by IC2. - * Getting assigned in preload. - */ - public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; - - public static boolean isIc2Available() { - if (ic2Available != null) return ic2Available; - - boolean loaded = Loader.isModLoaded("IC2"); - - if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { - ic2Available = loaded; - } - - return loaded; - } - - private static Boolean ic2Available = null; -} \ No newline at end of file diff --git a/src/main/java/ic2/api/info/package-info.java b/src/main/java/ic2/api/info/package-info.java deleted file mode 100644 index 59936e5e..00000000 --- a/src/main/java/ic2/api/info/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.info; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/item/ElectricItem.java b/src/main/java/ic2/api/item/ElectricItem.java deleted file mode 100644 index 19e5fc1b..00000000 --- a/src/main/java/ic2/api/item/ElectricItem.java +++ /dev/null @@ -1,59 +0,0 @@ -package ic2.api.item; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * Allows for charging, discharging and using electric items (IElectricItem). - */ -public final class ElectricItem { - /** - * IElectricItemManager to use for interacting with IElectricItem ItemStacks. - * - * This manager will act as a gateway and delegate the tasks to the final implementation - * (rawManager or a custom one) as necessary. - */ - public static IElectricItemManager manager; - - /** - * Standard IElectricItemManager implementation, only call it directly from another - * IElectricItemManager. Use manager instead. - */ - public static IElectricItemManager rawManager; - - /** - * Register an electric item manager for items not implementing IElectricItem. - * - * This method is only designed for special purposes, implementing IElectricItem or - * ISpecialElectricItem instead of using this is faster. - * - * Managers used with ISpecialElectricItem shouldn't be registered. - * - * @param manager Manager to register. - */ - public static void registerBackupManager(IBackupElectricItemManager manager) { - backupManagers.add(manager); - } - - /** - * Get the electric item manager suitable for the supplied item stack. - * - * This method is for internal use only. - * - * @param stack ItemStack to be handled. - * @return First suitable electric item manager. - */ - public static IBackupElectricItemManager getBackupManager(ItemStack stack) { - for (IBackupElectricItemManager manager : backupManagers) { - if (manager.handles(stack)) return manager; - } - - return null; - } - - - private static final List backupManagers = new ArrayList(); -} - diff --git a/src/main/java/ic2/api/item/IBoxable.java b/src/main/java/ic2/api/item/IBoxable.java deleted file mode 100644 index bca2cc0d..00000000 --- a/src/main/java/ic2/api/item/IBoxable.java +++ /dev/null @@ -1,14 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - - -public interface IBoxable { - /** - * Determine whether an item can be stored in a toolbox or not. - * - * @param itemstack item to be stored - * @return Whether to store the item in the toolbox or not - */ - public abstract boolean canBeStoredInToolbox(ItemStack itemstack); -} diff --git a/src/main/java/ic2/api/item/IElectricItem.java b/src/main/java/ic2/api/item/IElectricItem.java deleted file mode 100644 index 5525e00f..00000000 --- a/src/main/java/ic2/api/item/IElectricItem.java +++ /dev/null @@ -1,55 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -/** - * Provides the ability to store energy on the implementing item. - * - * The item should have a maximum damage of 13. - */ -public interface IElectricItem { - /** - * Determine if the item can be used in a machine or as an armor part to supply energy. - * - * @return Whether the item can supply energy - */ - boolean canProvideEnergy(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy greater than 0. - * - * @return Item ID to use - */ - Item getChargedItem(ItemStack itemStack); - - /** - * Get the item ID to use for a charge energy of 0. - * - * @return Item ID to use - */ - Item getEmptyItem(ItemStack itemStack); - - /** - * Get the item's maximum charge energy in EU. - * - * @return Maximum charge energy - */ - double getMaxCharge(ItemStack itemStack); - - /** - * Get the item's tier, lower tiers can't send energy to higher ones. - * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. - * - * @return Item's tier - */ - int getTier(ItemStack itemStack); - - /** - * Get the item's transfer limit in EU per transfer operation. - * - * @return Transfer limit - */ - double getTransferLimit(ItemStack itemStack); -} - diff --git a/src/main/java/ic2/api/item/IElectricItemManager.java b/src/main/java/ic2/api/item/IElectricItemManager.java deleted file mode 100644 index dfadbb26..00000000 --- a/src/main/java/ic2/api/item/IElectricItemManager.java +++ /dev/null @@ -1,93 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; - -/** - * This interface specifies a manager to handle the various tasks for electric items. - * - * The default implementation does the following: - * - store and retrieve the charge - * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account - * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) - * - update and manage the damage value for the visual charge indicator - * - * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the - * default implementations through ElectricItem.rawManager. The default implementation is designed - * to minimize its dependency on its own constraints/structure and delegates most work back to the - * more atomic features in the gateway manager. - */ -public interface IElectricItemManager { - /** - * Charge an item with a specified amount of energy. - * - * @param itemStack electric item's stack - * @param amount amount of energy to charge in EU - * @param tier tier of the charging device, has to be at least as high as the item to charge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param simulate don't actually change the item, just determine the return value - * @return Energy transferred into the electric item - */ - double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); - - /** - * Discharge an item by a specified amount of energy - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param tier tier of the discharging device, has to be at least as high as the item to discharge - * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() - * @param externally use the supplied item externally, i.e. to power something else as if it was a battery - * @param simulate don't actually discharge the item, just determine the return value - * @return Energy retrieved from the electric item - */ - double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); - - /** - * Determine the charge level for the specified item. - * - * @param itemStack ItemStack containing the electric item - * @return charge level in EU - */ - double getCharge(ItemStack stack); - - /** - * Determine if the specified electric item has at least a specific amount of EU. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * BatPacks are not taken into account. - * - * @param itemStack electric item's stack - * @param amount minimum amount of energy required - * @return true if there's enough energy - */ - boolean canUse(ItemStack stack, double amount); - - /** - * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU - * @param entity entity holding the item - * @return true if the operation succeeded - */ - boolean use(ItemStack stack, double amount, EntityLivingBase entity); - - /** - * Charge an item from the BatPack a player is wearing. - * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. - * use() already contains this functionality. - * - * @param itemStack electric item's stack - * @param entity entity holding the item - */ - void chargeFromArmor(ItemStack stack, EntityLivingBase entity); - - /** - * Get the tool tip to display for electric items. - * - * @param itemStack ItemStack to determine the tooltip for - * @return tool tip string or null for none - */ - String getToolTip(ItemStack stack); -} diff --git a/src/main/java/ic2/api/item/IKineticWindRotor.java b/src/main/java/ic2/api/item/IKineticWindRotor.java deleted file mode 100644 index 62f1fdc3..00000000 --- a/src/main/java/ic2/api/item/IKineticWindRotor.java +++ /dev/null @@ -1,15 +0,0 @@ -package ic2.api.item; - -import net.minecraft.util.ResourceLocation; - -public interface IKineticWindRotor { - public int getDiameter(); - - public ResourceLocation getRotorRenderTexture(); - - public float getefficiency(); - - int getminWindStrength(); - - int getmaxWindStrength(); -} diff --git a/src/main/java/ic2/api/item/IMetalArmor.java b/src/main/java/ic2/api/item/IMetalArmor.java deleted file mode 100644 index 16ffd24e..00000000 --- a/src/main/java/ic2/api/item/IMetalArmor.java +++ /dev/null @@ -1,20 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Armor items implementing this can be considered metal armor. - * - * Currently used for determining which boots can be used to slide up a magnetic pole. - */ -public interface IMetalArmor { - /** - * Determine if the given armor piece is metal armor. - * - * @param itemstack Armor piece as worn by the player - * @param player The player - * @return Whether the armor piece is metal armor - */ - public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player); -} diff --git a/src/main/java/ic2/api/item/ISpecialElectricItem.java b/src/main/java/ic2/api/item/ISpecialElectricItem.java deleted file mode 100644 index a7302f53..00000000 --- a/src/main/java/ic2/api/item/ISpecialElectricItem.java +++ /dev/null @@ -1,13 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; - -public interface ISpecialElectricItem extends IElectricItem { - /** - * Supply a custom IElectricItemManager. - * - * @param itemStack ItemStack to get the manager for - * @return IElectricItemManager instance - */ - IElectricItemManager getManager(ItemStack itemStack); -} diff --git a/src/main/java/ic2/api/item/ITerraformingBP.java b/src/main/java/ic2/api/item/ITerraformingBP.java deleted file mode 100644 index 59b46bae..00000000 --- a/src/main/java/ic2/api/item/ITerraformingBP.java +++ /dev/null @@ -1,34 +0,0 @@ -package ic2.api.item; - -import net.minecraft.world.World; - -/** - * Allows an item to act as a terraformer blueprint. - */ -public interface ITerraformingBP { - /** - * Get the energy consumption per operation of the blueprint. - * - * @return Energy consumption in EU - */ - public abstract int getConsume(); - - /** - * Get the maximum range of the blueprint. - * Should be a divisor of 5. - * - * @return Maximum range in blocks - */ - public abstract int getRange(); - - /** - * Perform the terraforming operation. - * - * @param world world to terraform - * @param x X position to terraform - * @param z Z position to terraform - * @param yCoord Y position of the terraformer - * @return Whether the operation was successful and the terraformer should consume energy. - */ - public abstract boolean terraform(World world, int x, int z, int yCoord); -} diff --git a/src/main/java/ic2/api/item/ItemWrapper.java b/src/main/java/ic2/api/item/ItemWrapper.java deleted file mode 100644 index 58f80734..00000000 --- a/src/main/java/ic2/api/item/ItemWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -package ic2.api.item; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - -/** - * Wrapper for inserting interfaces into items you don't own. - * - * @author Richard - */ -public class ItemWrapper { - private static final Multimap boxableItems = ArrayListMultimap.create(); - private static final Multimap metalArmorItems = ArrayListMultimap.create(); - - public static void registerBoxable(Item item, IBoxable boxable) { - boxableItems.put(item, boxable); - } - - public static boolean canBeStoredInToolbox(ItemStack stack) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IBoxable boxable : boxableItems.get(item)) { - if (boxable.canBeStoredInToolbox(stack)) return true; - } - - if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true; - - return false; - } - - public static void registerMetalArmor(Item item, IMetalArmor armor) { - metalArmorItems.put(item, armor); - } - - public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) { - Item item = stack.getItem(); - // use customs first to allow for overriding behavior - for (IMetalArmor metalArmor : metalArmorItems.get(item)) { - if (metalArmor.isMetalArmor(stack, player)) return true; - } - - if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true; - - return false; - } -} diff --git a/src/main/java/ic2/api/item/package-info.java b/src/main/java/ic2/api/item/package-info.java deleted file mode 100644 index 44ecdce9..00000000 --- a/src/main/java/ic2/api/item/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.item; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/network/INetworkItemEventListener.java b/src/main/java/ic2/api/network/INetworkItemEventListener.java deleted file mode 100644 index 5f3228ce..00000000 --- a/src/main/java/ic2/api/network/INetworkItemEventListener.java +++ /dev/null @@ -1,19 +0,0 @@ -package ic2.api.network; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Allows an item to receive network events received from the server. - */ -public interface INetworkItemEventListener { - /** - * Called when a network event is received. - * - * @param itemStack item stack - * @param player player containing the item - * @param event event ID - */ - void onNetworkEvent(ItemStack stack, EntityPlayer player, int event); -} - diff --git a/src/main/java/ic2/api/network/INetworkUpdateListener.java b/src/main/java/ic2/api/network/INetworkUpdateListener.java deleted file mode 100644 index 09414ae3..00000000 --- a/src/main/java/ic2/api/network/INetworkUpdateListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package ic2.api.network; - -/** - * Allows a tile entity to receive field sync updates received from the server. - */ -public interface INetworkUpdateListener { - /** - * Called when a field is synchronized. - * - * @param field field synchronized - */ - void onNetworkUpdate(String field); -} - diff --git a/src/main/java/ic2/api/network/NetworkHelper.java b/src/main/java/ic2/api/network/NetworkHelper.java deleted file mode 100644 index 5f9138d3..00000000 --- a/src/main/java/ic2/api/network/NetworkHelper.java +++ /dev/null @@ -1,194 +0,0 @@ -package ic2.api.network; - -import java.lang.reflect.Method; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -/** - * Provides methods to initiate events and synchronize tile entity fields in SMP. - * - * The methods are transparent between singleplayer and multiplayer - if a method is called in - * singleplayer, the associated callback will be locally executed. The implementation is different - * between the client and server versions of IC2. - * - * You'll usually want to use the server->client methods defined here to synchronize information - * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or - * producing effects. Anything which is only visible inside the GUI should be synchronized through - * the Container class associated to the GUI in Container.updateProgressBar(). - */ -public final class NetworkHelper { - // server -> client - - - /** - * Schedule a TileEntity's field to be updated to the clients in range. - * - * The updater will query the field's value during the next update, updates happen usually - * every 2 ticks. If low latency is important use initiateTileEntityEvent instead. - * - * IC2's network updates have to get triggered every time, it doesn't continuously poll/send - * the field value. Just call updateTileEntityField after every change to a field which needs - * network synchronization. - * - * The following field data types are currently supported: - * - int, int[], short, short[], byte, byte[], long, long[] - * - float, float[], double, double[] - * - boolean, boolean[] - * - String, String[] - * - ItemStack - * - NBTBase (includes NBTTagCompound) - * - Block, Item, Achievement, Potion, Enchantment - * - ChunkCoordinates, ChunkCoordIntPair - * - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world) - * - World (does not sync the actual world, instead looks up the world by its dimension ID) - * - * Once the update has been processed by the client, it'll call onNetworkUpdate on the client- - * side TileEntity if it implements INetworkUpdateListener. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkUpdateListener.onNetworkUpdate (if implemented by the te). - * - * @param te TileEntity to update - * @param field Name of the field to update - */ - public static void updateTileEntityField(TileEntity te, String field) { - try { - if (NetworkManager_updateTileEntityField == null) NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class); - if (instance == null) instance = getInstance(); - - NetworkManager_updateTileEntityField.invoke(instance, te, field); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified TileEntity to the clients in range. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te). - * - * @param te TileEntity to notify, should implement INetworkTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) { - try { - if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified Item to the clients in range. - * - * The item should implement INetworkItemEventListener to receive the event. - * - * If this method is being executed on the client (i.e. Singleplayer), it'll just call - * INetworkItemEventListener.onNetworkEvent (if implemented by the item). - * - * @param player EntityPlayer holding the item - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - * @param limitRange Limit the notification range to (currently) 20 blocks instead of the - * tracking distance if true - */ - public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) { - try { - if (NetworkManager_initiateItemEvent == null) NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - - // client -> server - - /** - * Immediately send an event for the specified TileEntity to the server. - * - * This method doesn't do anything if executed on the server. - * - * @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientTileEntityEvent(TileEntity te, int event) { - try { - if (NetworkManager_initiateClientTileEntityEvent == null) NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Immediately send an event for the specified Item to the clients in range. - * - * The item should implement INetworkItemEventListener to receive the event. - * - * This method doesn't do anything if executed on the server. - * - * @param itemStack ItemStack containing the item - * @param event Arbitrary integer to represent the event, choosing the values is up to you - */ - public static void initiateClientItemEvent(ItemStack itemStack, int event) { - try { - if (NetworkManager_initiateClientItemEvent == null) NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE); - if (instance == null) instance = getInstance(); - - NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = NetworkHelper.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.network".length()); - } - - return "ic2"; - } - - /** - * Get the NetworkManager instance, used internally. - * - * @return NetworkManager instance - */ - private static Object getInstance() { - try { - return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - - private static Object instance; - private static Method NetworkManager_updateTileEntityField; - private static Method NetworkManager_initiateTileEntityEvent; - private static Method NetworkManager_initiateItemEvent; - private static Method NetworkManager_initiateClientTileEntityEvent; - private static Method NetworkManager_initiateClientItemEvent; -} - diff --git a/src/main/java/ic2/api/network/package-info.java b/src/main/java/ic2/api/network/package-info.java deleted file mode 100644 index 25ea29e1..00000000 --- a/src/main/java/ic2/api/network/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.network; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/package-info.java b/src/main/java/ic2/api/package-info.java deleted file mode 100644 index e6f15228..00000000 --- a/src/main/java/ic2/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/reactor/IReactor.java b/src/main/java/ic2/api/reactor/IReactor.java deleted file mode 100644 index 55191ccf..00000000 --- a/src/main/java/ic2/api/reactor/IReactor.java +++ /dev/null @@ -1,158 +0,0 @@ -package ic2.api.reactor; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - -/** - * Interface implemented by the tile entity of nuclear reactors. - */ -public interface IReactor { - /** - * Get the reactor's position in the world. - * - * @return Position of the reactor - */ - public ChunkCoordinates getPosition(); - - /** - * Get the reactor's corresponding world. - * - * @return The reactor's world - */ - public World getWorld(); - - /** - * Get the reactor's heat. - * - * @return The reactor's heat - */ - public int getHeat(); - - /** - * Set the reactor's heat. - * - * @param heat reactor heat - */ - public void setHeat(int heat); - - /** - * Increase the reactor's heat. - * - * Use negative values to decrease. - * - * @param amount amount of heat to add - * @return The reactor's heat after adding the specified amount - */ - public int addHeat(int amount); - - /** - * Get the reactor's maximum heat before exploding. - * - * @return Maximum heat value - */ - public int getMaxHeat(); - - /** - * Set the reactor's stored maxHeat variable. - * Used by plating to increase the reactors MaxHeat capacity. - * Needs to be called during each cycle process. - */ - public void setMaxHeat(int newMaxHeat); - - /** - * add Heat to a EmitHeat Buffer - * for use in Reactor operation.. need to be use - * for all Componetents with self-cooling - * no more magic heat disappear - */ - - - public void addEmitHeat(int heat); - - /** - * Get's the reactor's HEM (Heat Effect Modifier) - * Basic value is 1.0F. - * Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors - * (F.e. water evaporation, melting, damaging entitys, etc) - * - * @return HEM - */ - public float getHeatEffectModifier(); - - /** - * Set's the reactor's HEM - * Needs to be called during each cycle process. - */ - public void setHeatEffectModifier(float newHEM); - - /** - * Get the reactor's energy output. - * - * @return Energy output, not multiplied by the base EU/t value - */ - public float getReactorEnergyOutput(); - - /** - * Get the reactor's energy output. - * - * @return Energy output, multiplied with base EU/t value and MainConfig.get().getFloat("balance/energy/generator/nuclear") - */ - public double getReactorEUEnergyOutput(); - - /** - * Add's the given amount of energy to the Reactor's output. - * - * @return Energy output after adding the value, not multiplied by the base EU/t value - */ - public float addOutput(float energy); - - /** - * Get the item at the specified grid coordinates. - * - * @param x X position of the item, out of bounds returns null - * @param y Y position of the item, out of bounds returns null - * @return The item or null if there is no item - */ - public ItemStack getItemAt(int x, int y); - - /** - * Set the item at the specified grid coordinates. - * - * @param x X position of the item, out of bounds is a no-op - * @param y Y position of the item, out of bounds is a no-op - * @param item The item to set. - */ - public void setItemAt(int x, int y, ItemStack item); - - /** - * Explode the reactor. - */ - public void explode(); - - /** - * Get the reactor's tick rate (game ticks per reactor tick). - * - * @return Tick rate - */ - public int getTickRate(); - - /** - * Get whether the reactor is active and supposed to produce energy - * @return Whether the reactor is active - */ - public boolean produceEnergy(); - - /** - * Set Redstone Signal without direct contact - * - */ - - public void setRedstoneSignal(boolean redstone); - - /** - * @return true if the reactor is FluidCooled - */ - - public boolean isFluidCooled(); -} diff --git a/src/main/java/ic2/api/reactor/IReactorChamber.java b/src/main/java/ic2/api/reactor/IReactorChamber.java deleted file mode 100644 index 4611a6af..00000000 --- a/src/main/java/ic2/api/reactor/IReactorChamber.java +++ /dev/null @@ -1,20 +0,0 @@ -package ic2.api.reactor; - -/** - * Interface implemented by the reactor chamber tile entity. - */ -public interface IReactorChamber { - /** - * Get the chamber's reactor. - * - * @return The reactor - */ - public IReactor getReactor(); - - /** - * Set Redstone Signal without direct contact - * - */ - - public void setRedstoneSignal(boolean redstone); -} diff --git a/src/main/java/ic2/api/reactor/IReactorComponent.java b/src/main/java/ic2/api/reactor/IReactorComponent.java deleted file mode 100644 index 84e011c7..00000000 --- a/src/main/java/ic2/api/reactor/IReactorComponent.java +++ /dev/null @@ -1,98 +0,0 @@ -package ic2.api.reactor; - -import net.minecraft.item.ItemStack; - -/** - * Design custom Reactor components by implementing this Interface - * Items implementing the interface will not be ejected from Reactors in their clean-up - * and can/will be interacted with by other elements, f.e. Uranium Cells. - * - * All IC2 ReactorComponents implement and use this Interface - * - */ -public interface IReactorComponent { - /** - * Called by reactor upon iterating through it's inventory (every cycle). - * Perform all necessary calculation/interaction here - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @param heatrun every Stack will cycle 2 time (true, false) first run for heat, sec for Eu calculation - */ - public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y, boolean heatrun); - - /** - * Can be called by Uranium-Components who attempt to generate energy by pulsing to other components. - * Uranium-Uranium interaction (f.e.) uses this method. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of called ItemStack - * @param pulsingStack Reference to the specific instance of pulsing ItemStack - * @param youX X-coordinate of your stack in the grid - * @param youY Y-coordinate of your stack in the grid - * @param pulseX X-coordinate of pulsing stack in the grid - * @param pulseY Y-coordinate of pulsing stack in the grid - * @param heatrun true for only create heat not EU, false for only EU not heat - * @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat) - */ - public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); - - /** - * Called by components to determine whether your component can be heated. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return true if your component can take heat - */ - public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the maximum capacity of your heat-containing component here. - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Maximum heat - */ - public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by heat-switches to determine how much heat to distribute into which direction. - * Please return the current amount of heat stored in this component - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @return Current Heat - */ - public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y); - - /** - * Called by components to distribute heat to your component. - * Perform heating-calculations and increase your heat (dmg) level accordingly. - * This method will as well be called to REDUCE heat, by providing a negative amount. - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @param x X-coordinate of the stack in the grid - * @param y Y-coordinate of the stack in the grid - * @param heat Amount of heat to be added (may be negative to subtract heat) - * @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0) - */ - public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat); - - /** - * Called upon reactor explosion - * Alter the explosion size. - * Returning a float 0 < f < 1 will be counted as multiplier. - * Anything else will be counted as a flat addition (in case of <0 = reduction). - * - * @param reactor Reference to the Reactor - * @param yourStack Reference to the specific instance of iterated ItemStack - * @return your explosion modifier - */ - public float influenceExplosion(IReactor reactor, ItemStack yourStack); -} diff --git a/src/main/java/ic2/api/reactor/package-info.java b/src/main/java/ic2/api/reactor/package-info.java deleted file mode 100644 index 5194aee0..00000000 --- a/src/main/java/ic2/api/reactor/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.reactor; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java b/src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java deleted file mode 100644 index 415b3c38..00000000 --- a/src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java +++ /dev/null @@ -1,51 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraft.item.ItemStack; - -public interface ICannerBottleRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param container Container to be filled - * @param fill Item to fill into the container - * @param output Filled container - */ - public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output); - - /** - * Gets the recipe output for the given input. - * - * @param container Container to be filled - * @param fill Item to fill into the container - * @param adjustInput modify the input according to the recipe's requirements - * @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe - * @return Recipe output, or null if none - */ - public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest); - - /** - * Gets a list of recipes. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); - - - public static class Input { - public Input(IRecipeInput container1, IRecipeInput fill1) { - this.container = container1; - this.fill = fill1; - } - - public boolean matches(ItemStack container1, ItemStack fill1) { - return this.container.matches(container1) && this.fill.matches(fill1); - } - - public final IRecipeInput container; - public final IRecipeInput fill; - } -} diff --git a/src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java deleted file mode 100644 index 5eba1b68..00000000 --- a/src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -public interface ICannerEnrichRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param input Fluid input - * @param additive Item to enrich the fluid with - * @param output Output fluid - */ - public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output); - - /** - * Gets the recipe output for the given input. - * - * @param input Fluid input - * @param additive Item to enrich the fluid with - * @param adjustInput modify the input according to the recipe's requirements - * @param acceptTest allow input or additive to be null to see if either of them is part of a recipe - * @return Recipe output, or null if none, output fluid in nbt - */ - public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest); - - /** - * Gets a list of recipes. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); - - - public static class Input { - public Input(FluidStack fluid1, IRecipeInput additive1) { - this.fluid = fluid1; - this.additive = additive1; - } - - public boolean matches(FluidStack fluid1, ItemStack additive1) { - return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) && - this.additive.matches(additive1); - } - - public final FluidStack fluid; - public final IRecipeInput additive; - } -} diff --git a/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java b/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java deleted file mode 100644 index 756eaf63..00000000 --- a/src/main/java/ic2/api/recipe/ICraftingRecipeManager.java +++ /dev/null @@ -1,26 +0,0 @@ -package ic2.api.recipe; - -import net.minecraft.item.ItemStack; - -/** - * Recipe manager interface for crafting recipes. - * - * @author Richard - */ -public interface ICraftingRecipeManager { - /** - * Adds a shaped crafting recipe. - * - * @param output Recipe output - * @param input Recipe input format - */ - public void addRecipe(ItemStack output, Object... input); - - /** - * Adds a shapeless crafting recipe. - * - * @param output Recipe output - * @param input Recipe input - */ - public void addShapelessRecipe(ItemStack output, Object... input); -} diff --git a/src/main/java/ic2/api/recipe/IFluidHeatManager.java b/src/main/java/ic2/api/recipe/IFluidHeatManager.java deleted file mode 100644 index 7ddecdce..00000000 --- a/src/main/java/ic2/api/recipe/IFluidHeatManager.java +++ /dev/null @@ -1,32 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraftforge.fluids.Fluid; - - -public interface IFluidHeatManager extends ILiquidAcceptManager { - /** - * Add a new fluid to the Fluid Heat Generator. - * - * @param fluidName the fluid to burn - * @param amount amount of fluid to consume per tick - * @param heat amount of heat generated per tick - */ - void addFluid(String fluidName, int amount, int heat); - - BurnProperty getBurnProperty(Fluid fluid); - - Map getBurnProperties(); - - - public static class BurnProperty { - public BurnProperty(int amount1, int heat1) { - this.amount = amount1; - this.heat = heat1; - } - - public final int amount; - public final int heat; - } -} diff --git a/src/main/java/ic2/api/recipe/IListRecipeManager.java b/src/main/java/ic2/api/recipe/IListRecipeManager.java deleted file mode 100644 index adc22912..00000000 --- a/src/main/java/ic2/api/recipe/IListRecipeManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package ic2.api.recipe; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * Recipe manager interface for basic lists. - * - * @author Richard - */ -public interface IListRecipeManager extends Iterable { - /** - * Adds a stack to the list. - * - * @param stack Stack to add - */ - public void add(IRecipeInput input); - - /** - * Checks whether the specified stack is in the list. - * - * @param stack Stack to check - * @return Whether the stack is in the list - */ - public boolean contains(ItemStack stack); - - /** - * @return if the List is Empty - */ - public boolean isEmpty(); - - /** - * Gets the list of stacks. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of stacks - */ - public List getInputs(); -} diff --git a/src/main/java/ic2/api/recipe/IMachineRecipeManager.java b/src/main/java/ic2/api/recipe/IMachineRecipeManager.java deleted file mode 100644 index 388e394a..00000000 --- a/src/main/java/ic2/api/recipe/IMachineRecipeManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -/** - * Recipe manager interface for basic machines. - * - * @author RichardG, Player - */ -public interface IMachineRecipeManager { - /** - * Adds a recipe to the machine. - * - * @param input Recipe input - * @param metadata meta data for additional recipe properties, may be null - * @param outputs Recipe outputs, zero or more depending on the machine - * - * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} - * For the ore washing plant @param metadata meta data {"amount": 1-8000} - * - */ - public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); - - /** - * Gets the recipe output for the given input. - * - * @param input Recipe input - * @param adjustInput modify the input according to the recipe's requirements - * @return Recipe output, or null if none - */ - public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); - - /** - * Gets a list of recipes. - * - * You're a mad evil scientist if you ever modify this. - * - * @return List of recipes - */ - public Map getRecipes(); -} diff --git a/src/main/java/ic2/api/recipe/IRecipeInput.java b/src/main/java/ic2/api/recipe/IRecipeInput.java deleted file mode 100644 index 0c842d63..00000000 --- a/src/main/java/ic2/api/recipe/IRecipeInput.java +++ /dev/null @@ -1,31 +0,0 @@ -package ic2.api.recipe; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -public interface IRecipeInput { - /** - * Check if subject matches this recipe input, ignoring the amount. - * - * @param subject ItemStack to check - * @return true if it matches the requirement - */ - boolean matches(ItemStack subject); - - /** - * Determine the minimum input stack size. - * - * @return input amount required - */ - int getAmount(); - - /** - * List all possible inputs (best effort). - * - * The stack size is undefined, use getAmount to get the correct one. - * - * @return list of inputs, may be incomplete - */ - List getInputs(); -} diff --git a/src/main/java/ic2/api/recipe/IScrapboxManager.java b/src/main/java/ic2/api/recipe/IScrapboxManager.java deleted file mode 100644 index 41b694dc..00000000 --- a/src/main/java/ic2/api/recipe/IScrapboxManager.java +++ /dev/null @@ -1,13 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraft.item.ItemStack; - -public interface IScrapboxManager { - void addDrop(ItemStack drop, float rawChance); - - ItemStack getDrop(ItemStack input, boolean adjustInput); - - Map getDrops(); -} diff --git a/src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java deleted file mode 100644 index 87c34270..00000000 --- a/src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java +++ /dev/null @@ -1,32 +0,0 @@ -package ic2.api.recipe; - -import java.util.Map; - -import net.minecraftforge.fluids.Fluid; - - -public interface ISemiFluidFuelManager extends ILiquidAcceptManager { - /** - * Add a new fluid to the semi fluid generator. - * - * @param fluidName the fluid to burn - * @param amount amount of fluid to consume per tick - * @param power amount of energy generated per tick - */ - void addFluid(String fluidName, int amount, double power); - - BurnProperty getBurnProperty(Fluid fluid); - - Map getBurnProperties(); - - - public static class BurnProperty { - public BurnProperty(int amount1, double power1) { - this.amount = amount1; - this.power = power1; - } - - public final int amount; - public final double power; - } -} diff --git a/src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java deleted file mode 100644 index 103d293e..00000000 --- a/src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java +++ /dev/null @@ -1,54 +0,0 @@ -package ic2.api.recipe; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; - -public class RecipeInputFluidContainer implements IRecipeInput { - public RecipeInputFluidContainer(Fluid fluid) { - this(fluid, FluidContainerRegistry.BUCKET_VOLUME); - } - - public RecipeInputFluidContainer(Fluid fluid, int amount) { - this.fluid = fluid; - this.amount = amount; - } - - @Override - public boolean matches(ItemStack subject) { - FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); - if (fs == null) return false; - - return fs.getFluid() == fluid; - } - - @Override - public int getAmount() { - return amount; - } - - @Override - public List getInputs() { - List ret = new ArrayList(); - - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); - } - - return ret; - } - - @Override - public String toString() { - return "RInputFluidContainer<"+amount+"x"+fluid.getName()+">"; - } - - public final Fluid fluid; - public final int amount; -} diff --git a/src/main/java/ic2/api/recipe/RecipeInputItemStack.java b/src/main/java/ic2/api/recipe/RecipeInputItemStack.java deleted file mode 100644 index e1b65f94..00000000 --- a/src/main/java/ic2/api/recipe/RecipeInputItemStack.java +++ /dev/null @@ -1,46 +0,0 @@ -package ic2.api.recipe; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.oredict.OreDictionary; - -public class RecipeInputItemStack implements IRecipeInput { - public RecipeInputItemStack(ItemStack aInput) { - this(aInput, aInput.stackSize); - } - - public RecipeInputItemStack(ItemStack aInput, int aAmount) { - if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); - - input = aInput.copy(); // Never forget to copy. - amount = aAmount; - } - - @Override - public boolean matches(ItemStack subject) { - return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); - } - - @Override - public int getAmount() { - return amount; - } - - @Override - public List getInputs() { - return Arrays.asList(input); - } - - @Override - public String toString() { - ItemStack stack = input.copy(); - input.stackSize = amount; - return "RInputItemStack<"+stack+">"; - } - - public final ItemStack input; - public final int amount; -} diff --git a/src/main/java/ic2/api/recipe/RecipeInputOreDict.java b/src/main/java/ic2/api/recipe/RecipeInputOreDict.java deleted file mode 100644 index 89f73dc2..00000000 --- a/src/main/java/ic2/api/recipe/RecipeInputOreDict.java +++ /dev/null @@ -1,71 +0,0 @@ -package ic2.api.recipe; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.oredict.OreDictionary; - -public class RecipeInputOreDict implements IRecipeInput { - public RecipeInputOreDict(String input1) { - this(input1, 1); - } - - public RecipeInputOreDict(String input1, int amount1) { - this(input1, amount1, null); - } - - public RecipeInputOreDict(String input1, int amount1, Integer meta) { - this.input = input1; - this.amount = amount1; - this.meta = meta; - } - - @Override - public boolean matches(ItemStack subject) { - List inputs = OreDictionary.getOres(input); - - for (ItemStack input1 : inputs) { - if (input1.getItem() == null) continue; // ignore invalid - int metaRequired = meta == null ? input1.getItemDamage() : meta; - - if (subject.getItem() == input1.getItem() && - (subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) { - return true; - } - } - - return false; - } - - @Override - public int getAmount() { - return amount; - } - - @Override - public List getInputs() { - List ores = OreDictionary.getOres(input); - List ret = new ArrayList(ores.size()); - - for (ItemStack stack : ores) { - if (stack.getItem() != null) ret.add(stack); // ignore invalid - } - - return ret; - } - - @Override - public String toString() { - if (meta == null) { - return "RInputOreDict<"+amount+"x"+input+">"; - } else { - return "RInputOreDict<"+amount+"x"+input+"@"+meta+">"; - } - } - - public final String input; - public final int amount; - public final Integer meta; -} diff --git a/src/main/java/ic2/api/recipe/RecipeOutput.java b/src/main/java/ic2/api/recipe/RecipeOutput.java deleted file mode 100644 index 867cfa25..00000000 --- a/src/main/java/ic2/api/recipe/RecipeOutput.java +++ /dev/null @@ -1,28 +0,0 @@ -package ic2.api.recipe; - -import java.util.Arrays; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public final class RecipeOutput { - public RecipeOutput(NBTTagCompound metadata1, List items1) { - assert !items1.contains(null); - - this.metadata = metadata1; - this.items = items1; - } - - public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) { - this(metadata1, Arrays.asList(items1)); - } - - @Override - public String toString() { - return "ROutput<"+items+","+metadata+">"; - } - - public final List items; - public final NBTTagCompound metadata; -} diff --git a/src/main/java/ic2/api/recipe/Recipes.java b/src/main/java/ic2/api/recipe/Recipes.java deleted file mode 100644 index 4c125976..00000000 --- a/src/main/java/ic2/api/recipe/Recipes.java +++ /dev/null @@ -1,60 +0,0 @@ -package ic2.api.recipe; - - -/** - * General recipe registry. - * - * @author Richard - */ -public class Recipes { - public static IMachineRecipeManager macerator; - public static IMachineRecipeManager extractor; - public static IMachineRecipeManager compressor; - public static IMachineRecipeManager centrifuge; - public static IMachineRecipeManager blockcutter; - public static IMachineRecipeManager blastfurance; - public static IMachineRecipeManager recycler; - public static IMachineRecipeManager metalformerExtruding; - public static IMachineRecipeManager metalformerCutting; - public static IMachineRecipeManager metalformerRolling; - public static IMachineRecipeManager oreWashing; - public static ICannerBottleRecipeManager cannerBottle; - public static ICannerEnrichRecipeManager cannerEnrich; - - /** - * Reference amplifier values: - * - * 5000: Scrap - * 45000: Scrapbox - * - * As Parameter for the Amplification Value you have to use the NBTTagCompound - * - * NBTTagCompound nbt = new NBTTagCompound(); - * nbt.setInteger("amplification", aValue); - * matterAmplifier.addRecipe(yourStack, nbt); - */ - public static IMachineRecipeManager matterAmplifier; - /** - * Reference scrap box chance values: - * - * 0.1: Diamond - * 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore - * 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone - * 1.5: Apple, Bread - * 2.0: Netherrack, Rotten Flesh - * 3.0: Grass, Gravel - * 4.0: Stick - * 5.0: Dirt, Wooden Hoe - */ - public static IScrapboxManager scrapboxDrops; - public static IListRecipeManager recyclerBlacklist; - /** - * Do not add anything to this Whitelist. This is for Configuration only. - * You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List - */ - public static IListRecipeManager recyclerWhitelist; - public static ICraftingRecipeManager advRecipes; - - public static ISemiFluidFuelManager semiFluidGenerator; - public static IFluidHeatManager FluidHeatGenerator; -} diff --git a/src/main/java/ic2/api/recipe/package-info.java b/src/main/java/ic2/api/recipe/package-info.java deleted file mode 100644 index 44e70e79..00000000 --- a/src/main/java/ic2/api/recipe/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.recipe; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/tile/ExplosionWhitelist.java b/src/main/java/ic2/api/tile/ExplosionWhitelist.java deleted file mode 100644 index fa4a474a..00000000 --- a/src/main/java/ic2/api/tile/ExplosionWhitelist.java +++ /dev/null @@ -1,47 +0,0 @@ -package ic2.api.tile; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.block.Block; - -/** - * Blocks on this whitelist will not resist an explosion but won't be destroyed. - * - * The explosion code by default ignores blocks which absorb more than 1000 explosion power to - * prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and - * invulnerable reactor chambers. Said blocks will not shield the explosion and won't get - * destroyed. - */ -public final class ExplosionWhitelist { - /** - * Add a block to the whitelist. - * - * @param block block to add - */ - public static void addWhitelistedBlock(Block block) { - whitelist.add(block); - } - - /** - * Remove a block from the whitelist. - * - * @param block block to remove - */ - public static void removeWhitelistedBlock(Block block) { - whitelist.remove(block); - } - - /** - * Check if a block is on the whitelist. - * - * @param block block to check if whitelisted - * @return Whether the block is whitelisted - */ - public static boolean isBlockWhitelisted(Block block) { - return whitelist.contains(block); - } - - private static Set whitelist = new HashSet(); -} - diff --git a/src/main/java/ic2/api/tile/IEnergyStorage.java b/src/main/java/ic2/api/tile/IEnergyStorage.java deleted file mode 100644 index 68f42703..00000000 --- a/src/main/java/ic2/api/tile/IEnergyStorage.java +++ /dev/null @@ -1,61 +0,0 @@ -package ic2.api.tile; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Interface implemented by the tile entity of energy storage blocks. - */ -public interface IEnergyStorage { - /** - * Get the amount of energy currently stored in the block. - * - * @return Energy stored in the block - */ - public int getStored(); - - /** - * Set the amount of energy currently stored in the block. - * - * @param energy stored energy - */ - public void setStored(int energy); - - /** - * Add the specified amount of energy. - * - * Use negative values to decrease. - * - * @param amount of energy to add - * @return Energy stored in the block after adding the specified amount - */ - public int addEnergy(int amount); - - /** - * Get the maximum amount of energy the block can store. - * - * @return Maximum energy stored - */ - public int getCapacity(); - - /** - * Get the block's energy output. - * - * @return Energy output in EU/t - */ - public int getOutput(); - - /** - * Get the block's energy output. - * - * @return Energy output in EU/t - */ - public double getOutputEnergyUnitsPerTick(); - - /** - * Get whether this block can have its energy used by an adjacent teleporter. - * - * @param side side the teleporter is draining energy from - * @return Whether the block is teleporter compatible - */ - public boolean isTeleporterCompatible(ForgeDirection side); -} diff --git a/src/main/java/ic2/api/tile/IWrenchable.java b/src/main/java/ic2/api/tile/IWrenchable.java deleted file mode 100644 index 8fcbea59..00000000 --- a/src/main/java/ic2/api/tile/IWrenchable.java +++ /dev/null @@ -1,61 +0,0 @@ -package ic2.api.tile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * Allows a tile entity to make use of the wrench's removal and rotation functions. - */ -public interface IWrenchable { - /** - * Determine if the wrench can be used to set the block's facing. - * Called before wrenchCanRemove(). - * - * @param entityPlayer player using the wrench, may be null - * @param side block's side the wrench was clicked on - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); - - /** - * Get the block's facing. - * - * @return Block facing - */ - short getFacing(); - - /** - * Set the block's facing - * - * @param facing facing to set the block to - */ - void setFacing(short facing); - - /** - * Determine if the wrench can be used to remove the block. - * Called if wrenchSetFacing fails. - * - * @param entityPlayer player using the wrench, may be null - * @return Whether the wrenching was done and the wrench should be damaged - */ - boolean wrenchCanRemove(EntityPlayer entityPlayer); - - /** - * Determine the probability to drop the block as it is. - * The first entry in getDrops will be replaced by blockid:meta if the drop is successful. - * - * @return Probability from 0 to 1 - */ - float getWrenchDropRate(); - - /** - * Determine the item the block will drop when the wrenching is successful. - * - * The ItemStack will be copied before creating the EntityItem. - * - * @param entityPlayer player using the wrench, may be null - * @return ItemStack to drop, may be null - */ - ItemStack getWrenchDrop(EntityPlayer entityPlayer); -} - diff --git a/src/main/java/ic2/api/tile/package-info.java b/src/main/java/ic2/api/tile/package-info.java deleted file mode 100644 index 5ebc76e2..00000000 --- a/src/main/java/ic2/api/tile/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.tile; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/ic2/api/util/IKeyboard.java b/src/main/java/ic2/api/util/IKeyboard.java deleted file mode 100644 index ff6eaea5..00000000 --- a/src/main/java/ic2/api/util/IKeyboard.java +++ /dev/null @@ -1,14 +0,0 @@ -package ic2.api.util; - -import net.minecraft.entity.player.EntityPlayer; - -public interface IKeyboard { - boolean isAltKeyDown(EntityPlayer player); - boolean isBoostKeyDown(EntityPlayer player); - boolean isForwardKeyDown(EntityPlayer player); - boolean isJumpKeyDown(EntityPlayer player); - boolean isModeSwitchKeyDown(EntityPlayer player); - boolean isSideinventoryKeyDown(EntityPlayer player); - boolean isHudModeKeyDown(EntityPlayer player); - boolean isSneakKeyDown(EntityPlayer player); -} diff --git a/src/main/java/ic2/api/util/package-info.java b/src/main/java/ic2/api/util/package-info.java deleted file mode 100644 index 4dd2d93b..00000000 --- a/src/main/java/ic2/api/util/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.util; -import cpw.mods.fml.common.API; - diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index e9a946fb..6b6a086b 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -24,7 +24,6 @@ import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; -import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.player.EntityPlayer; @@ -33,7 +32,6 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -46,19 +44,19 @@ import thaumcraft.api.aspects.IEssentiaTransport; import thaumic.tinkerer.common.compat.IndustrialcraftUnloadHelper; import thaumic.tinkerer.common.lib.LibFeatures; -@Optional.InterfaceList({ @Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), - @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), +@Optional.InterfaceList({@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), + @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), - @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API")}) + @Optional.Interface(iface = "IEnergySink", modid = "IC2API")}) public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { public boolean addedToICEnergyNet = false; - @Override - public void updateEntity() { - /* if(worldObj.getTotalWorldTime()%100==0) + @Override + public void updateEntity() { + /* if(worldObj.getTotalWorldTime()%100==0) { worldObj.notifyBlockChange(xCoord,yCoord,zCoord,worldObj.getBlockId(xCoord,yCoord,zCoord)); } @@ -66,12 +64,12 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); addedToICEnergyNet = true; }*/ - } + } - @Override - public int getMaxDistance() { - return LibFeatures.INTERFACE_DISTANCE; - } + @Override + public int getMaxDistance() { + return LibFeatures.INTERFACE_DISTANCE; + } @Override public void invalidate() { @@ -79,180 +77,180 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } super.invalidate(); - } + } - @Override - public void onChunkUnload() { + @Override + public void onChunkUnload() { if (Loader.isModLoaded("IC2API")) { IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } } - @Override - public void markDirty() { - super.markDirty(); - TileEntity tile = getTile(); - if (tile != null) - tile.markDirty(); - } + @Override + public void markDirty() { + super.markDirty(); + TileEntity tile = getTile(); + if (tile != null) + tile.markDirty(); + } - @Override - public int getSizeInventory() { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).getSizeInventory() : 0; - } + @Override + public int getSizeInventory() { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).getSizeInventory() : 0; + } - @Override - public ItemStack getStackInSlot(int i) { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).getStackInSlot(i) : null; - } + @Override + public ItemStack getStackInSlot(int i) { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).getStackInSlot(i) : null; + } - @Override - public ItemStack decrStackSize(int i, int j) { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).decrStackSize(i, j) : null; - } + @Override + public ItemStack decrStackSize(int i, int j) { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).decrStackSize(i, j) : null; + } - @Override - public ItemStack getStackInSlotOnClosing(int i) { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).getStackInSlotOnClosing(i) : null; - } + @Override + public ItemStack getStackInSlotOnClosing(int i) { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).getStackInSlotOnClosing(i) : null; + } - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) { - TileEntity tile = getTile(); - if (tile instanceof IInventory) - ((IInventory) tile).setInventorySlotContents(i, itemstack); - } + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + TileEntity tile = getTile(); + if (tile instanceof IInventory) + ((IInventory) tile).setInventorySlotContents(i, itemstack); + } - @Override - public String getInventoryName() { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).getInventoryName() : ""; - } + @Override + public String getInventoryName() { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).getInventoryName() : ""; + } - @Override - public boolean hasCustomInventoryName() { - TileEntity tile = getTile(); - return tile instanceof IInventory && ((IInventory) tile).hasCustomInventoryName(); - } + @Override + public boolean hasCustomInventoryName() { + TileEntity tile = getTile(); + return tile instanceof IInventory && ((IInventory) tile).hasCustomInventoryName(); + } - @Override - public int getInventoryStackLimit() { - TileEntity tile = getTile(); - return tile instanceof IInventory ? ((IInventory) tile).getInventoryStackLimit() : 0; - } + @Override + public int getInventoryStackLimit() { + TileEntity tile = getTile(); + return tile instanceof IInventory ? ((IInventory) tile).getInventoryStackLimit() : 0; + } - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - TileEntity tile = getTile(); - return tile instanceof IInventory && ((IInventory) tile).isUseableByPlayer(entityplayer); - } + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + TileEntity tile = getTile(); + return tile instanceof IInventory && ((IInventory) tile).isUseableByPlayer(entityplayer); + } - @Override - public void openInventory() { - TileEntity tile = getTile(); - if (tile instanceof IInventory) - ((IInventory) tile).openInventory(); - } + @Override + public void openInventory() { + TileEntity tile = getTile(); + if (tile instanceof IInventory) + ((IInventory) tile).openInventory(); + } - @Override - public void closeInventory() { - TileEntity tile = getTile(); - if (tile instanceof IInventory) - ((IInventory) tile).closeInventory(); - } + @Override + public void closeInventory() { + TileEntity tile = getTile(); + if (tile instanceof IInventory) + ((IInventory) tile).closeInventory(); + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - TileEntity tile = getTile(); - return tile instanceof IInventory && ((IInventory) tile).isItemValidForSlot(i, itemstack); - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + TileEntity tile = getTile(); + return tile instanceof IInventory && ((IInventory) tile).isItemValidForSlot(i, itemstack); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler ? ((IFluidHandler) tile).fill(from, resource, doFill) : 0; - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler ? ((IFluidHandler) tile).fill(from, resource, doFill) : 0; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, resource, doDrain) : null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, resource, doDrain) : null; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, maxDrain, doDrain) : null; - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler ? ((IFluidHandler) tile).drain(from, maxDrain, doDrain) : null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler && ((IFluidHandler) tile).canFill(from, fluid); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler && ((IFluidHandler) tile).canFill(from, fluid); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler && ((IFluidHandler) tile).canDrain(from, fluid); - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler && ((IFluidHandler) tile).canDrain(from, fluid); + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) { - TileEntity tile = getTile(); - return tile instanceof IFluidHandler ? ((IFluidHandler) tile).getTankInfo(from) : null; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + TileEntity tile = getTile(); + return tile instanceof IFluidHandler ? ((IFluidHandler) tile).getTankInfo(from) : null; + } - @Override - public int[] getAccessibleSlotsFromSide(int var1) { - TileEntity tile = getTile(); - return tile instanceof ISidedInventory ? ((ISidedInventory) tile).getAccessibleSlotsFromSide(var1) : tile instanceof IInventory ? buildSlotsForLinearInventory((IInventory) tile) : new int[0]; - } + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + TileEntity tile = getTile(); + return tile instanceof ISidedInventory ? ((ISidedInventory) tile).getAccessibleSlotsFromSide(var1) : tile instanceof IInventory ? buildSlotsForLinearInventory((IInventory) tile) : new int[0]; + } - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) { - TileEntity tile = getTile(); - return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canInsertItem(i, itemstack, j) : tile instanceof IInventory; - } + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + TileEntity tile = getTile(); + return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canInsertItem(i, itemstack, j) : tile instanceof IInventory; + } - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) { - TileEntity tile = getTile(); - return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canExtractItem(i, itemstack, j) : tile instanceof IInventory; - } + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + TileEntity tile = getTile(); + return tile instanceof ISidedInventory ? ((ISidedInventory) tile).canExtractItem(i, itemstack, j) : tile instanceof IInventory; + } - public static int[] buildSlotsForLinearInventory(IInventory inv) { - int[] slots = new int[inv.getSizeInventory()]; - for (int i = 0; i < slots.length; i++) - slots[i] = i; + public static int[] buildSlotsForLinearInventory(IInventory inv) { + int[] slots = new int[inv.getSizeInventory()]; + for (int i = 0; i < slots.length; i++) + slots[i] = i; - return slots; - } + return slots; + } - @Override - @Optional.Method(modid = "BuildCraft|Energy") - public PowerReceiver getPowerReceiver(ForgeDirection side) { - TileEntity tile = getTile(); - return tile instanceof IPowerReceptor ? ((IPowerReceptor) tile).getPowerReceiver(side) : null; - } + @Override + @Optional.Method(modid = "BuildCraft|Energy") + public PowerReceiver getPowerReceiver(ForgeDirection side) { + TileEntity tile = getTile(); + return tile instanceof IPowerReceptor ? ((IPowerReceptor) tile).getPowerReceiver(side) : null; + } - @Override - @Optional.Method(modid = "BuildCraft|Energy") - public void doWork(PowerHandler workProvider) { - TileEntity tile = getTile(); - if (tile instanceof IPowerReceptor) - ((IPowerReceptor) tile).doWork(workProvider); - } + @Override + @Optional.Method(modid = "BuildCraft|Energy") + public void doWork(PowerHandler workProvider) { + TileEntity tile = getTile(); + if (tile instanceof IPowerReceptor) + ((IPowerReceptor) tile).doWork(workProvider); + } - @Override - public World getWorld() { - return worldObj; - } + @Override + public World getWorld() { + return worldObj; + } @Optional.Method(modid = "IC2API") @Override @@ -281,33 +279,33 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override @Optional.Method(modid = "CoFHLib") - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - TileEntity tile = getTile(); - return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).receiveEnergy(from, maxReceive, simulate) : 0; - } + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + TileEntity tile = getTile(); + return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).receiveEnergy(from, maxReceive, simulate) : 0; + } - @Override + @Override @Optional.Method(modid = "CoFHLib") - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - TileEntity tile = getTile(); - return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).extractEnergy(from, maxExtract, simulate) : 0; - } + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + TileEntity tile = getTile(); + return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).extractEnergy(from, maxExtract, simulate) : 0; + } - - @Override + @Override @Optional.Method(modid = "CoFHLib") - public int getEnergyStored(ForgeDirection from) { - TileEntity tile = getTile(); - return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getEnergyStored(from) : 0; - } + public int getEnergyStored(ForgeDirection from) { + TileEntity tile = getTile(); + return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getEnergyStored(from) : 0; + } - @Override + @Override @Optional.Method(modid = "CoFHLib") - public int getMaxEnergyStored(ForgeDirection from) { - TileEntity tile = getTile(); - return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getMaxEnergyStored(from) : 0; - } + public int getMaxEnergyStored(ForgeDirection from) { + TileEntity tile = getTile(); + return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).getMaxEnergyStored(from) : 0; + } + @Override @Optional.Method(modid = "CoFHLib") public boolean canConnectEnergy(ForgeDirection from) { @@ -315,171 +313,171 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI return tile instanceof IEnergyHandler ? ((IEnergyHandler) tile).canConnectEnergy(from) : false; } - @Override - public AspectList getAspects() { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer ? ((IAspectContainer) tile).getAspects() : null; - } + @Override + public AspectList getAspects() { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer ? ((IAspectContainer) tile).getAspects() : null; + } - @Override - public void setAspects(AspectList paramAspectList) { - TileEntity tile = getTile(); - if (tile != null) - ((IAspectContainer) tile).setAspects(paramAspectList); - } + @Override + public void setAspects(AspectList paramAspectList) { + TileEntity tile = getTile(); + if (tile != null) + ((IAspectContainer) tile).setAspects(paramAspectList); + } - @Override - public boolean doesContainerAccept(Aspect paramAspect) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerAccept(paramAspect); - } + @Override + public boolean doesContainerAccept(Aspect paramAspect) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerAccept(paramAspect); + } - @Override - public int addToContainer(Aspect paramAspect, int paramInt) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer ? ((IAspectContainer) tile).addToContainer(paramAspect, paramInt) : 0; - } + @Override + public int addToContainer(Aspect paramAspect, int paramInt) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer ? ((IAspectContainer) tile).addToContainer(paramAspect, paramInt) : 0; + } - @Override - public boolean takeFromContainer(Aspect paramAspect, int paramInt) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer && ((IAspectContainer) tile).takeFromContainer(paramAspect, paramInt); - } + @Override + public boolean takeFromContainer(Aspect paramAspect, int paramInt) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer && ((IAspectContainer) tile).takeFromContainer(paramAspect, paramInt); + } - @Override - public boolean takeFromContainer(AspectList paramAspectList) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer && ((IAspectContainer) tile).takeFromContainer(paramAspectList); - } + @Override + public boolean takeFromContainer(AspectList paramAspectList) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer && ((IAspectContainer) tile).takeFromContainer(paramAspectList); + } - @Override - public boolean doesContainerContainAmount(Aspect paramAspect, int paramInt) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerContainAmount(paramAspect, paramInt); - } + @Override + public boolean doesContainerContainAmount(Aspect paramAspect, int paramInt) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerContainAmount(paramAspect, paramInt); + } - @Override - public boolean doesContainerContain(AspectList paramAspectList) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerContain(paramAspectList); - } + @Override + public boolean doesContainerContain(AspectList paramAspectList) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer && ((IAspectContainer) tile).doesContainerContain(paramAspectList); + } - @Override - public int containerContains(Aspect paramAspect) { - TileEntity tile = getTile(); - return tile instanceof IAspectContainer ? ((IAspectContainer) tile).containerContains(paramAspect) : 0; - } + @Override + public int containerContains(Aspect paramAspect) { + TileEntity tile = getTile(); + return tile instanceof IAspectContainer ? ((IAspectContainer) tile).containerContains(paramAspect) : 0; + } - @Override - public boolean isConnectable(ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).isConnectable(forgeDirection); - } + @Override + public boolean isConnectable(ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).isConnectable(forgeDirection); + } - @Override - public boolean canInputFrom(ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).canInputFrom(forgeDirection); - } + @Override + public boolean canInputFrom(ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).canInputFrom(forgeDirection); + } - @Override - public boolean canOutputTo(ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).canOutputTo(forgeDirection); - } + @Override + public boolean canOutputTo(ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport && ((IEssentiaTransport) tile).canOutputTo(forgeDirection); + } - @Override - public void setSuction(Aspect paramAspect, int paramInt) { - TileEntity tile = getTile(); - if (tile instanceof IEssentiaTransport) - ((IEssentiaTransport) tile).setSuction(paramAspect, paramInt); - } + @Override + public void setSuction(Aspect paramAspect, int paramInt) { + TileEntity tile = getTile(); + if (tile instanceof IEssentiaTransport) + ((IEssentiaTransport) tile).setSuction(paramAspect, paramInt); + } - @Override - public Aspect getSuctionType(ForgeDirection forgeDirection) { - return null; - } + @Override + public Aspect getSuctionType(ForgeDirection forgeDirection) { + return null; + } - @Override - public int getSuctionAmount(ForgeDirection forgeDirection) { - return 0; - } + @Override + public int getSuctionAmount(ForgeDirection forgeDirection) { + return 0; + } - @Override - public int takeEssentia(Aspect paramAspect, int paramInt, ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).takeEssentia(paramAspect, paramInt, forgeDirection) : 0; - } + @Override + public int takeEssentia(Aspect paramAspect, int paramInt, ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).takeEssentia(paramAspect, paramInt, forgeDirection) : 0; + } - @Override - public int getMinimumSuction() { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getMinimumSuction() : 0; - } + @Override + public int getMinimumSuction() { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getMinimumSuction() : 0; + } - @Override - public boolean renderExtendedTube() { - return false; - } + @Override + public boolean renderExtendedTube() { + return false; + } - @Override - public int addEssentia(Aspect arg0, int arg1, ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).addEssentia(arg0, arg1, forgeDirection) : 0; - } + @Override + public int addEssentia(Aspect arg0, int arg1, ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).addEssentia(arg0, arg1, forgeDirection) : 0; + } - @Override - public Aspect getEssentiaType(ForgeDirection forgeDirection) { + @Override + public Aspect getEssentiaType(ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getEssentiaType(forgeDirection) : null; - } + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getEssentiaType(forgeDirection) : null; + } - @Override - public int getEssentiaAmount(ForgeDirection forgeDirection) { - TileEntity tile = getTile(); - return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getEssentiaAmount(forgeDirection) : 0; - } + @Override + public int getEssentiaAmount(ForgeDirection forgeDirection) { + TileEntity tile = getTile(); + return tile instanceof IEssentiaTransport ? ((IEssentiaTransport) tile).getEssentiaAmount(forgeDirection) : 0; + } - @Override - @Optional.Method(modid = "ComputerCraft") - public String getType() { - return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).getType() : "Transvector Interface Unconnected Peripherad"; - } + @Override + @Optional.Method(modid = "ComputerCraft") + public String getType() { + return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).getType() : "Transvector Interface Unconnected Peripherad"; + } - @Override - @Optional.Method(modid = "ComputerCraft") - public String[] getMethodNames() { - return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).getMethodNames() : new String[0]; - } + @Override + @Optional.Method(modid = "ComputerCraft") + public String[] getMethodNames() { + return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).getMethodNames() : new String[0]; + } - @Override - @Optional.Method(modid = "ComputerCraft") - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { - return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).callMethod(computer, context, method, arguments) : new Object[0]; - } + @Override + @Optional.Method(modid = "ComputerCraft") + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { + return getTile() instanceof IPeripheral ? ((IPeripheral) getTile()).callMethod(computer, context, method, arguments) : new Object[0]; + } - @Override + @Override - public void attach(IComputerAccess computer) { - if (getTile() instanceof IPeripheral) { - ((IPeripheral) getTile()).attach(computer); - } - } + public void attach(IComputerAccess computer) { + if (getTile() instanceof IPeripheral) { + ((IPeripheral) getTile()).attach(computer); + } + } - @Override - @Optional.Method(modid = "ComputerCraft") - public void detach(IComputerAccess computer) { - if (getTile() instanceof IPeripheral) { - ((IPeripheral) getTile()).detach(computer); - } - } + @Override + @Optional.Method(modid = "ComputerCraft") + public void detach(IComputerAccess computer) { + if (getTile() instanceof IPeripheral) { + ((IPeripheral) getTile()).detach(computer); + } + } - @Override - @Optional.Method(modid = "ComputerCraft") - public boolean equals(IPeripheral other) { - return this.equals((Object) other); - } + @Override + @Optional.Method(modid = "ComputerCraft") + public boolean equals(IPeripheral other) { + return this.equals((Object) other); + } @Override diff --git a/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java index 6e95db23..49c62ed7 100644 --- a/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java +++ b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java @@ -2,7 +2,6 @@ package thaumic.tinkerer.common.compat; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; -import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import thaumic.tinkerer.common.block.tile.transvector.TileTransvectorInterface; From a4415ae83862d256f1de3c0b71bc677b9e8681b8 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:29:47 -0400 Subject: [PATCH 20/26] added @Optional to acceptsEnergyFrom --- .../common/block/tile/transvector/TileTransvectorInterface.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 6b6a086b..29b6427a 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -480,6 +480,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } + @Optional.Method(modid = "IC2API") @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { TileEntity tile = getTile(); From cc44bf7c2556606b7b9211291ccc71b20738ee34 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Tue, 26 Aug 2014 18:47:59 -0400 Subject: [PATCH 21/26] Made @Optional depend on "IC2" instead of "IC2API" --- .../tile/transvector/TileTransvectorInterface.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 29b6427a..75cce812 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -47,7 +47,7 @@ import thaumic.tinkerer.common.lib.LibFeatures; @Optional.InterfaceList({@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), - @Optional.Interface(iface = "IEnergySink", modid = "IC2API")}) + @Optional.Interface(iface = "IEnergySink", modid = "IC2")}) public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { @@ -73,7 +73,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void invalidate() { - if (Loader.isModLoaded("IC2API")) { + if (Loader.isModLoaded("IC2")) { IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } super.invalidate(); @@ -82,7 +82,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void onChunkUnload() { - if (Loader.isModLoaded("IC2API")) { + if (Loader.isModLoaded("IC2")) { IndustrialcraftUnloadHelper.removeFromIC2EnergyNet(this); } } @@ -252,7 +252,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI return worldObj; } - @Optional.Method(modid = "IC2API") + @Optional.Method(modid = "IC2") @Override public double getDemandedEnergy() { TileEntity tile = getTile(); @@ -260,7 +260,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } - @Optional.Method(modid = "IC2API") + @Optional.Method(modid = "IC2") @Override public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { @@ -269,7 +269,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } - @Optional.Method(modid = "IC2API") + @Optional.Method(modid = "IC2") @Override public int getSinkTier() { TileEntity tile = getTile(); @@ -480,7 +480,7 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI } - @Optional.Method(modid = "IC2API") + @Optional.Method(modid = "IC2") @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { TileEntity tile = getTile(); From ebbb330fe23b130b0471362cbebdb134ee87fc55 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Wed, 27 Aug 2014 08:04:06 -0400 Subject: [PATCH 22/26] Fixed silly mistake with IC2 api --- .../transvector/TileTransvectorInterface.java | 17 +++++++++-------- .../compat/IndustrialcraftUnloadHelper.java | 5 +++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 75cce812..3f5d6ed1 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -24,6 +24,7 @@ import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; +import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.player.EntityPlayer; @@ -32,6 +33,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -47,7 +49,7 @@ import thaumic.tinkerer.common.lib.LibFeatures; @Optional.InterfaceList({@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft"), @Optional.Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraft|Energy"), @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), - @Optional.Interface(iface = "IEnergySink", modid = "IC2")}) + @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")}) public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { @@ -56,14 +58,13 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI @Override public void updateEntity() { - /* if(worldObj.getTotalWorldTime()%100==0) - { - worldObj.notifyBlockChange(xCoord,yCoord,zCoord,worldObj.getBlockId(xCoord,yCoord,zCoord)); + if (worldObj.getTotalWorldTime() % 100 == 0) { + worldObj.notifyBlockChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); + } + if (!addedToICEnergyNet && !worldObj.isRemote) { + IndustrialcraftUnloadHelper.addToIC2EnergyNet(this); + addedToICEnergyNet = true; } - if(!addedToICEnergyNet && !worldObj.isRemote) { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - addedToICEnergyNet = true; - }*/ } @Override diff --git a/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java index 49c62ed7..308fc227 100644 --- a/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java +++ b/src/main/java/thaumic/tinkerer/common/compat/IndustrialcraftUnloadHelper.java @@ -1,5 +1,6 @@ package thaumic.tinkerer.common.compat; +import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; import net.minecraftforge.common.MinecraftForge; @@ -16,4 +17,8 @@ public class IndustrialcraftUnloadHelper { tileEntity.addedToICEnergyNet = false; } } + + public static void addToIC2EnergyNet(TileTransvectorInterface tileTransvectorInterface) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(tileTransvectorInterface)); + } } From e851cbf73a55807890e47feb59abe374db3745c3 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Wed, 27 Aug 2014 08:27:25 -0400 Subject: [PATCH 23/26] Added IC2 loaded check --- .../block/tile/transvector/TileTransvectorInterface.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index 3f5d6ed1..acb63a8b 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -51,7 +51,6 @@ import thaumic.tinkerer.common.lib.LibFeatures; @Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHLib"), @Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")}) - public class TileTransvectorInterface extends TileTransvector implements ISidedInventory, IEnergySink, IFluidHandler, IPowerReceptor, IEnergyHandler, IAspectContainer, IEssentiaTransport, IPeripheral { public boolean addedToICEnergyNet = false; @@ -61,7 +60,8 @@ public class TileTransvectorInterface extends TileTransvector implements ISidedI if (worldObj.getTotalWorldTime() % 100 == 0) { worldObj.notifyBlockChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); } - if (!addedToICEnergyNet && !worldObj.isRemote) { + if (!addedToICEnergyNet && !worldObj.isRemote && Loader.isModLoaded("IC2")) { + IndustrialcraftUnloadHelper.addToIC2EnergyNet(this); addedToICEnergyNet = true; } From d1dc02134a7c897aa3135a6aec663115b46d081e Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Wed, 27 Aug 2014 08:47:47 -0400 Subject: [PATCH 24/26] Closes #470 --- .../thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java index 8837f858..bbd51e0e 100644 --- a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java +++ b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java @@ -131,6 +131,8 @@ public class ItemGemBoots extends ItemIchorclothArmorAdv { if (!highStepListed && (hasHighStep && ThaumicTinkerer.proxy.armorStatus(player) && player.getCurrentArmor(0).getItemDamage() == 0)) playersWith1Step.add(player.getGameProfile().getName()); + player.stepHeight = 1F; + if ((!hasHighStep || !ThaumicTinkerer.proxy.armorStatus(player) || player.getCurrentArmor(0).getItemDamage() == 1) && highStepListed) { playersWith1Step.remove(player.getGameProfile().getName()); From 1c81f4cb2a81a62dcf920c9f42908dd39cba32a9 Mon Sep 17 00:00:00 2001 From: Pixlepix Date: Wed, 27 Aug 2014 12:39:52 -0400 Subject: [PATCH 25/26] Added registration to TileCamo. Closes #471 --- .../java/thaumic/tinkerer/common/block/BlockPlatform.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/BlockPlatform.java b/src/main/java/thaumic/tinkerer/common/block/BlockPlatform.java index 587640a4..f7a1000c 100644 --- a/src/main/java/thaumic/tinkerer/common/block/BlockPlatform.java +++ b/src/main/java/thaumic/tinkerer/common/block/BlockPlatform.java @@ -92,8 +92,8 @@ public class BlockPlatform extends BlockCamo { @Override public Class getTileEntity() { - return null; - } + return TileCamo.class; + } @Override public IRegisterableResearch getResearchItem() { From 5b2c1e0d84980a1e82f6a6a25dc46b90bda27aed Mon Sep 17 00:00:00 2001 From: nekosune Date: Wed, 27 Aug 2014 17:42:20 +0100 Subject: [PATCH 26/26] Fixed Fix for #470 And made enchant not work on gem boots --- .../tile/transvector/TileTransvectorInterface.java | 1 - .../common/enchantment/EnchantmentShockwave.java | 13 ++++++++++++- .../common/item/kami/armor/ItemGemBoots.java | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java index acb63a8b..a3d0f6e6 100644 --- a/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java +++ b/src/main/java/thaumic/tinkerer/common/block/tile/transvector/TileTransvectorInterface.java @@ -24,7 +24,6 @@ import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; -import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/thaumic/tinkerer/common/enchantment/EnchantmentShockwave.java b/src/main/java/thaumic/tinkerer/common/enchantment/EnchantmentShockwave.java index de9fcbd1..9e50fa55 100644 --- a/src/main/java/thaumic/tinkerer/common/enchantment/EnchantmentShockwave.java +++ b/src/main/java/thaumic/tinkerer/common/enchantment/EnchantmentShockwave.java @@ -2,13 +2,24 @@ package thaumic.tinkerer.common.enchantment; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnumEnchantmentType; +import net.minecraft.item.ItemStack; +import thaumic.tinkerer.common.ThaumicTinkerer; +import thaumic.tinkerer.common.item.kami.armor.ItemGemBoots; +import thaumic.tinkerer.common.registry.TTRegistry; public class EnchantmentShockwave extends EnchantmentMod { public EnchantmentShockwave(int par1) { super(par1, 5, EnumEnchantmentType.armor_feet); } - @Override + @Override + public boolean canApply(ItemStack p_92089_1_) { + + return (p_92089_1_.getItem() == ThaumicTinkerer.registry.getFirstItemFromClass(ItemGemBoots.class))?false:super.canApply(p_92089_1_); + + } + + @Override public boolean canApplyTogether(Enchantment par1Enchantment) { return par1Enchantment.effectId != Enchantment.featherFalling.effectId && par1Enchantment.effectId != ModEnchantments.slowFall.effectId && super.canApplyTogether(par1Enchantment); } diff --git a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java index bbd51e0e..b8d2c8f6 100644 --- a/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java +++ b/src/main/java/thaumic/tinkerer/common/item/kami/armor/ItemGemBoots.java @@ -131,7 +131,6 @@ public class ItemGemBoots extends ItemIchorclothArmorAdv { if (!highStepListed && (hasHighStep && ThaumicTinkerer.proxy.armorStatus(player) && player.getCurrentArmor(0).getItemDamage() == 0)) playersWith1Step.add(player.getGameProfile().getName()); - player.stepHeight = 1F; if ((!hasHighStep || !ThaumicTinkerer.proxy.armorStatus(player) || player.getCurrentArmor(0).getItemDamage() == 1) && highStepListed) {