diff --git a/src/api/java/ic2/api/Direction.class b/src/api/java/ic2/api/Direction.class deleted file mode 100644 index 937799309..000000000 Binary files a/src/api/java/ic2/api/Direction.class and /dev/null differ diff --git a/src/api/java/ic2/api/crops/BaseSeed.class b/src/api/java/ic2/api/crops/BaseSeed.class index fd4b77b55..988c7c665 100644 Binary files a/src/api/java/ic2/api/crops/BaseSeed.class and b/src/api/java/ic2/api/crops/BaseSeed.class differ diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java index 89e7865fa..8770bcfcf 100644 --- a/src/api/java/ic2/api/crops/BaseSeed.java +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -9,16 +9,14 @@ public class BaseSeed { * * @param crop plant * @param size plant size - * @param statGrowth1 plant growth stat - * @param statGain1 plant gain stat - * @param statResistance1 plant resistance stat - * @param stackSize1 for internal usage only + * @param statGrowth plant growth stat + * @param statGain plant gain stat + * @param statResistance plant resistance stat + * @param stackSize for internal usage only */ - @SuppressWarnings("deprecation") public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) { super(); this.crop = crop; - this.id = Crops.instance.getIdFor(crop); this.size = size; this.statGrowth = statGrowth; this.statGain = statGain; @@ -26,35 +24,11 @@ public class BaseSeed { this.stackSize = stackSize; } - /** - * @deprecated Use the CropCard version. - */ - @Deprecated - public BaseSeed(int id, int size, int statGrowth, int statGain, int statResistance, int stackSize) { - this(getCropFromId(id), size, statGrowth, statGain, statResistance, stackSize); - } - - @SuppressWarnings("deprecation") - private static CropCard getCropFromId(int id) { - CropCard[] crops = Crops.instance.getCropList(); - - if (id < 0 || id >= crops.length) return null; - - return crops[id]; - } - - /** * Plant. */ public final CropCard crop; - /** - * @deprecated IDs aren't used anymore. - */ - @Deprecated - public int id; - /** * Plant size. */ diff --git a/src/api/java/ic2/api/crops/CropCard.class b/src/api/java/ic2/api/crops/CropCard.class index e117b0c95..ed102068e 100644 Binary files a/src/api/java/ic2/api/crops/CropCard.class and b/src/api/java/ic2/api/crops/CropCard.class differ diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java index 6afb26d24..347803a8d 100644 --- a/src/api/java/ic2/api/crops/CropCard.java +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -1,11 +1,15 @@ package ic2.api.crops; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; /** * Base agriculture crop. @@ -14,7 +18,6 @@ import net.minecraftforge.fml.common.ModContainer; */ public abstract class CropCard { public CropCard() { - modId = getModId(); // initialize mod id while we should be in the real owner's init event } /** @@ -27,20 +30,19 @@ public abstract class CropCard { * * @return Plant name */ - public abstract String name(); + public abstract String getName(); /** * Determine the mod id owning this crop. * - * It's recommended to hard code this to your mod id. + * The owner serves as a name space. With every mod using a different owner, a mod only has to + * make sure it doesn't have conflicts with name() in itself. + * It's recommended to hard code this to your mod id as specified in the @Mod annotation. + * Do not use IC2's mod id here. * * @note changing name or owner will cause existing crops in users' worlds to disappear. - * - * @return Mod id. */ - public String owner() { - return modId; - } + public abstract String getOwner(); /** * Translation key for display to the player. @@ -51,8 +53,8 @@ public abstract class CropCard { * * @return Unlocalized name. */ - public String displayName() { - return name(); // return the raw name for backwards compatibility + public String getDisplayName() { + return getName(); // return the raw name for backwards compatibility } /** @@ -60,7 +62,7 @@ public abstract class CropCard { * * @return Your name */ - public String discoveredBy() { + public String getDiscoveredBy() { return "unknown"; } @@ -72,7 +74,7 @@ public abstract class CropCard { * @return The line */ public String desc(int i) { - String[] att = attributes(); + String[] att = getAttributes(); if (att == null || att.length == 0) return ""; @@ -91,37 +93,18 @@ public abstract class CropCard { } /** - * * - * @param crop reference to ICropTile - * @return roots lengt use in isBlockBelow + * Crop roots length. Maximum roots length should be 5. + * @param cropTile reference to ICropTile + * @return roots length use in isBlockBelow */ - public int getrootslength(ICropTile crop) { + public int getRootsLength(ICropTile cropTile) { return 1; } /** - * 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 + * Object containing the crop properties info - See ic2.api.crops.CropProperties for more info. */ - 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); + public abstract CropProperties getProperties(); /** * Additional attributes of the plant, also influencing breeding. @@ -129,21 +112,23 @@ public abstract class CropCard { * * @return Attributes as an array of strings */ - public abstract String[] attributes(); + public String[] getAttributes() { + return new String[] {}; + } /** * Determine the max crop size. * * Currently only used for texture allocation. */ - public abstract int maxSize(); + public abstract int getMaxSize(); /** * Amount of growth points needed to increase the plant's size. * Default is 200 * tier. */ - public int growthDuration(ICropTile crop) { - return tier() * 200; + public int getGrowthDuration(ICropTile cropTile) { + return getProperties().getTier() * 200; } /** @@ -157,10 +142,12 @@ public abstract class CropCard { * * 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 + * @param cropTile reference to ICropTile * @return Whether the crop can grow */ - public abstract boolean canGrow(ICropTile crop); + public boolean canGrow(ICropTile cropTile) { + return cropTile.getCurrentSize() < getMaxSize(); + } /** * Calculate the influence for the plant to grow based on humidity, nutrients and air. @@ -175,8 +162,8 @@ public abstract class CropCard { * @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); + public int getWeightInfluences(ICropTile crop, int humidity, int nutrients, int air) { + return humidity + nutrients + air; } /** @@ -186,7 +173,7 @@ public abstract class CropCard { * @param crop crop to crossbreed with */ public boolean canCross(ICropTile crop) { - return crop.getSize() >= 3; + return crop.getCurrentSize() >= 3; } @@ -196,30 +183,34 @@ public abstract class CropCard { * * Only called Serverside. * - * @param crop reference to ICropTile + * @param cropTile 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); + public boolean onRightClick(ICropTile cropTile, EntityPlayer player) { + return cropTile.performManualHarvest(); } /** - * Use in Crop Havester with insert Cropnalyzer to get best Output. + * Use in Crop Harvester with insert Cropnalyzer to get best Output. * - * @param crop reference to ICropTile - * @return need crop size for best output. + * @param cropTile reference to ICropTile + * @return need crop size for best output. */ - public abstract int getOptimalHavestSize(ICropTile crop); + public int getOptimalHarvestSize(ICropTile cropTile) { + return getMaxSize(); + } /** * Check whether the crop can be harvested. * - * @param crop reference to ICropTile + * @param cropTile reference to ICropTile * @return Whether the crop can be harvested in its current state. */ - public abstract boolean canBeHarvested(ICropTile crop); + public boolean canBeHarvested(ICropTile cropTile) { + return cropTile.getCurrentSize() == getMaxSize(); + } /** * Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops. @@ -227,10 +218,8 @@ public abstract class CropCard { * * @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 double dropGainChance() { + return Math.pow(0.95, getProperties().getTier()); } /** @@ -245,24 +234,26 @@ public abstract class CropCard { * Get the size of the plant after harvesting. * Default is 1. * - * @param crop reference to ICropTile + * @param cropTile reference to ICropTile * @return Plant size after harvesting */ - public byte getSizeAfterHarvest(ICropTile crop) {return 1;} + public int getSizeAfterHarvest(ICropTile cropTile) { + return 1; + } /** - * Called when the plant is leftclicked by a player. + * Called when the plant is left clicked by a player. * Default action is picking the plant. * - * Only called Serverside. + * Only called server side. * - * @param crop reference to ICropTile - * @param player player leftclicked the crop + * @param cropTile reference to ICropTile + * @param player player left clicked the crop * @return Whether the plant has changed */ - public boolean leftclick(ICropTile crop, EntityPlayer player) { - return crop.pick(true); + public boolean onLeftClick(ICropTile cropTile, EntityPlayer player) { + return cropTile.pick(); } /** @@ -273,10 +264,12 @@ public abstract class CropCard { * @return Chance to drop the seeds */ public float dropSeedChance(ICropTile crop) { - if (crop.getSize() == 1) return 0; + if (crop.getCurrentSize() == 1) return 0; float base = 0.5F; - if (crop.getSize() == 2) base/=2F; - for (int i = 0; i < tier(); i++) {base*=0.8;} + if (crop.getCurrentSize() == 2) base/=2F; + for (int i = 0; i < getProperties().getTier(); i++) { + base*=0.8; + } return base; } @@ -289,7 +282,7 @@ public abstract class CropCard { * @return Seeds */ public ItemStack getSeeds(ICropTile crop) { - return crop.generateSeeds(crop.getCrop(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel()); + return crop.generateSeeds(crop.getCrop(), crop.getStatGrowth(), crop.getStatGain(), crop.getStatResistance(), crop.getScanLevel()); } /** @@ -302,11 +295,22 @@ public abstract class CropCard { } /** - * Check if the crop should emit redstone. + * Check if the crop emits a redstone signal. * - * @return Whether the crop should emit redstone + * @return Whether the crop emits a redstone signal. */ - public int emitRedstone(ICropTile crop) {return 0;} + public boolean isRedstoneSignalEmitter(ICropTile cropTile) { + return false; + } + + /*** + * Get the emitted redstone signal strength. + * + * @return The redstone signal strength. + */ + public int getEmittedRedstoneSignal(ICropTile cropTile) { + return 0; + } /** * Called when the crop is destroyed. @@ -335,11 +339,7 @@ public abstract class CropCard { * @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; + return (entity instanceof EntityLivingBase && entity.isSprinting()); } @@ -347,9 +347,9 @@ public abstract class CropCard { * Called every time the crop ticks. * Should be called every 256 ticks or around 13 seconds. * - * @param crop reference to ICropTile + * @param cropTile reference to ICropTile */ - public void tick(ICropTile crop) { + public void tick(ICropTile cropTile) { // nothing by default } @@ -357,38 +357,36 @@ public abstract class CropCard { * 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 + * @param cropTile reference to ICropTile * @return Whether the plant spreads weed */ - public boolean isWeed(ICropTile crop) { - return crop.getSize() >= 2 && - (crop == Crops.weed || crop.getGrowth() >= 24); + public boolean isWeed(ICropTile cropTile) { + return cropTile.getCurrentSize() >= 2 && + (cropTile.getCrop() == Crops.weed || cropTile.getStatGrowth() >= 24); } - /** - * Get this plant's ID. - * - * @return ID of this CropCard or -1 if it's not registered - * @deprecated IDs aren't used anymore. + * Retrieve the crop world. + * @param cropTile reference to ICropTile. + * @return The crop world object. */ - @Deprecated - public final int getId() { - return Crops.instance.getIdFor(this); + public World getWorld(ICropTile cropTile) { + return cropTile.getWorld(); } - private static String getModId() { - ModContainer modContainer = Loader.instance().activeModContainer(); + /** + * Retrieve the crop's unlocalized name. + * @return Unlocalized name + */ + public String getUnlocalizedName() { + return "crop." + getName() + ".name"; + } - if (modContainer != null) { - return modContainer.getModId(); - } else { - // this is bad if you are not actually IC2 - assert false; - - return "unknown"; + public List getModelLocation() { + List ret = new ArrayList(); + for (int i = 1; i <= getMaxSize(); i++) { + ret.add(new ResourceLocation(getOwner().toLowerCase(Locale.ENGLISH), "blocks/crop/"+getName()+"_"+i)); } + return ret; } - - private final String modId; // TODO: make owner abstract, remove modId auto detection } diff --git a/src/api/java/ic2/api/crops/CropProperties.class b/src/api/java/ic2/api/crops/CropProperties.class new file mode 100644 index 000000000..31cd7c24f Binary files /dev/null and b/src/api/java/ic2/api/crops/CropProperties.class differ diff --git a/src/api/java/ic2/api/crops/CropProperties.java b/src/api/java/ic2/api/crops/CropProperties.java new file mode 100644 index 000000000..7271461d4 --- /dev/null +++ b/src/api/java/ic2/api/crops/CropProperties.java @@ -0,0 +1,78 @@ +package ic2.api.crops; + +/** + * Describe the plant through a set of properties, influencing breeding. + * Plants sharing properties and attributes will tend to cross-breed more often. + * + * Properties: + * - 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.) + * - Chemistry (Industrial uses based on chemical plant components) + * - Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used) + * - Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general) + * - Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects) + * - Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here) + * + * @author IC2 Team + */ +public class CropProperties { + + /** + * Create a CropProperties object. + * + * @param tier Tier property value + * @param chemistry Chemistry property value + * @param consumable Consumable property value + * @param defensive Defensive property value + * @param colorful Colorful property value + * @param weed Weed property value + */ + public CropProperties(int tier, int chemistry, int consumable, int defensive, + int colorful, int weed) { + this.tier = tier; + this.chemistry = chemistry; + this.consumable = consumable; + this.defensive = defensive; + this.colorful = colorful; + this.weed = weed; + } + + public int getTier() { + return this.tier; + } + + public int getChemistry() { + return this.chemistry; + } + + public int getConsumable() { + return this.consumable; + } + + public int getDefensive() { + return this.defensive; + } + + public int getColorful() { + return this.colorful; + } + + public int getWeed() { + return this.weed; + } + + public int[] getAllProperties() { + return new int[] { this.getChemistry(), this.getConsumable(), this.getDefensive(), + this.getColorful(), this.getWeed() }; + } + + /** + * Fields + */ + private final int tier; + private final int chemistry; + private final int consumable; + private final int defensive; + private final int colorful; + private final int weed; +} diff --git a/src/api/java/ic2/api/crops/Crops.class b/src/api/java/ic2/api/crops/Crops.class index 1844fa959..8e10c6268 100644 Binary files a/src/api/java/ic2/api/crops/Crops.class and b/src/api/java/ic2/api/crops/Crops.class differ diff --git a/src/api/java/ic2/api/crops/Crops.java b/src/api/java/ic2/api/crops/Crops.java index 74dc7f1fb..cfaeb19f1 100644 --- a/src/api/java/ic2/api/crops/Crops.java +++ b/src/api/java/ic2/api/crops/Crops.java @@ -4,6 +4,7 @@ import java.util.Collection; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.Biome; + import net.minecraftforge.common.BiomeDictionary.Type; /** @@ -75,42 +76,18 @@ public abstract class Crops { */ public abstract Collection getCrops(); - /** - * Returns the list of registered crops. - * - * @return Registered crops by ID - */ - @Deprecated - public abstract CropCard[] getCropList(); - - /** - * Register a plant. - * - * @param crop Plant to register. - * @return Autoassigned id for legacy compatibility, TODO: change to void. - */ - public abstract short registerCrop(CropCard crop); - /** * Register a plant and provide a legacy id for migration. * * @param crop Plant to register. - * @param legacyId ID previously used for this crop. - * @return true, TODO: change to void. */ - public abstract boolean registerCrop(CropCard crop, int legacyId); - - /** - * @deprecated use the CropCard version. - */ - @Deprecated - public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); + public abstract void registerCrop(CropCard crop); /** * Registers a base seed, an item used to plant a crop. * * @param stack item - * @param id plant ID + * @param crop crop * @param size initial size * @param growth initial growth stat * @param gain initial gain stat @@ -127,12 +104,10 @@ public abstract class Crops { public abstract BaseSeed getBaseSeed(ItemStack stack); /** - * Returns the ID for the given crop. + * Execute registerSprites for all registered crop cards. * - * @param crop Crop to look up - * @return ID, or -1 if not found - * @deprecated IDs aren't used anymore. + * This method will get called by IC2, don't call it yourself. */ - @Deprecated - public abstract int getIdFor(CropCard crop); + //@SideOnly(Side.CLIENT) + //public abstract void startSpriteRegistration(IIconRegister iconRegister); } diff --git a/src/api/java/ic2/api/crops/ICropSeed.class b/src/api/java/ic2/api/crops/ICropSeed.class new file mode 100644 index 000000000..21e648ea1 Binary files /dev/null and b/src/api/java/ic2/api/crops/ICropSeed.class differ diff --git a/src/api/java/ic2/api/crops/ICropSeed.java b/src/api/java/ic2/api/crops/ICropSeed.java new file mode 100644 index 000000000..8140678b6 --- /dev/null +++ b/src/api/java/ic2/api/crops/ICropSeed.java @@ -0,0 +1,81 @@ +package ic2.api.crops; + +import net.minecraft.item.ItemStack; + +/** + * Interface implemented by ItemCropSeed. + * @author estebes + */ +public interface ICropSeed { + /** + * Get the seed's crop. + * @param itemStack The seed's itemstack. + * @return Seed's crop. + */ + public CropCard getCropFromStack(ItemStack itemStack); + + /** + * Set the seed's crop. + * @param itemStack The seed's itemstack. + * @param crop New CropCard object. + */ + public void setCropFromStack(ItemStack itemStack, CropCard crop); + + /** + * Get the seed's growth. + * @param itemStack The seed's itemstack. + * @return Seed's growth. + */ + public int getGrowthFromStack(ItemStack itemStack); + + /** + * Set the seed's growth. + * @param itemStack The seed's itemstack. + * @param value New growth value. + */ + public void setGrowthFromStack(ItemStack itemStack, int value); + + /** + * Get the seed's gain. + * @param itemStack The seed's itemstack. + * @return Seed's gain. + */ + public int getGainFromStack(ItemStack itemStack); + + /** + * Set the seed's growth. + * @param itemStack The seed's itemstack. + * @param value New growth value. + */ + public void setGainFromStack(ItemStack itemStack, int value); + + /** + * Get the seed's resistance. + * @param itemStack The seed's itemstack. + * @return Seed's resistance. + */ + public int getResistanceFromStack(ItemStack itemStack); + + /** + * Set the seed's resistance. + * @param itemStack The seed's itemstack. + * @param value New resistance value. + */ + public void setResistanceFromStack(ItemStack itemStack, int value); + + /** + * Get the seed's scan level. + * @param itemStack The seed's itemstack. + * @return Seed's scan level. + */ + public int getScannedFromStack(ItemStack itemStack); + + /** + * Set the seed's scan level. + * @param itemStack The seed's itemstack. + * @param value New scan level value. + */ + public void setScannedFromStack(ItemStack itemStack, int value); + + public void incrementScannedFromStack(ItemStack itemStack); +} diff --git a/src/api/java/ic2/api/crops/ICropTile.class b/src/api/java/ic2/api/crops/ICropTile.class index b359a00f9..cc8c4eb01 100644 Binary files a/src/api/java/ic2/api/crops/ICropTile.class and b/src/api/java/ic2/api/crops/ICropTile.class differ diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java index 0d50f8e9a..8df7968d6 100644 --- a/src/api/java/ic2/api/crops/ICropTile.java +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -1,5 +1,7 @@ package ic2.api.crops; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -24,31 +26,19 @@ public interface ICropTile { */ public void setCrop(CropCard cropCard); - /** - * @deprecated IDs have been removed. - */ - @Deprecated - public short getID(); - - /** - * @deprecated IDs have been removed. - */ - @Deprecated - 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(); + public int getCurrentSize(); /** * Set the crop's plant size. * * @param size Plant size */ - public void setSize(byte size); + public void setCurrentSize(int size); /** * Get the crop's plant growth stat. @@ -56,14 +46,14 @@ public interface ICropTile { * * @return Plant growth stat */ - public byte getGrowth(); + public int getStatGrowth(); /** * Set the crop's plant growth stat. * * @param growth Plant growth stat */ - public void setGrowth(byte growth); + public void setStatGrowth(int growth); /** * Get the crop's plant gain stat. @@ -71,14 +61,14 @@ public interface ICropTile { * * @return Plant gain stat */ - public byte getGain(); + public int getStatGain(); /** * Set the crop's plant gain stat. * * @param gain Plant gain stat */ - public void setGain(byte gain); + public void setStatGain(int gain); /** * Get the crop's plant resistance stat. @@ -86,14 +76,58 @@ public interface ICropTile { * * @return Plant resistance stat */ - public byte getResistance(); + public int getStatResistance(); /** * Set the crop's plant resistance stat. * * @param resistance Plant resistance stat */ - public void setResistance(byte resistance); + public void setStatResistance(int resistance); + + /** + * Get the crop's nutrient storage. + * Ranges from 0 to 100. + * + * @return Crop nutrient storage + */ + public int getStorageNutrient(); + + /** + * Set the crop's nutrient storage. + * + * @param storageNutrient Crop nutrient storage + */ + public void setStorageNutrient(int storageNutrient); + + /** + * 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 getStorageWater(); + + /** + * Set the crop's water storage. + * + * @param storageWater Crop water storage + */ + public void setStorageWater(int storageWater); + + /** + * Get the crop's Weed-Ex storage. + * + * @return Crop Weed-Ex storage + */ + public int getStorageWeedEX(); + + /** + * Set the crop's Weed-Ex storage. + * + * @param storageWeedEX Crop Weed-Ex storage + */ + public void setStorageWeedEX(int storageWeedEX); /** * Get the crop's plant scan level. @@ -101,14 +135,22 @@ public interface ICropTile { * * @return Plant scan level */ - public byte getScanLevel(); + public int getScanLevel(); /** * Set the crop's plant scan level. * * @param scanLevel Plant scan level */ - public void setScanLevel(byte scanLevel); + public void setScanLevel(int scanLevel); + + public int getGrowthPoints(); + + public void setGrowthPoints(int growthPoints); + + public boolean isCrossingBase(); + + public void setCrossingBase(boolean crossingBase); /** * Get the crop's plant custom data, stored alongside the crop. @@ -118,50 +160,6 @@ public interface ICropTile { */ 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). @@ -171,7 +169,7 @@ public interface ICropTile { * * @return Crop humidity level */ - public byte getHumidity(); + public int getHumidity(); /** * Get the crop's nutrient level. @@ -182,7 +180,7 @@ public interface ICropTile { * * @return Crop nutrient level */ - public byte getNutrients(); + public int getNutrients(); /** * Get the crop's air quality. @@ -193,7 +191,7 @@ public interface ICropTile { * * @return Crop air quality */ - public byte getAirQuality(); + public int getAirQuality(); /** * Get the crop's world. @@ -219,27 +217,23 @@ public interface ICropTile { /** * 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); + public boolean pick(); /** * 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); + public boolean performManualHarvest(); /** * 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 + * @return List of harvest output */ - ItemStack[] harvest_automated(boolean Optimal); + public List performHarvest(); /** * Fully clears the crop without dropping anything. @@ -253,28 +247,31 @@ public interface ICropTile { /** * 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. + * Searches up to 4 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); + /** + * Check if a block is under the farmland containing the crop. + * Searches up to 4 blocks below the farmland or an air space, whichever appears first. + * + * @param oreDictionaryName blocks to search + * @return Whether the blocks were found + */ + public boolean isBlockBelow(String oreDictionaryName); + /** * Generate plant seeds with the given parameters. * * @param crop plant * @param growth plant growth stat * @param gain plant gain stat - * @param resis plant resistance stat + * @param resistance plant resistance stat * @param scan plant scan level * @return Plant seed item */ - public ItemStack generateSeeds(CropCard crop, byte growth, byte gain, byte resis, byte scan); - - /** - * @deprecated Use the CropCard version instead. - */ - @Deprecated - public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan); + public ItemStack generateSeeds(CropCard crop, int growth, int gain, int resistance, int scan); } diff --git a/src/api/java/ic2/api/crops/package-info.class b/src/api/java/ic2/api/crops/package-info.class index 1c2c0e119..3ca3f3754 100644 Binary files a/src/api/java/ic2/api/crops/package-info.class and b/src/api/java/ic2/api/crops/package-info.class differ diff --git a/src/api/java/ic2/api/energy/IEnergyNet.class b/src/api/java/ic2/api/energy/IEnergyNet.class index 76b574630..1880b7d3e 100644 Binary files a/src/api/java/ic2/api/energy/IEnergyNet.class and b/src/api/java/ic2/api/energy/IEnergyNet.class differ diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java index cee3344d1..fc2dc58a0 100644 --- a/src/api/java/ic2/api/energy/IEnergyNet.java +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -1,76 +1,66 @@ package ic2.api.energy; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import ic2.api.energy.tile.IEnergyTile; + /** * 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 + * Get the EnergyNet-registered tile for the specified position. + * + * The returned tile is always the main tile implementing IEnergySource/-Sink/-Conductor, which + * is also what was registered to the energy net. + * + * For multi-blocks (IMetaDelegate) the connectivity handling is being done by sub tiles that + * may or may not include the main tile. Sub tiles have to be queried separately through the + * getSubTile method. + * + * As a consequence of always returning the main tile, the supplied position may not match the + * returned tile's position. + * + * Connectivity checking -> IEnergyEmitter/IEnergyAcceptor -> getSubTile + * Logic like energy I/O -> IEnergySource/IEnergySink/IEnergyConductor -> getTile + * + * @param world World containing the tile + * @param pos position + * @return main tile for the specified position or null if none is registered */ - TileEntity getTileEntity(World world, BlockPos pos); + IEnergyTile getTile(World world, BlockPos pos); /** - * 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 + * Get the sub tile at the specified position. + * + * See the description of {@link #getTile} about whether getTile or getSubTile is applicable. + * + * @param world World containing the tile + * @param pos position + * @return sub tile at the specified position or null if none is registered */ - TileEntity getNeighbor(TileEntity te, EnumFacing dir); + IEnergyTile getSubTile(World world, BlockPos pos); - /** - * 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); + World getWorld(IEnergyTile tile); - /** - * 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); + BlockPos getPos(IEnergyTile tile); /** * Retrieve statistics for the tile entity specified. - * + * * The statistics apply to the last simulated tick. - * - * @param te Tile entity to check. + * + * @param tile Tile entity to check. * @return Statistics for the tile entity. */ - NodeStats getNodeStats(TileEntity te); + NodeStats getNodeStats(IEnergyTile tile); /** * 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 */ @@ -78,7 +68,7 @@ public interface IEnergyNet { /** * Determine minimum tier required to handle the specified power, e.g. tier 2 for 128 eu/t. - * + * * @param power in eu/t * @return tier */ diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.class b/src/api/java/ic2/api/energy/event/EnergyTileEvent.class index 25e3e25e4..5d1523da6 100644 Binary files a/src/api/java/ic2/api/energy/event/EnergyTileEvent.class and b/src/api/java/ic2/api/energy/event/EnergyTileEvent.class differ diff --git a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java index 5c8cc094b..2bb1ac960 100644 --- a/src/api/java/ic2/api/energy/event/EnergyTileEvent.java +++ b/src/api/java/ic2/api/energy/event/EnergyTileEvent.java @@ -1,23 +1,24 @@ package ic2.api.energy.event; -import ic2.api.energy.tile.IEnergyTile; -import net.minecraft.tileentity.TileEntity; import net.minecraftforge.event.world.WorldEvent; +import ic2.api.energy.EnergyNet; +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).getWorld()); + public EnergyTileEvent(IEnergyTile tile) { + super(EnergyNet.instance.getWorld(tile)); if (getWorld() == null) throw new NullPointerException("world is null"); - this.energyTile = energyTile1; + this.tile = tile; } + + public final IEnergyTile tile; } diff --git a/src/api/java/ic2/api/energy/event/package-info.class b/src/api/java/ic2/api/energy/event/package-info.class index fc279ec0f..1b070c88f 100644 Binary files a/src/api/java/ic2/api/energy/event/package-info.class and b/src/api/java/ic2/api/energy/event/package-info.class differ diff --git a/src/api/java/ic2/api/energy/package-info.class b/src/api/java/ic2/api/energy/package-info.class index baaed208f..68a0db695 100644 Binary files a/src/api/java/ic2/api/energy/package-info.class and b/src/api/java/ic2/api/energy/package-info.class differ diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.class b/src/api/java/ic2/api/energy/prefab/BasicSink.class index b0b895ce0..35d58ecb5 100644 Binary files a/src/api/java/ic2/api/energy/prefab/BasicSink.class and b/src/api/java/ic2/api/energy/prefab/BasicSink.class differ 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 000000000..70c29fb63 --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSink.java @@ -0,0 +1,374 @@ +package ic2.api.energy.prefab; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.FMLCommonHandler; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyEmitter; +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 update() { + * ic2EnergySink.update(); // 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, ITickable { + // ********************************** + // *** 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 update(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void update() { + 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 && + !parent.getWorld().isRemote && + Info.isIc2Available()) { + worldObj = parent.getWorld(); + pos = parent.getPos(); + + 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 NBTTagCompound 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); + + return tag; + } + + // << 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 onupdate() { + update(); + } + + @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(IEnergyEmitter emitter, EnumFacing direction) { + return true; + } + + @Override + public double getDemandedEnergy() { + return Math.max(0, capacity - energyStored); + } + + @Override + public double injectEnergy(EnumFacing 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.class b/src/api/java/ic2/api/energy/prefab/BasicSource.class index 164213b2c..1ac62875a 100644 Binary files a/src/api/java/ic2/api/energy/prefab/BasicSource.class and b/src/api/java/ic2/api/energy/prefab/BasicSource.class differ 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 000000000..9715cd4bd --- /dev/null +++ b/src/api/java/ic2/api/energy/prefab/BasicSource.java @@ -0,0 +1,376 @@ +package ic2.api.energy.prefab; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.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.IEnergyAcceptor; +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 update() { + * ic2EnergySource.update(); // 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, ITickable { + // ********************************** + // *** 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 update(), used for creating the energy net link. + * Either updateEntity or onLoaded have to be used. + */ + @Override + public void update() { + 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 && + !parent.getWorld().isRemote && + Info.isIc2Available()) { + worldObj = parent.getWorld(); + pos = parent.getPos(); + + 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 NBTTagCompound 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); + + return tag; + } + + // << 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 onupdate() { + update(); + } + + @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(IEnergyAcceptor receiver, EnumFacing 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.class b/src/api/java/ic2/api/energy/prefab/package-info.class index 52651b15a..59b4c1ff8 100644 Binary files a/src/api/java/ic2/api/energy/prefab/package-info.class and b/src/api/java/ic2/api/energy/prefab/package-info.class differ diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.class b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.class index ddc8f3af2..5347aea0c 100644 Binary files a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.class and b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.class differ diff --git a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java index 0ecd6c8cc..652330116 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyAcceptor.java @@ -1,6 +1,5 @@ package ic2.api.energy.tile; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; /** @@ -8,19 +7,19 @@ import net.minecraft.util.EnumFacing; * * @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 + * @param side side the energy is being received from */ - boolean acceptsEnergyFrom(TileEntity emitter, EnumFacing direction); + boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.class b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.class index eab917d66..a7394c855 100644 Binary files a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.class and b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.class differ diff --git a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java index d20b73e1c..10fbeabe5 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java +++ b/src/api/java/ic2/api/energy/tile/IEnergyEmitter.java @@ -1,6 +1,5 @@ package ic2.api.energy.tile; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; /** @@ -8,20 +7,20 @@ import net.minecraft.util.EnumFacing; * * @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 + * @param side side the energy is to be sent to * @return Whether energy should be emitted */ - boolean emitsEnergyTo(TileEntity receiver, EnumFacing direction); + boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side); } diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.class b/src/api/java/ic2/api/energy/tile/IEnergySink.class index bcb05cee7..0ca533026 100644 Binary files a/src/api/java/ic2/api/energy/tile/IEnergySink.class and b/src/api/java/ic2/api/energy/tile/IEnergySink.class differ diff --git a/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.class b/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.class new file mode 100644 index 000000000..e478add70 Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.class differ diff --git a/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.java b/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.java new file mode 100644 index 000000000..02144e4f1 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IExplosionPowerOverride.java @@ -0,0 +1,25 @@ +package ic2.api.energy.tile; + +/** + * Implement with an {@link IEnergySink} tile entity to change the force of the explosion when overpowered. + */ +public interface IExplosionPowerOverride { + + /** + * Checks if the electric tile should explode. If you return false here, + * the explosion will just not happen at all and the block will stay. + * This is NOT recommended. + * @return Whether the block should explode. + * + * @note It should not be dependent on the tier of the power injected, consider {@link IOverloadHandler} if necessary. + */ + boolean shouldExplode(); + + /** + * The explosion force when too much power is received. + * @param tier The tier of power, that was injected into the energy sink, that caused it to explode. + * @param defaultPower The default explosion power. + * @return The explosion power + */ + float getExplosionPower(int tier, float defaultPower); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/IHeatSource.class b/src/api/java/ic2/api/energy/tile/IHeatSource.class index 4b24af949..34f9e1e6a 100644 Binary files a/src/api/java/ic2/api/energy/tile/IHeatSource.class and b/src/api/java/ic2/api/energy/tile/IHeatSource.class differ diff --git a/src/api/java/ic2/api/energy/tile/IKineticSource.class b/src/api/java/ic2/api/energy/tile/IKineticSource.class index 225191cc3..05257b06f 100644 Binary files a/src/api/java/ic2/api/energy/tile/IKineticSource.class and b/src/api/java/ic2/api/energy/tile/IKineticSource.class differ diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.class b/src/api/java/ic2/api/energy/tile/IMetaDelegate.class index 98228465c..16e51c133 100644 Binary files a/src/api/java/ic2/api/energy/tile/IMetaDelegate.class and b/src/api/java/ic2/api/energy/tile/IMetaDelegate.class differ diff --git a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java index f7319d0e1..1bb9b1e92 100644 --- a/src/api/java/ic2/api/energy/tile/IMetaDelegate.java +++ b/src/api/java/ic2/api/energy/tile/IMetaDelegate.java @@ -2,35 +2,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. - * + * Get the sub-Tiles belonging to this Meta Tile. + * * @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 + * @note The parent tile implementing IMetaDelegate isn't automatically included. + * + * @return sub-Tile array */ - List getSubTiles(); + List getSubTiles(); } diff --git a/src/api/java/ic2/api/energy/tile/IMultiEnergySource.class b/src/api/java/ic2/api/energy/tile/IMultiEnergySource.class new file mode 100644 index 000000000..09b4b0f78 Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IMultiEnergySource.class differ diff --git a/src/api/java/ic2/api/energy/tile/IMultiEnergySource.java b/src/api/java/ic2/api/energy/tile/IMultiEnergySource.java new file mode 100644 index 000000000..ef63f1927 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IMultiEnergySource.java @@ -0,0 +1,24 @@ +package ic2.api.energy.tile; + +/** + * Allows an {@link IEnergySource} to emit more than one EU packet per tick. + * Note: support for this will be dropped in a future version of IC2. + * @author Aroma1997 + */ +public interface IMultiEnergySource extends IEnergySource +{ + + /** + * If you want your machine to emit more than one EU packets per tick return true here. + * @return if the machine in its current state can emit more than one EU packet per tick. + */ + public boolean sendMultipleEnergyPackets(); + + /** + * If {@link #sendMultipleEnergyPackets()} returned true, this will get called. + * The value returned by this method will determine the amount of EU packets, this machine can emit. + * @return the amount of EU packets, this machine can emit per tick. + */ + public int getMultipleEnergyPacketAmount(); + +} \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/IOverloadHandler.class b/src/api/java/ic2/api/energy/tile/IOverloadHandler.class new file mode 100644 index 000000000..46ed18ca7 Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IOverloadHandler.class differ diff --git a/src/api/java/ic2/api/energy/tile/IOverloadHandler.java b/src/api/java/ic2/api/energy/tile/IOverloadHandler.java new file mode 100644 index 000000000..db2f39caf --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IOverloadHandler.java @@ -0,0 +1,17 @@ +package ic2.api.energy.tile; + +/** + * Complete control for when an {@link IEnergySink} is overloaded. + */ +public interface IOverloadHandler { + + /** + * Called when overloaded. This will override the default explosion. + * The default explosion will therefore NOT happen, when you return true here. + * If you return false, you can use this as a onExplode hook, but still let the default explosion happen. + * @note Would set the block to air and cause an explosion of power 2.5 by default + * @param tier The tier of power, that was injected into the energy sink, that caused it to explode. + * @return Whether you the default explosion should be cancelled. + */ + boolean onOverload(int tier); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/package-info.class b/src/api/java/ic2/api/energy/tile/package-info.class index fdee4a772..8f2d38743 100644 Binary files a/src/api/java/ic2/api/energy/tile/package-info.class and b/src/api/java/ic2/api/energy/tile/package-info.class differ diff --git a/src/api/java/ic2/api/energy/usage.txt b/src/api/java/ic2/api/energy/usage.txt index 49bd9955e..e3c9de817 100644 --- a/src/api/java/ic2/api/energy/usage.txt +++ b/src/api/java/ic2/api/energy/usage.txt @@ -38,7 +38,7 @@ loading the chunk which contains it or after the user placing the block. The energy net implementation will use the event to add it to its energy grid map, taking it into account for further energy transfers. -You can detect the loading by either using the 1st iteration of updateEntity() or by waiting for +You can detect the loading by either using the 1st iteration of update() or by waiting for the next world tick after TileEntity.validate(). The 2nd approach is obviously more sophisticated and requires to use some tick queuing mechanism. diff --git a/src/api/java/ic2/api/event/ExplosionEvent.class b/src/api/java/ic2/api/event/ExplosionEvent.class index 68a268d87..59a2f8c0d 100644 Binary files a/src/api/java/ic2/api/event/ExplosionEvent.class and b/src/api/java/ic2/api/event/ExplosionEvent.class differ diff --git a/src/api/java/ic2/api/event/ExplosionEvent.java b/src/api/java/ic2/api/event/ExplosionEvent.java index 091c8d9ec..7d670aa97 100644 --- a/src/api/java/ic2/api/event/ExplosionEvent.java +++ b/src/api/java/ic2/api/event/ExplosionEvent.java @@ -2,23 +2,23 @@ package ic2.api.event; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; + import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; @Cancelable public class ExplosionEvent extends WorldEvent { public ExplosionEvent(World world, Entity entity, - double x, double y, double z, + Vec3d pos, double power, EntityLivingBase igniter, int radiationRange, double rangeLimit) { super(world); this.entity = entity; - this.x = x; - this.y = y; - this.z = z; + this.pos = pos;; this.power = power; this.igniter = igniter; this.radiationRange = radiationRange; @@ -29,10 +29,8 @@ public class ExplosionEvent extends WorldEvent { * Entity representing the explosive, may be null. */ public final Entity entity; - public double x; - public double y; - public double z; - public double power; + public final Vec3d pos; + public final double power; /** * Entity causing the explosion, may be null. */ diff --git a/src/api/java/ic2/api/event/LaserEvent$LaserExplodesEvent.class b/src/api/java/ic2/api/event/LaserEvent$LaserExplodesEvent.class index 27664e99d..ea9d54941 100644 Binary files a/src/api/java/ic2/api/event/LaserEvent$LaserExplodesEvent.class and b/src/api/java/ic2/api/event/LaserEvent$LaserExplodesEvent.class differ diff --git a/src/api/java/ic2/api/event/LaserEvent$LaserHitsBlockEvent.class b/src/api/java/ic2/api/event/LaserEvent$LaserHitsBlockEvent.class index a41b7f28b..1b3b0d955 100644 Binary files a/src/api/java/ic2/api/event/LaserEvent$LaserHitsBlockEvent.class and b/src/api/java/ic2/api/event/LaserEvent$LaserHitsBlockEvent.class differ diff --git a/src/api/java/ic2/api/event/LaserEvent$LaserHitsEntityEvent.class b/src/api/java/ic2/api/event/LaserEvent$LaserHitsEntityEvent.class index 627a8ea49..deec489bf 100644 Binary files a/src/api/java/ic2/api/event/LaserEvent$LaserHitsEntityEvent.class and b/src/api/java/ic2/api/event/LaserEvent$LaserHitsEntityEvent.class differ diff --git a/src/api/java/ic2/api/event/LaserEvent$LaserShootEvent.class b/src/api/java/ic2/api/event/LaserEvent$LaserShootEvent.class index 368dc061c..08d6cbc30 100644 Binary files a/src/api/java/ic2/api/event/LaserEvent$LaserShootEvent.class and b/src/api/java/ic2/api/event/LaserEvent$LaserShootEvent.class differ diff --git a/src/api/java/ic2/api/event/LaserEvent.class b/src/api/java/ic2/api/event/LaserEvent.class index fa1a1b08e..8c8a55cf1 100644 Binary files a/src/api/java/ic2/api/event/LaserEvent.class and b/src/api/java/ic2/api/event/LaserEvent.class differ diff --git a/src/api/java/ic2/api/event/LaserEvent.java b/src/api/java/ic2/api/event/LaserEvent.java index abbad0ae4..6564a1a25 100644 --- a/src/api/java/ic2/api/event/LaserEvent.java +++ b/src/api/java/ic2/api/event/LaserEvent.java @@ -3,7 +3,10 @@ package ic2.api.event; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; @@ -25,88 +28,91 @@ public class LaserEvent extends WorldEvent { // 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 world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt) { + super(world); + + this.lasershot = lasershot; + this.owner = owner; + this.range = range; + this.power = power; + this.blockBreaks = blockBreaks; + this.explosive = explosive; + this.smelt = smelt; } /** * 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; + 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 world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, ItemStack laseritem) { + super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt); + + this.laserItem = laseritem; } } /** * 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 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 world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) { + super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt); + + 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; + public BlockPos pos; + public EnumFacing 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 world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive1, boolean smelt1, BlockPos pos, EnumFacing side, float dropChance, boolean removeBlock, boolean dropBlock) { + super(world, lasershot, owner, range, power, blockBreaks, explosive1, smelt1); + + this.pos = pos; + this.side = side; + this.removeBlock = removeBlock; + this.dropBlock = dropBlock; + this.dropChance = dropChance; } } /** * 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 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 world, Entity lasershot, EntityLivingBase owner, float range, float power, int blockBreaks, boolean explosive, boolean smelt, Entity hitentity) { + super(world, lasershot, owner, range, power, blockBreaks, explosive, smelt); + + this.hitEntity = hitentity; } } } diff --git a/src/api/java/ic2/api/event/PaintEvent.class b/src/api/java/ic2/api/event/PaintEvent.class deleted file mode 100644 index 0a4c1aab4..000000000 Binary files a/src/api/java/ic2/api/event/PaintEvent.class and /dev/null differ diff --git a/src/api/java/ic2/api/event/PaintEvent.java b/src/api/java/ic2/api/event/PaintEvent.java deleted file mode 100644 index fc01535c8..000000000 --- a/src/api/java/ic2/api/event/PaintEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -package ic2.api.event; - -import net.minecraft.world.World; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.common.eventhandler.Cancelable; - -@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.class b/src/api/java/ic2/api/event/RetextureEvent.class index e3df863a4..be92cb32a 100644 Binary files a/src/api/java/ic2/api/event/RetextureEvent.class and b/src/api/java/ic2/api/event/RetextureEvent.class differ diff --git a/src/api/java/ic2/api/event/RetextureEvent.java b/src/api/java/ic2/api/event/RetextureEvent.java index 9fda0116f..195f0d3f4 100644 --- a/src/api/java/ic2/api/event/RetextureEvent.java +++ b/src/api/java/ic2/api/event/RetextureEvent.java @@ -1,35 +1,54 @@ package ic2.api.event; -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; @Cancelable public class RetextureEvent extends WorldEvent { + public RetextureEvent(World world, BlockPos pos, IBlockState state, EnumFacing side, EntityPlayer player, + IBlockState refState, String refVariant, EnumFacing refSide, int[] refColorMultipliers) { + super(world); + + if (world == null) throw new NullPointerException("null world"); + if (world.isRemote) throw new IllegalStateException("remote world"); + if (pos == null) throw new NullPointerException("null pos"); + if (state == null) throw new NullPointerException("null state"); + if (side == null) throw new NullPointerException("null side"); + if (refState == null) throw new NullPointerException("null refState"); + if (refVariant == null) throw new NullPointerException("null refVariant"); + if (refSide == null) throw new NullPointerException("null refSide"); + if (refColorMultipliers == null) throw new NullPointerException("null refColorMultipliers"); + + this.pos = pos; + this.state = state; + this.side = side; + this.player = player; + this.refState = refState; + this.refVariant = refVariant; + this.refSide = refSide; + this.refColorMultipliers = refColorMultipliers; + } + // target block - public final int x; - public final int y; - public final int z; - public final int side; + public final BlockPos pos; + public final IBlockState state; + public final EnumFacing side; + + // player causing the action, may be null + public final EntityPlayer player; // referenced block (to grab the texture from) - public final Block referencedBlock; - public final int referencedMeta; - public final int referencedSide; + public final IBlockState refState; + public final String refVariant; + public final EnumFacing refSide; + public final int[] refColorMultipliers; // 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.class b/src/api/java/ic2/api/event/package-info.class index 718d8f14c..c1ce15887 100644 Binary files a/src/api/java/ic2/api/event/package-info.class and b/src/api/java/ic2/api/event/package-info.class differ diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.class b/src/api/java/ic2/api/info/IEnergyValueProvider.class deleted file mode 100644 index abe05e1c2..000000000 Binary files a/src/api/java/ic2/api/info/IEnergyValueProvider.class and /dev/null differ diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java deleted file mode 100644 index 1e7b2cc57..000000000 --- a/src/api/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/api/java/ic2/api/info/IFuelValueProvider.class b/src/api/java/ic2/api/info/IFuelValueProvider.class deleted file mode 100644 index 57f9f4bfc..000000000 Binary files a/src/api/java/ic2/api/info/IFuelValueProvider.class and /dev/null differ diff --git a/src/api/java/ic2/api/info/IFuelValueProvider.java b/src/api/java/ic2/api/info/IFuelValueProvider.java deleted file mode 100644 index 7c7fe0f4c..000000000 --- a/src/api/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/api/java/ic2/api/info/IInfoProvider.class b/src/api/java/ic2/api/info/IInfoProvider.class new file mode 100644 index 000000000..95ce6945f Binary files /dev/null and b/src/api/java/ic2/api/info/IInfoProvider.class differ diff --git a/src/api/java/ic2/api/info/IInfoProvider.java b/src/api/java/ic2/api/info/IInfoProvider.java new file mode 100644 index 000000000..c4e8f6dc6 --- /dev/null +++ b/src/api/java/ic2/api/info/IInfoProvider.java @@ -0,0 +1,27 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IInfoProvider { + /** + * 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 stack ItemStack containing the item to evaluate. + * @return energy in EU + */ + double getEnergyValue(ItemStack stack); + + /** + * Determine the fuel value for a single item in the supplied stack. + * The information currently applies to Generators and the Iron Furnace. + * + * @param stack 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 stack, boolean allowLava); +} diff --git a/src/api/java/ic2/api/info/Info.class b/src/api/java/ic2/api/info/Info.class index 7099fae6c..54987885d 100644 Binary files a/src/api/java/ic2/api/info/Info.class and b/src/api/java/ic2/api/info/Info.class differ diff --git a/src/api/java/ic2/api/info/Info.java b/src/api/java/ic2/api/info/Info.java index 7bc07062e..8d3884216 100644 --- a/src/api/java/ic2/api/info/Info.java +++ b/src/api/java/ic2/api/info/Info.java @@ -1,12 +1,13 @@ package ic2.api.info; +import net.minecraft.potion.Potion; import net.minecraft.util.DamageSource; + import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.LoaderState; public class Info { - public static IEnergyValueProvider itemEnergy; - public static IFuelValueProvider itemFuel; + public static IInfoProvider itemInfo; public static Object ic2ModInstance; /** @@ -15,6 +16,12 @@ public class Info { */ public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION; + /** + * Potions used by IC2. + * Getting assigned in preload. + */ + public static Potion POTION_RADIATION; + public static boolean isIc2Available() { if (ic2Available != null) return ic2Available; diff --git a/src/api/java/ic2/api/info/package-info.class b/src/api/java/ic2/api/info/package-info.class index 96b88b7d9..6cd21d416 100644 Binary files a/src/api/java/ic2/api/info/package-info.class and b/src/api/java/ic2/api/info/package-info.class differ diff --git a/src/api/java/ic2/api/item/ElectricItem.class b/src/api/java/ic2/api/item/ElectricItem.class index be9260675..ad45f925c 100644 Binary files a/src/api/java/ic2/api/item/ElectricItem.class and b/src/api/java/ic2/api/item/ElectricItem.class differ diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.class b/src/api/java/ic2/api/item/IBlockCuttingBlade.class index 8654649e7..6602efc17 100644 Binary files a/src/api/java/ic2/api/item/IBlockCuttingBlade.class and b/src/api/java/ic2/api/item/IBlockCuttingBlade.class differ diff --git a/src/api/java/ic2/api/item/IBlockCuttingBlade.java b/src/api/java/ic2/api/item/IBlockCuttingBlade.java index 24a8f00d4..0c2e53deb 100644 --- a/src/api/java/ic2/api/item/IBlockCuttingBlade.java +++ b/src/api/java/ic2/api/item/IBlockCuttingBlade.java @@ -1,6 +1,7 @@ package ic2.api.item; +import net.minecraft.item.ItemStack; public interface IBlockCuttingBlade { - int gethardness(); + int getHardness(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IBoxable.java b/src/api/java/ic2/api/item/IBoxable.java index bca2cc0dc..3204a3844 100644 --- a/src/api/java/ic2/api/item/IBoxable.java +++ b/src/api/java/ic2/api/item/IBoxable.java @@ -6,9 +6,9 @@ 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 + * + * @param stack item to be stored * @return Whether to store the item in the toolbox or not */ - public abstract boolean canBeStoredInToolbox(ItemStack itemstack); + public abstract boolean canBeStoredInToolbox(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IC2Items.class b/src/api/java/ic2/api/item/IC2Items.class index 267272d0b..a68e242fd 100644 Binary files a/src/api/java/ic2/api/item/IC2Items.class and b/src/api/java/ic2/api/item/IC2Items.class differ diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java index 9b8c7df3a..5240178f7 100644 --- a/src/api/java/ic2/api/item/IC2Items.java +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -2,597 +2,824 @@ package ic2.api.item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; + + /** * 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() + * + * 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: + * ((ItemBlock)x.getItem).getBlock() Items: x.getItem() + * Alternatively, you can direwctly call IC2Items.instance.getItem(name) or IC2Items.instance.getBlock(name) + * + * It is recommended, that you keep a reference to the Items you get here. + * + * @author Aroma1997 */ public final class IC2Items { + + /* + * To find out the name and variant of an Item/ItemStack + * have that Item in your hand in-game and type "/ic2 itemNameWithVariant" + */ + /** - * 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. + * Get an ItemStack for a specific item name. * - * @param name item name + * @param name + * item name + * @param variant + * the variant/subtype for the Item. + * @return The item or null if the item does not exist or an error occurred + */ + public static ItemStack getItem(String name, String variant) { + if (instance == null) { + return null; + } + return instance.getItemStack(name, variant); + } + + /** + * Get an ItemStack for a specific item name. + * + * @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; - } + return getItem(name, 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 + * Get the ItemAPI Instance. + * @return the ItemAPI instance. */ - 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"; + public static IItemAPI getItemAPI() { + return instance; + } + + + private static IItemAPI instance; + + /** + * Sets the internal IItemAPI instance. + * ONLY IC2 CAN DO THIS!!!!!!! + */ + public static void setInstance(IItemAPI api) { + ModContainer mc = Loader.instance().activeModContainer(); + + if (mc == null || !"IC2".equals(mc.getModId())) { + throw new IllegalAccessError("invoked from "+mc); + } + + instance = api; } - private static Class Ic2Items; } +/* +================================================= +Info +================================================= + +The different Items are separaed by an empty line. +The first entry is always the itemname followed by a ":" +If you only want to access the Item, you have to use getItemAPI().getItem() with that name. +If you only want to access the Block, you have to use getItemAPI().getBlock() with that name. +Then come the different variants as follows: +If the item has variants, it is displayed like that: +itemname,variant Display name +Otherwise, it is displayed like that: +itemname Display name +You can access ItemStacks of Items without variants using the variant null + + +================================================= +Items +================================================= + +boat: +boat,broken_rubber Damaged Rubber Dinghy +boat,rubber Rubber Dinghy +boat,carbon Carbon Fiber Canoe +boat,electric Electric Boat + +crushed: +crushed,copper Crushed Copper Ore +crushed,gold Crushed Gold Ore +crushed,iron Crushed Iron Ore +crushed,lead Crushed Lead Ore +crushed,silver Crushed Silver Ore +crushed,tin Crushed Tin Ore +crushed,uranium Crushed Uranium Ore + +purified: +purified,copper Purified Crushed Copper Ore +purified,gold Purified Crushed Gold Ore +purified,iron Purified Crushed Iron Ore +purified,lead Purified Crushed Lead Ore +purified,silver Purified Crushed Silver Ore +purified,tin Purified Crushed Tin Ore +purified,uranium Purified Crushed Uranium Ore + +dust: +dust,bronze Bronze Dust +dust,clay Clay Dust +dust,coal Coal Dust +dust,coal_fuel Hydrated Coal Dust +dust,copper Copper Dust +dust,diamond Diamond Dust +dust,energium Energium Dust +dust,gold Gold Dust +dust,iron Iron Dust +dust,lapis Lapis Lazuli Dust +dust,lead Lead Dust +dust,lithium Lithium Dust +dust,obsidian Obsidian Dust +dust,silicon_dioxide Silicon Dioxide +dust,silver Silver Dust +dust,stone Stone Dust +dust,sulfur Sulfur Dust +dust,tin Tin Dust +dust,small_bronze Tiny Pile of Bronze Dust +dust,small_copper Tiny Pile of Copper Dust +dust,small_gold Tiny Pile of Gold Dust +dust,small_iron Tiny Pile of Iron Dust +dust,small_lapis Tiny Pile of Lapis Dust +dust,small_lead Tiny Pile of Lead Dust +dust,small_lithium Tiny Pile of Lithium Dust +dust,small_obsidian Tiny Pile of Obsidian Dust +dust,small_silver Tiny Pile of Silver Dust +dust,small_sulfur Tiny Pile of Sulfur Dust +dust,small_tin Tiny Pile of Tin Dust + +ingot: +ingot,alloy Mixed Metal Ingot +ingot,bronze Bronze Ingot +ingot,copper Copper Ingot +ingot,lead Lead Ingot +ingot,silver Silver Ingot +ingot,steel Steel Ingot +ingot,tin Tin Ingot + +plate: +plate,bronze Bronze Plate +plate,copper Copper Plate +plate,gold Gold Plate +plate,iron Iron Plate +plate,lapis Lapis Lazuli Plate +plate,lead Lead Plate +plate,obsidian Obsidian Plate +plate,steel Steel Plate +plate,tin Tin Plate +plate,dense_bronze Dense Bronze Plate +plate,dense_copper Dense Copper Plate +plate,dense_gold Dense Gold Plate +plate,dense_iron Dense Iron Plate +plate,dense_lapis Dense Lapis Lazuli Plate +plate,dense_lead Dense Lead Plate +plate,dense_obsidian Dense Obsidian Plate +plate,dense_steel Dense Steel Plate +plate,dense_tin Dense Tin Plate + +casing: +casing,bronze Bronze Item Casing +casing,copper Copper Item Casing +casing,gold Gold Item Casing +casing,iron Iron Item Casing +casing,lead Lead Item Casing +casing,steel Steel Item Casing +casing,tin Tin Item Casing + +nuclear: +nuclear,uranium Enriched Uranium Nuclear Fuel +nuclear,uranium_235 Uranium 235 +nuclear,uranium_238 Uranium 238 +nuclear,plutonium Plutonium +nuclear,mox MOX Nuclear Fuel +nuclear,small_uranium_235 Tiny Pile of Uranium 235 +nuclear,small_uranium_238 Tiny Pile of Uranium 238 +nuclear,small_plutonium Tiny Pile of Plutonium +nuclear,uranium_pellet Pellets of Enriched Uranium Nuclear Fuel +nuclear,mox_pellet Pellets of MOX Nuclear Fuel +nuclear,rtg_pellet Pellets of RTG Fuel +nuclear,depleted_uranium Fuel Rod (Depleted Uranium) +nuclear,depleted_dual_uranium Dual Fuel Rod (Depleted Uranium) +nuclear,depleted_quad_uranium Quad Fuel Rod (Depleted Uranium) +nuclear,depleted_mox Fuel Rod (Depleted MOX) +nuclear,depleted_dual_mox Dual Fuel Rod (Depleted MOX) +nuclear,depleted_quad_mox Quad Fuel Rod (Depleted MOX) + +misc_resource: +misc_resource,ashes Ashes +misc_resource,iridium_ore Iridium Ore +misc_resource,iridium_shard Iridium Shard +misc_resource,matter UU-Matter +misc_resource,resin Sticky Resin +misc_resource,slag Slag + +block_cutting_blade: +block_cutting_blade,iron Block Cutting Blade (Iron) +block_cutting_blade,steel Block Cutting Blade (Steel) +block_cutting_blade,diamond Block Cutting Blade (Diamond) + +crafting: +crafting,rubber Rubber +crafting,circuit Electronic Circuit +crafting,advanced_circuit Advanced Circuit +crafting,alloy Advanced Alloy +crafting,iridium Iridium Reinforced Plate +crafting,coil Coil +crafting,electric_motor Electric Motor +crafting,heat_conductor Heat Conductor +crafting,copper_boiler Copper Boiler +crafting,fuel_rod Fuel Rod (Empty) +crafting,tin_can Tin Can +crafting,small_power_unit Small Power Unit +crafting,power_unit Power Unit +crafting,carbon_fibre Raw Carbon Fibre +crafting,carbon_mesh Raw Carbon Mesh +crafting,carbon_plate Carbon Plate +crafting,coal_ball Coal Ball +crafting,coal_block Compressed Coal Ball +crafting,coal_chunk Coal Chunk +crafting,industrial_diamond Industrial Diamond +crafting,plant_ball Plantball +crafting,bio_chaff Bio Chaff +crafting,compressed_hydrated_coal H. Coal +crafting,scrap Scrap +crafting,scrap_box Scrap Box +crafting,cf_powder CF Powder +crafting,pellet CF Pellet +crafting,raw_crystal_memory Crystal Memory (raw) +crafting,iron_shaft Shaft (Iron) +crafting,steel_shaft Shaft (Steel) +crafting,wood_rotor_blade Wood Rotor Blade +crafting,iron_rotor_blade Iron Rotor Blade +crafting,steel_rotor_blade Steel Rotor Blade +crafting,carbon_rotor_blade Carbon Rotor Blade +crafting,steam_turbine_blade Steam Turbine Blade +crafting,steam_turbine Steam Turbine + +crystal_memory: +crystal_memory Crystal Memory + +upgrade_kit: +upgrade_kit,mfsu MFSU Upgrade Kit + +crop_res: +crop_res,coffee_beans Coffee Beans +crop_res,coffee_powder Coffee Powder +crop_res,fertilizer Fertilizer +crop_res,grin_powder Grin Powder +crop_res,hops Hops +crop_res,weed Weed + +terra_wart: +terra_wart item.terra_wart + +re_battery: +re_battery RE-Battery + +advanced_re_battery: +advanced_re_battery Advanced RE-Battery + +energy_crystal: +energy_crystal Energy Crystal + +lapotron_crystal: +lapotron_crystal Lapotron Crystal + +single_use_battery: +single_use_battery Single-Use Battery + +charging_re_battery: +charging_re_battery Charging RE Battery + +advanced_charging_re_battery: +advanced_charging_re_battery Advanced Charging Battery + +charging_energy_crystal: +charging_energy_crystal Charging Energy Crystal + +charging_lapotron_crystal: +charging_lapotron_crystal Charging Lapotron Crystal + +heat_storage: +heat_storage 10k Coolant Cell + +tri_heat_storage: +tri_heat_storage 30k Coolant Cell + +hex_heat_storage: +hex_heat_storage 60k Coolant Cell + +plating: +plating Reactor Plating + +heat_plating: +heat_plating Heat-Capacity Reactor Plating + +containment_plating: +containment_plating Containment Reactor Plating + +heat_exchanger: +heat_exchanger Heat Exchanger + +reactor_heat_exchanger: +reactor_heat_exchanger Reactor Heat Exchanger + +component_heat_exchanger: +component_heat_exchanger Component Heat Exchanger + +advanced_heat_exchanger: +advanced_heat_exchanger Advanced Heat Exchanger + +heat_vent: +heat_vent Heat Vent + +reactor_heat_vent: +reactor_heat_vent Reactor Heat Vent + +overclocked_heat_vent: +overclocked_heat_vent Overclocked Heat Vent + +component_heat_vent: +component_heat_vent Component Heat Vent + +advanced_heat_vent: +advanced_heat_vent Advanced Heat Vent + +neutron_reflector: +neutron_reflector Neutron Reflector + +thick_neutron_reflector: +thick_neutron_reflector Thick Neutron Reflector + +rsh_condensator: +rsh_condensator RSH-Condensator + +lzh_condensator: +lzh_condensator LZH-Condensator + +uranium_fuel_rod: +uranium_fuel_rod Fuel Rod (Uranium) + +dual_uranium_fuel_rod: +dual_uranium_fuel_rod Dual Fuel Rod (Uranium) + +quad_uranium_fuel_rod: +quad_uranium_fuel_rod Quad Fuel Rod (Uranium) + +mox_fuel_rod: +mox_fuel_rod Fuel Rod (MOX) + +dual_mox_fuel_rod: +dual_mox_fuel_rod Dual Fuel Rod (MOX) + +quad_mox_fuel_rod: +quad_mox_fuel_rod Quad Fuel Rod (MOX) + +lithium_fuel_rod: +lithium_fuel_rod Fuel Rod (Lithium) + +tfbp: +tfbp,blank TFBP - Empty +tfbp,chilling TFBP - Chilling +tfbp,cultivation TFBP - Cultivation +tfbp,desertification TFBP - Desertification +tfbp,flatification TFBP - Flatification +tfbp,irrigation TFBP - Irrigation +tfbp,mushroom TFBP - Mushroom + +bronze_axe: +bronze_axe Bronze Axe + +bronze_hoe: +bronze_hoe Bronze Hoe + +bronze_pickaxe: +bronze_pickaxe Bronze Pickaxe + +bronze_shovel: +bronze_shovel Bronze Shovel + +bronze_sword: +bronze_sword Bronze Sword + +containment_box: +containment_box Containment Box + +cutter: +cutter Cutter + +debug_item: +debug_item Debug Item + +foam_sprayer: +foam_sprayer CF Sprayer + +forge_hammer: +forge_hammer Forge Hammer + +frequency_transmitter: +frequency_transmitter Frequency Transmitter + +meter: +meter EU-Reader + +tool_box: +tool_box Tool Box + +treetap: +treetap Treetap + +wrench: +wrench Wrench + +barrel: +barrel Empty Booze Barrel + +booze_mug: +booze_mug Zero + +mug: +mug,empty Stone Mug +mug,cold_coffee Cold Coffee +mug,dark_coffee Dark Coffee +mug,coffee Coffee + +cropnalyzer: +cropnalyzer Cropnalyzer + +weeding_trowel: +weeding_trowel Weeding Trowel + +advanced_scanner: +advanced_scanner OV Scanner + +chainsaw: +chainsaw Chainsaw + +diamond_drill: +diamond_drill Diamond Drill + +drill: +drill Mining Drill + +electric_hoe: +electric_hoe Electric Hoe + +electric_treetap: +electric_treetap Electric Treetap + +electric_wrench: +electric_wrench Electric Wrench + +iridium_drill: +iridium_drill Iridium Drill + +mining_laser: +mining_laser Mining Laser + +nano_saber: +nano_saber Nano Saber + +obscurator: +obscurator Obscurator + +scanner: +scanner OD Scanner + +wind_meter: +wind_meter Windmeter + +painter: +painter Painter +painter,black Black Painter +painter,blue Blue Painter +painter,brown Brown Painter +painter,cyan Cyan Painter +painter,gray Dark Grey Painter +painter,green Green Painter +painter,light_blue Light Blue Painter +painter,light_gray Light Grey Painter +painter,lime Lime Painter +painter,magenta Magenta Painter +painter,orange Orange Painter +painter,pink Pink Painter +painter,purple Purple Painter +painter,red Red Painter +painter,white White Painter +painter,yellow Yellow Painter + +fluid_cell: +fluid_cell Universal Fluid Cell +fluid_cell,ic2air Universal Fluid Cell +fluid_cell,ic2biogas Universal Fluid Cell +fluid_cell,ic2biomass Universal Fluid Cell +fluid_cell,ic2construction_foam Universal Fluid Cell +fluid_cell,ic2coolant Universal Fluid Cell +fluid_cell,ic2distilled_water Universal Fluid Cell +fluid_cell,ic2heavy_water Universal Fluid Cell +fluid_cell,ic2hot_coolant Universal Fluid Cell +fluid_cell,ic2hot_water Universal Fluid Cell +fluid_cell,ic2hydrogen Universal Fluid Cell +fluid_cell,ic2oxygen Universal Fluid Cell +fluid_cell,ic2pahoehoe_lava Universal Fluid Cell +fluid_cell,ic2steam Universal Fluid Cell +fluid_cell,ic2superheated_steam Universal Fluid Cell +fluid_cell,ic2uu_matter Universal Fluid Cell +fluid_cell,ic2weed_ex Universal Fluid Cell +fluid_cell,lava Universal Fluid Cell +fluid_cell,water Universal Fluid Cell + +cable: +cable,type:copper,insulation:0 Copper Cable +cable,type:copper,insulation:1 Insulated Copper Cable +cable,type:glass,insulation:0 Glass Fibre Cable +cable,type:gold,insulation:0 Gold Cable +cable,type:gold,insulation:1 Insulated Gold Cable +cable,type:gold,insulation:2 2x Ins. Gold Cable +cable,type:iron,insulation:0 HV Cable +cable,type:iron,insulation:1 Insulated HV Cable +cable,type:iron,insulation:2 2x Ins. HV Cable +cable,type:iron,insulation:3 3x Ins. HV Cable +cable,type:tin,insulation:0 Tin Cable +cable,type:tin,insulation:1 Insulated Tin Cable +cable,type:detector,insulation:0 EU-Detector Cable +cable,type:splitter,insulation:0 EU-Splitter Cable + +upgrade: +upgrade,overclocker Overclocker Upgrade +upgrade,transformer Transformer Upgrade +upgrade,energy_storage Energy Storage Upgrade +upgrade,redstone_inverter Redstone Signal Inverter Upgrade +upgrade,ejector Ejector Upgrade +upgrade,pulling Pulling Upgrade +upgrade,fluid_ejector Fluid Ejector Upgrade + +advanced_batpack: +advanced_batpack Adv.Batpack + +alloy_chestplate: +alloy_chestplate Composite Vest + +batpack: +batpack BatPack + +bronze_boots: +bronze_boots Bronze Boots + +bronze_chestplate: +bronze_chestplate Bronze Chestplate + +bronze_helmet: +bronze_helmet Bronze Helmet + +bronze_leggings: +bronze_leggings Bronze Leggings + +cf_pack: +cf_pack CF Backpack +cf_pack CF Backpack + +energy_pack: +energy_pack Energypack + +hazmat_chestplate: +hazmat_chestplate Hazmat Suit + +hazmat_helmet: +hazmat_helmet Scuba Helmet + +hazmat_leggings: +hazmat_leggings Hazmat Suit Leggings + +jetpack: +jetpack Jetpack +jetpack Jetpack + +jetpack_electric: +jetpack_electric Electric Jetpack + +lappack: +lappack Lappack + +nano_boots: +nano_boots NanoSuit Boots + +nano_chestplate: +nano_chestplate NanoSuit Bodyarmor + +nano_helmet: +nano_helmet NanoSuit Helmet + +nano_leggings: +nano_leggings NanoSuit Leggings + +nightvision_goggles: +nightvision_goggles Nightvision Goggles + +quantum_boots: +quantum_boots QuantumSuit Boots + +quantum_chestplate: +quantum_chestplate QuantumSuit Bodyarmor + +quantum_helmet: +quantum_helmet QuantumSuit Helmet + +quantum_leggings: +quantum_leggings QuantumSuit Leggings + +rubber_boots: +rubber_boots Rubber Boots + +solar_helmet: +solar_helmet Solar Helmet + +static_boots: +static_boots Static Boots + +filled_tin_can: +filled_tin_can (Filled) Tin Can + +rotor_wood: +rotor_wood Kinetic Gearbox Rotor (Wood) + +rotor_iron: +rotor_iron Kinetic Gearbox Rotor (Iron) + +rotor_carbon: +rotor_carbon Kinetic Gearbox Rotor (Carbon) + +rotor_steel: +rotor_steel Kinetic Gearbox Rotor (Steel) + + +================================================= +Blocks: +================================================= + +te: +te,itnt Industrial TNT +te,nuke Nuke +te,generator Generator +te,geo_generator Geothermal Generator +te,kinetic_generator Kinetic Generator +te,rt_generator Radioisotope Thermoelectric Generator +te,semifluid_generator Semifluid Generator +te,solar_generator Solar Panel +te,stirling_generator Stirling Generator +te,water_generator Water Mill +te,wind_generator Wind Mill +te,electric_heat_generator Electric Heater +te,fluid_heat_generator Liquid Fuel Firebox +te,rt_heat_generator Radioisotope Heat Generator +te,solid_heat_generator Solid Fuel Firebox +te,electric_kinetic_generator Electric Motor +te,manual_kinetic_generator Manual Kinetic Generator +te,steam_kinetic_generator Steam Turbine +te,stirling_kinetic_generator Stirling Kinetic Generator +te,water_kinetic_generator Water Turbine +te,wind_kinetic_generator Wind Turbine +te,nuclear_reactor Nuclear Reactor +te,reactor_access_hatch Reactor Access Hatch +te,reactor_chamber Reactor Chamber +te,reactor_fluid_port Reactor Fluid Port +te,reactor_redstone_port Reactor Redstone Port +te,condenser Condenser +te,fluid_bottler Bottling Plant +te,fluid_distributor Fluid Distributor +te,fluid_regulator Fluid Regulator +te,liquid_heat_exchanger Liquid Heat Exchanger +te,pump Pump +te,solar_distiller Solar Distiller +te,steam_generator Steam Boiler +te,item_buffer Item Buffer +te,luminator_flat Luminator +te,magnetizer Magnetizer +te,sorting_machine Electric Sorting Machine +te,teleporter Teleporter +te,terraformer Terraformer +te,tesla_coil Tesla Coil +te,canner Fluid/Solid Canning Machine +te,compressor Compressor +te,electric_furnace Electric Furnace +te,extractor Extractor +te,iron_furnace Iron Furnace +te,macerator Macerator +te,recycler Recycler +te,solid_canner Solid Canning Machine +te,blast_furnace Blast Furnace +te,block_cutter Block Cutting Machine +te,centrifuge Thermal Centrifuge +te,fermenter Fermenter +te,induction_furnace Induction Furnace +te,metal_former Metal Former +te,ore_washing_plant Ore Washing Plant +te,advanced_miner Advanced Miner +te,crop_harvester Crop Harvester +te,cropmatron Crop-Matron +te,miner Miner +te,matter_generator Mass Fabricator +te,pattern_storage Pattern Storage +te,replicator Replicator +te,scanner Scanner +te,energy_o_mat Energy-O-Mat +te,personal_chest Personal Safe +te,trade_o_mat Trade-O-Mat +te,chargepad_batbox Charge Pad (BatBox) +te,chargepad_cesu Charge Pad (CESU) +te,chargepad_mfe Charge Pad (MFE) +te,chargepad_mfsu Charge Pad (MFSU) +te,batbox BatBox +te,cesu CESU +te,mfe MFE +te,mfsu MFSU +te,electrolyzer Electrolyzer +te,lv_transformer LV-Transformer +te,mv_transformer MV-Transformer +te,hv_transformer HV-Transformer +te,ev_transformer EV-Transformer +te,tank Tank +te,chunk_loader Chunk Loader + +resource: +resource,basalt Basalt +resource,copper_ore Copper Ore +resource,lead_ore Lead Ore +resource,tin_ore Tin Ore +resource,uranium_ore Uranium Ore +resource,bronze_block Bronze Block +resource,copper_block Copper Block +resource,lead_block Lead Block +resource,steel_block Steel Block +resource,tin_block Tin Block +resource,uranium_block Uranium Block +resource,reinforced_stone Reinforced Stone +resource,machine Basic Machine Casing +resource,advanced_machine Advanced Machine Casing +resource,reactor_vessel Reactor Pressure Vessel + +leaves: +leaves Rubber Tree Leaves + +rubber_wood: +rubber_wood Rubber Wood + +sapling: +sapling Rubber Tree Sapling + +scaffold: +scaffold,wood Scaffold +scaffold,reinforced_wood Reinforced Scaffold +scaffold,iron Iron Scaffold +scaffold,reinforced_iron Reinforced Iron Scaffold + +foam: +foam,normal Construction Foam +foam,reinforced Reinforced Construction Foam + +fence: +fence,iron Iron Fence + +sheet: +sheet,rubber Rubber Sheet + +glass: +glass,reinforced Reinforced Glass + +wall: +wall,black Construction Foam Wall (Black) +wall,blue Construction Foam Wall (Blue) +wall,brown Construction Foam Wall (Brown) +wall,cyan Construction Foam Wall (Cyan) +wall,gray Construction Foam Wall (Gray) +wall,green Construction Foam Wall (Green) +wall,light_blue Construction Foam Wall (Light Blue) +wall,light_gray Construction Foam Wall (Light Gray) +wall,lime Construction Foam Wall (Lime) +wall,magenta Construction Foam Wall (Magenta) +wall,orange Construction Foam Wall (Orange) +wall,pink Construction Foam Wall (Pink) +wall,purple Construction Foam Wall (Purple) +wall,red Construction Foam Wall (Red) +wall,white Construction Foam Wall (White) +wall,yellow Construction Foam Wall (Yellow) + +mining_pipe: +mining_pipe,pipe Mining Pipe + +reinforced_door: +reinforced_door Reinforced Door + + */ diff --git a/src/api/java/ic2/api/item/IElectricItem.class b/src/api/java/ic2/api/item/IElectricItem.class index a49d1839e..4ca3a7eed 100644 Binary files a/src/api/java/ic2/api/item/IElectricItem.class and b/src/api/java/ic2/api/item/IElectricItem.class differ diff --git a/src/api/java/ic2/api/item/IElectricItem.java b/src/api/java/ic2/api/item/IElectricItem.java index 5525e00f6..b94634a63 100644 --- a/src/api/java/ic2/api/item/IElectricItem.java +++ b/src/api/java/ic2/api/item/IElectricItem.java @@ -1,6 +1,5 @@ package ic2.api.item; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; /** @@ -14,42 +13,30 @@ public interface IElectricItem { * * @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); + boolean canProvideEnergy(ItemStack stack); /** * Get the item's maximum charge energy in EU. * * @return Maximum charge energy */ - double getMaxCharge(ItemStack itemStack); + double getMaxCharge(ItemStack stack); /** * 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. + * + * Batteries are Tier 1, Advanced Batteries are Tier 2, Energy Crystals are Tier 3, Lapotron + * Crystals are Tier 4. * * @return Item's tier */ - int getTier(ItemStack itemStack); + int getTier(ItemStack stack); /** * Get the item's transfer limit in EU per transfer operation. * * @return Transfer limit */ - double getTransferLimit(ItemStack itemStack); + double getTransferLimit(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IElectricItemManager.class b/src/api/java/ic2/api/item/IElectricItemManager.class index 978eb9147..dc89a3a67 100644 Binary files a/src/api/java/ic2/api/item/IElectricItemManager.class and b/src/api/java/ic2/api/item/IElectricItemManager.class differ diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java index 5de43d773..74964a24d 100644 --- a/src/api/java/ic2/api/item/IElectricItemManager.java +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -11,7 +11,18 @@ import net.minecraft.item.ItemStack; * - 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 - * + * + * Implementation hints: + * - operations require the tier to be at least as high as the item being manipulated + * - ignoreTransferLimit = true should allow the total charge to be transferred in one pass + * - externally = false should always allow discharging + * - all simulated operations should be deterministic and repeatable until a non-simulated + * operation happens or the item had a chance to be manipulated elsewhere. + * - usually getCharge(stack) mirrors + * discharge(stack, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false, true) + * - usually getMaxCharge(stack) mirrors + * getCharge(stack) + charge(stack, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, true) + * * @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 @@ -21,10 +32,10 @@ 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 stack electric item's stack + * @param amount max 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 ignoreTransferLimit ignore any transfer limits, infinite charge rate * @param simulate don't actually change the item, just determine the return value * @return Energy transferred into the electric item */ @@ -33,10 +44,14 @@ public interface IElectricItemManager { /** * Discharge an item by a specified amount of energy * - * @param itemStack electric item's stack - * @param amount amount of energy to discharge in EU + * The externally parameter is used to prevent non-battery-like items from providing power. For + * example discharge slots set externally to true, but items using energy for themselves don't. + * Special cases like the nano saber hitting armor will discharge with externally = false. + * + * @param stack electric item's stack + * @param amount max 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 ignoreTransferLimit ignore any transfer limits, infinite discharge rate * @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 @@ -45,18 +60,29 @@ public interface IElectricItemManager { /** * Determine the charge level for the specified item. - * - * @param itemStack ItemStack containing the electric item + * + * @param stack ItemStack containing the electric item * @return charge level in EU */ double getCharge(ItemStack stack); + /** + * Determine the charge level for the specified item. + * + * The item may not actually be chargeable to the returned level, e.g. if it is a + * non-rechargeable single use battery. + * + * @param stack ItemStack containing the electric item + * @return maximum charge level in EU + */ + double getMaxCharge(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 stack electric item's stack * @param amount minimum amount of energy required * @return true if there's enough energy */ @@ -66,7 +92,7 @@ public interface IElectricItemManager { * 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 stack 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 @@ -78,18 +104,23 @@ public interface IElectricItemManager { * 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 stack 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 + * + * @param stack ItemStack to determine the tooltip for * @return tool tip string or null for none */ String getToolTip(ItemStack stack); - // TODO: add tier getter + /** + * Get the tier of the specified item. + * @param stack the item to get the tier from. + * @return The tier of the item. + */ + int getTier(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IItemAPI.class b/src/api/java/ic2/api/item/IItemAPI.class new file mode 100644 index 000000000..12684eb4b Binary files /dev/null and b/src/api/java/ic2/api/item/IItemAPI.class differ diff --git a/src/api/java/ic2/api/item/IItemAPI.java b/src/api/java/ic2/api/item/IItemAPI.java new file mode 100644 index 000000000..ba6dc0a42 --- /dev/null +++ b/src/api/java/ic2/api/item/IItemAPI.java @@ -0,0 +1,43 @@ +package ic2.api.item; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * A simple interface for the ItemAPI. + * @author Aroma1997 + * + */ +public interface IItemAPI { + + /** + * Get an ItemStack for a specific item name. + * + * @param name + * item name + * @param variant + * the variant/subtype for the Item. + * @return The item or null if the item does not exist or an error occurred + */ + ItemStack getItemStack(String name, String variant); + + /** + * Get a Block for a specific block name. + * + * @param name + * block name + * @return The Block or null if the block does not exist or an error occurred + */ + Block getBlock(String name); + + /** + * Get an Item for a specific block name. + * + * @param name + * item name + * @return The Item or null if the block does not exist or an error occurred + */ + Item getItem(String name); + +} diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java index da9731876..35194f366 100644 --- a/src/api/java/ic2/api/item/IItemHudInfo.java +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -7,10 +7,10 @@ import net.minecraft.item.ItemStack; public interface IItemHudInfo { /* Add Info to Nano- and Quantum-Suit Helm Hud - for itemStack + for stack @Override - public List getHudInfo(ItemStack itemStack) { + public List getHudInfo(ItemStack stack) { List info = new LinkedList(); info.add("i am a Cool Item"); info.add("and have Cool info"); @@ -20,5 +20,5 @@ public interface IItemHudInfo { */ - public List getHudInfo(ItemStack itemStack); + public List getHudInfo(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/IKineticRotor$GearboxType.class b/src/api/java/ic2/api/item/IKineticRotor$GearboxType.class new file mode 100644 index 000000000..4c6ab9db6 Binary files /dev/null and b/src/api/java/ic2/api/item/IKineticRotor$GearboxType.class differ diff --git a/src/api/java/ic2/api/item/IKineticRotor.class b/src/api/java/ic2/api/item/IKineticRotor.class new file mode 100644 index 000000000..4bba1ebde Binary files /dev/null and b/src/api/java/ic2/api/item/IKineticRotor.class differ diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.java b/src/api/java/ic2/api/item/IKineticRotor.java similarity index 68% rename from src/api/java/ic2/api/item/IKineticWindRotor.java rename to src/api/java/ic2/api/item/IKineticRotor.java index de696e381..a61d1622c 100644 --- a/src/api/java/ic2/api/item/IKineticWindRotor.java +++ b/src/api/java/ic2/api/item/IKineticRotor.java @@ -3,7 +3,7 @@ package ic2.api.item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public interface IKineticWindRotor { +public interface IKineticRotor { int getDiameter(ItemStack stack); ResourceLocation getRotorRenderTexture(ItemStack stack); @@ -13,4 +13,11 @@ public interface IKineticWindRotor { int getMinWindStrength(ItemStack stack); int getMaxWindStrength(ItemStack stack); + + boolean isAcceptedType(ItemStack stack, GearboxType type); + + public static enum GearboxType { + WATER, + WIND, + } } diff --git a/src/api/java/ic2/api/item/IKineticWindRotor.class b/src/api/java/ic2/api/item/IKineticWindRotor.class deleted file mode 100644 index 00f10fc86..000000000 Binary files a/src/api/java/ic2/api/item/IKineticWindRotor.class and /dev/null differ diff --git a/src/api/java/ic2/api/item/ILatheItem.class b/src/api/java/ic2/api/item/ILatheItem.class deleted file mode 100644 index 7bbb877de..000000000 Binary files a/src/api/java/ic2/api/item/ILatheItem.class and /dev/null differ diff --git a/src/api/java/ic2/api/item/ILatheItem.java b/src/api/java/ic2/api/item/ILatheItem.java deleted file mode 100644 index c1df3562c..000000000 --- a/src/api/java/ic2/api/item/ILatheItem.java +++ /dev/null @@ -1,46 +0,0 @@ -package ic2.api.item; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface ILatheItem { - - /** - * Returns the radius of this Lathe Item - * Should be no more than 15 to still be able to display it properly. - */ - int getWidth(ItemStack stack); - - /** - * Returns the current state of this Lathe Item - * The length of the array should be 5 - * The value should be the current size of the item at this time. - * It should also not be greater than getWidth() - */ - int[] getCurrentState(ItemStack stack); - - /** - * This will set the current state of the Item on that position to that value. - */ - void setState(ItemStack stack, int position, int value); - - /** - * Returns the output Item (normally dust) when you lathe on this position. - */ - ItemStack getOutputItem(ItemStack stack, int position); - - /** - * How common it is if the above item will be put into the output slot. - * 1.0 means it will always be outputted, 0.0 means it will never be outputted. - */ - float getOutputChance(ItemStack stack, int position); - - /** - * Returns the ResourceLocation of the texture used to display the item inside of the Lathe GUI - */ - @SideOnly(Side.CLIENT) - ResourceLocation getTexture(ItemStack stack); - -} diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.class b/src/api/java/ic2/api/item/ISpecialElectricItem.class index ca93ed277..b21e26d12 100644 Binary files a/src/api/java/ic2/api/item/ISpecialElectricItem.class and b/src/api/java/ic2/api/item/ISpecialElectricItem.class differ diff --git a/src/api/java/ic2/api/item/ISpecialElectricItem.java b/src/api/java/ic2/api/item/ISpecialElectricItem.java index a7302f530..14218d8c1 100644 --- a/src/api/java/ic2/api/item/ISpecialElectricItem.java +++ b/src/api/java/ic2/api/item/ISpecialElectricItem.java @@ -2,12 +2,12 @@ package ic2.api.item; import net.minecraft.item.ItemStack; -public interface ISpecialElectricItem extends IElectricItem { +public interface ISpecialElectricItem { /** * Supply a custom IElectricItemManager. - * - * @param itemStack ItemStack to get the manager for + * + * @param stack ItemStack to get the manager for * @return IElectricItemManager instance */ - IElectricItemManager getManager(ItemStack itemStack); + IElectricItemManager getManager(ItemStack stack); } diff --git a/src/api/java/ic2/api/item/ITerraformingBP.class b/src/api/java/ic2/api/item/ITerraformingBP.class index 3242ee063..d244d1fc5 100644 Binary files a/src/api/java/ic2/api/item/ITerraformingBP.class and b/src/api/java/ic2/api/item/ITerraformingBP.class differ diff --git a/src/api/java/ic2/api/item/ITerraformingBP.java b/src/api/java/ic2/api/item/ITerraformingBP.java index 59b46baec..9b27279fe 100644 --- a/src/api/java/ic2/api/item/ITerraformingBP.java +++ b/src/api/java/ic2/api/item/ITerraformingBP.java @@ -1,5 +1,8 @@ package ic2.api.item; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** @@ -8,27 +11,32 @@ import net.minecraft.world.World; public interface ITerraformingBP { /** * Get the energy consumption per operation of the blueprint. - * + * @param stack TODO + * * @return Energy consumption in EU */ - public abstract int getConsume(); - + double getConsume(ItemStack stack); + /** * Get the maximum range of the blueprint. * Should be a divisor of 5. - * + * @param stack TODO + * * @return Maximum range in blocks */ - public abstract int getRange(); - + int getRange(ItemStack stack); + + boolean canInsert(ItemStack stack, EntityPlayer player, World world, BlockPos pos); + /** * Perform the terraforming operation. - * + * @param stack TODO * @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); + boolean terraform(ItemStack stack, World world, BlockPos pos); } diff --git a/src/api/java/ic2/api/item/ItemWrapper.class b/src/api/java/ic2/api/item/ItemWrapper.class index 7c6a6de70..5454f5eff 100644 Binary files a/src/api/java/ic2/api/item/ItemWrapper.class and b/src/api/java/ic2/api/item/ItemWrapper.class differ diff --git a/src/api/java/ic2/api/item/ItemWrapper.java b/src/api/java/ic2/api/item/ItemWrapper.java index 58f807340..6859d29c1 100644 --- a/src/api/java/ic2/api/item/ItemWrapper.java +++ b/src/api/java/ic2/api/item/ItemWrapper.java @@ -1,12 +1,12 @@ 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; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - /** * Wrapper for inserting interfaces into items you don't own. * diff --git a/src/api/java/ic2/api/item/package-info.class b/src/api/java/ic2/api/item/package-info.class index 222a18333..69fb7c313 100644 Binary files a/src/api/java/ic2/api/item/package-info.class and b/src/api/java/ic2/api/item/package-info.class differ diff --git a/src/api/java/ic2/api/network/ClientModifiable.class b/src/api/java/ic2/api/network/ClientModifiable.class new file mode 100644 index 000000000..dea7b6fc1 Binary files /dev/null and b/src/api/java/ic2/api/network/ClientModifiable.class differ diff --git a/src/api/java/ic2/api/network/ClientModifiable.java b/src/api/java/ic2/api/network/ClientModifiable.java new file mode 100644 index 000000000..a950cbf03 --- /dev/null +++ b/src/api/java/ic2/api/network/ClientModifiable.java @@ -0,0 +1,10 @@ +package ic2.api.network; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface ClientModifiable { } diff --git a/src/api/java/ic2/api/network/INetworkDataProvider.java b/src/api/java/ic2/api/network/INetworkDataProvider.java index c3f283e5f..f5a3d24b9 100644 --- a/src/api/java/ic2/api/network/INetworkDataProvider.java +++ b/src/api/java/ic2/api/network/INetworkDataProvider.java @@ -4,13 +4,16 @@ 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. - * + * + * If a name contains =, the name will be split into the actual name and the value, avoiding a + * field read. + * * @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 5f3228cec..7c59a270e 100644 --- a/src/api/java/ic2/api/network/INetworkItemEventListener.java +++ b/src/api/java/ic2/api/network/INetworkItemEventListener.java @@ -10,7 +10,7 @@ public interface INetworkItemEventListener { /** * Called when a network event is received. * - * @param itemStack item stack + * @param stack item stack * @param player player containing the item * @param event event ID */ diff --git a/src/api/java/ic2/api/network/INetworkManager.class b/src/api/java/ic2/api/network/INetworkManager.class new file mode 100644 index 000000000..d0fd9c34a Binary files /dev/null and b/src/api/java/ic2/api/network/INetworkManager.class differ diff --git a/src/api/java/ic2/api/network/INetworkManager.java b/src/api/java/ic2/api/network/INetworkManager.java new file mode 100644 index 000000000..bef3c59d0 --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkManager.java @@ -0,0 +1,28 @@ +package ic2.api.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +/** + * This is just here for the API functions. + * Do not implement by yourself. + * + * @see NetworkHelper + * + * @author Aroma1997 + * + */ +public interface INetworkManager { + + void updateTileEntityField(TileEntity te, String field); + + void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange); + + void initiateItemEvent(EntityPlayer player, ItemStack stack, int event, boolean limitRange); + + void initiateClientTileEntityEvent(TileEntity te, int event); + + void initiateClientItemEvent(ItemStack stack, int event); + +} diff --git a/src/api/java/ic2/api/network/NetworkHelper.class b/src/api/java/ic2/api/network/NetworkHelper.class index 85ff02b47..665d98507 100644 Binary files a/src/api/java/ic2/api/network/NetworkHelper.class and b/src/api/java/ic2/api/network/NetworkHelper.class differ diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java index 5f9138d30..a2f71256d 100644 --- a/src/api/java/ic2/api/network/NetworkHelper.java +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -1,11 +1,14 @@ 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.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.relauncher.Side; + /** * Provides methods to initiate events and synchronize tile entity fields in SMP. * @@ -40,7 +43,7 @@ public final class NetworkHelper { * - ItemStack * - NBTBase (includes NBTTagCompound) * - Block, Item, Achievement, Potion, Enchantment - * - ChunkCoordinates, ChunkCoordIntPair + * - BlockPos, 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) * @@ -54,14 +57,7 @@ public final class NetworkHelper { * @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); - } + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).updateTileEntityField(te, field); } /** @@ -76,14 +72,7 @@ public final class NetworkHelper { * 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); - } + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).initiateTileEntityEvent(te, event, limitRange); } /** @@ -95,20 +84,13 @@ public final class NetworkHelper { * INetworkItemEventListener.onNetworkEvent (if implemented by the item). * * @param player EntityPlayer holding the item - * @param itemStack ItemStack containing the item + * @param stack 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); - } + public static void initiateItemEvent(EntityPlayer player, ItemStack stack, int event, boolean limitRange) { + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).initiateItemEvent(player, stack, event, limitRange); } @@ -123,14 +105,7 @@ public final class NetworkHelper { * @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); - } + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).initiateClientTileEntityEvent(te, event); } /** @@ -140,55 +115,41 @@ public final class NetworkHelper { * * This method doesn't do anything if executed on the server. * - * @param itemStack ItemStack containing the item + * @param stack 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); - } + public static void initiateClientItemEvent(ItemStack stack, int event) { + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).initiateClientItemEvent(stack, event); } /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 + * This will return the NetworkManager for the given side. + * @param side the side to get the NetworkManager for. + * @return The NetworkManager for the given side. */ - 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()); + public static INetworkManager getNetworkManager(Side side) { + if (side.isClient()) { + return clientInstance; + } + else { + return serverInstance; } - - return "ic2"; } + private static INetworkManager serverInstance; + private static INetworkManager clientInstance; + /** - * Get the NetworkManager instance, used internally. - * - * @return NetworkManager instance + * Sets the internal INetworkManager instance. + * ONLY IC2 CAN DO THIS!!!!!!! */ - private static Object getInstance() { - try { - return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null); - } catch (Throwable e) { - throw new RuntimeException(e); + public static void setInstance(INetworkManager server, INetworkManager client) { + ModContainer mc = Loader.instance().activeModContainer(); + if (mc == null || !"IC2".equals(mc.getModId())) { + throw new IllegalAccessError(); } + serverInstance = server; + clientInstance = client; } - - 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.class b/src/api/java/ic2/api/network/package-info.class index f4f18429e..c2d4dd55b 100644 Binary files a/src/api/java/ic2/api/network/package-info.class and b/src/api/java/ic2/api/network/package-info.class differ diff --git a/src/api/java/ic2/api/package-info.class b/src/api/java/ic2/api/package-info.class index 7caf69978..70b3064f5 100644 Binary files a/src/api/java/ic2/api/package-info.class and b/src/api/java/ic2/api/package-info.class differ diff --git a/src/api/java/ic2/api/reactor/IReactor.class b/src/api/java/ic2/api/reactor/IReactor.class new file mode 100644 index 000000000..6f62b5b2c Binary files /dev/null and b/src/api/java/ic2/api/reactor/IReactor.class differ 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 000000000..0c43add16 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -0,0 +1,144 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; + +/** + * Interface implemented by the tile entity of nuclear reactors. + */ +public interface IReactor { + /** + * Return the tile entity representing the reactor core. + * + * @return the reactor core's TE or null. + */ + public TileEntity getCoreTe(); + + /** + * 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(); + + // TODO: add the rs modifier capability to the api somehow + + /** + * @return true if the reactor is FluidCooled + */ + public boolean isFluidCooled(); +} diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.class b/src/api/java/ic2/api/reactor/IReactorComponent.class new file mode 100644 index 000000000..cf1b0fb7a Binary files /dev/null and b/src/api/java/ic2/api/reactor/IReactorComponent.class differ 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 000000000..4b934e0c0 --- /dev/null +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -0,0 +1,98 @@ +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 stack Reference to the specific instance of called ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, 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 stack Reference to the specific instance of called ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY, boolean heatrun); + + /** + * Called by components to determine whether your component can be heated. + * @param stack Reference to the specific instance of iterated ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, 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 stack Reference to the specific instance of iterated ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, 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 stack Reference to the specific instance of iterated ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, 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 stack Reference to the specific instance of iterated ItemStack + * @param reactor Reference to the Reactor + * @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(ItemStack stack, IReactor reactor, 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 stack Reference to the specific instance of iterated ItemStack + * @param reactor Reference to the Reactor + * @return your explosion modifier + */ + public float influenceExplosion(ItemStack stack, IReactor reactor); +} diff --git a/src/api/java/ic2/api/reactor/package-info.class b/src/api/java/ic2/api/reactor/package-info.class new file mode 100644 index 000000000..d27d5e085 Binary files /dev/null and b/src/api/java/ic2/api/reactor/package-info.class differ 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 000000000..b500c3d34 --- /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 net.minecraftforge.fml.common.API; + diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class index eebdb6bd1..309dd5d11 100644 Binary files a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class and b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class differ diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java index 87240e70f..5eba1b68e 100644 --- a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java +++ b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager.java @@ -3,6 +3,7 @@ package ic2.api.recipe; import java.util.Map; import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.FluidStack; public interface ICannerEnrichRecipeManager { diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class b/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class new file mode 100644 index 000000000..cb375fc2b Binary files /dev/null and b/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class differ diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class new file mode 100644 index 000000000..78c4f28f8 Binary files /dev/null and b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class differ diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java new file mode 100644 index 000000000..a7b7907ab --- /dev/null +++ b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java @@ -0,0 +1,64 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +/** + * Fermenter recipe manager, very closely based off of {@link ISemiFluidFuelManager} + * + * @author Chocohead + */ +public interface IFermenterRecipeManager extends ILiquidAcceptManager { + /** + * Add a new fluid to the fermenter. + * + * @param input The name of the fluid to ferment + * @param inputAmount The amount of input fluid used per operation + * @param ticks The total amount of heat needed to convert the input into the output + * @param output The name of the fluid that is being fermented into + * @param outputAmount The amount of output fluid produced per operation + */ + void addRecipe(String input, int inputAmount, int heat, String output, int outputAmount); + + /** + * Get a fermenter recipe for the given fluid + * + * @return The found recipe or null if no recipe is found + */ + FermentationProperty getFermentationInformation(Fluid fluid); + + /** + * Get the {@link FluidStack} output for the given input fluid + * + * @param Input fluid + * @return Output fluid + amount + */ + FluidStack getOutput(Fluid input); + + /** + * Gets the whole current fluid mappings + * @return The current fluid map + */ + Map getRecipeMap(); + + public static class FermentationProperty { + public FermentationProperty(int inputAmount, int heat, String output, int outputAmount) { + this.inputAmount = inputAmount; + this.heat = heat; + this.output = output; + this.outputAmount = outputAmount; + } + + public FluidStack getOutput() { + return FluidRegistry.getFluid(this.output) == null ? null : new FluidStack(FluidRegistry.getFluid(this.output), this.outputAmount); + } + + public final int inputAmount; + public final int heat; + public final String output; + public final int outputAmount; + } +} \ No newline at end of file diff --git a/src/api/java/ic2/api/recipe/IFluidRecipeManager$RecipeIoContainerFluid.class b/src/api/java/ic2/api/recipe/IFluidRecipeManager$RecipeIoContainerFluid.class new file mode 100644 index 000000000..d2fad7753 Binary files /dev/null and b/src/api/java/ic2/api/recipe/IFluidRecipeManager$RecipeIoContainerFluid.class differ diff --git a/src/api/java/ic2/api/recipe/IFluidRecipeManager.class b/src/api/java/ic2/api/recipe/IFluidRecipeManager.class new file mode 100644 index 000000000..a6f3a2d4e Binary files /dev/null and b/src/api/java/ic2/api/recipe/IFluidRecipeManager.class differ diff --git a/src/api/java/ic2/api/recipe/IFluidRecipeManager.java b/src/api/java/ic2/api/recipe/IFluidRecipeManager.java new file mode 100644 index 000000000..7cc662429 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IFluidRecipeManager.java @@ -0,0 +1,60 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.fluids.FluidStack; + + +/** + * Recipe manager interface for machines that will probably never be added. + * + * @author estebes, Player + */ +public interface IFluidRecipeManager { + /** + * Adds a recipe to the machine. + * + * @param input Fluid input + * @param output Output fluid + */ + public boolean addRecipe(IRecipeInput input, NBTTagCompound metadata, boolean replace, FluidStack... output); + + /** + * Gets the recipe output for the given input. + * + * @param input Fluid input + * @param adjustInput modify the input according to the recipe's requirements + * @return Recipe output, or null if none, output fluid in nbt + */ + public RecipeOutputFluid getOutputFor(ItemStack input, boolean adjustInput); + + /** + * Get all registered recipes (optional operation). + * + * The method is only available if {@link #isIterable()} is true. + * You're a mad evil scientist if you ever modify this. + * + * @return Iterable of all recipes registered to the manager. + * @throws UnsupportedOperationException if {@link #isIterable()} is false. + */ + public Iterable getRecipes(); + + /** + * Determine whether the recipes can be iterated. + * + * @return true if {@link #getRecipes()} is implemented, false otherwise. + */ + public boolean isIterable(); + + + public static class RecipeIoContainerFluid { + public RecipeIoContainerFluid(IRecipeInput input, RecipeOutputFluid output) { + this.input = input; + this.output = output; + } + + public final IRecipeInput input; + public final RecipeOutputFluid output; + } +} diff --git a/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager$HeatExchangeProperty.class b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager$HeatExchangeProperty.class new file mode 100644 index 000000000..374f186d7 Binary files /dev/null and b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager$HeatExchangeProperty.class differ diff --git a/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.class b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.class new file mode 100644 index 000000000..b58008d86 Binary files /dev/null and b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.class differ diff --git a/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java new file mode 100644 index 000000000..68decbb39 --- /dev/null +++ b/src/api/java/ic2/api/recipe/ILiquidHeatExchangerManager.java @@ -0,0 +1,39 @@ +package ic2.api.recipe; + +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; + +public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager { + + /** + * Add a new fluid heatup/cooldown recipe. + * + * @param fluidName the fluid to heat up/cool down + * @param fluidOutput the fluid the above fluid turns into + * @param huPerMB the Thermal Energy difference in hU for the conversion of one mB fluid + */ + void addFluid(String fluidName, String fluidOutput, int huPerMB); + + HeatExchangeProperty getHeatExchangeProperty(Fluid fluid); + + Map getHeatExchangeProperties(); + + /** + * This returns an ILiquidAcceptManager that only accepts fluids, that can be heated up / cooled down, but not both. + * You can basically use this to check if the liquid resulting from this conversion can be reprocessed into the first one. + * @return Returns the SingleDirectionManager. + */ + ILiquidAcceptManager getSingleDirectionLiquidManager(); + + public static class HeatExchangeProperty { + public HeatExchangeProperty(Fluid outputFluid, int huPerMB) { + this.outputFluid = outputFluid; + this.huPerMB = huPerMB; + } + + public final Fluid outputFluid; + public final int huPerMB; + } + +} diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager$RecipeIoContainer.class b/src/api/java/ic2/api/recipe/IMachineRecipeManager$RecipeIoContainer.class new file mode 100644 index 000000000..0d21f7ada Binary files /dev/null and b/src/api/java/ic2/api/recipe/IMachineRecipeManager$RecipeIoContainer.class differ diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.class b/src/api/java/ic2/api/recipe/IMachineRecipeManager.class index 5476c9df2..35823e21f 100644 Binary files a/src/api/java/ic2/api/recipe/IMachineRecipeManager.class and b/src/api/java/ic2/api/recipe/IMachineRecipeManager.class differ diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java index d2d4382b7..efa62cc88 100644 --- a/src/api/java/ic2/api/recipe/IMachineRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IMachineRecipeManager.java @@ -1,28 +1,30 @@ 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 + * @author Player, RichardG */ -public interface IMachineRecipeManager { // TODO: merge with IMachineRecipeManagerExt +public interface IMachineRecipeManager { /** * Adds a recipe to the machine. * + * Meta data format: + * - thermal centrifuge: {"minHeat": 1-xxx} + * - ore washing plant: {"amount": 1-8000} + * + * @note Replace is only as reliable as IRecipeInput.getInputs(). + * * @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} - * + * @param metadata Meta data for additional recipe properties, may be null. + * @param replace Replace conflicting existing recipes, not recommended, may be ignored. + * @param outputs Recipe outputs, zero or more depending on the machine. + * @return true on success, false otherwise, e.g. on conflicts. */ - public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs); + public boolean addRecipe(IRecipeInput input, NBTTagCompound metadata, boolean replace, ItemStack... outputs); /** * Gets the recipe output for the given input. @@ -34,11 +36,31 @@ public interface IMachineRecipeManager { // TODO: merge with IMachineRecipeManag public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput); /** - * Gets a list of recipes. + * Get all registered recipes (optional operation). * + * The method is only available if {@link #isIterable()} is true. * You're a mad evil scientist if you ever modify this. * - * @return List of recipes + * @return Iterable of all recipes registered to the manager. + * @throws UnsupportedOperationException if {@link #isIterable()} is false. */ - public Map getRecipes(); // TODO: Change to iterable/collection/list + public Iterable getRecipes(); + + /** + * Determine whether the recipes can be iterated. + * + * @return true if {@link #getRecipes()} is implemented, false otherwise. + */ + public boolean isIterable(); + + + public static class RecipeIoContainer { + public RecipeIoContainer(IRecipeInput input, RecipeOutput output) { + this.input = input; + this.output = output; + } + + public final IRecipeInput input; + public final RecipeOutput output; + } } diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.class b/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.class deleted file mode 100644 index b6f9bac0e..000000000 Binary files a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.class and /dev/null differ diff --git a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java b/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java deleted file mode 100644 index 9c68706d9..000000000 --- a/src/api/java/ic2/api/recipe/IMachineRecipeManagerExt.java +++ /dev/null @@ -1,22 +0,0 @@ -package ic2.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public interface IMachineRecipeManagerExt extends IMachineRecipeManager { - /** - * Adds a recipe to the machine. - * - * @note Overwrite is only as reliable as IRecipeInput.getInputs(). - * - * @param input Recipe input - * @param metadata Meta data for additional recipe properties, may be null. - * @param overwrite Replace an existing recipe, not recommended, may be ignored. - * @param outputs Recipe outputs, zero or more depending on the machine. - * @return true on success, false otherwise, e.g. on conflicts. - * - * For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx} - * For the ore washing plant @param metadata meta data {"amount": 1-8000} - */ - public boolean addRecipe(IRecipeInput input, NBTTagCompound metadata, boolean overwrite, ItemStack... outputs); -} diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class index 74e0273f8..eb5042a08 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class and b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java index ae9d1dccd..cc832e61a 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -1,5 +1,7 @@ package ic2.api.recipe; +import ic2.api.item.IC2Items; + import java.util.ArrayList; import java.util.List; @@ -8,6 +10,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; public class RecipeInputFluidContainer implements IRecipeInput { public RecipeInputFluidContainer(Fluid fluid) { @@ -22,9 +25,15 @@ public class RecipeInputFluidContainer implements IRecipeInput { @Override public boolean matches(ItemStack subject) { FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); - if (fs == null) return false; - return fs.getFluid() == fluid; + if (fs == null && subject.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem item = (IFluidContainerItem)subject.getItem(); + fs = item.getFluid(subject); + } + + // match amount precisely to avoid having to deal with leftover + return fs == null && fluid == null || + fs != null && fs.getFluid() == fluid && fs.amount >= amount; } @Override @@ -39,6 +48,7 @@ public class RecipeInputFluidContainer implements IRecipeInput { for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); } + ret.add(IC2Items.getItem("fluid_cell", fluid.getName())); return ret; } diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.class b/src/api/java/ic2/api/recipe/RecipeInputItemStack.class index 2f3a70ba1..c956c06d8 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputItemStack.class and b/src/api/java/ic2/api/recipe/RecipeInputItemStack.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java index f00951381..84f86ea12 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import net.minecraft.item.ItemStack; + import net.minecraftforge.oredict.OreDictionary; public class RecipeInputItemStack implements IRecipeInput { diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.class b/src/api/java/ic2/api/recipe/RecipeInputOreDict.class index 5db862212..e7a3a2db3 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputOreDict.class and b/src/api/java/ic2/api/recipe/RecipeInputOreDict.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java index e90676328..e6e4695d0 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -6,6 +6,7 @@ import java.util.List; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import net.minecraftforge.oredict.OreDictionary; public class RecipeInputOreDict implements IRecipeInput { diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.class b/src/api/java/ic2/api/recipe/RecipeOutput.class index 0dad69cfc..a2a19b3b1 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeOutput.class and b/src/api/java/ic2/api/recipe/RecipeOutput.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java index 34c7fe9c3..80ad5fb5c 100644 --- a/src/api/java/ic2/api/recipe/RecipeOutput.java +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -25,8 +25,7 @@ public final class RecipeOutput { RecipeOutput ro = (RecipeOutput) obj; if (items.size() == ro.items.size() && - (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null) && - metadata.equals(ro.metadata)) { + (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) { Iterator itA = items.iterator(); Iterator itB = ro.items.iterator(); diff --git a/src/api/java/ic2/api/recipe/RecipeOutputFluid.class b/src/api/java/ic2/api/recipe/RecipeOutputFluid.class new file mode 100644 index 000000000..ef597f4dd Binary files /dev/null and b/src/api/java/ic2/api/recipe/RecipeOutputFluid.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeOutputFluid.java b/src/api/java/ic2/api/recipe/RecipeOutputFluid.java new file mode 100644 index 000000000..750492245 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeOutputFluid.java @@ -0,0 +1,57 @@ +package ic2.api.recipe; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.fluids.FluidStack; + +/** + * @author estebes + */ +public class RecipeOutputFluid { + public RecipeOutputFluid(NBTTagCompound metadata, List outputs) { + assert !outputs.contains(null); + + this.metadata = metadata; + this.outputs = outputs; + } + + public RecipeOutputFluid(NBTTagCompound metadata, FluidStack... outputs) { + this(metadata, Arrays.asList(outputs)); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof RecipeOutputFluid) { + RecipeOutputFluid ro = (RecipeOutputFluid) obj; + + if (outputs.size() == ro.outputs.size() && + (metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) { + Iterator itA = outputs.iterator(); + Iterator itB = ro.outputs.iterator(); + + while (itA.hasNext() && itB.hasNext()) { + FluidStack stackA = itA.next(); + FluidStack stackB = itB.next(); + + if (stackA.isFluidStackIdentical(stackB)) return false; + } + + return true; + } + } + + return false; + } + + @Override + public String toString() { + return "ROutput<"+outputs+","+metadata+">"; + } + + public final List outputs; + public final NBTTagCompound metadata; +} diff --git a/src/api/java/ic2/api/recipe/Recipes.class b/src/api/java/ic2/api/recipe/Recipes.class index 559ffe865..135ea928e 100644 Binary files a/src/api/java/ic2/api/recipe/Recipes.class and b/src/api/java/ic2/api/recipe/Recipes.class differ diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java index 4c1259768..50fc6e6fb 100644 --- a/src/api/java/ic2/api/recipe/Recipes.java +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -3,16 +3,17 @@ package ic2.api.recipe; /** * General recipe registry. - * + * * @author Richard */ public class Recipes { + public static IMachineRecipeManager furnace; 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 blastfurnace; public static IMachineRecipeManager recycler; public static IMachineRecipeManager metalformerExtruding; public static IMachineRecipeManager metalformerCutting; @@ -20,15 +21,16 @@ public class Recipes { public static IMachineRecipeManager oreWashing; public static ICannerBottleRecipeManager cannerBottle; public static ICannerEnrichRecipeManager cannerEnrich; + public static IFermenterRecipeManager fermenter; /** * 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); @@ -56,5 +58,13 @@ public class Recipes { public static ICraftingRecipeManager advRecipes; public static ISemiFluidFuelManager semiFluidGenerator; - public static IFluidHeatManager FluidHeatGenerator; + public static IFluidHeatManager fluidHeatGenerator; + /** + * Used by the Liquid Heat Exchanger to cool down liquids and determine the amount of hu generated for every mb. + */ + public static ILiquidHeatExchangerManager liquidCooldownManager; + /** + * Opposite of {@link #liquidCooldownManager}. This is for Liquids that can be heated up again. + */ + public static ILiquidHeatExchangerManager liquidHeatupManager; } diff --git a/src/api/java/ic2/api/recipe/package-info.class b/src/api/java/ic2/api/recipe/package-info.class index f30b57f78..8a795bbdb 100644 Binary files a/src/api/java/ic2/api/recipe/package-info.class and b/src/api/java/ic2/api/recipe/package-info.class differ diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.class b/src/api/java/ic2/api/tile/ExplosionWhitelist.class index 0fbd082df..a55a2c524 100644 Binary files a/src/api/java/ic2/api/tile/ExplosionWhitelist.class and b/src/api/java/ic2/api/tile/ExplosionWhitelist.class differ diff --git a/src/api/java/ic2/api/tile/ExplosionWhitelist.java b/src/api/java/ic2/api/tile/ExplosionWhitelist.java index fa4a474a5..9a4d96998 100644 --- a/src/api/java/ic2/api/tile/ExplosionWhitelist.java +++ b/src/api/java/ic2/api/tile/ExplosionWhitelist.java @@ -1,13 +1,14 @@ package ic2.api.tile; -import java.util.HashSet; +import java.util.Collections; +import java.util.IdentityHashMap; 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 @@ -16,25 +17,25 @@ import net.minecraft.block.Block; 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 */ @@ -42,6 +43,6 @@ public final class ExplosionWhitelist { return whitelist.contains(block); } - private static Set whitelist = new HashSet(); + private static Set whitelist = Collections.newSetFromMap(new IdentityHashMap()); } diff --git a/src/api/java/ic2/api/tile/IEnergyStorage.class b/src/api/java/ic2/api/tile/IEnergyStorage.class index e03e23fce..603752384 100644 Binary files a/src/api/java/ic2/api/tile/IEnergyStorage.class and b/src/api/java/ic2/api/tile/IEnergyStorage.class differ diff --git a/src/api/java/ic2/api/tile/IRotorProvider.class b/src/api/java/ic2/api/tile/IRotorProvider.class new file mode 100644 index 000000000..c772aea74 Binary files /dev/null and b/src/api/java/ic2/api/tile/IRotorProvider.class differ diff --git a/src/api/java/ic2/api/tile/IRotorProvider.java b/src/api/java/ic2/api/tile/IRotorProvider.java new file mode 100644 index 000000000..0a3597e1e --- /dev/null +++ b/src/api/java/ic2/api/tile/IRotorProvider.java @@ -0,0 +1,33 @@ +package ic2.api.tile; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; + +import ic2.api.item.IKineticRotor; + +/** + * Interface for {@link TileEntity}s that can have rotors, see also {@link IKineticRotor}
+ * Use the {@link RotorRegistry} to use IC2's default windmill renderer + */ +public interface IRotorProvider { + /** + * @return Radius of current rotor (in blocks), or 0 for no rotor + */ + public int getRotorDiameter(); + + /** + * @return The current direction the rotor is facing + */ + public EnumFacing getFacing(); + + /** + * @return Angle (in degrees) to render the rotor at + */ + public float getAngle(); + + /** + * @return Texture of the current rotor, called every tick so remember to store in a variable + */ + public ResourceLocation getRotorRenderTexture(); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/tile/IWrenchable.class b/src/api/java/ic2/api/tile/IWrenchable.class index 3bc6fff8c..c3628ae7c 100644 Binary files a/src/api/java/ic2/api/tile/IWrenchable.class and b/src/api/java/ic2/api/tile/IWrenchable.class differ diff --git a/src/api/java/ic2/api/tile/IWrenchable.java b/src/api/java/ic2/api/tile/IWrenchable.java index 8fcbea59e..f43067b3a 100644 --- a/src/api/java/ic2/api/tile/IWrenchable.java +++ b/src/api/java/ic2/api/tile/IWrenchable.java @@ -1,61 +1,67 @@ package ic2.api.tile; +import java.util.List; + +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; /** - * Allows a tile entity to make use of the wrench's removal and rotation functions. + * Allows a block 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 + * Get direction the block is facing. + * + * The direction typically refers to the front/main/functionally dominant side of a block. + * + * @param world World containing the block. + * @param pos The block's current position in the world. + * @return Current block facing. */ - boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side); + EnumFacing getFacing(World world, BlockPos pos); /** - * Get the block's facing. - * - * @return Block facing + * Set the block's facing to face towards the specified direction. + * + * Contrary to Block.rotateBlock the block should always face the requested direction after + * successfully processing this method. + * + * @param world World containing the block. + * @param pos The block's current position in the world. + * @param newDirection Requested facing, see {@link #getFacing}. + * @param player Player causing the action, may be null. + * @return true if successful, false otherwise. */ - short getFacing(); - - /** - * Set the block's facing - * - * @param facing facing to set the block to - */ - void setFacing(short facing); + boolean setFacing(World world, BlockPos pos, EnumFacing newDirection, EntityPlayer player); /** * 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 + * @param world World containing the block. + * @param pos The block's current position in the world. + * @param player Player causing the action, may be null. + * @return true if allowed, false otherwise. */ - boolean wrenchCanRemove(EntityPlayer entityPlayer); + boolean wrenchCanRemove(World world, BlockPos pos, EntityPlayer player); /** - * 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. - * + * Determine the items 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 + * + * @param world World containing the block. + * @param pos The block's current position in the world. + * @param state The block's block state before removal. + * @param te The block's tile entity before removal, if any, may be null. + * @param player Player removing the block, may be null. + * @param fortune Fortune level for drop calculation. + * @return ItemStacks to drop, may be empty. */ - ItemStack getWrenchDrop(EntityPlayer entityPlayer); + List getWrenchDrops(World world, BlockPos pos, IBlockState state, TileEntity te, EntityPlayer player, int fortune); } diff --git a/src/api/java/ic2/api/tile/RotorRegistry$IRotorRegistry.class b/src/api/java/ic2/api/tile/RotorRegistry$IRotorRegistry.class new file mode 100644 index 000000000..4b25b38aa Binary files /dev/null and b/src/api/java/ic2/api/tile/RotorRegistry$IRotorRegistry.class differ diff --git a/src/api/java/ic2/api/tile/RotorRegistry.class b/src/api/java/ic2/api/tile/RotorRegistry.class new file mode 100644 index 000000000..329ff28ad Binary files /dev/null and b/src/api/java/ic2/api/tile/RotorRegistry.class differ diff --git a/src/api/java/ic2/api/tile/RotorRegistry.java b/src/api/java/ic2/api/tile/RotorRegistry.java new file mode 100644 index 000000000..dd652f2cc --- /dev/null +++ b/src/api/java/ic2/api/tile/RotorRegistry.java @@ -0,0 +1,43 @@ +package ic2.api.tile; + +import static net.minecraftforge.fml.relauncher.Side.CLIENT; + +import net.minecraft.tileentity.TileEntity; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Helper class for registering {@link IRotorProvider}s to provide the default windmill renderer + */ +@SideOnly(CLIENT) +public class RotorRegistry { + /** + * Method to register a tile entity with the default IC2 windmill TESH + * @param clazz {@link TileEntity} that implements {@link IRotorProvider} + * @param Type checking to ensure only {@link IRotorProvider} implementing classes are registered + */ + public static void registerRotorProvider(Class clazz) { + if (INSTANCE != null) INSTANCE.registerRotorProvider(clazz); + } + + /** + * Sets the internal Registry instance. + * ONLY IC2 CAN DO THIS!!!!!!! + */ + public static void setInstance(IRotorRegistry i) { + ModContainer mc = Loader.instance().activeModContainer(); + if (mc == null || !"IC2".equals(mc.getModId())) { + throw new IllegalAccessError("Only IC2 can set the instance"); + } else { + INSTANCE = i; + } + } + + private static IRotorRegistry INSTANCE; + + public static interface IRotorRegistry { + public void registerRotorProvider(Class clazz); + } +} \ No newline at end of file diff --git a/src/api/java/ic2/api/tile/package-info.class b/src/api/java/ic2/api/tile/package-info.class index 226d45541..9cd6bac26 100644 Binary files a/src/api/java/ic2/api/tile/package-info.class and b/src/api/java/ic2/api/tile/package-info.class differ diff --git a/src/api/java/ic2/api/util/package-info.class b/src/api/java/ic2/api/util/package-info.class index 4c91d9186..6aa78d24c 100644 Binary files a/src/api/java/ic2/api/util/package-info.class and b/src/api/java/ic2/api/util/package-info.class differ diff --git a/src/main/java/mekanism/common/integration/IC2ItemManager.java b/src/main/java/mekanism/common/integration/IC2ItemManager.java index 04d2c1539..3dd1e921b 100644 --- a/src/main/java/mekanism/common/integration/IC2ItemManager.java +++ b/src/main/java/mekanism/common/integration/IC2ItemManager.java @@ -24,14 +24,14 @@ public class IC2ItemManager implements IElectricItemManager if(energizedItem.canReceive(itemStack)) { double energyNeeded = energizedItem.getMaxEnergy(itemStack)-energizedItem.getEnergy(itemStack); - double energyToStore = Math.min(Math.min(amount* general.FROM_IC2, energizedItem.getMaxEnergy(itemStack)*0.01), energyNeeded); + double energyToStore = Math.min(Math.min(amount*general.FROM_IC2, energizedItem.getMaxEnergy(itemStack)*0.01), energyNeeded); if(!simulate) { energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToStore); } - return (int)Math.round(energyToStore* general.TO_IC2); + return (int)Math.round(energyToStore*general.TO_IC2); } return 0; @@ -42,7 +42,7 @@ public class IC2ItemManager implements IElectricItemManager { if(energizedItem.canSend(itemStack)) { - double energyWanted = amount* general.FROM_IC2; + double energyWanted = amount*general.FROM_IC2; double energyToGive = Math.min(Math.min(energyWanted, energizedItem.getMaxEnergy(itemStack)*0.01), energizedItem.getEnergy(itemStack)); if(!simulate) @@ -50,7 +50,7 @@ public class IC2ItemManager implements IElectricItemManager energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToGive); } - return (int)Math.round(energyToGive* general.TO_IC2); + return (int)Math.round(energyToGive*general.TO_IC2); } return 0; @@ -59,13 +59,13 @@ public class IC2ItemManager implements IElectricItemManager @Override public boolean canUse(ItemStack itemStack, double amount) { - return energizedItem.getEnergy(itemStack) >= amount* general.FROM_IC2; + return energizedItem.getEnergy(itemStack) >= amount*general.FROM_IC2; } @Override public double getCharge(ItemStack itemStack) { - return (int)Math.round(energizedItem.getEnergy(itemStack)* general.TO_IC2); + return (int)Math.round(energizedItem.getEnergy(itemStack)*general.TO_IC2); } @Override @@ -85,4 +85,16 @@ public class IC2ItemManager implements IElectricItemManager { return null; } + + @Override + public double getMaxCharge(ItemStack stack) + { + return 0; + } + + @Override + public int getTier(ItemStack stack) + { + return 4; + } } diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index 733b36c22..2bbd99ebf 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -1,13 +1,11 @@ package mekanism.common.integration; -import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.IMachineRecipeManager.RecipeIoContainer; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; -import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.Recipes; import java.util.List; -import java.util.Map; import li.cil.oc.api.Driver; import mekanism.common.Mekanism; @@ -74,11 +72,11 @@ public final class MekanismHooks @Method(modid = "IC2") public void hookIC2Recipes() { - for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) + for(RecipeIoContainer entry : Recipes.macerator.getRecipes()) { - if(!entry.getKey().getInputs().isEmpty()) + if(!entry.input.getInputs().isEmpty()) { - List names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); + List names = MekanismUtils.getOreDictName(entry.input.getInputs().get(0)); for(String name : names) { @@ -86,7 +84,7 @@ public final class MekanismHooks if(name.startsWith("ingot")) { - RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); + RecipeHandler.addCrusherRecipe(entry.input.getInputs().get(0), entry.output.items.get(0)); did = true; } @@ -99,20 +97,20 @@ public final class MekanismHooks } try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal())); + Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, false, new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal())); } catch(Exception e) {} try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal())); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(MekanismItems.OtherDust, 1, 5)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Items.GLOWSTONE_DUST)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, new ItemStack(MekanismItems.OtherDust, 1, 1)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, false, new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal())); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, false, new ItemStack(MekanismItems.OtherDust, 1, 5)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, false, new ItemStack(Items.GLOWSTONE_DUST)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, false, new ItemStack(MekanismItems.OtherDust, 1, 1)); } catch(Exception e) {} try { for(Resource resource : Resource.values()) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("clump" + resource.getName()), null, new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); + Recipes.macerator.addRecipe(new RecipeInputOreDict("clump" + resource.getName()), null, false, new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); } } catch(Exception e) {} @@ -120,7 +118,7 @@ public final class MekanismHooks tag.setInteger("amplification", 50000); - Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(MekanismItems.EnrichedAlloy), 1), tag); + Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(MekanismItems.EnrichedAlloy), 1), tag, false); } @Method(modid = "ComputerCraft") diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 34a2bb458..a87c8bbfd 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -319,7 +319,7 @@ public final class OreDictManager public static void addIC2BronzeRecipe() { try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); + Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, false, StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); } catch(Exception e) {} } diff --git a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java index 904b6a8fc..9ac87929a 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -32,7 +32,6 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -164,34 +163,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS itemstack.getTagCompound().setInteger("tier", tier.ordinal()); } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return true; - } - - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } - - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } - - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } - @Override public void setInventory(NBTTagList nbtTags, Object... data) { @@ -326,20 +297,6 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS { return IC2ItemManager.getManager(this); } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } @Override public String getOwner(ItemStack stack) diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index b78144d97..620ad2aab 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -50,7 +50,6 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.SoundEvents; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -401,34 +400,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec return false; } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return false; - } - - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } - - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } - - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } - public boolean tryPlaceContainedLiquid(World world, ItemStack itemstack, BlockPos pos) { if(getFluidStack(itemstack) == null || !getFluidStack(itemstack).getFluid().canBePlacedInWorld()) @@ -780,20 +751,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { return IC2ItemManager.getManager(this); } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } @Override public FluidStack getFluid(ItemStack container) diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index 2af154ee7..55dc4f1d2 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -71,48 +71,6 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec list.add(charged); } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } - - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } - - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } - @Override public double getEnergy(ItemStack itemStack) { diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index 95f229ad5..c05524a0f 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -93,48 +93,6 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci list.add(charged); } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } - - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } - - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } - @Override public double getEnergy(ItemStack itemStack) { diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index dd819e2ad..9dde3f4f1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -1,5 +1,6 @@ package mekanism.common.tile; +import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergySink; import mekanism.api.Coord4D; import mekanism.api.IConfigCardAccess.ISpecialConfigData; @@ -216,7 +217,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, EnumFacing direction) + public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { if(getInv() == null) { diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java index 7acd7ddfc..cc4651328 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java @@ -1,6 +1,5 @@ package mekanism.common.tile; -import ic2.api.tile.IWrenchable; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -27,7 +26,6 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -35,10 +33,9 @@ import net.minecraft.util.ITickable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Optional.Interface; -import net.minecraftforge.fml.common.Optional.Method; @Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2") -public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork, IChunkLoadHandler, IFrequencyHandler, ITickable +public abstract class TileEntityBasicBlock extends TileEntity implements ITileNetwork, IChunkLoadHandler, IFrequencyHandler, ITickable { /** The direction this block is facing. */ public EnumFacing facing = EnumFacing.NORTH; @@ -229,21 +226,6 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench return super.getCapability(capability, facing); } - @Override - @Method(modid = "IC2") - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) - { - return true; - } - - @Override - @Method(modid = "IC2") - public short getFacing() - { - return (short)facing.ordinal(); - } - - @Override public void setFacing(short direction) { if(canSetFacing(direction)) @@ -269,27 +251,6 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench return true; } - @Override - @Method(modid = "IC2") - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { - return true; - } - - @Override - @Method(modid = "IC2") - public float getWrenchDropRate() - { - return 1.0F; - } - - @Override - @Method(modid = "IC2") - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) - { - return getBlockType().getPickBlock(worldObj.getBlockState(getPos()), null, worldObj, getPos(), entityPlayer); - } - public boolean isPowered() { return redstone; diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index 27a1e5780..09d08cf2b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -3,7 +3,9 @@ package mekanism.common.tile; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergyConductor; +import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergyTile; import io.netty.buffer.ByteBuf; @@ -55,13 +57,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered != this) { if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } else if(registered == null) { @@ -77,11 +79,11 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } } } @@ -312,14 +314,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, EnumFacing direction) + public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { return getConsumingSides().contains(direction); } @Override @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, EnumFacing direction) + public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; } diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java index fbeb0aae1..ae673d574 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java @@ -3,7 +3,9 @@ package mekanism.common.tile; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergyConductor; +import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergyTile; import io.netty.buffer.ByteBuf; @@ -112,13 +114,13 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered != this) { if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } else if(registered == null) { @@ -134,11 +136,11 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } } } @@ -334,14 +336,14 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, EnumFacing direction) + public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { return getConsumingSides().contains(direction); } @Override @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, EnumFacing direction) + public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; } diff --git a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java index c3e92dc9f..91bc2d5c3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java +++ b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java @@ -4,7 +4,6 @@ import mekanism.common.security.ISecurityTile; import mekanism.common.tile.component.TileComponentSecurity; import mekanism.common.util.InventoryUtils; import mekanism.common.util.SecurityUtils; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -105,12 +104,6 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements return true; } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { - return SecurityUtils.canAccess(entityPlayer, this); - } - @Override public boolean canSetFacing(int side) { diff --git a/src/main/java/mekanism/common/util/CableUtils.java b/src/main/java/mekanism/common/util/CableUtils.java index e33365d46..d159e8979 100644 --- a/src/main/java/mekanism/common/util/CableUtils.java +++ b/src/main/java/mekanism/common/util/CableUtils.java @@ -2,6 +2,7 @@ package mekanism.common.util; import ic2.api.energy.EnergyNet; import ic2.api.energy.tile.IEnergyAcceptor; +import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySource; @@ -136,9 +137,9 @@ public final class CableUtils return true; } } - else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergyAcceptor) + else if(MekanismUtils.useIC2() && orig instanceof IEnergyEmitter && tileEntity instanceof IEnergyAcceptor) { - if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(orig, side.getOpposite())) + if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom((IEnergyEmitter)orig, side.getOpposite())) { return true; } @@ -258,7 +259,7 @@ public final class CableUtils } else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink) { - if(((IEnergySink)tileEntity).acceptsEnergyFrom((TileEntity)from, side.getOpposite())) + if(((IEnergySink)tileEntity).acceptsEnergyFrom(from, side.getOpposite())) { double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(((IEnergySink)tileEntity).getSinkTier())*general.FROM_IC2); toSend = Math.min(Math.min(toSend, ((IEnergySink)tileEntity).getDemandedEnergy()*general.FROM_IC2), Integer.MAX_VALUE); diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index 06814831d..a352fa126 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -28,7 +28,6 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -257,48 +256,6 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp return false; } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } - - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } - - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } - - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } - @Override public void setInventory(NBTTagList nbtTags, Object... data) { diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java index 681eb9244..a0becb887 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java @@ -3,7 +3,9 @@ package mekanism.generators.common.tile.turbine; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyAcceptor; import ic2.api.energy.tile.IEnergyConductor; +import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergyTile; import java.util.EnumSet; @@ -16,7 +18,6 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.PipeUtils; import mekanism.generators.common.content.turbine.TurbineFluidTank; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.Fluid; @@ -97,13 +98,13 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered != this) { if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } else if(registered == null) { @@ -119,11 +120,11 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I { if(!worldObj.isRemote) { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); if(registered instanceof IEnergyTile) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(registered)); } } } @@ -252,14 +253,14 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, EnumFacing direction) + public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { return false; } @Override @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, EnumFacing direction) + public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; }