Re-add an updated ic2, alter CC and update DepLoader. Fix more of the things.
1792 errors. A good night's work, I think.
This commit is contained in:
parent
ab47724473
commit
db7121454a
280 changed files with 6850 additions and 2031 deletions
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,7 @@ package dan200.computercraft.api.turtle;
|
|||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
/**
|
||||
* The primary interface for defining an turtle for Turtles. A turtle turtle
|
||||
|
@ -85,7 +85,7 @@ public interface ITurtleUpgrade
|
|||
* @param side Which side of the turtle (left or right) the peripheral resides on.
|
||||
* @return The Icon that you wish to be used to render your turtle peripheral.
|
||||
*/
|
||||
public Icon getIcon( ITurtleAccess turtle, TurtleSide side );
|
||||
public IIcon getIcon( ITurtleAccess turtle, TurtleSide side );
|
||||
|
||||
/**
|
||||
* TODO: Document me
|
||||
|
|
113
src/main/java/ic2/api/Direction.java
Normal file
113
src/main/java/ic2/api/Direction.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
package ic2.api;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Represents the 6 possible directions along the axis of a block.
|
||||
*/
|
||||
public enum Direction {
|
||||
/**
|
||||
* -X
|
||||
*/
|
||||
XN(0),
|
||||
/**
|
||||
* +X
|
||||
*/
|
||||
XP(1),
|
||||
|
||||
/**
|
||||
* -Y
|
||||
*/
|
||||
YN(2), //MC-Code starts with 0 here
|
||||
/**
|
||||
* +Y
|
||||
*/
|
||||
YP(3), // 1...
|
||||
|
||||
/**
|
||||
* -Z
|
||||
*/
|
||||
ZN(4),
|
||||
/**
|
||||
* +Z
|
||||
*/
|
||||
ZP(5);
|
||||
|
||||
Direction(int dir1) {
|
||||
this.dir = dir1;
|
||||
}
|
||||
|
||||
/*public CoordinateTuple ApplyToCoordinates(CoordinateTuple coordinates) {
|
||||
CoordinateTuple ret = new CoordinateTuple(coordinates);
|
||||
|
||||
ret.coords[dir/2] += GetSign();
|
||||
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get the tile entity next to a tile entity following this direction.
|
||||
*
|
||||
* @param tileEntity tile entity to check
|
||||
* @return Adjacent tile entity or null if none exists
|
||||
*/
|
||||
public TileEntity applyToTileEntity(TileEntity tileEntity) {
|
||||
int coords[] = { tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord };
|
||||
|
||||
coords[dir/2] += getSign();
|
||||
World world = tileEntity.getWorldObj();
|
||||
|
||||
if (world != null && world.blockExists(coords[0], coords[1], coords[2])) {
|
||||
try {
|
||||
return world.getTileEntity(coords[0], coords[1], coords[2]);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("error getting TileEntity at dim "+world.provider.dimensionId+" "+coords[0]+"/"+coords[1]+"/"+coords[2]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the inverse of this direction (XN -> XP, XP -> XN, etc.)
|
||||
*
|
||||
* @return Inverse direction
|
||||
*/
|
||||
public Direction getInverse() {
|
||||
int inverseDir = dir - getSign();
|
||||
|
||||
for (Direction direction : directions) {
|
||||
if (direction.dir == inverseDir) return direction;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert this direction to a Minecraft side value.
|
||||
*
|
||||
* @return Minecraft side value
|
||||
*/
|
||||
public int toSideValue() {
|
||||
return (dir + 4) % 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine direction sign (N for negative or P for positive).
|
||||
*
|
||||
* @return -1 if the direction is negative, +1 if the direction is positive
|
||||
*/
|
||||
private int getSign() {
|
||||
return (dir % 2) * 2 - 1;
|
||||
}
|
||||
|
||||
public ForgeDirection toForgeDirection() {
|
||||
return ForgeDirection.getOrientation(toSideValue());
|
||||
}
|
||||
|
||||
private int dir;
|
||||
public static final Direction[] directions = Direction.values();
|
||||
}
|
||||
|
56
src/main/java/ic2/api/crops/BaseSeed.java
Normal file
56
src/main/java/ic2/api/crops/BaseSeed.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package ic2.api.crops;
|
||||
|
||||
/**
|
||||
* Base agriculture seed. Used to determine the state of a plant once it is planted from an item.
|
||||
*/
|
||||
public class BaseSeed {
|
||||
/**
|
||||
* Plant ID.
|
||||
*/
|
||||
public int id;
|
||||
|
||||
/**
|
||||
* Plant size.
|
||||
*/
|
||||
public int size;
|
||||
|
||||
/**
|
||||
* Plant growth stat.
|
||||
*/
|
||||
public int statGrowth;
|
||||
|
||||
/**
|
||||
* Plant gain stat.
|
||||
*/
|
||||
public int statGain;
|
||||
|
||||
/**
|
||||
* Plant resistance stat.
|
||||
*/
|
||||
public int statResistance;
|
||||
|
||||
/**
|
||||
* For internal usage only.
|
||||
*/
|
||||
public int stackSize;
|
||||
|
||||
/**
|
||||
* Create a BaseSeed object.
|
||||
*
|
||||
* @param id1 plant ID
|
||||
* @param size1 plant size
|
||||
* @param statGrowth1 plant growth stat
|
||||
* @param statGain1 plant gain stat
|
||||
* @param statResistance1 plant resistance stat
|
||||
* @param stackSize1 for internal usage only
|
||||
*/
|
||||
public BaseSeed(int id1, int size1, int statGrowth1, int statGain1, int statResistance1, int stackSize1) {
|
||||
super();
|
||||
this.id = id1;
|
||||
this.size = size1;
|
||||
this.statGrowth = statGrowth1;
|
||||
this.statGain = statGain1;
|
||||
this.statResistance = statResistance1;
|
||||
this.stackSize = stackSize1;
|
||||
}
|
||||
}
|
374
src/main/java/ic2/api/crops/CropCard.java
Normal file
374
src/main/java/ic2/api/crops/CropCard.java
Normal file
|
@ -0,0 +1,374 @@
|
|||
package ic2.api.crops;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Base agriculture crop.
|
||||
*
|
||||
* Any crop extending this can be registered using registerCrop to be added into the game.
|
||||
*/
|
||||
public abstract class CropCard
|
||||
{
|
||||
/**
|
||||
* Plant name. Will be displayed to the player.
|
||||
*
|
||||
* @return Plant name
|
||||
*/
|
||||
public abstract String name();
|
||||
|
||||
/**
|
||||
* Your name here, will be shown in "Discovered by:" when analyzing seeds.
|
||||
*
|
||||
* @return Your name
|
||||
*/
|
||||
public String discoveredBy() {return "Alblaka";}
|
||||
|
||||
/**
|
||||
* Description of your plant. Keep it short, a few characters per line for up to two lines.
|
||||
* Default is showing attributes of your plant, 2 per line.
|
||||
*
|
||||
* @param i line to get, starting from 0
|
||||
* @return The line
|
||||
*/
|
||||
public String desc(int i)
|
||||
{
|
||||
String[] att = attributes();
|
||||
if (att == null || att.length==0) return "";
|
||||
if (i == 0)
|
||||
{
|
||||
String s = att[0];
|
||||
if (att.length >= 2)
|
||||
{
|
||||
s+=", "+att[1];
|
||||
if (att.length >= 3) s+=",";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
if (att.length < 3) return "";
|
||||
String s = att[2];
|
||||
if (att.length >= 4) s+=", "+att[3];
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tier of the plant. Ranges from 1 to 16, 0 is Weed.
|
||||
* Valuable and powerful crops have higher tiers, useless and weak ones have lower tiers.
|
||||
*
|
||||
* @return Tier
|
||||
*/
|
||||
public abstract int tier();
|
||||
|
||||
/**
|
||||
* Describe the plant through a set of stats, influencing breeding.
|
||||
* Plants sharing stats and attributes will tend to cross-breed more often.
|
||||
*
|
||||
* Stats:
|
||||
* - 0: Chemistry (Industrial uses based on chemical plant components)
|
||||
* - 1: Consumable (Food, potion ingredients, stuff meant to be eaten or similarly used)
|
||||
* - 2: Defensive (Plants with defense capabilities (damaging, explosive, chemical) or special abilities in general)
|
||||
* - 3: Colorful (How colorful/aesthetically/beautiful is the plant, like dye-plants or plants without actual effects)
|
||||
* - 4: Weed (Is this plant weed-like and rather unwanted/quick-spreading? Rare super-breed plants should have low values here)
|
||||
*
|
||||
* @param n index of the requested stat
|
||||
* @return The requested value of the stats
|
||||
*/
|
||||
public abstract int stat(int n);
|
||||
|
||||
/**
|
||||
* Additional attributes of the plant, also influencing breeding.
|
||||
* Plants sharing stats and attributes will tend to cross-breed more often.
|
||||
*
|
||||
* @return Attributes as an array of strings
|
||||
*/
|
||||
public abstract String[] attributes();
|
||||
|
||||
/**
|
||||
* Determine the max crop size.
|
||||
*
|
||||
* Currently only used for texture allocation.
|
||||
*/
|
||||
public abstract int maxSize();
|
||||
|
||||
/**
|
||||
* Instantiate your Icons here.
|
||||
*
|
||||
* This method will get called by IC2, don't call it yourself.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(IIconRegister iconRegister) {
|
||||
textures = new IIcon[maxSize()];
|
||||
|
||||
for (int i = 1; i <= textures.length; i++) {
|
||||
textures[i-1] = iconRegister.registerIcon("ic2:crop/blockCrop."+name()+"."+i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sprite the crop is meant to be rendered with.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return 0-255, representing the sprite index on the crop's spritesheet.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getSprite(ICropTile crop) {
|
||||
if (crop.getSize() <= 0 || crop.getSize() > textures.length) return null;
|
||||
|
||||
return textures[crop.getSize() - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop's spritesheet.
|
||||
* Per default crops_0.png of ic2-sprites
|
||||
* @return Texture file path
|
||||
*/
|
||||
public String getTextureFile() {
|
||||
return "/ic2/sprites/crops_0.png";
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of growth points needed to increase the plant's size.
|
||||
* Default is 200 * tier.
|
||||
*/
|
||||
public int growthDuration(ICropTile crop)
|
||||
{
|
||||
return tier()*200;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the plant can grow further.
|
||||
*
|
||||
* Consider:
|
||||
* - Humidity, nutrients and air quality
|
||||
* - Current size
|
||||
* - Light level
|
||||
* - Special biomes or conditions, accessible through crop.worldObj
|
||||
*
|
||||
* This method will be called upon empty upgraded crops to check whether a neighboring plant can cross onto it! Don't check if the size is greater than 0 and if the ID is real.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Whether the crop can grow
|
||||
*/
|
||||
public abstract boolean canGrow(ICropTile crop);
|
||||
|
||||
/**
|
||||
* Calculate the influence for the plant to grow based on humidity, nutrients and air.
|
||||
* Normal behavior is rating the three stats "normal", with each of them ranging from 0-30.
|
||||
* Basic rule: Assume everything returns 10. All together must equal 30. Add the factors to your likings, for example (humidity*0.7)+(nutrients*0.9)+(air*1.4)
|
||||
*
|
||||
* Default is humidity + nutrients + air (no factors).
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param humidity ground humidity, influenced by hydration
|
||||
* @param nutrients nutrient quality in ground, based on fertilizers
|
||||
* @param air air quality, influences by open gardens and less crops surrounding this one
|
||||
* @return 0-30
|
||||
*/
|
||||
public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air)
|
||||
{
|
||||
return (int) (humidity+nutrients+air);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to determine whether the plant can crossbreed with another crop.
|
||||
* Default is allow crossbreeding if the size is greater or equal than 3.
|
||||
*
|
||||
* @param crop crop to crossbreed with
|
||||
*/
|
||||
public boolean canCross(ICropTile crop)
|
||||
{
|
||||
return crop.getSize() >= 3;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plant is rightclicked by a player.
|
||||
* Default action is harvesting.
|
||||
*
|
||||
* Only called Serverside.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param player player rightclicking the crop
|
||||
* @return Whether the plant has changed
|
||||
*/
|
||||
public boolean rightclick(ICropTile crop, EntityPlayer player)
|
||||
{
|
||||
return crop.harvest(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the crop can be harvested.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Whether the crop can be harvested in its current state.
|
||||
*/
|
||||
public abstract boolean canBeHarvested(ICropTile crop);
|
||||
|
||||
/**
|
||||
* Base chance for dropping the plant's gains, specify values greater than 1 for multiple drops.
|
||||
* Default is 0.95^tier.
|
||||
*
|
||||
* @return Chance to drop the gains
|
||||
*/
|
||||
public float dropGainChance()
|
||||
{
|
||||
float base = 1F;
|
||||
for (int i = 0; i < tier(); i++) {base*=0.95;}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item obtained from harvesting the plant.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Item obtained
|
||||
*/
|
||||
public abstract ItemStack getGain(ICropTile crop);
|
||||
|
||||
/**
|
||||
* Get the size of the plant after harvesting.
|
||||
* Default is 1.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Plant size after harvesting
|
||||
*/
|
||||
public byte getSizeAfterHarvest(ICropTile crop) {return 1;}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plant is leftclicked by a player.
|
||||
* Default action is picking the plant.
|
||||
*
|
||||
* Only called Serverside.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param player player leftclicked the crop
|
||||
* @return Whether the plant has changed
|
||||
*/
|
||||
public boolean leftclick(ICropTile crop, EntityPlayer player)
|
||||
{
|
||||
return crop.pick(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base chance for dropping seeds when the plant is picked.
|
||||
* Default is 0.5*0.8^tier with a bigger chance for sizes greater than 2 and absolutely no chance for size 0.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Chance to drop the seeds
|
||||
*/
|
||||
public float dropSeedChance(ICropTile crop)
|
||||
{
|
||||
if (crop.getSize() == 1) return 0;
|
||||
float base = 0.5F;
|
||||
if (crop.getSize() == 2) base/=2F;
|
||||
for (int i = 0; i < tier(); i++) {base*=0.8;}
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain seeds dropped when the plant is picked.
|
||||
* Multiple drops of the returned ItemStack can occur.
|
||||
* Default action is generating a seed from this crop.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Seeds
|
||||
*/
|
||||
public ItemStack getSeeds(ICropTile crop)
|
||||
{
|
||||
return crop.generateSeeds(crop.getID(), crop.getGrowth(), crop.getGain(), crop.getResistance(), crop.getScanLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a neighbor block to the crop has changed.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
*/
|
||||
public void onNeighbourChange(ICropTile crop){
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the crop should emit redstone.
|
||||
*
|
||||
* @return Whether the crop should emit redstone
|
||||
*/
|
||||
public int emitRedstone(ICropTile crop){return 0;}
|
||||
|
||||
/**
|
||||
* Called when the crop is destroyed.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
*/
|
||||
public void onBlockDestroyed(ICropTile crop){
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the light value emitted by the plant.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Light value emitted
|
||||
*/
|
||||
public int getEmittedLight(ICropTile crop) {return 0;}
|
||||
|
||||
/**
|
||||
* Default is true if the entity is an EntityLiving in jumping or sprinting state.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @param entity entity colliding
|
||||
* @return Whether trampling calculation should happen, return false if the plant is no longer valid.
|
||||
*/
|
||||
public boolean onEntityCollision(ICropTile crop, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
return ((EntityLivingBase)entity).isSprinting();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called every time the crop ticks.
|
||||
* Should be called every 256 ticks or around 13 seconds.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
*/
|
||||
public void tick(ICropTile crop) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this plant spreads weed to surrounding tiles.
|
||||
* Default is true if the plant has a high growth stat (or is weeds) and size greater or equal than 2.
|
||||
*
|
||||
* @param crop reference to ICropTile
|
||||
* @return Whether the plant spreads weed
|
||||
*/
|
||||
public boolean isWeed(ICropTile crop)
|
||||
{
|
||||
return crop.getSize()>=2 && (crop.getID()==0 || crop.getGrowth()>=24);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get this plant's ID.
|
||||
*
|
||||
* @return ID of this CropCard or -1 if it's not registered
|
||||
*/
|
||||
public final int getId()
|
||||
{
|
||||
return Crops.instance.getIdFor(this);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon textures[];
|
||||
}
|
117
src/main/java/ic2/api/crops/Crops.java
Normal file
117
src/main/java/ic2/api/crops/Crops.java
Normal file
|
@ -0,0 +1,117 @@
|
|||
package ic2.api.crops;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary.Type;
|
||||
|
||||
/**
|
||||
* General management of the crop system.
|
||||
*/
|
||||
public abstract class Crops {
|
||||
public static Crops instance;
|
||||
|
||||
/**
|
||||
* Adds a crop humidity and nutrient biome bonus.
|
||||
*
|
||||
* 0 indicates no bonus and negative values indicate a penalty.
|
||||
*
|
||||
* @param biome Biome to apply the bonus in
|
||||
* @param humidityBonus Humidity stat bonus
|
||||
* @param nutrientsBonus Nutrient stat bonus
|
||||
*/
|
||||
public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus);
|
||||
|
||||
/**
|
||||
* Adds a crop humidity and nutrient biome bonus.
|
||||
*
|
||||
* 0 indicates no bonus and negative values indicate a penalty.
|
||||
*
|
||||
* @param type Forge biome type to apply the bonus in
|
||||
* @param humidityBonus Humidity stat bonus
|
||||
* @param nutrientsBonus Nutrient stat bonus
|
||||
*/
|
||||
public abstract void addBiomeBonus(Type type, int humidityBonus, int nutrientsBonus);
|
||||
|
||||
/**
|
||||
* Gets the humidity bonus for a biome.
|
||||
*
|
||||
* @param biome Biome to check
|
||||
* @return Humidity bonus or 0 if none
|
||||
*/
|
||||
public abstract int getHumidityBiomeBonus(BiomeGenBase biome);
|
||||
|
||||
/**
|
||||
* Gets the nutrient bonus for a biome.
|
||||
*
|
||||
* @param biome Biome to check
|
||||
* @return Nutrient bonus or 0 if none
|
||||
*/
|
||||
public abstract int getNutrientBiomeBonus(BiomeGenBase biome);
|
||||
|
||||
/**
|
||||
* Returns the list of registered crops.
|
||||
*
|
||||
* @return Registered crops by ID
|
||||
*/
|
||||
public abstract CropCard[] getCropList();
|
||||
|
||||
/**
|
||||
* Auto-assign an ID to a plant and register it.
|
||||
* Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants.
|
||||
*
|
||||
* @param crop plant to register
|
||||
* @return The ID assigned to the plant
|
||||
*/
|
||||
public abstract short registerCrop(CropCard crop);
|
||||
|
||||
/**
|
||||
* Attempt to register a plant to an ID.
|
||||
* If the ID is taken, the crop will not be registered and a console print will notify the user.
|
||||
*
|
||||
* @param crop plant to register
|
||||
* @param i ID to register the plant to
|
||||
* @return Whether the crop was registered
|
||||
*/
|
||||
public abstract boolean registerCrop(CropCard crop, int i);
|
||||
|
||||
/**
|
||||
* Registers a base seed, an item used to plant a crop.
|
||||
*
|
||||
* @param stack item
|
||||
* @param id plant ID
|
||||
* @param size initial size
|
||||
* @param growth initial growth stat
|
||||
* @param gain initial gain stat
|
||||
* @param resistance initial resistance stat
|
||||
* @return True if successful
|
||||
*/
|
||||
public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance);
|
||||
|
||||
/**
|
||||
* Finds a base seed from the given item.
|
||||
*
|
||||
* @return Base seed or null if none found
|
||||
*/
|
||||
public abstract BaseSeed getBaseSeed(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Execute registerSprites for all registered crop cards.
|
||||
*
|
||||
* This method will get called by IC2, don't call it yourself.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract void startSpriteRegistration(IIconRegister iconRegister);
|
||||
|
||||
/**
|
||||
* Returns the ID for the given crop.
|
||||
*
|
||||
* @param crop Crop to look up
|
||||
* @return ID, or -1 if not found
|
||||
*/
|
||||
public abstract int getIdFor(CropCard crop);
|
||||
}
|
253
src/main/java/ic2/api/crops/ICropTile.java
Normal file
253
src/main/java/ic2/api/crops/ICropTile.java
Normal file
|
@ -0,0 +1,253 @@
|
|||
package ic2.api.crops;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Interface implemented by the crop tile entity.
|
||||
*/
|
||||
public interface ICropTile {
|
||||
/**
|
||||
* Get the crop's plant ID.
|
||||
*
|
||||
* @return Plant ID, or -1 if there is no plant currently on the crop
|
||||
*/
|
||||
public short getID();
|
||||
|
||||
/**
|
||||
* Set the crop's plant ID.
|
||||
*
|
||||
* @param id Plant ID, or -1 for no plant
|
||||
*/
|
||||
public void setID(short id);
|
||||
|
||||
/**
|
||||
* Get the crop's plant size.
|
||||
*
|
||||
* @return Plant size, starting with 1 and maximum varies depending on plant
|
||||
*/
|
||||
public byte getSize();
|
||||
|
||||
/**
|
||||
* Set the crop's plant size.
|
||||
*
|
||||
* @param size Plant size
|
||||
*/
|
||||
public void setSize(byte size);
|
||||
|
||||
/**
|
||||
* Get the crop's plant growth stat.
|
||||
* Higher values indicate faster growth.
|
||||
*
|
||||
* @return Plant growth stat
|
||||
*/
|
||||
public byte getGrowth();
|
||||
|
||||
/**
|
||||
* Set the crop's plant growth stat.
|
||||
*
|
||||
* @param growth Plant growth stat
|
||||
*/
|
||||
public void setGrowth(byte growth);
|
||||
|
||||
/**
|
||||
* Get the crop's plant gain stat.
|
||||
* Higher values indicate more drops.
|
||||
*
|
||||
* @return Plant gain stat
|
||||
*/
|
||||
public byte getGain();
|
||||
|
||||
/**
|
||||
* Set the crop's plant gain stat.
|
||||
*
|
||||
* @param gain Plant gain stat
|
||||
*/
|
||||
public void setGain(byte gain);
|
||||
|
||||
/**
|
||||
* Get the crop's plant resistance stat.
|
||||
* Higher values indicate more resistance against trampling.
|
||||
*
|
||||
* @return Plant resistance stat
|
||||
*/
|
||||
public byte getResistance();
|
||||
|
||||
/**
|
||||
* Set the crop's plant resistance stat.
|
||||
*
|
||||
* @param resistance Plant resistance stat
|
||||
*/
|
||||
public void setResistance(byte resistance);
|
||||
|
||||
/**
|
||||
* Get the crop's plant scan level.
|
||||
* Increases every time the seed is analyzed.
|
||||
*
|
||||
* @return Plant scan level
|
||||
*/
|
||||
public byte getScanLevel();
|
||||
|
||||
/**
|
||||
* Set the crop's plant scan level.
|
||||
*
|
||||
* @param scanLevel Plant scan level
|
||||
*/
|
||||
public void setScanLevel(byte scanLevel);
|
||||
|
||||
/**
|
||||
* Get the crop's plant custom data, stored alongside the crop.
|
||||
* Can be modified in place.
|
||||
*
|
||||
* @return Plant custom data
|
||||
*/
|
||||
public NBTTagCompound getCustomData();
|
||||
|
||||
/**
|
||||
* Get the crop's nutrient storage.
|
||||
* Ranges from 0 to 100.
|
||||
*
|
||||
* @return Crop nutrient storage
|
||||
*/
|
||||
public int getNutrientStorage();
|
||||
|
||||
/**
|
||||
* Set the crop's nutrient storage.
|
||||
*
|
||||
* @param nutrientStorage Crop nutrient storage
|
||||
*/
|
||||
public void setNutrientStorage(int nutrientStorage);
|
||||
|
||||
/**
|
||||
* Get the crop's hydration storage.
|
||||
* 0 indicates nothing, 1-10 indicate water hydration and 11-100 for hydration cells.
|
||||
*
|
||||
* @return Crop hydration storage
|
||||
*/
|
||||
public int getHydrationStorage();
|
||||
|
||||
/**
|
||||
* Set the crop's hydration storage.
|
||||
*
|
||||
* @param hydrationStorage Crop hydration storage
|
||||
*/
|
||||
public void setHydrationStorage(int hydrationStorage);
|
||||
|
||||
/**
|
||||
* Get the crop's Weed-Ex storage.
|
||||
*
|
||||
* @return Crop Weed-Ex storage
|
||||
*/
|
||||
public int getWeedExStorage();
|
||||
|
||||
/**
|
||||
* Set the crop's Weed-Ex storage.
|
||||
*
|
||||
* @param weedExStorage Crop Weed-Ex storage
|
||||
*/
|
||||
public void setWeedExStorage(int weedExStorage);
|
||||
|
||||
/**
|
||||
* Get the crop's humidity.
|
||||
* Ranges from 0 (dry) to 10 (humid).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop humidity level
|
||||
*/
|
||||
public byte getHumidity();
|
||||
|
||||
/**
|
||||
* Get the crop's nutrient level.
|
||||
* Ranges from 0 (empty) to 10 (full).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop nutrient level
|
||||
*/
|
||||
public byte getNutrients();
|
||||
|
||||
/**
|
||||
* Get the crop's air quality.
|
||||
* Ranges from 0 (cluttered) to 10 (fresh).
|
||||
* Updates every couple of seconds or when an update is requested.
|
||||
*
|
||||
* @see #updateState()
|
||||
*
|
||||
* @return Crop air quality
|
||||
*/
|
||||
public byte getAirQuality();
|
||||
|
||||
/**
|
||||
* Get the crop's world.
|
||||
*
|
||||
* @return Crop world
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the crop's location.
|
||||
*
|
||||
* @return Crop location
|
||||
*/
|
||||
public ChunkCoordinates getLocation();
|
||||
|
||||
/**
|
||||
* Get the crop's light level.
|
||||
*
|
||||
* @return Crop light level
|
||||
*/
|
||||
public int getLightLevel();
|
||||
|
||||
/**
|
||||
* Pick the crop, removing and giving seeds for the plant.
|
||||
*
|
||||
* @param manual whether it was done by hand (not automated)
|
||||
* @return true if successfully picked
|
||||
*/
|
||||
public boolean pick(boolean manual);
|
||||
|
||||
/**
|
||||
* Harvest the crop, turning it into gain and resetting its size.
|
||||
*
|
||||
* @param manual whether it one by hand (not automated)
|
||||
* @return true if successfully harvested
|
||||
*/
|
||||
public boolean harvest(boolean manual);
|
||||
|
||||
/**
|
||||
* Fully clears the crop without dropping anything.
|
||||
*/
|
||||
public void reset();
|
||||
|
||||
/**
|
||||
* Request a texture and lighting update.
|
||||
*/
|
||||
public void updateState();
|
||||
|
||||
/**
|
||||
* Check if a block is under the farmland containing the crop.
|
||||
* Searches up to 2 blocks below the farmland or an air space, whichever appears first.
|
||||
*
|
||||
* @param block block to search
|
||||
* @return Whether the block was found
|
||||
*/
|
||||
public boolean isBlockBelow(Block block);
|
||||
|
||||
/**
|
||||
* Generate plant seeds with the given parameters.
|
||||
*
|
||||
* @param plant plant ID
|
||||
* @param growth plant growth stat
|
||||
* @param gain plant gain stat
|
||||
* @param resis plant resistance stat
|
||||
* @param scan plant scan level
|
||||
* @return Plant seed item
|
||||
*/
|
||||
public ItemStack generateSeeds(short plant, byte growth, byte gain, byte resis, byte scan);
|
||||
}
|
18
src/main/java/ic2/api/energy/EnergyNet.java
Normal file
18
src/main/java/ic2/api/energy/EnergyNet.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package ic2.api.energy;
|
||||
|
||||
|
||||
/**
|
||||
* Provides access to the energy network.
|
||||
*
|
||||
* The old EnergyNet methods missing in IEnergyNet have been migrated to events (load, unload) or
|
||||
* removed (tiles no longer emit energy actively, the energy net implementation requests it).
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public final class EnergyNet {
|
||||
/**
|
||||
* Instance of the global EnergyNet class.
|
||||
*/
|
||||
public static IEnergyNet instance;
|
||||
}
|
||||
|
64
src/main/java/ic2/api/energy/IEnergyNet.java
Normal file
64
src/main/java/ic2/api/energy/IEnergyNet.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
package ic2.api.energy;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Interface representing the methods provided by the global EnergyNet class.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyNet {
|
||||
/**
|
||||
* Get the EnergyNet-registered tile entity at the specified position.
|
||||
*
|
||||
* This is not the same as World.getTileEntity(), it's possible to register delegate tile
|
||||
* entities with the energy net which are different from what's actually in the world. Those
|
||||
* delegates allow to use separate TileEntity objects just for the EnergyNet interfaces,
|
||||
* simplifying cross-mod dependencies and multi-blocks.
|
||||
*
|
||||
* @param world World containing the tile entity
|
||||
* @param x x-coordinate
|
||||
* @param y y-coordinate
|
||||
* @param z z-coordinate
|
||||
* @return tile entity registered to the energy net or null if none is registered
|
||||
*/
|
||||
TileEntity getTileEntity(World world, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Get the EnergyNet-registered neighbor tile entity at the specified position.
|
||||
*
|
||||
* @param te TileEntity indicating the world and position to search from
|
||||
* @param dir direction the neighbor is to be found
|
||||
* @return neighbor tile entity registered to the energy net or null if none is registered
|
||||
*/
|
||||
TileEntity getNeighbor(TileEntity te, ForgeDirection dir);
|
||||
|
||||
/**
|
||||
* determine how much energy has been emitted by the EnergyEmitter specified
|
||||
*
|
||||
* @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick
|
||||
*
|
||||
* @param tileEntity energy emitter
|
||||
*/
|
||||
long getTotalEnergyEmitted(TileEntity tileEntity);
|
||||
|
||||
/**
|
||||
* determine how much energy has been sunken by the EnergySink specified
|
||||
*
|
||||
* @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick
|
||||
*
|
||||
* @param tileEntity energy emitter
|
||||
*/
|
||||
long getTotalEnergySunken(TileEntity tileEntity);
|
||||
|
||||
/**
|
||||
* Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2.
|
||||
*
|
||||
* @param tier tier
|
||||
* @return power in eu/t
|
||||
*/
|
||||
int getPowerFromTier(int tier);
|
||||
}
|
23
src/main/java/ic2/api/energy/event/EnergyTileEvent.java
Normal file
23
src/main/java/ic2/api/energy/event/EnergyTileEvent.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package ic2.api.energy.event;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Base class for energy net events, don't use it directly.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileEvent extends WorldEvent {
|
||||
public final IEnergyTile energyTile;
|
||||
|
||||
public EnergyTileEvent(IEnergyTile energyTile1) {
|
||||
super(((TileEntity) energyTile1).getWorldObj());
|
||||
|
||||
this.energyTile = energyTile1;
|
||||
}
|
||||
}
|
||||
|
26
src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java
Normal file
26
src/main/java/ic2/api/energy/event/EnergyTileLoadEvent.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package ic2.api.energy.event;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Event announcing new energy tiles.
|
||||
*
|
||||
* This event notifies subscribers of loaded energy tiles, e.g. after getting
|
||||
* loaded through the chunk they are in or after being placed down by the
|
||||
* player or another deployer mechanism.
|
||||
*
|
||||
* Every energy tile which wants to get connected to the IC2 Energy Network has
|
||||
* to either post this event or alternatively call EnergyNet.addTileEntity().
|
||||
*
|
||||
* You may use this event to build a static representation of energy tiles for
|
||||
* your own energy grid implementation if you need to. It's not required if you
|
||||
* always lookup energy paths on demand.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileLoadEvent extends EnergyTileEvent {
|
||||
public EnergyTileLoadEvent(IEnergyTile energyTile1) {
|
||||
super(energyTile1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package ic2.api.energy.event;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
|
||||
/**
|
||||
* Event announcing terminated energy tiles.
|
||||
*
|
||||
* This event notifies subscribers of unloaded energy tiles, e.g. after getting
|
||||
* unloaded through the chunk they are in or after being destroyed by the
|
||||
* player or another block pick/destruction mechanism.
|
||||
*
|
||||
* Every energy tile which wants to get disconnected from the IC2 Energy
|
||||
* Network has to either post this event or alternatively call
|
||||
* EnergyNet.removeTileEntity().
|
||||
*
|
||||
* You may use this event to build a static representation of energy tiles for
|
||||
* your own energy grid implementation if you need to. It's not required if you
|
||||
* always lookup energy paths on demand.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public class EnergyTileUnloadEvent extends EnergyTileEvent {
|
||||
public EnergyTileUnloadEvent(IEnergyTile energyTile1) {
|
||||
super(energyTile1);
|
||||
}
|
||||
}
|
||||
|
375
src/main/java/ic2/api/energy/prefab/BasicSink.java
Normal file
375
src/main/java/ic2/api/energy/prefab/BasicSink.java
Normal file
|
@ -0,0 +1,375 @@
|
|||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.info.Info;
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
/**
|
||||
* BasicSink is a simple adapter to provide an ic2 energy sink.
|
||||
*
|
||||
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a
|
||||
* one-time configurable input energy buffer, thus providing a common use case for machines.
|
||||
*
|
||||
* Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended.
|
||||
* The delegate can be extended with additional functionality through a sub class though.
|
||||
*
|
||||
* The constraints set by BasicSink like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySink directly while aiming for
|
||||
* optimal performance.
|
||||
*
|
||||
* Using BasicSink involves the following steps:
|
||||
* - create a BasicSink instance in your TileEntity, typically in a field
|
||||
* - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink
|
||||
* instance.
|
||||
* If you have other means of determining when the tile entity is fully loaded, notify onLoaded
|
||||
* that way instead of forwarding updateEntity.
|
||||
* - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available
|
||||
* without consuming the energy.
|
||||
* - optionally use getEnergyStored to display the output buffer charge level
|
||||
* - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container)
|
||||
*
|
||||
* Example implementation code:
|
||||
* @code{.java}
|
||||
* public class SomeTileEntity extends TileEntity {
|
||||
* // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV)
|
||||
* private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1);
|
||||
*
|
||||
* @Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySink.invalidate(); // notify the energy sink
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySink.onChunkUnload(); // notify the energy sink
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySink.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void updateEntity() {
|
||||
* ic2EnergySink.updateEntity(); // notify the energy sink
|
||||
* ...
|
||||
* if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick
|
||||
* ... // do something with the energy
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
public class BasicSink extends TileEntity implements IEnergySink {
|
||||
|
||||
// **********************************
|
||||
// *** Methods for use by the mod ***
|
||||
// **********************************
|
||||
|
||||
/**
|
||||
* Constructor for a new BasicSink delegate.
|
||||
*
|
||||
* @param parent1 TileEntity represented by this energy sink.
|
||||
* @param capacity1 Maximum amount of eu to store.
|
||||
* @param tier1 IC2 tier, 1=LV, 2=MV, ...
|
||||
*/
|
||||
public BasicSink(TileEntity parent1, int capacity1, int tier1) {
|
||||
this.parent = parent1;
|
||||
this.capacity = capacity1;
|
||||
this.tier = tier1;
|
||||
}
|
||||
|
||||
// in-world te forwards >>
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!addedToEnet) onLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the base TileEntity finished loaded, for advanced uses.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onLoaded() {
|
||||
if (!addedToEnet &&
|
||||
!FMLCommonHandler.instance().getEffectiveSide().isClient() &&
|
||||
Info.isIc2Available()) {
|
||||
worldObj = parent.getWorldObj();
|
||||
xCoord = parent.xCoord;
|
||||
yCoord = parent.yCoord;
|
||||
zCoord = parent.zCoord;
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
|
||||
addedToEnet = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (addedToEnet &&
|
||||
Info.isIc2Available()) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
|
||||
addedToEnet = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagCompound data = tag.getCompoundTag("IC2BasicSink");
|
||||
|
||||
energyStored = data.getDouble("energy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
try {
|
||||
super.writeToNBT(tag);
|
||||
} catch (RuntimeException e) {
|
||||
// happens if this is a delegate, ignore
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
data.setDouble("energy", energyStored);
|
||||
|
||||
tag.setTag("IC2BasicSink", data);
|
||||
}
|
||||
|
||||
// << in-world te forwards
|
||||
// methods for using this adapter >>
|
||||
|
||||
/**
|
||||
* Get the maximum amount of energy this sink can hold in its buffer.
|
||||
*
|
||||
* @return Capacity in EU.
|
||||
*/
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum amount of energy this sink can hold in its buffer.
|
||||
*
|
||||
* @param capacity1 Capacity in EU.
|
||||
*/
|
||||
public void setCapacity(int capacity1) {
|
||||
this.capacity = capacity1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IC2 energy tier for this sink.
|
||||
*
|
||||
* @return IC2 Tier.
|
||||
*/
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this sink.
|
||||
*
|
||||
* @param tier1 IC2 Tier.
|
||||
*/
|
||||
public void setTier(int tier1) {
|
||||
this.tier = tier1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the energy stored in the sink's input buffer.
|
||||
*
|
||||
* @return amount in EU, may be above capacity
|
||||
*/
|
||||
public double getEnergyStored() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stored energy to the specified amount.
|
||||
*
|
||||
* This is intended for server -> client synchronization, e.g. to display the stored energy in
|
||||
* a GUI through getEnergyStored().
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
public void setEnergyStored(double amount) {
|
||||
energyStored = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the specified amount of energy is available.
|
||||
*
|
||||
* @param amount in EU
|
||||
* @return true if the amount is available
|
||||
*/
|
||||
public boolean canUseEnergy(double amount) {
|
||||
return energyStored >= amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the specified amount of energy, if available.
|
||||
*
|
||||
* @param amount amount to use
|
||||
* @return true if the amount was available
|
||||
*/
|
||||
public boolean useEnergy(double amount) {
|
||||
if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
energyStored -= amount;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discharge the supplied ItemStack into this sink's energy buffer.
|
||||
*
|
||||
* @param stack ItemStack to discharge (null is ignored)
|
||||
* @param limit Transfer limit, values <= 0 will use the battery's limit
|
||||
* @return true if energy was transferred
|
||||
*/
|
||||
public boolean discharge(ItemStack stack, int limit) {
|
||||
if (stack == null || !Info.isIc2Available()) return false;
|
||||
|
||||
int amount = (int) Math.floor(capacity - energyStored);
|
||||
if (amount <= 0) return false;
|
||||
|
||||
if (limit > 0 && limit < amount) amount = limit;
|
||||
|
||||
amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, false);
|
||||
|
||||
energyStored += amount;
|
||||
|
||||
return amount > 0;
|
||||
}
|
||||
|
||||
// << methods for using this adapter
|
||||
|
||||
// backwards compatibility (ignore these) >>
|
||||
|
||||
@Deprecated
|
||||
public void onUpdateEntity() {
|
||||
updateEntity();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onInvalidate() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onOnChunkUnload() {
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
writeToNBT(tag);
|
||||
}
|
||||
|
||||
// << backwards compatibility
|
||||
|
||||
// ******************************
|
||||
// *** Methods for use by ic2 ***
|
||||
// ******************************
|
||||
|
||||
// energy net interface >>
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits() {
|
||||
return Math.max(0, capacity - energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection directionFrom, double amount) {
|
||||
energyStored += amount;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput() {
|
||||
return EnergyNet.instance.getPowerFromTier(tier);
|
||||
}
|
||||
|
||||
// << energy net interface
|
||||
|
||||
|
||||
public final TileEntity parent;
|
||||
|
||||
protected int capacity;
|
||||
protected int tier;
|
||||
protected double energyStored;
|
||||
protected boolean addedToEnet;
|
||||
}
|
375
src/main/java/ic2/api/energy/prefab/BasicSource.java
Normal file
375
src/main/java/ic2/api/energy/prefab/BasicSource.java
Normal file
|
@ -0,0 +1,375 @@
|
|||
package ic2.api.energy.prefab;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.info.Info;
|
||||
import ic2.api.item.ElectricItem;
|
||||
|
||||
/**
|
||||
* BasicSource is a simple adapter to provide an ic2 energy source.
|
||||
*
|
||||
* It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a
|
||||
* one-time configurable output energy buffer, thus providing a common use case for generators.
|
||||
*
|
||||
* Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended.
|
||||
* The delegate can be extended with additional functionality through a sub class though.
|
||||
*
|
||||
* The constraints set by BasicSource like the strict tank-like energy buffering should provide a
|
||||
* more easy to use and stable interface than using IEnergySource directly while aiming for
|
||||
* optimal performance.
|
||||
*
|
||||
* Using BasicSource involves the following steps:
|
||||
* - create a BasicSource instance in your TileEntity, typically in a field
|
||||
* - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource
|
||||
* instance.
|
||||
* If you have other means of determining when the tile entity is fully loaded, notify onLoaded
|
||||
* that way instead of forwarding updateEntity.
|
||||
* - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator
|
||||
* should run
|
||||
* - optionally use getEnergyStored to display the output buffer charge level
|
||||
* - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container)
|
||||
*
|
||||
* Example implementation code:
|
||||
* @code{.java}
|
||||
* public class SomeTileEntity extends TileEntity {
|
||||
* // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV)
|
||||
* private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1);
|
||||
*
|
||||
* @Override
|
||||
* public void invalidate() {
|
||||
* ic2EnergySource.invalidate(); // notify the energy source
|
||||
* ...
|
||||
* super.invalidate(); // this is important for mc!
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void onChunkUnload() {
|
||||
* ic2EnergySource.onChunkUnload(); // notify the energy source
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void readFromNBT(NBTTagCompound tag) {
|
||||
* super.readFromNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.readFromNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void writeToNBT(NBTTagCompound tag) {
|
||||
* super.writeToNBT(tag);
|
||||
*
|
||||
* ic2EnergySource.writeToNBT(tag);
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
* public void updateEntity() {
|
||||
* ic2EnergySource.updateEntity(); // notify the energy source
|
||||
* ...
|
||||
* ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
* }
|
||||
* @endcode
|
||||
*/
|
||||
public class BasicSource extends TileEntity implements IEnergySource {
|
||||
|
||||
// **********************************
|
||||
// *** Methods for use by the mod ***
|
||||
// **********************************
|
||||
|
||||
/**
|
||||
* Constructor for a new BasicSource delegate.
|
||||
*
|
||||
* @param parent1 Base TileEntity represented by this energy source.
|
||||
* @param capacity1 Maximum amount of eu to store.
|
||||
* @param tier1 IC2 tier, 1=LV, 2=MV, ...
|
||||
*/
|
||||
public BasicSource(TileEntity parent1, int capacity1, int tier1) {
|
||||
int power = EnergyNet.instance.getPowerFromTier(tier1);
|
||||
|
||||
this.parent = parent1;
|
||||
this.capacity = capacity1 < power ? power : capacity1;
|
||||
this.tier = tier1;
|
||||
}
|
||||
|
||||
// in-world te forwards >>
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's updateEntity(), used for creating the energy net link.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!addedToEnet) onLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the base TileEntity finished loading, for advanced uses.
|
||||
* Either updateEntity or onLoaded have to be used.
|
||||
*/
|
||||
public void onLoaded() {
|
||||
if (!addedToEnet &&
|
||||
!FMLCommonHandler.instance().getEffectiveSide().isClient() &&
|
||||
Info.isIc2Available()) {
|
||||
worldObj = parent.getWorldObj();
|
||||
xCoord = parent.xCoord;
|
||||
yCoord = parent.yCoord;
|
||||
zCoord = parent.zCoord;
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
|
||||
addedToEnet = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's invalidate(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link.
|
||||
* Both invalidate and onChunkUnload have to be used.
|
||||
*/
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (addedToEnet &&
|
||||
Info.isIc2Available()) {
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
|
||||
addedToEnet = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's readFromNBT(), used for loading the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.readFromNBT()
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagCompound data = tag.getCompoundTag("IC2BasicSource");
|
||||
|
||||
energyStored = data.getDouble("energy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward for the base TileEntity's writeToNBT(), used for saving the state.
|
||||
*
|
||||
* @param tag Compound tag as supplied by TileEntity.writeToNBT()
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
try {
|
||||
super.writeToNBT(tag);
|
||||
} catch (RuntimeException e) {
|
||||
// happens if this is a delegate, ignore
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
data.setDouble("energy", energyStored);
|
||||
|
||||
tag.setTag("IC2BasicSource", data);
|
||||
}
|
||||
|
||||
// << in-world te forwards
|
||||
// methods for using this adapter >>
|
||||
|
||||
/**
|
||||
* Get the maximum amount of energy this source can hold in its buffer.
|
||||
*
|
||||
* @return Capacity in EU.
|
||||
*/
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum amount of energy this source can hold in its buffer.
|
||||
*
|
||||
* @param capacity1 Capacity in EU.
|
||||
*/
|
||||
public void setCapacity(int capacity1) {
|
||||
int power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (capacity1 < power) capacity1 = power;
|
||||
|
||||
this.capacity = capacity1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IC2 energy tier for this source.
|
||||
*
|
||||
* @return IC2 Tier.
|
||||
*/
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the IC2 energy tier for this source.
|
||||
*
|
||||
* @param tier1 IC2 Tier.
|
||||
*/
|
||||
public void setTier(int tier1) {
|
||||
int power = EnergyNet.instance.getPowerFromTier(tier1);
|
||||
|
||||
if (capacity < power) capacity = power;
|
||||
|
||||
this.tier = tier1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the energy stored in the source's output buffer.
|
||||
*
|
||||
* @return amount in EU
|
||||
*/
|
||||
public double getEnergyStored() {
|
||||
return energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stored energy to the specified amount.
|
||||
*
|
||||
* This is intended for server -> client synchronization, e.g. to display the stored energy in
|
||||
* a GUI through getEnergyStored().
|
||||
*
|
||||
* @param amount
|
||||
*/
|
||||
public void setEnergyStored(double amount) {
|
||||
energyStored = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the free capacity in the source's output buffer.
|
||||
*
|
||||
* @return amount in EU
|
||||
*/
|
||||
public double getFreeCapacity() {
|
||||
return capacity - energyStored;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some energy to the output buffer.
|
||||
*
|
||||
* @param amount maximum amount of energy to add
|
||||
* @return amount added/used, NOT remaining
|
||||
*/
|
||||
public double addEnergy(double amount) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0;
|
||||
if (amount > capacity - energyStored) amount = capacity - energyStored;
|
||||
|
||||
energyStored += amount;
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge the supplied ItemStack from this source's energy buffer.
|
||||
*
|
||||
* @param stack ItemStack to charge (null is ignored)
|
||||
* @return true if energy was transferred
|
||||
*/
|
||||
public boolean charge(ItemStack stack) {
|
||||
if (stack == null || !Info.isIc2Available()) return false;
|
||||
|
||||
int amount = ElectricItem.manager.charge(stack, (int) energyStored, tier, false, false);
|
||||
|
||||
energyStored -= amount;
|
||||
|
||||
return amount > 0;
|
||||
}
|
||||
|
||||
// << methods for using this adapter
|
||||
|
||||
// backwards compatibility (ignore these) >>
|
||||
|
||||
@Deprecated
|
||||
public void onUpdateEntity() {
|
||||
updateEntity();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onInvalidate() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onOnChunkUnload() {
|
||||
onChunkUnload();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onReadFromNbt(NBTTagCompound tag) {
|
||||
readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onWriteToNbt(NBTTagCompound tag) {
|
||||
writeToNBT(tag);
|
||||
}
|
||||
|
||||
// << backwards compatibility
|
||||
|
||||
// ******************************
|
||||
// *** Methods for use by ic2 ***
|
||||
// ******************************
|
||||
|
||||
// energy net interface >>
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy() {
|
||||
int power = EnergyNet.instance.getPowerFromTier(tier);
|
||||
|
||||
if (energyStored >= power) {
|
||||
return power;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount) {
|
||||
energyStored -= amount;
|
||||
}
|
||||
|
||||
// << energy net interface
|
||||
|
||||
|
||||
public final TileEntity parent;
|
||||
|
||||
protected int capacity;
|
||||
protected int tier;
|
||||
protected double energyStored;
|
||||
protected boolean addedToEnet;
|
||||
}
|
27
src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java
Normal file
27
src/main/java/ic2/api/energy/tile/IEnergyAcceptor.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For internal/multi-block usage only.
|
||||
*
|
||||
* @see IEnergySink
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyAcceptor extends IEnergyTile {
|
||||
/**
|
||||
* Determine if this acceptor can accept current from an adjacent emitter in a direction.
|
||||
*
|
||||
* The TileEntity in the emitter parameter is what was originally added to the energy net,
|
||||
* which may be normal in-world TileEntity, a delegate or an IMetaDelegate.
|
||||
*
|
||||
* @param emitter energy emitter, may also be null or an IMetaDelegate
|
||||
* @param direction direction the energy is being received from
|
||||
*/
|
||||
boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction);
|
||||
}
|
||||
|
53
src/main/java/ic2/api/energy/tile/IEnergyConductor.java
Normal file
53
src/main/java/ic2/api/energy/tile/IEnergyConductor.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this
|
||||
* interface.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter {
|
||||
/**
|
||||
* Energy loss for the conductor in EU per block.
|
||||
*
|
||||
* @return Energy loss
|
||||
*/
|
||||
double getConductionLoss();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before shocking nearby players and mobs.
|
||||
*
|
||||
* @return Insulation energy absorption in EU
|
||||
*/
|
||||
int getInsulationEnergyAbsorption();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before it is destroyed.
|
||||
* Ensure that this value is greater than the insulation energy absorption + 64.
|
||||
*
|
||||
* @return Insulation-destroying energy in EU
|
||||
*/
|
||||
int getInsulationBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Amount of energy the conductor will handle before it melts.
|
||||
*
|
||||
* @return Conductor-destroying energy in EU
|
||||
*/
|
||||
int getConductorBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Remove the conductor's insulation if the insulation breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getInsulationBreakdownEnergy()
|
||||
*/
|
||||
void removeInsulation();
|
||||
|
||||
/**
|
||||
* Remove the conductor if the conductor breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getConductorBreakdownEnergy()
|
||||
*/
|
||||
void removeConductor();
|
||||
}
|
||||
|
28
src/main/java/ic2/api/energy/tile/IEnergyEmitter.java
Normal file
28
src/main/java/ic2/api/energy/tile/IEnergyEmitter.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* For internal/multi-block usage only.
|
||||
*
|
||||
* @see IEnergySource
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyEmitter extends IEnergyTile {
|
||||
/**
|
||||
* Determine if this emitter can emit energy to an adjacent receiver.
|
||||
*
|
||||
* The TileEntity in the receiver parameter is what was originally added to the energy net,
|
||||
* which may be normal in-world TileEntity, a delegate or an IMetaDelegate.
|
||||
*
|
||||
* @param receiver receiver, may also be null or an IMetaDelegate
|
||||
* @param direction direction the receiver is from the emitter
|
||||
* @return Whether energy should be emitted
|
||||
*/
|
||||
boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction);
|
||||
}
|
||||
|
50
src/main/java/ic2/api/energy/tile/IEnergySink.java
Normal file
50
src/main/java/ic2/api/energy/tile/IEnergySink.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Allows a tile entity (mostly a machine) to receive energy.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergySink extends IEnergyAcceptor {
|
||||
/**
|
||||
* Determine how much energy the sink accepts.
|
||||
*
|
||||
* This value is unrelated to getMaxSafeInput().
|
||||
*
|
||||
* Make sure that injectEnergy() does accepts energy if demandsEnergy() returns anything > 0.
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return max accepted input in eu
|
||||
*/
|
||||
double demandedEnergyUnits();
|
||||
|
||||
/**
|
||||
* Transfer energy to the sink.
|
||||
*
|
||||
* It's highly recommended to accept all energy by letting the internal buffer overflow to
|
||||
* increase the performance and accuracy of the distribution simulation.
|
||||
*
|
||||
* @param directionFrom direction from which the energy comes from
|
||||
* @param amount energy to be transferred
|
||||
* @return Energy not consumed (leftover)
|
||||
*/
|
||||
double injectEnergyUnits(ForgeDirection directionFrom, double amount);
|
||||
|
||||
/**
|
||||
* Determine the amount of eu which can be safely injected into the specific energy sink without exploding.
|
||||
*
|
||||
* Typical values are 32 for LV, 128 for MV, 512 for HV and 2048 for EV. A value of Integer.MAX_VALUE indicates no
|
||||
* limit.
|
||||
*
|
||||
* This value is unrelated to demandsEnergy().
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return max safe input in eu
|
||||
*/
|
||||
int getMaxSafeInput();
|
||||
}
|
||||
|
28
src/main/java/ic2/api/energy/tile/IEnergySource.java
Normal file
28
src/main/java/ic2/api/energy/tile/IEnergySource.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Allows a tile entity (mostly a generator) to emit energy.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergySource extends IEnergyEmitter {
|
||||
/**
|
||||
* Energy output provided by the source this tick.
|
||||
* This is typically Math.min(stored energy, max output/tick).
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
*
|
||||
* @return Energy offered this tick
|
||||
*/
|
||||
double getOfferedEnergy();
|
||||
|
||||
/**
|
||||
* Draw energy from this source's buffer.
|
||||
*
|
||||
* If the source doesn't have a buffer, this is a no-op.
|
||||
*
|
||||
* @param amount amount of EU to draw, may be negative
|
||||
*/
|
||||
void drawEnergy(double amount);
|
||||
}
|
||||
|
15
src/main/java/ic2/api/energy/tile/IEnergyTile.java
Normal file
15
src/main/java/ic2/api/energy/tile/IEnergyTile.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* For internal usage only, base class for all energy tiles.
|
||||
*
|
||||
* @see IEnergySink
|
||||
* @see IEnergySource
|
||||
* @see IEnergyConductor
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyTile {
|
||||
//
|
||||
}
|
||||
|
34
src/main/java/ic2/api/energy/tile/IMetaDelegate.java
Normal file
34
src/main/java/ic2/api/energy/tile/IMetaDelegate.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
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.
|
||||
*
|
||||
* @note the list has to be consistent between the EnergyNet Load and Unload events.
|
||||
*
|
||||
* @return sub-TileEntity array
|
||||
*/
|
||||
List<TileEntity> getSubTiles();
|
||||
}
|
144
src/main/java/ic2/api/energy/usage.txt
Normal file
144
src/main/java/ic2/api/energy/usage.txt
Normal file
|
@ -0,0 +1,144 @@
|
|||
--------------------------------
|
||||
-- Energy Network Description --
|
||||
--------------------------------
|
||||
|
||||
There are currently three different types of energy network blocks:
|
||||
- energy sources, e.g. generators or the output side of a storage block/transformer
|
||||
- energy sinks, e.g. machines or the input side of a storage block/transformer
|
||||
- conductors, e.g. cables
|
||||
|
||||
Note that storage blocks or transformers are both sources and sinks.
|
||||
|
||||
All those blocks have to have a tile entity which has to implement the interface corresponding to
|
||||
its function and also post events to the Forge event bus.
|
||||
|
||||
The energy generation, distribution and consumption is strictly limited to the simulating (server)
|
||||
side, use the proper side checks before posting the related events. One possibility is to check for
|
||||
FMLCommonHandler.instance().getEffectiveSide().isClient() being false.
|
||||
|
||||
The energy network works by calculating the energy flow between the sources which offer energy
|
||||
through getOfferedEnergy() and the sinks which request energy through demandedEnergyUnits().
|
||||
Conductors will carry the energy over a distance. Once the energy distribution is calculated, the
|
||||
energy net will update the sources and sinks through drawEnergy() and injectEnergyUnits() respectively.
|
||||
|
||||
|
||||
---------------------------
|
||||
-- Energy Network Events --
|
||||
---------------------------
|
||||
|
||||
The energy network currently requires 2 events to manage its internal representation of the grids:
|
||||
|
||||
-- EnergyTileLoadEvent --
|
||||
|
||||
For all energy network tiles (sources, sinks, conductors) you have to post an EnergyTileLoadEvent.
|
||||
|
||||
The event has to be posted as soon as the implementing tile entity is fully loaded, usually after
|
||||
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
|
||||
the next world tick after TileEntity.validate(). The 2nd approach is obviously more sophisticated
|
||||
and requires to use some tick queuing mechanism.
|
||||
|
||||
The event can by posted as following:
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
|
||||
-- EnergyTileUnloadEvent --
|
||||
|
||||
Another event every energy tile has to post is the EnergyTileUnloadEvent.
|
||||
|
||||
The event has to be posted as soon as the implementing tile entity is being unloaded, either by
|
||||
unloading the containing chunk or by destroying the block containing it.
|
||||
|
||||
It's possible to detect the unloading by triggering on both the beginning of
|
||||
TileEntity.invalidate() and the beginning of TileEntity.onChunkUnload().
|
||||
|
||||
It is important that the tile entity is still properly linked to the world while posting the unload
|
||||
event, otherwise the energy net can't find all affected connections.
|
||||
|
||||
|
||||
--------------------------------------
|
||||
-- Participating Block Requirements --
|
||||
--------------------------------------
|
||||
|
||||
The energy net blocks have to do the following to work properly:
|
||||
|
||||
-- energy source --
|
||||
|
||||
An energy source has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergySource has to be implemented.
|
||||
|
||||
-- energy sink --
|
||||
|
||||
An energy sink has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergySink has to be implemented.
|
||||
|
||||
-- energy conductor --
|
||||
|
||||
An energy conductor has to post the following events:
|
||||
- EnergyTileLoadEvent on load
|
||||
- EnergyTileUnloadEvent on unload
|
||||
|
||||
Additionally the interface IEnergyConductor has to be implemented.
|
||||
|
||||
|
||||
------------------------------
|
||||
-- Energy Network Delegates --
|
||||
------------------------------
|
||||
|
||||
A delegate is a separate object which performs tasks for the original object, in this case handling
|
||||
the energy net interaction.
|
||||
|
||||
The TileEntity instances used by the events don't have to be the same as the in-world TileEntity
|
||||
instance for the corresponding position, it can be delegated to a separate TileEntity instance.
|
||||
This separate instance (delegate) needs to have its world and xyz coordinate fields set to match
|
||||
the in-world instance. The delegate implements the energy net interfaces and is added and removed
|
||||
to/from the energy net through EnergyTileLoadEvent and EnergyTileUnloadEvent.
|
||||
|
||||
Separating the interfaces through a delegate allows to isolate the IC2 API usage into separate
|
||||
classes an potentially share common code like an input buffer with battery discharging outside the
|
||||
class hierarchy.
|
||||
It's even possible to use an ic2 energy net delegate alongside an in-world TileEntity which isn't
|
||||
designed to work with ic2 energy at all, like making a furnace electric by receiving energy through
|
||||
a delegate and adding the corresponding fuel amount to the in-world furnace TileEntity.
|
||||
|
||||
Getting the in-world TileEntity for a delegate involves calling World.getBlockTileEntity() with the
|
||||
delegate's world and xyz coordinate information.
|
||||
|
||||
|
||||
------------------
|
||||
-- Multi Blocks --
|
||||
------------------
|
||||
|
||||
Multi blocks are a group of blocks which act as one functional entity.
|
||||
|
||||
The IMetaDelegate interface groups multiple TileEntity instances (=sub tiles) representing the
|
||||
individual blocks to a single Energy Net relevant node. The sub tiles may be normal in-world or
|
||||
delegate TileEntity instances.
|
||||
|
||||
The meta delegate is added to energy net once for the whole multi block structure and implements
|
||||
the energy net interfaces as well. The sub tiles may optionally implement IEnergyEmitter and/or
|
||||
IEnergyAcceptor to specify their connectivity rules independently, otherwise the meta delegate will
|
||||
be queried.
|
||||
|
||||
|
||||
--------------------------------------------------
|
||||
-- How to implement/add your own energy network --
|
||||
--------------------------------------------------
|
||||
|
||||
If you want to create an alternative way of distributing energy, e.g. to have different
|
||||
distribution rules or to use energy networks provided by other mods, you can register to the energy
|
||||
tile events and use the interfaces to handle the energy distribution yourself. It's no longer
|
||||
required to use conversion blocks.
|
||||
|
||||
IC2's EnergyNet itself is built on top of the api events and interfaces, providing their default
|
||||
use case.
|
||||
|
114
src/main/java/ic2/api/event/LaserEvent.java
Normal file
114
src/main/java/ic2/api/event/LaserEvent.java
Normal file
|
@ -0,0 +1,114 @@
|
|||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
/**
|
||||
* A bunch of Events to handle the power of the Mining Laser.
|
||||
*/
|
||||
@Cancelable
|
||||
public class LaserEvent extends WorldEvent {
|
||||
// the Laser Entity
|
||||
public final Entity lasershot;
|
||||
|
||||
// the following variables can be changed and the Laser will adjust to them
|
||||
|
||||
// the Player firing the Laser. If the Laser gets "reflected" the Player could change.
|
||||
public EntityLivingBase owner;
|
||||
// Range of the Laser Shot. Determine the amount of broken blocks, as well, as each broken block will subtract ~1F from range.
|
||||
public float range, power;
|
||||
public int blockBreaks;
|
||||
// Determines whether the laser will explode upon hitting something
|
||||
public boolean explosive, smelt;
|
||||
|
||||
public LaserEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1) {
|
||||
super(world1);
|
||||
this.lasershot = lasershot1;
|
||||
this.owner = owner1;
|
||||
this.range = range1;
|
||||
this.power = power1;
|
||||
this.blockBreaks = blockBreaks1;
|
||||
this.explosive = explosive1;
|
||||
this.smelt = smelt1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is getting shot by a Player.
|
||||
*
|
||||
* The Item is the Laser Gun which the "Player" has shot
|
||||
*/
|
||||
public static class LaserShootEvent extends LaserEvent {
|
||||
ItemStack laseritem;
|
||||
|
||||
public LaserShootEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, ItemStack laseritem1) {
|
||||
super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1);
|
||||
this.laseritem = laseritem1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is exploding for some Reason.
|
||||
*
|
||||
* The Laser will no longer exist after this Event is posted as it either Explodes or despawns after the Event is fired.
|
||||
*/
|
||||
public static class LaserExplodesEvent extends LaserEvent {
|
||||
// explosion strength, even that can be changed!
|
||||
public float explosionpower, explosiondroprate, explosionentitydamage;
|
||||
|
||||
public LaserExplodesEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, float explosionpower1, float explosiondroprate1, float explosionentitydamage1) {
|
||||
super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1);
|
||||
this.explosionpower = explosionpower1;
|
||||
this.explosiondroprate = explosiondroprate1;
|
||||
this.explosionentitydamage = explosionentitydamage1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is hitting a Block
|
||||
* x, y and z are the Coords of the Block.
|
||||
*
|
||||
* Canceling this Event stops the Laser from attempting to break the Block, what is very useful for Glass.
|
||||
* Use lasershot.setDead() to remove the Shot entirely.
|
||||
*/
|
||||
public static class LaserHitsBlockEvent extends LaserEvent {
|
||||
// targeted block, even that can be changed!
|
||||
public int x, y, z;
|
||||
public int side;
|
||||
// removeBlock determines if the Block will be removed. dropBlock determines if the Block should drop something.
|
||||
public boolean removeBlock, dropBlock;
|
||||
public float dropChance;
|
||||
|
||||
public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) {
|
||||
super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1);
|
||||
this.x = x1;
|
||||
this.y = y1;
|
||||
this.z = z1;
|
||||
this.side = side1;
|
||||
this.removeBlock = removeBlock1;
|
||||
this.dropBlock = dropBlock1;
|
||||
this.dropChance = dropChance1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event when the Laser is getting at a Living Entity
|
||||
*
|
||||
* Canceling this Event ignores the Entity
|
||||
* Use lasershot.setDead() to remove the Shot entirely.
|
||||
*/
|
||||
public static class LaserHitsEntityEvent extends LaserEvent {
|
||||
// the Entity which the Laser has shot at, even the target can be changed!
|
||||
public Entity hitentity;
|
||||
|
||||
public LaserHitsEntityEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, Entity hitentity1) {
|
||||
super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1);
|
||||
this.hitentity = hitentity1;
|
||||
}
|
||||
}
|
||||
}
|
32
src/main/java/ic2/api/event/PaintEvent.java
Normal file
32
src/main/java/ic2/api/event/PaintEvent.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
@Cancelable
|
||||
public class PaintEvent extends WorldEvent {
|
||||
// target block
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final int side;
|
||||
|
||||
// color to paint the block
|
||||
public final int color;
|
||||
|
||||
// set to true to confirm the operation
|
||||
public boolean painted = false;
|
||||
|
||||
public PaintEvent(World world1, int x1, int y1, int z1, int side1, int color1) {
|
||||
super(world1);
|
||||
|
||||
this.x = x1;
|
||||
this.y = y1;
|
||||
this.z = z1;
|
||||
this.side = side1;
|
||||
this.color = color1;
|
||||
}
|
||||
}
|
37
src/main/java/ic2/api/event/RetextureEvent.java
Normal file
37
src/main/java/ic2/api/event/RetextureEvent.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package ic2.api.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
@Cancelable
|
||||
public class RetextureEvent extends WorldEvent {
|
||||
// target block
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final int side;
|
||||
|
||||
// referenced block (to grab the texture from)
|
||||
public final Block referencedBlock;
|
||||
public final int referencedMeta;
|
||||
public final int referencedSide;
|
||||
|
||||
// set to true to confirm the operation
|
||||
public boolean applied = false;
|
||||
|
||||
public RetextureEvent(World world1, int x1, int y1, int z1, int side1, Block referencedBlock, int referencedMeta1, int referencedSide1) {
|
||||
super(world1);
|
||||
|
||||
this.x = x1;
|
||||
this.y = y1;
|
||||
this.z = z1;
|
||||
this.side = side1;
|
||||
this.referencedBlock = referencedBlock;
|
||||
this.referencedMeta = referencedMeta1;
|
||||
this.referencedSide = referencedSide1;
|
||||
}
|
||||
}
|
14
src/main/java/ic2/api/info/IEnergyValueProvider.java
Normal file
14
src/main/java/ic2/api/info/IEnergyValueProvider.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IEnergyValueProvider {
|
||||
/**
|
||||
* Determine the energy value for a single item in the supplied stack.
|
||||
* The value is used by most machines in the discharge slot.
|
||||
*
|
||||
* @param itemStack ItemStack containing the item to evaluate.
|
||||
* @return energy in EU
|
||||
*/
|
||||
int getEnergyValue(ItemStack itemStack);
|
||||
}
|
15
src/main/java/ic2/api/info/IFuelValueProvider.java
Normal file
15
src/main/java/ic2/api/info/IFuelValueProvider.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFuelValueProvider {
|
||||
/**
|
||||
* Determine the fuel value for a single item in the supplied stack.
|
||||
* The information currently applies to Generators and the Iron Furnace.
|
||||
*
|
||||
* @param itemStack ItemStack containing the item to evaluate.
|
||||
* @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace.
|
||||
* @return fuel value
|
||||
*/
|
||||
int getFuelValue(ItemStack itemStack, boolean allowLava);
|
||||
}
|
32
src/main/java/ic2/api/info/Info.java
Normal file
32
src/main/java/ic2/api/info/Info.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package ic2.api.info;
|
||||
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderState;
|
||||
|
||||
public class Info {
|
||||
public static IEnergyValueProvider itemEnergy;
|
||||
public static IFuelValueProvider itemFuel;
|
||||
public static Object ic2ModInstance;
|
||||
|
||||
/**
|
||||
* Damage Sources used by IC2.
|
||||
* Getting assigned in preload.
|
||||
*/
|
||||
public static DamageSource DMG_ELECTRIC, DMG_NUKE_EXPLOSION, DMG_RADIATION;
|
||||
|
||||
public static boolean isIc2Available() {
|
||||
if (ic2Available != null) return ic2Available;
|
||||
|
||||
boolean loaded = Loader.isModLoaded("IC2");
|
||||
|
||||
if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) {
|
||||
ic2Available = loaded;
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
private static Boolean ic2Available = null;
|
||||
}
|
108
src/main/java/ic2/api/item/ElectricItem.java
Normal file
108
src/main/java/ic2/api/item/ElectricItem.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Allows for charging, discharging and using electric items (IElectricItem).
|
||||
*
|
||||
* The charge or remaining capacity of an item can be determined by calling charge/discharge with
|
||||
* ignoreTransferLimit and simulate set to true.
|
||||
*/
|
||||
public final class ElectricItem {
|
||||
/**
|
||||
* IElectricItemManager to use for interacting with IElectricItem ItemStacks.
|
||||
*
|
||||
* This manager will act as a gateway and delegate the tasks to the final implementation
|
||||
* (rawManager or a custom one) as necessary.
|
||||
*/
|
||||
public static IElectricItemManager manager;
|
||||
|
||||
/**
|
||||
* Standard IElectricItemManager implementation, only call it directly from another
|
||||
* IElectricItemManager. Use manager instead.
|
||||
*/
|
||||
public static IElectricItemManager rawManager;
|
||||
|
||||
/**
|
||||
* Charge an item with a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the charging device, has to be at least as high as the item to charge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually change the item, just determine the return value
|
||||
* @return Energy transferred into the electric item
|
||||
*
|
||||
* @deprecated use manager.charge() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
||||
return manager.charge(itemStack, amount, tier, ignoreTransferLimit, simulate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discharge an item by a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the discharging device, has to be at least as high as the item to discharge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually discharge the item, just determine the return value
|
||||
* @return Energy retrieved from the electric item
|
||||
*
|
||||
* @deprecated use manager.discharge() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
||||
return manager.discharge(itemStack, amount, tier, ignoreTransferLimit, simulate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the specified electric item has at least a specific amount of EU.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
* BatPacks are not taken into account.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount minimum amount of energy required
|
||||
* @return true if there's enough energy
|
||||
*
|
||||
* @deprecated use manager.canUse() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean canUse(ItemStack itemStack, int amount) {
|
||||
return manager.canUse(itemStack, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to discharge in EU
|
||||
* @param player player holding the item
|
||||
* @return true if the operation succeeded
|
||||
*
|
||||
* @deprecated use manager.use() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean use(ItemStack itemStack, int amount, EntityPlayer player) {
|
||||
return manager.use(itemStack, amount, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge an item from the BatPack a player is wearing.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
* use() already contains this functionality.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param player player holding the item
|
||||
*
|
||||
* @deprecated use manager.chargeFromArmor() instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void chargeFromArmor(ItemStack itemStack, EntityPlayer player) {
|
||||
manager.chargeFromArmor(itemStack, player);
|
||||
}
|
||||
}
|
||||
|
14
src/main/java/ic2/api/item/IBoxable.java
Normal file
14
src/main/java/ic2/api/item/IBoxable.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public interface IBoxable {
|
||||
/**
|
||||
* Determine whether an item can be stored in a toolbox or not.
|
||||
*
|
||||
* @param itemstack item to be stored
|
||||
* @return Whether to store the item in the toolbox or not
|
||||
*/
|
||||
public abstract boolean canBeStoredInToolbox(ItemStack itemstack);
|
||||
}
|
599
src/main/java/ic2/api/item/IC2Items.java
Normal file
599
src/main/java/ic2/api/item/IC2Items.java
Normal file
|
@ -0,0 +1,599 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides access to IC2 blocks and items.
|
||||
*
|
||||
* Some items can be acquired through the ore dictionary which is the recommended way.
|
||||
* The items are initialized while IC2 is being loaded - try to use ModsLoaded() or load your mod after IC2.
|
||||
* Some blocks/items can be disabled by a config setting, so it's recommended to check if they're null first.
|
||||
*
|
||||
* Getting the associated Block/Item for an ItemStack x:
|
||||
* Blocks: Block.blocksList[x.itemID]
|
||||
* Items: x.getItem()
|
||||
*/
|
||||
public final class IC2Items {
|
||||
/**
|
||||
* Get an ItemStack for a specific item name, example: Items.getItem("resin")
|
||||
* See the list below for item names.
|
||||
* Make sure to copy() the ItemStack if you want to modify it.
|
||||
*
|
||||
* @param name item name
|
||||
* @return The item or null if the item does not exist or an error occurred
|
||||
*/
|
||||
public static ItemStack getItem(String name) {
|
||||
try {
|
||||
if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items");
|
||||
|
||||
Object ret = Ic2Items.getField(name).get(null);
|
||||
|
||||
if (ret instanceof ItemStack) {
|
||||
return (ItemStack) ret;
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
System.out.println("IC2 API: Call getItem failed for "+name);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* Possible values:
|
||||
|
||||
// ores
|
||||
copperOre; // Copper Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreCopper, null with enableWorldGenOreCopper=false
|
||||
tinOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreTin, null with enableWorldGenOreTin=false
|
||||
uraniumOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreUranium, null with enableWorldGenOreUranium=false
|
||||
leadOre; // Lead Ore Block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreLead, null with enableWorldGenOreLead=false
|
||||
|
||||
// rubber related
|
||||
|
||||
Rubber wood block, meta reflects the state, meta in ItemStack set to 0, ore dictionary: woodRubber (with meta 0), null with enableWorldGenTreeRubber=false
|
||||
dropped (as an item) -> metadata 0
|
||||
block, no resin spot -> metadata 0 or 1
|
||||
block, wet resin spot -> metadata 2-5 (according to the side)
|
||||
block, dry resin spot -> metadata 8-11 (wet state + 6)
|
||||
|
||||
rubberWood;
|
||||
rubberLeaves; // Rubber Leaves block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
|
||||
rubberSapling; // Rubber Sapling block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
|
||||
resinSheet; // Resin Sheet block, currently not meta sensitive
|
||||
rubberTrampoline; // Rubber Trampoline block, meta reflects internal state, meta in ItemStack set to 0
|
||||
|
||||
// building/storage
|
||||
ironFence; // Iron Fence block, currently not meta sensitive
|
||||
|
||||
reinforcedStone; // Reinforced Stone block, currently not meta sensitive
|
||||
reinforcedGlass; // Reinforced Glass block, currently not meta sensitive
|
||||
reinforcedDoorBlock; // Reinforced Door block, meta reflects the state (see vanilla doors), meta in ItemStack set to 0
|
||||
|
||||
constructionreinforcedFoam; // Construction Reinforced Foam block, currently not meta sensitive
|
||||
constructionFoam; // Construction Foam block, currently not meta sensitive
|
||||
constructionFoamWall; // Construction Foam Wall block, meta = color, implements IPaintableBlock
|
||||
scaffold; // Scaffold block, meta reflects internal physical model data
|
||||
ironScaffold; // Scaffold block, meta reflects internal physical model data
|
||||
|
||||
bronzeBlock; // Bronze block, meta sensitive
|
||||
copperBlock; // Copper block, meta sensitive
|
||||
tinBlock; // Tin block, meta sensitive
|
||||
uraniumBlock; // Uranium block, meta sensitive
|
||||
leadBlock; // Uranium block, meta sensitive
|
||||
|
||||
// cables (when placed as a block, inventory items are different; TE implements IEnergyConductor)
|
||||
|
||||
copperCableBlock; // Copper Cable block, meta sensitive
|
||||
insulatedCopperCableBlock; // Insulated Copper Cable block, meta sensitive
|
||||
|
||||
goldCableBlock; // Gold Cable block, meta sensitive
|
||||
insulatedGoldCableBlock; // Insulated Gold Cable block, meta sensitive
|
||||
doubleInsulatedGoldCableBlock; // Double Insulated Gold Cable block, meta sensitive
|
||||
|
||||
ironCableBlock; // Iron Cable block, meta sensitive
|
||||
insulatedIronCableBlock; // Insulated Iron Cable block, meta sensitive
|
||||
doubleInsulatedIronCableBlock; // Double Insulated Iron Cable block, meta sensitive
|
||||
trippleInsulatedIronCableBlock; // Tripple Insulated Iron Cable block, meta sensitive
|
||||
|
||||
glassFiberCableBlock; // Glass Fiber Cable block, meta sensitive
|
||||
|
||||
tinCableBlock; // Tin Cable block, meta sensitive
|
||||
insulatedtinCableBlock; // Insulated Tin Cable item, meta sensitive
|
||||
detectorCableBlock; // Detector Cable block, meta sensitive
|
||||
splitterCableBlock; // Splitter Cable block, meta sensitive
|
||||
|
||||
// generators + related (TE implements IEnergySource ex. reactorChamber)
|
||||
|
||||
generator; // Generator block, meta sensitive
|
||||
geothermalGenerator; // Geothermal Generator block, meta sensitive
|
||||
waterMill; // Water Mill block, meta sensitive
|
||||
solarPanel; // Solar Panel block, meta sensitive
|
||||
windMill; // Wind Mill block, meta sensitive
|
||||
nuclearReactor; // Nuclear Reactor block, meta sensitive
|
||||
reactorChamber; // Reactor Chamber block, currently not meta sensitive
|
||||
RTGenerator; // Radioisotope Thermoelectric Generator block, meta sensitive
|
||||
semifluidGenerator; // Semifluid Generator block, meta sensitive
|
||||
|
||||
|
||||
// energy storages (TE implements IEnergySource and IEnergyConductor)
|
||||
|
||||
batBox; // BatBox block, meta sensitive
|
||||
cesuUnit; // CESU Unit block, meta sensitive
|
||||
mfeUnit; // MFE Unit block, meta sensitive
|
||||
mfsUnit; // MFS Unit block, meta sensitive
|
||||
|
||||
// transformers (TE implements IEnergySource and IEnergyConductor)
|
||||
|
||||
lvTransformer; // LV Transformer block, meta sensitive
|
||||
mvTransformer; // MV Transformer block, meta sensitive
|
||||
hvTransformer; // HV Transformer block, meta sensitive
|
||||
evTransformer; // EV Transformer block, meta sensitive
|
||||
|
||||
// machines + related (TE implements IEnergySink ex. machine, miningPipe, miningPipeTip)
|
||||
|
||||
machine; // Machine block, meta sensitive
|
||||
advancedMachine; // Advanced Machine block, meta sensitive
|
||||
|
||||
ironFurnace; // Iron Furnace block, meta sensitive
|
||||
electroFurnace; // Electro Furnace block, meta sensitive
|
||||
macerator; // Macerator block, meta sensitive
|
||||
extractor; // Extractor block, meta sensitive
|
||||
compressor; // Compressor block, meta sensitive
|
||||
canner; // Canner block, meta sensitive
|
||||
miner; // Miner block, meta sensitive
|
||||
pump; // Pump block, meta sensitive
|
||||
magnetizer; // Magnetizer block, meta sensitive
|
||||
electrolyzer; // Electrolyzer block, meta sensitive
|
||||
recycler; // Recycler block, meta sensitive
|
||||
inductionFurnace; // Induction Furnace block, meta sensitive
|
||||
massFabricator; // Mass Fabricator block, meta sensitive
|
||||
terraformer; // Terraformer block, meta sensitive
|
||||
teleporter; // Teleporter block, meta sensitive
|
||||
teslaCoil; // Tesla Coil block, meta sensitive
|
||||
luminator; // Passive (dark) Luminator block, meta = facing
|
||||
activeLuminator; // Active (bright) Luminator block, meta = facing
|
||||
centrifuge; // Centrifuge block, meta sensitive
|
||||
metalformer; // MetalFormer block ,meta sensitive
|
||||
orewashingplant; // Ore Wasching Plant,Meta sensitive
|
||||
patternstorage; // Pattern Storage,Meta sensitive
|
||||
scanner; // Scanner,Meta sensitive
|
||||
replicator; // Replicator,Meta sensitive
|
||||
|
||||
miningPipe; // Mining Pipe block, currently not meta sensitive, meta in ItemStack set to 0
|
||||
miningPipeTip; // Mining Pipe Tip block, currently not meta sensitive, meta in ItemStack set to 0
|
||||
|
||||
|
||||
// personal blocks
|
||||
|
||||
personalSafe; // Personal Safe block, meta sensitive
|
||||
tradeOMat; // Trade-O-Mat block, meta sensitive
|
||||
energyOMat; // Energy-O-Mat block, meta sensitive
|
||||
|
||||
// explosives
|
||||
|
||||
industrialTnt; // Industrial TNT block, currently not meta sensitive
|
||||
nuke; // Nuke block, currently not meta sensitive
|
||||
dynamiteStick; // Dynamite Stick block, meta = placement, meta in ItemStack set to 0
|
||||
dynamiteStickWithRemote; // Dynamite Stick with Remote block, meta = placement, meta in ItemStack set to 0
|
||||
|
||||
// Agriculture Stuff
|
||||
|
||||
crop; // Crop Block, empty, not meta sensitive
|
||||
cropmatron; // Cropmatron machien block, meta sensititve
|
||||
|
||||
// ----- items -----
|
||||
|
||||
// rubber + related
|
||||
resin; // Resin item, currently not meta sensitive
|
||||
rubber; // Rubber item, currently not meta sensitive, ore dictionary: itemRubber
|
||||
|
||||
FluidCell;
|
||||
|
||||
// Lithium -> Tritium
|
||||
|
||||
reactorLithiumCell; // LithiumCell use in Reaktor, , meta = damage value
|
||||
TritiumCell; // Tritium, currently not meta sensitive
|
||||
|
||||
// Nuclear Fuel
|
||||
|
||||
UranFuel; // , currently not meta sensitive
|
||||
MOXFuel; // , currently not meta sensitive
|
||||
Plutonium; // , currently not meta sensitive
|
||||
smallPlutonium; // , currently not meta sensitive
|
||||
Uran235; // , currently not meta sensitive
|
||||
smallUran235; // , currently not meta sensitive
|
||||
Uran238; // , currently not meta sensitive
|
||||
|
||||
reactorDepletedUraniumSimple; // Depleted Uranium Cell items, currently not meta sensitive
|
||||
reactorDepletedUraniumDual;
|
||||
reactorDepletedUraniumQuad;
|
||||
reactorDepletedMOXSimple; // Depleted MOX Cell items, currently not meta sensitive
|
||||
reactorDepletedMOXDual;
|
||||
reactorDepletedMOXQuad;
|
||||
reactorMOXSimple; // Depleted MOX Cell items, currently not meta sensitive
|
||||
reactorMOXDual;
|
||||
reactorMOXQuad;
|
||||
RTGPellets;
|
||||
|
||||
|
||||
// Recipe Parts
|
||||
|
||||
coil; // Coil, meta sensitive
|
||||
elemotor; // electric motor, meta sensitive
|
||||
powerunit; // Item Power Unit, meta sensitive
|
||||
powerunitsmall; // Item Power Unit, meta sensitive
|
||||
|
||||
|
||||
// ItemCasing
|
||||
|
||||
casingcopper; // Copper ItemCasing, meta sensitive
|
||||
casingtin; // Tin ItemCasing, meta sensitive
|
||||
casingbronze; // Bronze ItemCasing, meta sensitive
|
||||
casinggold; // Gold ItemCasing, meta sensitive
|
||||
casingiron; // Iron ItemCasing, meta sensitive
|
||||
@Deprecated
|
||||
casingadviron; // Refined Iron ItemCasing, meta sensitive
|
||||
casinglead; // Lead ItemCasing, meta sensitive
|
||||
|
||||
// Crushed Ore
|
||||
crushedIronOre; // Crushed Iron Ore, meta sensitive
|
||||
crushedCopperOre; // Crushed Copper Ore, meta sensitive
|
||||
crushedGoldOre; // Crushed Gold Ore, meta sensitive
|
||||
crushedTinOre; // Crushed Tin Ore, meta sensitive
|
||||
crushedUraniumOre; // Crushed Uranium Ore, meta sensitive
|
||||
crushedSilverOre; // Crushed Silver Ore, meta sensitive
|
||||
crushedLeadOre; // Crushed Lead Ore, meta sensitive
|
||||
|
||||
|
||||
//Purify Crushed Ore
|
||||
purifiedCrushedIronOre; // Purify Crushed Iron Ore, meta sensitive
|
||||
purifiedCrushedCopperOre; // Purify Crushed Copper Ore, meta sensitive
|
||||
purifiedCrushedGoldOre; // Purify Crushed Gold Ore, meta sensitive
|
||||
purifiedCrushedTinOre; // Purify Crushed Tin Ore, meta sensitive
|
||||
purifiedCrushedUraniumOre; // Purify Crushed Uranium Ore, meta sensitive
|
||||
purifiedCrushedSilverOre; // Purify Crushed Silver Ore, meta sensitive
|
||||
purifiedCrushedLeadOre; // Purify Crushed Lead Ore, meta sensitive
|
||||
|
||||
// dusts
|
||||
stoneDust;
|
||||
bronzeDust; // Bronze Dust item, meta sensitive, ore dictionary: dustBronze
|
||||
clayDust; // Clay Dust item, meta sensitive, ore dictionary: dustClay
|
||||
coalDust; // Coal Dust item, meta sensitive, ore dictionary: dustCoal
|
||||
copperDust; // Copper Dust item, meta sensitive, ore dictionary: dustCopper
|
||||
goldDust; // Gold Dust item, meta sensitive, ore dictionary: dustGold
|
||||
ironDust; // Iron Dust item, meta sensitive, ore dictionary: dustIron
|
||||
silverDust; // Silver Dust item, meta sensitive, ore dictionary: dustSilver
|
||||
tinDust; // Tin Dust item, meta sensitive, ore dictionary: dustTin
|
||||
hydratedCoalDust; // Hydrated Coal Dust item, meta sensitive
|
||||
leadDust; // Lead Dust item, meta sensitive, ore dictionary: dustLead
|
||||
obsidianDust; // Obsidian Dust item, meta sensitive, ore dictionary: dustObsidian
|
||||
lapiDust; // Lapi Dust item, meta sensitive, ore dictionary: dustLapi
|
||||
sulfurDust; // Sulfur Dust item, meta sensitive, ore dictionary: dustSulfur
|
||||
lithiumDust; // Lithium dust, meta sensitive, ore dictionary: dustLithium
|
||||
|
||||
// small dusts
|
||||
|
||||
smallIronDust; // Small Iron Dust item, meta sensitive
|
||||
smallCopperDust; // Small Copper Dust item, meta sensitive
|
||||
smallGoldDust; // Small Gold Dust item, meta sensitive
|
||||
smallTinDust; // Small Tin Dust item, meta sensitive
|
||||
smallSilverDust; // Small Silver Dust item, meta sensitive
|
||||
smallLeadDust; // Small Lead Dust item, meta sensitive
|
||||
smallSulfurDust; // Small Sulfur Dust item, meta sensitive
|
||||
smallLithiumDust; // Small Lithium Dust item, meta sensitive
|
||||
|
||||
|
||||
// ingots
|
||||
@Deprecated
|
||||
refinedIronIngot; // Refined Iron Ingot item, currently not meta sensitive, ore dictionary: ingotRefinedIron
|
||||
copperIngot; // Copper Ingot item, currently not meta sensitive, ore dictionary: ingotCopper
|
||||
tinIngot; // Tin Ingot item, currently not meta sensitive, ore dictionary: ingotTin
|
||||
bronzeIngot; // Bronze Ingot item, currently not meta sensitive, ore dictionary: ingotBronze
|
||||
mixedMetalIngot; // Mixed Metal Ingot item, currently not meta sensitive
|
||||
leadIngot; // Lead Ingot item, currently not meta sensitive
|
||||
|
||||
|
||||
// tools/weapons (without electric tools)
|
||||
treetap; // Treetap item, meta = damage value
|
||||
wrench; // Wrench item, meta = damage value
|
||||
cutter; // Insulation Cutter item, meta = damage value
|
||||
constructionFoamSprayer; // Construction Foam Sprayer item, meta = charges (as of v1.45)
|
||||
|
||||
bronzePickaxe; // Bronze Pickaxe item, meta = damage value
|
||||
bronzeAxe; // Bronze Axe item, meta = damage value
|
||||
bronzeSword; // Bronze Sword item, meta = damage value
|
||||
bronzeShovel; // Bronze Shovel item, meta = damage value
|
||||
bronzeHoe; // Bronze Hoe item, meta = damage value
|
||||
|
||||
ForgeHammer; // Refine Iron Hammer item, meta = damage value
|
||||
|
||||
// el. tools/devices/weapons
|
||||
miningDrill; // Mining Drill item, meta = damage value for charge level
|
||||
diamondDrill; // Diamond Tipped Mining Drill item, meta = damage value for charge level
|
||||
iridiumDrill; // Iridium Tipped Mining Drill item, meta = damage value for charge level
|
||||
chainsaw; // Chainsaw item, meta = damage value for charge level
|
||||
electricWrench; // Electric Wrench item, meta = damage value for charge level
|
||||
electricTreetap; // Electric Treetap item, meta = damage value for charge level
|
||||
miningLaser; // Mining Laser item, meta = damage value for charge level
|
||||
|
||||
ecMeter; // EC-Mater item, meta = itemdata db index (as of v1.45)
|
||||
odScanner; // Ore Density Scanner item, meta = damage value for charge level
|
||||
ovScanner; // Ore Value Scanner item, meta = damage value for charge level
|
||||
obscurator; // Obscurator item, meta = damage value for charge level
|
||||
|
||||
frequencyTransmitter; // Frequency Transmitter item, meta = itemdata db index (as of v1.45)
|
||||
|
||||
nanoSaber; // Idle Nano Saber item, meta = damage value for charge level
|
||||
enabledNanoSaber; // Enabled Nano Saber item, meta = damage value for charge level
|
||||
|
||||
toolbox; // Open/Empty toolbox, meta = Open (0) / Closed (1)
|
||||
|
||||
// armor/wearable
|
||||
hazmatHelmet; // Hazmat Helmet item, meta = damage value
|
||||
hazmatChestplate; // Hazmat Chestplate item, meta = damage value
|
||||
hazmatLeggings; // Hazmat Leggings item, meta = damage value
|
||||
hazmatBoots; // Hazmat Boots item, meta = damage value
|
||||
|
||||
bronzeHelmet; // Bronze Helmet Armor item, meta = damage value
|
||||
bronzeChestplate; // Bronze Chestplate Armor item, meta = damage value
|
||||
bronzeLeggings; // Bronze Leggings Armor item, meta = damage value
|
||||
bronzeBoots; // Bronze Boots Armor item, meta = damage value
|
||||
|
||||
compositeArmor; // Composite Armor item, meta = damage value for charge level
|
||||
|
||||
nanoHelmet; // Nano Helmet Armor item, meta = damage value for charge level
|
||||
nanoBodyarmor; // Nano Bodyarmor item, meta = damage value for charge level
|
||||
nanoLeggings; // Nano Leggings Armor item, meta = damage value for charge level
|
||||
nanoBoots; // Nano Boots Armor item, meta = damage value for charge level
|
||||
|
||||
quantumHelmet; // Quantum Helmet Armor item, meta = damage value for charge level
|
||||
quantumBodyarmor; // Quantum Bodyarmor item, meta = damage value for charge level
|
||||
quantumLeggings; // Quantum Leggings Armor item, meta = damage value for charge level
|
||||
quantumBoots; // Quantum Boots Armor item, meta = damage value for charge level
|
||||
|
||||
jetpack; // Jetpack item, meta = damage value for fuel level
|
||||
electricJetpack; // Electric Jetpack item, meta = damage value for charge level
|
||||
|
||||
batPack; // BatPack item, meta = damage value for charge level
|
||||
advbatPack; // Adv.BatPack item, meta = damage value for charge level
|
||||
lapPack; // LapPack item, meta = damage value for charge level
|
||||
energyPack; // EnergyPack item, meta = damage value for charge level
|
||||
|
||||
cfPack; // CF Pack item, meta = charges (as of v1.45)
|
||||
solarHelmet; // Solar Helmet, currently not meta sensitive
|
||||
staticBoots; // Static Boots, currently not meta sensitive
|
||||
nightvisionGoggles; // Nightvision Goggles, meta = damage value for charge level
|
||||
|
||||
// batteries
|
||||
reBattery; // Empty RE Battery item, currently not meta sensitive
|
||||
chargedReBattery; // RE Battery item, meta = damage value for charge level
|
||||
advBattery; // Adv Batteryitem, meta = damage value for charge level
|
||||
energyCrystal; // Energy Crystal item, meta = damage value for charge level
|
||||
lapotronCrystal; // Lapotron Crystal item, meta = damage value for charge level
|
||||
suBattery; // SU Battery item, meta = damage value for charge level
|
||||
|
||||
// cables
|
||||
copperCableItem; // Copper Cable item, meta sensitive
|
||||
insulatedCopperCableItem; // Insulated Copper Cable item, meta sensitive
|
||||
|
||||
goldCableItem; // Gold Cable item, meta sensitive
|
||||
insulatedGoldCableItem; // Insulated Gold Cable item, meta sensitive
|
||||
|
||||
@Deprecated
|
||||
doubleInsulatedGoldCableItem; // Double Insulated Gold Cable item, meta sensitive
|
||||
|
||||
ironCableItem; // Iron Cable item, meta sensitive
|
||||
insulatedIronCableItem; // Insulated Iron Cable item, meta sensitive
|
||||
|
||||
@Deprecated
|
||||
doubleInsulatedIronCableItem; // Double Insulated Iron Cable item, meta sensitive
|
||||
@Deprecated
|
||||
trippleInsulatedIronCableItem; // Tripple Insulated Iron Cable item, meta sensitive
|
||||
insulatedTinCableItem;
|
||||
glassFiberCableItem; // Glass Fiber Cable item, meta sensitive
|
||||
tinCableItem; // Tin Cable item, meta sensitive
|
||||
|
||||
|
||||
detectorCableItem; // Detector Cable item, meta sensitive
|
||||
splitterCableItem; // Splitter Cable item, meta sensitive
|
||||
|
||||
// cells/containers (without reactor components)
|
||||
|
||||
cell; // Empty Cell item, meta sensitive
|
||||
lavaCell; // Lava Cell item, meta sensitive
|
||||
waterCell; // Water Cell item, meta sensitive
|
||||
UuMatterCell; // UUMatter Cell item, meta sensitive
|
||||
CFCell; // constructionFoam Cell item, meta sensitive
|
||||
|
||||
|
||||
fuelRod; // Empy Fuel Rod item, currently not meta sensitive
|
||||
hydratedCoalCell; // Hydrated Coal Cell item, currently not meta sensitive
|
||||
bioCell; // Bio Cell item, currently not meta sensitive
|
||||
coalfuelCell; // Coalfuel Cell item, currently not meta sensitive
|
||||
biofuelCell; // Biofuel Cell item, currently not meta sensitive
|
||||
electrolyzedWaterCell; // Electrolyzed Water Cell item, currently not meta sensitive
|
||||
airCell; // Compressed Air item, currently not meta sensitive
|
||||
|
||||
fuelCan; // Empty Fuel Can item, currently not meta sensitive
|
||||
filledFuelCan; // Fuel Can item, meta = fuel value (as of v1.45)
|
||||
|
||||
tinCan; // Empty Tin Can item, currently not meta sensitive
|
||||
filledTinCan; // Filled Tin Can item, currently not meta sensitive
|
||||
|
||||
// reactor components
|
||||
reactorUraniumSimple; // Uranium Cell items, meta = consumed uranium ticks
|
||||
reactorUraniumDual;
|
||||
reactorUraniumQuad;
|
||||
|
||||
reactorCoolantSimple;
|
||||
reactorCoolantTriple ; // Coolant Cell item, NBT for heat-storage, meta is 0-10000 for display
|
||||
reactorCoolantSix;
|
||||
|
||||
reactorPlating; // Integrated Reactor Plating item, currently not meta sensitive
|
||||
reactorPlatingHeat;
|
||||
reactorPlatingExplosive;
|
||||
|
||||
reactorHeatSwitch; // Integrated Heat Disperser item, NBT for heat-storage, meta is 0-10000 for display
|
||||
reactorHeatSwitchCore;
|
||||
reactorHeatSwitchSpread;
|
||||
reactorHeatSwitchDiamond;
|
||||
|
||||
reactorVent; // Heat Venting component, NBT for heat-storage, meta is 0-10000 for display
|
||||
reactorVentCore;
|
||||
reactorVentGold;
|
||||
reactorVentSpread;// Special: Does not store heat
|
||||
reactorVentDiamond;
|
||||
|
||||
reactorReflector; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display
|
||||
reactorReflectorThick; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display
|
||||
reactorCondensator; // Consumes redstone to absorb heat, NBT for storage, meta is 0-10000 for display
|
||||
reactorCondensatorLap; // Consumes redstone/lapis to absorb heat, mNBT for storage, meta is 0-10000 for display
|
||||
|
||||
// terraformer blueprints
|
||||
terraformerBlueprint; // Empty Terraformer Blueprint item, currently not meta sensitive
|
||||
cultivationTerraformerBlueprint; // Cultivation Terraformer Blueprint item, currently not meta sensitive
|
||||
irrigationTerraformerBlueprint; // Irrigation Terraformer Blueprint item, currently not meta sensitive
|
||||
chillingTerraformerBlueprint; // Chilling Terraformer Blueprint item, currently not meta sensitive
|
||||
desertificationTerraformerBlueprint; // Desertification Terraformer Blueprint item, currently not meta sensitive
|
||||
flatificatorTerraformerBlueprint; // Flatificator Terraformer Blueprint item, currently not meta sensitive
|
||||
mushroomTerraformerBlueprint; // Mushroom Terraformer Blueprint item, currently not meta sensitive
|
||||
|
||||
// diamond chain
|
||||
coalBall; // Coal Ball item, currently not meta sensitive
|
||||
compressedCoalBall; // Compressed Coal Ball item, currently not meta sensitive
|
||||
coalChunk; // Coal Chunk item, currently not meta sensitive
|
||||
industrialDiamond; // Industrial Diamond item, currently not meta sensitive, DEPRECATED
|
||||
|
||||
// recycler chain
|
||||
scrap; // Scrap item, currently not meta sensitive
|
||||
scrapBox; // Scrap Box item, currently not meta sensitive
|
||||
|
||||
// fuel production chain
|
||||
hydratedCoalClump; // Hydrated Coal Clump item, currently not meta sensitive
|
||||
plantBall; // Plant Ball item, currently not meta sensitive
|
||||
compressedPlantBall; // Compressed Plant Ball item, currently not meta sensitive
|
||||
|
||||
// painting
|
||||
painter; // Painter item, currently not meta sensitive
|
||||
|
||||
blackPainter; // Black Painter item, meta = damage value
|
||||
redPainter; // Red Painter item, meta = damage value
|
||||
greenPainter; // Green Painter item, meta = damage value
|
||||
brownPainter; // Brown Painter item, meta = damage value
|
||||
bluePainter; // Blue Painter item, meta = damage value
|
||||
purplePainter; // Purple Painter item, meta = damage value
|
||||
cyanPainter; // Cyan Painter item, meta = damage value
|
||||
lightGreyPainter; // Light Grey Painter item, meta = damage value
|
||||
darkGreyPainter; // Dark Grey Painter item, meta = damage value
|
||||
pinkPainter; // Pink Painter item, meta = damage value
|
||||
limePainter; // Lime Painter item, meta = damage value
|
||||
yellowPainter; // Yellow Painter item, meta = damage value
|
||||
cloudPainter; // Cloud Painter item, meta = damage value
|
||||
magentaPainter; // Magenta Painter item, meta = damage value
|
||||
orangePainter; // Orange Painter item, meta = damage value
|
||||
whitePainter; // White Painter item, meta = damage value
|
||||
|
||||
// explosives + related
|
||||
dynamite; // Throwable Dynamite item, currently not meta sensitive
|
||||
stickyDynamite; // Throwable Sticky Dynamite item, currently not meta sensitive
|
||||
|
||||
remote; // Dynamite Remote item, currently not meta sensitive
|
||||
|
||||
// misc intermediate recipe ingredients
|
||||
electronicCircuit; // Electronic Circuit item, currently not meta sensitive
|
||||
advancedCircuit; // Advanced Circuit item, currently not meta sensitive
|
||||
|
||||
advancedAlloy; // Advanced Alloy item, currently not meta sensitive
|
||||
|
||||
carbonFiber; // Raw Carbon Fiber item, currently not meta sensitive
|
||||
carbonMesh; // Raw Carbon Mesh item, currently not meta sensitive
|
||||
carbonPlate; // Carbon Plate item, currently not meta sensitive
|
||||
|
||||
matter; // UUA item, currently not meta sensitive
|
||||
iridiumOre; // Iridium Ore item, currently not meta sensitive
|
||||
iridiumPlate; // Iridium Plate item, currently not meta sensitive
|
||||
|
||||
|
||||
// Metal Plates
|
||||
|
||||
platecopper; // Metal plate item, meta sensitive
|
||||
platetin; // Metal plate item, meta sensitive
|
||||
platebronze; // Metal plate item, meta sensitive
|
||||
plategold; // Metal plate item, meta sensitive
|
||||
plateiron; // Metal plate item, meta sensitive
|
||||
platelead; // Metal plate item, meta sensitive
|
||||
platelapi; // Metal plate item, meta sensitive
|
||||
plateobsidian; // Metal plate item, meta sensitive
|
||||
plateadviron; // Metal plate item, meta sensitive
|
||||
|
||||
// Metal Dense Plates
|
||||
denseplatecopper; // Metal dense plate item, meta sensitive
|
||||
denseplatetin; // Metal dense plate item, meta sensitive
|
||||
denseplatebronze; // Metal dense plate item, meta sensitive
|
||||
denseplategold; // Metal dense plate item, meta sensitive
|
||||
denseplateiron; // Metal dense plate item, meta sensitive
|
||||
@Deprecated
|
||||
denseplateadviron; // Metal dense plate item, meta sensitive
|
||||
denseplatelead; // Metal dense plate item, meta sensitive
|
||||
denseplatelapi; // Metal dense plate item, meta sensitive
|
||||
denseplateobsidian; // Metal dense plate item, meta sensitive
|
||||
|
||||
|
||||
|
||||
// upgrade modules
|
||||
overclockerUpgrade; // overclocker upgrade item, meta sensitive
|
||||
transformerUpgrade; // transformer upgrade item, meta sensitive
|
||||
energyStorageUpgrade; // energy storage upgrade item, meta sensitive
|
||||
ejectorUpgrade; // ejector upgrade item, meta sensitive
|
||||
|
||||
// misc
|
||||
coin; // Coin item, currently not meta sensitive
|
||||
reinforcedDoor; // Reinforced Door item, currently not meta sensitive
|
||||
constructionFoamPowder; // Construction Foam Powder item, currently not meta sensitive
|
||||
grinPowder; // Poisonous ingrident, currently not meta sensitive
|
||||
debug; // Debug item, currently not meta sensitive
|
||||
boatCarbon; // Carbon Fiber Canoe item, meta sensitive
|
||||
boatRubber; // Rubber Dinghy item, meta sensitive
|
||||
boatRubberBroken; // Damaged Rubber Dinghy item, meta sensitive
|
||||
boatElectric; // Electric Boat item, meta sensitive
|
||||
|
||||
//Agriculture
|
||||
cropSeed; // Crop seeds, stuff stored in NBT, don't use for crafting recipes!
|
||||
cropnalyzer; // Cropnalyzer handheld device
|
||||
fertilizer; // Basic IC2Item, used to provide nutrients toCropBlocks
|
||||
hydratingCell; // Cell used to hydrate Crops, meta = Content, 0= Full, 9999 = Near empty
|
||||
electricHoe; // Electric Hoe, Metadata indicates charge level
|
||||
terraWart; // Mystic opposite of NEtherWart, cures StatusEffects, simply consumeable
|
||||
weedEx; // Spraying can of WEED-EX, meta indicates usages left
|
||||
|
||||
//Boozeception
|
||||
mugEmpty; // Simple stone mug
|
||||
coffeeBeans; // Harvested CoffeeBeans
|
||||
coffeePowder; // Processed Coffee Beans, used to craft drinkable Coffee
|
||||
mugCoffee; // Mug of Coffee, Meta indicates status 0 = cold, 1 = Normal, 2 = Sugar'd
|
||||
hops; // Hops, harvested freshly from crop
|
||||
barrel; // Carried Barrel, metadata encrypts the information about the liquid inside
|
||||
blockBarrel; // Unobtainable "placed barrel", TileEntity controlling the Fermentation process
|
||||
mugBooze; // Mug filled with booze, metadata encrypts the information about the liquid inside
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the base IC2 package name, used internally.
|
||||
*
|
||||
* @return IC2 package name, if unable to be determined defaults to ic2
|
||||
*/
|
||||
private static String getPackage() {
|
||||
Package pkg = IC2Items.class.getPackage();
|
||||
|
||||
if (pkg != null) {
|
||||
String packageName = pkg.getName();
|
||||
|
||||
return packageName.substring(0, packageName.length() - ".api.item".length());
|
||||
}
|
||||
|
||||
return "ic2";
|
||||
}
|
||||
|
||||
private static Class<?> Ic2Items;
|
||||
}
|
||||
|
67
src/main/java/ic2/api/item/ICustomElectricItem.java
Normal file
67
src/main/java/ic2/api/item/ICustomElectricItem.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides the ability to store energy on the implementing item.
|
||||
*
|
||||
* This interface is a special version of IElectricItem which delegates the implementation of
|
||||
* charge(), discharge() and canUse() to the implementing Item.
|
||||
*
|
||||
* The default implementation (when not using ICustomElectricItem) does the following:
|
||||
* - store and retrieve the charge
|
||||
* - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account
|
||||
* - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId())
|
||||
* - update and manage the damage value for the visual charge indicator
|
||||
*
|
||||
* @note ICustomElectricItem must not call the ElectricItem methods charge, discharge or canUse
|
||||
*
|
||||
* @deprecated Use ISpecialElectricItem instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ICustomElectricItem extends IElectricItem {
|
||||
/**
|
||||
* Charge an item with a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the charging device, has to be at least as high as the item to charge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually change the item, just determine the return value
|
||||
* @return Energy transferred into the electric item
|
||||
*/
|
||||
public int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate);
|
||||
|
||||
/**
|
||||
* Discharge an item by a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the discharging device, has to be at least as high as the item to discharge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually discharge the item, just determine the return value
|
||||
* @return Energy retrieved from the electric item
|
||||
*/
|
||||
public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate);
|
||||
|
||||
/**
|
||||
* Determine if the specified electric item has at least a specific amount of EU.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
* BatPacks are not taken into account.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount minimum amount of energy required
|
||||
* @return true if there's enough energy
|
||||
*/
|
||||
public boolean canUse(ItemStack itemStack, int amount);
|
||||
|
||||
/**
|
||||
* Determine whether to show the charge tool tip with NEI or other means.
|
||||
*
|
||||
* Return false if IC2's handler is incompatible, you want to implement your own or you don't
|
||||
* want to display the charge at all.
|
||||
*
|
||||
* @return true to show the tool tip (x/y EU)
|
||||
*/
|
||||
public boolean canShowChargeToolTip(ItemStack itemStack);
|
||||
}
|
23
src/main/java/ic2/api/item/IDebuggable.java
Normal file
23
src/main/java/ic2/api/item/IDebuggable.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package ic2.api.item;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allows a tile entity to output a debug message when the debugItem is used on it.
|
||||
* Suggestions by Myrathi
|
||||
*/
|
||||
public abstract interface IDebuggable {
|
||||
/**
|
||||
* Checks if the tile entity is in a state that can be debugged.
|
||||
*
|
||||
* @return True if the tile entity can be debugged
|
||||
*/
|
||||
public abstract boolean isDebuggable();
|
||||
|
||||
/**
|
||||
* Gets the debug text for the tile entity.
|
||||
*
|
||||
* @return The text that the debugItem should show
|
||||
*/
|
||||
public abstract String getDebugText();
|
||||
}
|
55
src/main/java/ic2/api/item/IElectricItem.java
Normal file
55
src/main/java/ic2/api/item/IElectricItem.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Provides the ability to store energy on the implementing item.
|
||||
*
|
||||
* The item should have a maximum damage of 13.
|
||||
*/
|
||||
public interface IElectricItem {
|
||||
/**
|
||||
* Determine if the item can be used in a machine or as an armor part to supply energy.
|
||||
*
|
||||
* @return Whether the item can supply energy
|
||||
*/
|
||||
boolean canProvideEnergy(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get the item ID to use for a charge energy greater than 0.
|
||||
*
|
||||
* @return Item ID to use
|
||||
*/
|
||||
Item getChargedItem(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get the item ID to use for a charge energy of 0.
|
||||
*
|
||||
* @return Item ID to use
|
||||
*/
|
||||
Item getEmptyItem(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get the item's maximum charge energy in EU.
|
||||
*
|
||||
* @return Maximum charge energy
|
||||
*/
|
||||
int getMaxCharge(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get the item's tier, lower tiers can't send energy to higher ones.
|
||||
* Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3.
|
||||
*
|
||||
* @return Item's tier
|
||||
*/
|
||||
int getTier(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Get the item's transfer limit in EU per transfer operation.
|
||||
*
|
||||
* @return Transfer limit
|
||||
*/
|
||||
int getTransferLimit(ItemStack itemStack);
|
||||
}
|
||||
|
92
src/main/java/ic2/api/item/IElectricItemManager.java
Normal file
92
src/main/java/ic2/api/item/IElectricItemManager.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This interface specifies a manager to handle the various tasks for electric items.
|
||||
*
|
||||
* The default implementation does the following:
|
||||
* - store and retrieve the charge
|
||||
* - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account
|
||||
* - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId())
|
||||
* - update and manage the damage value for the visual charge indicator
|
||||
*
|
||||
* @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the
|
||||
* default implementations through ElectricItem.rawManager. The default implementation is designed
|
||||
* to minimize its dependency on its own constraints/structure and delegates most work back to the
|
||||
* more atomic features in the gateway manager.
|
||||
*/
|
||||
public interface IElectricItemManager {
|
||||
/**
|
||||
* Charge an item with a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the charging device, has to be at least as high as the item to charge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually change the item, just determine the return value
|
||||
* @return Energy transferred into the electric item
|
||||
*/
|
||||
int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate);
|
||||
|
||||
/**
|
||||
* Discharge an item by a specified amount of energy
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to charge in EU
|
||||
* @param tier tier of the discharging device, has to be at least as high as the item to discharge
|
||||
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
|
||||
* @param simulate don't actually discharge the item, just determine the return value
|
||||
* @return Energy retrieved from the electric item
|
||||
*/
|
||||
int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate);
|
||||
|
||||
/**
|
||||
* Determine the charge level for the specified item
|
||||
*
|
||||
* @param itemStack ItemStack containing the electric item
|
||||
* @return charge level in EU
|
||||
*/
|
||||
int getCharge(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Determine if the specified electric item has at least a specific amount of EU.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
* BatPacks are not taken into account.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount minimum amount of energy required
|
||||
* @return true if there's enough energy
|
||||
*/
|
||||
boolean canUse(ItemStack itemStack, int amount);
|
||||
|
||||
/**
|
||||
* Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param amount amount of energy to discharge in EU
|
||||
* @param entity entity holding the item
|
||||
* @return true if the operation succeeded
|
||||
*/
|
||||
boolean use(ItemStack itemStack, int amount, EntityLivingBase entity);
|
||||
|
||||
/**
|
||||
* Charge an item from the BatPack a player is wearing.
|
||||
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
|
||||
* use() already contains this functionality.
|
||||
*
|
||||
* @param itemStack electric item's stack
|
||||
* @param entity entity holding the item
|
||||
*/
|
||||
void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity);
|
||||
|
||||
/**
|
||||
* Get the tool tip to display for electric items.
|
||||
*
|
||||
* @param itemStack ItemStack to determine the tooltip for
|
||||
* @return tool tip string or null for none
|
||||
*/
|
||||
String getToolTip(ItemStack itemStack);
|
||||
}
|
26
src/main/java/ic2/api/item/IItemHudInfo.java
Normal file
26
src/main/java/ic2/api/item/IItemHudInfo.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemHudInfo {
|
||||
|
||||
/*
|
||||
Add Info to Nano- and Quantum-Suit Helm Hud
|
||||
for itemStack
|
||||
|
||||
@Override
|
||||
public List<String> getHudInfo(ItemStack itemStack) {
|
||||
List<String> info = new LinkedList<String>();
|
||||
info.add("i am a Cool Item");
|
||||
info.add("and have Cool info");
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
public List<String> getHudInfo(ItemStack itemStack);
|
||||
|
||||
}
|
20
src/main/java/ic2/api/item/IMetalArmor.java
Normal file
20
src/main/java/ic2/api/item/IMetalArmor.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Armor items implementing this can be considered metal armor.
|
||||
*
|
||||
* Currently used for determining which boots can be used to slide up a magnetic pole.
|
||||
*/
|
||||
public interface IMetalArmor {
|
||||
/**
|
||||
* Determine if the given armor piece is metal armor.
|
||||
*
|
||||
* @param itemstack Armor piece as worn by the player
|
||||
* @param player The player
|
||||
* @return Whether the armor piece is metal armor
|
||||
*/
|
||||
public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player);
|
||||
}
|
13
src/main/java/ic2/api/item/ISpecialElectricItem.java
Normal file
13
src/main/java/ic2/api/item/ISpecialElectricItem.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISpecialElectricItem extends IElectricItem {
|
||||
/**
|
||||
* Supply a custom IElectricItemManager.
|
||||
*
|
||||
* @param itemStack ItemStack to get the manager for
|
||||
* @return IElectricItemManager instance
|
||||
*/
|
||||
IElectricItemManager getManager(ItemStack itemStack);
|
||||
}
|
35
src/main/java/ic2/api/item/ITerraformingBP.java
Normal file
35
src/main/java/ic2/api/item/ITerraformingBP.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Allows an item to act as a terraformer blueprint.
|
||||
*/
|
||||
public interface ITerraformingBP
|
||||
{
|
||||
/**
|
||||
* Get the energy consumption per operation of the blueprint.
|
||||
*
|
||||
* @return Energy consumption in EU
|
||||
*/
|
||||
public abstract int getConsume();
|
||||
|
||||
/**
|
||||
* Get the maximum range of the blueprint.
|
||||
* Should be a divisor of 5.
|
||||
*
|
||||
* @return Maximum range in blocks
|
||||
*/
|
||||
public abstract int getRange();
|
||||
|
||||
/**
|
||||
* Perform the terraforming operation.
|
||||
*
|
||||
* @param world world to terraform
|
||||
* @param x X position to terraform
|
||||
* @param z Z position to terraform
|
||||
* @param yCoord Y position of the terraformer
|
||||
* @return Whether the operation was successful and the terraformer should consume energy.
|
||||
*/
|
||||
public abstract boolean terraform(World world, int x, int z, int yCoord);
|
||||
}
|
50
src/main/java/ic2/api/item/ItemWrapper.java
Normal file
50
src/main/java/ic2/api/item/ItemWrapper.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package ic2.api.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Wrapper for inserting interfaces into items you don't own.
|
||||
*
|
||||
* @author Richard
|
||||
*/
|
||||
public class ItemWrapper {
|
||||
private static final Multimap<Item, IBoxable> boxableItems = ArrayListMultimap.create();
|
||||
private static final Multimap<Item, IMetalArmor> metalArmorItems = ArrayListMultimap.create();
|
||||
|
||||
public static void registerBoxable(Item item, IBoxable boxable) {
|
||||
boxableItems.put(item, boxable);
|
||||
}
|
||||
|
||||
public static boolean canBeStoredInToolbox(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
// use customs first to allow for overriding behavior
|
||||
for (IBoxable boxable : boxableItems.get(item)) {
|
||||
if (boxable.canBeStoredInToolbox(stack)) return true;
|
||||
}
|
||||
|
||||
if (item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void registerMetalArmor(Item item, IMetalArmor armor) {
|
||||
metalArmorItems.put(item, armor);
|
||||
}
|
||||
|
||||
public static boolean isMetalArmor(ItemStack stack, EntityPlayer player) {
|
||||
Item item = stack.getItem();
|
||||
// use customs first to allow for overriding behavior
|
||||
for (IMetalArmor metalArmor : metalArmorItems.get(item)) {
|
||||
if (metalArmor.isMetalArmor(stack, player)) return true;
|
||||
}
|
||||
|
||||
if (item instanceof IMetalArmor && ((IMetalArmor) item).isMetalArmor(stack, player)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package ic2.api.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Allows a tile entity to receive network events received from clients.
|
||||
*/
|
||||
public interface INetworkClientTileEntityEventListener {
|
||||
/**
|
||||
* Called when a network event is received.
|
||||
*
|
||||
* @param player client which sent the event
|
||||
* @param event event ID
|
||||
*/
|
||||
void onNetworkEvent(EntityPlayer player, int event);
|
||||
}
|
||||
|
18
src/main/java/ic2/api/network/INetworkDataProvider.java
Normal file
18
src/main/java/ic2/api/network/INetworkDataProvider.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package ic2.api.network;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tile entities which want to synchronized specific fields between client and server have to implement this.
|
||||
*
|
||||
* The fields don't update themselves, a field update must be sent every time a synchronized field changes.
|
||||
*/
|
||||
public interface INetworkDataProvider {
|
||||
/**
|
||||
* Get the list of synchronized fields.
|
||||
*
|
||||
* @return Names of the synchronized fields
|
||||
*/
|
||||
List<String> getNetworkedFields();
|
||||
}
|
||||
|
19
src/main/java/ic2/api/network/INetworkItemEventListener.java
Normal file
19
src/main/java/ic2/api/network/INetworkItemEventListener.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package ic2.api.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Allows an item to receive network events received from the server.
|
||||
*/
|
||||
public interface INetworkItemEventListener {
|
||||
/**
|
||||
* Called when a network event is received.
|
||||
*
|
||||
* @param itemStack item stack
|
||||
* @param player player containing the item
|
||||
* @param event event ID
|
||||
*/
|
||||
void onNetworkEvent(ItemStack stack, EntityPlayer player, int event);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package ic2.api.network;
|
||||
|
||||
/**
|
||||
* Allows a tile entity to receive network events received from the server.
|
||||
*/
|
||||
public interface INetworkTileEntityEventListener {
|
||||
/**
|
||||
* Called when a network event is received.
|
||||
*
|
||||
* @param event Event ID
|
||||
*/
|
||||
void onNetworkEvent(int event);
|
||||
}
|
||||
|
14
src/main/java/ic2/api/network/INetworkUpdateListener.java
Normal file
14
src/main/java/ic2/api/network/INetworkUpdateListener.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ic2.api.network;
|
||||
|
||||
/**
|
||||
* Allows a tile entity to receive field sync updates received from the server.
|
||||
*/
|
||||
public interface INetworkUpdateListener {
|
||||
/**
|
||||
* Called when a field is synchronized.
|
||||
*
|
||||
* @param field field synchronized
|
||||
*/
|
||||
void onNetworkUpdate(String field);
|
||||
}
|
||||
|
194
src/main/java/ic2/api/network/NetworkHelper.java
Normal file
194
src/main/java/ic2/api/network/NetworkHelper.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package ic2.api.network;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* Provides methods to initiate events and synchronize tile entity fields in SMP.
|
||||
*
|
||||
* The methods are transparent between singleplayer and multiplayer - if a method is called in
|
||||
* singleplayer, the associated callback will be locally executed. The implementation is different
|
||||
* between the client and server versions of IC2.
|
||||
*
|
||||
* You'll usually want to use the server->client methods defined here to synchronize information
|
||||
* which is needed by the clients outside the GUI, such as rendering the block, playing sounds or
|
||||
* producing effects. Anything which is only visible inside the GUI should be synchronized through
|
||||
* the Container class associated to the GUI in Container.updateProgressBar().
|
||||
*/
|
||||
public final class NetworkHelper {
|
||||
// server -> client
|
||||
|
||||
|
||||
/**
|
||||
* Schedule a TileEntity's field to be updated to the clients in range.
|
||||
*
|
||||
* The updater will query the field's value during the next update, updates happen usually
|
||||
* every 2 ticks. If low latency is important use initiateTileEntityEvent instead.
|
||||
*
|
||||
* IC2's network updates have to get triggered every time, it doesn't continuously poll/send
|
||||
* the field value. Just call updateTileEntityField after every change to a field which needs
|
||||
* network synchronization.
|
||||
*
|
||||
* The following field data types are currently supported:
|
||||
* - int, int[], short, short[], byte, byte[], long, long[]
|
||||
* - float, float[], double, double[]
|
||||
* - boolean, boolean[]
|
||||
* - String, String[]
|
||||
* - ItemStack
|
||||
* - NBTBase (includes NBTTagCompound)
|
||||
* - Block, Item, Achievement, Potion, Enchantment
|
||||
* - ChunkCoordinates, ChunkCoordIntPair
|
||||
* - TileEntity (does not sync the actual tile entity, instead looks up the tile entity by its position in the client world)
|
||||
* - World (does not sync the actual world, instead looks up the world by its dimension ID)
|
||||
*
|
||||
* Once the update has been processed by the client, it'll call onNetworkUpdate on the client-
|
||||
* side TileEntity if it implements INetworkUpdateListener.
|
||||
*
|
||||
* If this method is being executed on the client (i.e. Singleplayer), it'll just call
|
||||
* INetworkUpdateListener.onNetworkUpdate (if implemented by the te).
|
||||
*
|
||||
* @param te TileEntity to update
|
||||
* @param field Name of the field to update
|
||||
*/
|
||||
public static void updateTileEntityField(TileEntity te, String field) {
|
||||
try {
|
||||
if (NetworkManager_updateTileEntityField == null) NetworkManager_updateTileEntityField = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("updateTileEntityField", TileEntity.class, String.class);
|
||||
if (instance == null) instance = getInstance();
|
||||
|
||||
NetworkManager_updateTileEntityField.invoke(instance, te, field);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately send an event for the specified TileEntity to the clients in range.
|
||||
*
|
||||
* If this method is being executed on the client (i.e. Singleplayer), it'll just call
|
||||
* INetworkTileEntityEventListener.onNetworkEvent (if implemented by the te).
|
||||
*
|
||||
* @param te TileEntity to notify, should implement INetworkTileEntityEventListener
|
||||
* @param event Arbitrary integer to represent the event, choosing the values is up to you
|
||||
* @param limitRange Limit the notification range to (currently) 20 blocks instead of the
|
||||
* tracking distance if true
|
||||
*/
|
||||
public static void initiateTileEntityEvent(TileEntity te, int event, boolean limitRange) {
|
||||
try {
|
||||
if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE);
|
||||
if (instance == null) instance = getInstance();
|
||||
|
||||
NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately send an event for the specified Item to the clients in range.
|
||||
*
|
||||
* The item should implement INetworkItemEventListener to receive the event.
|
||||
*
|
||||
* If this method is being executed on the client (i.e. Singleplayer), it'll just call
|
||||
* INetworkItemEventListener.onNetworkEvent (if implemented by the item).
|
||||
*
|
||||
* @param player EntityPlayer holding the item
|
||||
* @param itemStack ItemStack containing the item
|
||||
* @param event Arbitrary integer to represent the event, choosing the values is up to you
|
||||
* @param limitRange Limit the notification range to (currently) 20 blocks instead of the
|
||||
* tracking distance if true
|
||||
*/
|
||||
public static void initiateItemEvent(EntityPlayer player, ItemStack itemStack, int event, boolean limitRange) {
|
||||
try {
|
||||
if (NetworkManager_initiateItemEvent == null) NetworkManager_initiateItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateItemEvent", EntityPlayer.class, ItemStack.class, Integer.TYPE, Boolean.TYPE);
|
||||
if (instance == null) instance = getInstance();
|
||||
|
||||
NetworkManager_initiateItemEvent.invoke(instance, player, itemStack, event, limitRange);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// client -> server
|
||||
|
||||
/**
|
||||
* Immediately send an event for the specified TileEntity to the server.
|
||||
*
|
||||
* This method doesn't do anything if executed on the server.
|
||||
*
|
||||
* @param te TileEntity to notify, should implement INetworkClientTileEntityEventListener
|
||||
* @param event Arbitrary integer to represent the event, choosing the values is up to you
|
||||
*/
|
||||
public static void initiateClientTileEntityEvent(TileEntity te, int event) {
|
||||
try {
|
||||
if (NetworkManager_initiateClientTileEntityEvent == null) NetworkManager_initiateClientTileEntityEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientTileEntityEvent", TileEntity.class, Integer.TYPE);
|
||||
if (instance == null) instance = getInstance();
|
||||
|
||||
NetworkManager_initiateClientTileEntityEvent.invoke(instance, te, event);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately send an event for the specified Item to the clients in range.
|
||||
*
|
||||
* The item should implement INetworkItemEventListener to receive the event.
|
||||
*
|
||||
* This method doesn't do anything if executed on the server.
|
||||
*
|
||||
* @param itemStack ItemStack containing the item
|
||||
* @param event Arbitrary integer to represent the event, choosing the values is up to you
|
||||
*/
|
||||
public static void initiateClientItemEvent(ItemStack itemStack, int event) {
|
||||
try {
|
||||
if (NetworkManager_initiateClientItemEvent == null) NetworkManager_initiateClientItemEvent = Class.forName(getPackage() + ".core.network.NetworkManager").getMethod("initiateClientItemEvent", ItemStack.class, Integer.TYPE);
|
||||
if (instance == null) instance = getInstance();
|
||||
|
||||
NetworkManager_initiateClientItemEvent.invoke(instance, itemStack, event);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base IC2 package name, used internally.
|
||||
*
|
||||
* @return IC2 package name, if unable to be determined defaults to ic2
|
||||
*/
|
||||
private static String getPackage() {
|
||||
Package pkg = NetworkHelper.class.getPackage();
|
||||
|
||||
if (pkg != null) {
|
||||
String packageName = pkg.getName();
|
||||
|
||||
return packageName.substring(0, packageName.length() - ".api.network".length());
|
||||
}
|
||||
|
||||
return "ic2";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NetworkManager instance, used internally.
|
||||
*
|
||||
* @return NetworkManager instance
|
||||
*/
|
||||
private static Object getInstance() {
|
||||
try {
|
||||
return Class.forName(getPackage() + ".core.IC2").getDeclaredField("network").get(null);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Object instance;
|
||||
private static Method NetworkManager_updateTileEntityField;
|
||||
private static Method NetworkManager_initiateTileEntityEvent;
|
||||
private static Method NetworkManager_initiateItemEvent;
|
||||
private static Method NetworkManager_initiateClientTileEntityEvent;
|
||||
private static Method NetworkManager_initiateClientItemEvent;
|
||||
}
|
||||
|
34
src/main/java/ic2/api/reactor/IC2Reactor.java
Normal file
34
src/main/java/ic2/api/reactor/IC2Reactor.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package ic2.api.reactor;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class IC2Reactor {
|
||||
private static Field energyGeneratorNuclear;
|
||||
|
||||
public static int getEUOutput() {
|
||||
try {
|
||||
if (energyGeneratorNuclear == null) energyGeneratorNuclear = Class.forName(getPackage() + ".core.IC2").getDeclaredField("energyGeneratorNuclear");
|
||||
|
||||
return energyGeneratorNuclear.getInt(null);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base IC2 package name, used internally.
|
||||
*
|
||||
* @return IC2 package name, if unable to be determined defaults to ic2
|
||||
*/
|
||||
private static String getPackage() {
|
||||
Package pkg = IC2Reactor.class.getPackage();
|
||||
|
||||
if (pkg != null) {
|
||||
String packageName = pkg.getName();
|
||||
|
||||
return packageName.substring(0, packageName.length() - ".api.reactor".length());
|
||||
}
|
||||
|
||||
return "ic2";
|
||||
}
|
||||
}
|
138
src/main/java/ic2/api/reactor/IReactor.java
Normal file
138
src/main/java/ic2/api/reactor/IReactor.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
package ic2.api.reactor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Interface implemented by the tile entity of nuclear reactors.
|
||||
*/
|
||||
public interface IReactor {
|
||||
/**
|
||||
* Get the reactor's position in the world.
|
||||
*
|
||||
* @return Position of the reactor
|
||||
*/
|
||||
public ChunkCoordinates getPosition();
|
||||
|
||||
/**
|
||||
* Get the reactor's corresponding world.
|
||||
*
|
||||
* @return The reactor's world
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the reactor's heat.
|
||||
*
|
||||
* @return The reactor's heat
|
||||
*/
|
||||
public int getHeat();
|
||||
|
||||
/**
|
||||
* Set the reactor's heat.
|
||||
*
|
||||
* @param heat reactor heat
|
||||
*/
|
||||
public void setHeat(int heat);
|
||||
|
||||
/**
|
||||
* Increase the reactor's heat.
|
||||
*
|
||||
* Use negative values to decrease.
|
||||
*
|
||||
* @param amount amount of heat to add
|
||||
* @return The reactor's heat after adding the specified amount
|
||||
*/
|
||||
public int addHeat(int amount);
|
||||
|
||||
/**
|
||||
* Get the reactor's maximum heat before exploding.
|
||||
*
|
||||
* @return Maximum heat value
|
||||
*/
|
||||
public int getMaxHeat();
|
||||
|
||||
/**
|
||||
* Set the reactor's stored maxHeat variable.
|
||||
* Used by plating to increase the reactors MaxHeat capacity.
|
||||
* Needs to be called during each cycle process.
|
||||
*/
|
||||
public void setMaxHeat(int newMaxHeat);
|
||||
|
||||
/**
|
||||
* add Heat to a EmitHeat Buffer
|
||||
* for use in Reactor operation.. need to be use
|
||||
* for all Componetents with self-cooling
|
||||
* no more magic heat disappear
|
||||
*/
|
||||
|
||||
|
||||
public void addEmitHeat(int heat);
|
||||
|
||||
/**
|
||||
* Get's the reactor's HEM (Heat Effect Modifier)
|
||||
* Basic value is 1.0F.
|
||||
* Reducing the value causes a weakening/reduction of the heat-based sideeffects of reactors
|
||||
* (F.e. water evaporation, melting, damaging entitys, etc)
|
||||
*
|
||||
* @return HEM
|
||||
*/
|
||||
public float getHeatEffectModifier();
|
||||
|
||||
/**
|
||||
* Set's the reactor's HEM
|
||||
* Needs to be called during each cycle process.
|
||||
*/
|
||||
public void setHeatEffectModifier(float newHEM);
|
||||
|
||||
/**
|
||||
* Get the reactor's energy output.
|
||||
*
|
||||
* @return Energy output, not multiplied by the base EU/t value
|
||||
*/
|
||||
public float getReactorEnergyOutput();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
13
src/main/java/ic2/api/reactor/IReactorChamber.java
Normal file
13
src/main/java/ic2/api/reactor/IReactorChamber.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package ic2.api.reactor;
|
||||
|
||||
/**
|
||||
* Interface implemented by the reactor chamber tile entity.
|
||||
*/
|
||||
public interface IReactorChamber {
|
||||
/**
|
||||
* Get the chamber's reactor.
|
||||
*
|
||||
* @return The reactor
|
||||
*/
|
||||
public IReactor getReactor();
|
||||
}
|
99
src/main/java/ic2/api/reactor/IReactorComponent.java
Normal file
99
src/main/java/ic2/api/reactor/IReactorComponent.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
package ic2.api.reactor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Design custom Reactor components by implementing this Interface
|
||||
* Items implementing the interface will not be ejected from Reactors in their clean-up
|
||||
* and can/will be interacted with by other elements, f.e. Uranium Cells.
|
||||
*
|
||||
* All IC2 ReactorComponents implement and use this Interface
|
||||
*
|
||||
*/
|
||||
public interface IReactorComponent
|
||||
{
|
||||
/**
|
||||
* Called by reactor upon iterating through it's inventory (every cycle).
|
||||
* Perform all necessary calculation/interaction here
|
||||
*
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @param x X-coordinate of the stack in the grid
|
||||
* @param y Y-coordinate of the stack in the grid
|
||||
* @param heatrun every Stack will cycle 2 time (true,false) first run for heat, sec for Eu calculation
|
||||
*/
|
||||
public void processChamber(IReactor reactor, ItemStack yourStack, int x, int y,boolean heatrun);
|
||||
|
||||
/**
|
||||
* Can be called by Uranium-Components who attempt to generate energy by pulsing to other components.
|
||||
* Uranium-Uranium interaction (f.e.) uses this method.
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of called ItemStack
|
||||
* @param pulsingStack Reference to the specific instance of pulsing ItemStack
|
||||
* @param youX X-coordinate of your stack in the grid
|
||||
* @param youY Y-coordinate of your stack in the grid
|
||||
* @param pulseX X-coordinate of pulsing stack in the grid
|
||||
* @param pulseY Y-coordinate of pulsing stack in the grid
|
||||
* @param heatrun true for only create heat not EU, false for only EU not heat
|
||||
* @return true if this component reacts to the pulse (and pulse is therefore meant to produce heat)
|
||||
*/
|
||||
public boolean acceptUraniumPulse(IReactor reactor, ItemStack yourStack, ItemStack pulsingStack, int youX, int youY, int pulseX, int pulseY,boolean heatrun);
|
||||
|
||||
/**
|
||||
* Called by components to determine whether your component can be heated.
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @param x X-coordinate of the stack in the grid
|
||||
* @param y Y-coordinate of the stack in the grid
|
||||
* @return true if your component can take heat
|
||||
*/
|
||||
public boolean canStoreHeat(IReactor reactor, ItemStack yourStack, int x, int y);
|
||||
|
||||
/**
|
||||
* Called by heat-switches to determine how much heat to distribute into which direction.
|
||||
* Please return the maximum capacity of your heat-containing component here.
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @param x X-coordinate of the stack in the grid
|
||||
* @param y Y-coordinate of the stack in the grid
|
||||
* @return Maximum heat
|
||||
*/
|
||||
public int getMaxHeat(IReactor reactor, ItemStack yourStack, int x, int y);
|
||||
|
||||
/**
|
||||
* Called by heat-switches to determine how much heat to distribute into which direction.
|
||||
* Please return the current amount of heat stored in this component
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @param x X-coordinate of the stack in the grid
|
||||
* @param y Y-coordinate of the stack in the grid
|
||||
* @return Current Heat
|
||||
*/
|
||||
public int getCurrentHeat(IReactor reactor, ItemStack yourStack, int x, int y);
|
||||
|
||||
/**
|
||||
* Called by components to distribute heat to your component.
|
||||
* Perform heating-calculations and increase your heat (dmg) level accordingly.
|
||||
* This method will as well be called to REDUCE heat, by providing a negative amount.
|
||||
*
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @param x X-coordinate of the stack in the grid
|
||||
* @param y Y-coordinate of the stack in the grid
|
||||
* @param heat Amount of heat to be added (may be negative to subtract heat)
|
||||
* @return 0 if the 'order' was accepted, return >0 to indicate the 'remaining' heat which couldn't be absorbed (and vice versa for <0)
|
||||
*/
|
||||
public int alterHeat(IReactor reactor, ItemStack yourStack, int x, int y, int heat);
|
||||
|
||||
/**
|
||||
* Called upon reactor explosion
|
||||
* Alter the explosion size.
|
||||
* Returning a float 0 < f < 1 will be counted as multiplier.
|
||||
* Anything else will be counted as a flat addition (in case of <0 = reduction).
|
||||
*
|
||||
* @param reactor Reference to the Reactor
|
||||
* @param yourStack Reference to the specific instance of iterated ItemStack
|
||||
* @return your explosion modifier
|
||||
*/
|
||||
public float influenceExplosion(IReactor reactor, ItemStack yourStack);
|
||||
}
|
51
src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java
Normal file
51
src/main/java/ic2/api/recipe/ICannerBottleRecipeManager.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ICannerBottleRecipeManager {
|
||||
/**
|
||||
* Adds a recipe to the machine.
|
||||
*
|
||||
* @param container Container to be filled
|
||||
* @param fill Item to fill into the container
|
||||
* @param output Filled container
|
||||
*/
|
||||
public void addRecipe(IRecipeInput container, IRecipeInput fill, ItemStack output);
|
||||
|
||||
/**
|
||||
* Gets the recipe output for the given input.
|
||||
*
|
||||
* @param container Container to be filled
|
||||
* @param fill Item to fill into the container
|
||||
* @param adjustInput modify the input according to the recipe's requirements
|
||||
* @param acceptTest allow either container or fill to be null to see if either of them is part of a recipe
|
||||
* @return Recipe output, or null if none
|
||||
*/
|
||||
public RecipeOutput getOutputFor(ItemStack container, ItemStack fill, boolean adjustInput, boolean acceptTest);
|
||||
|
||||
/**
|
||||
* Gets a list of recipes.
|
||||
*
|
||||
* You're a mad evil scientist if you ever modify this.
|
||||
*
|
||||
* @return List of recipes
|
||||
*/
|
||||
public Map<Input, RecipeOutput> getRecipes();
|
||||
|
||||
|
||||
public static class Input {
|
||||
public Input(IRecipeInput container1, IRecipeInput fill1) {
|
||||
this.container = container1;
|
||||
this.fill = fill1;
|
||||
}
|
||||
|
||||
public boolean matches(ItemStack container1, ItemStack fill1) {
|
||||
return this.container.matches(container1) && this.fill.matches(fill1);
|
||||
}
|
||||
|
||||
public final IRecipeInput container;
|
||||
public final IRecipeInput fill;
|
||||
}
|
||||
}
|
54
src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java
Normal file
54
src/main/java/ic2/api/recipe/ICannerEnrichRecipeManager.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface ICannerEnrichRecipeManager {
|
||||
/**
|
||||
* Adds a recipe to the machine.
|
||||
*
|
||||
* @param input Fluid input
|
||||
* @param additive Item to enrich the fluid with
|
||||
* @param output Output fluid
|
||||
*/
|
||||
public void addRecipe(FluidStack input, IRecipeInput additive, FluidStack output);
|
||||
|
||||
/**
|
||||
* Gets the recipe output for the given input.
|
||||
*
|
||||
* @param input Fluid input
|
||||
* @param additive Item to enrich the fluid with
|
||||
* @param adjustInput modify the input according to the recipe's requirements
|
||||
* @param acceptTest allow input or additive to be null to see if either of them is part of a recipe
|
||||
* @return Recipe output, or null if none, output fluid in nbt
|
||||
*/
|
||||
public RecipeOutput getOutputFor(FluidStack input, ItemStack additive, boolean adjustInput, boolean acceptTest);
|
||||
|
||||
/**
|
||||
* Gets a list of recipes.
|
||||
*
|
||||
* You're a mad evil scientist if you ever modify this.
|
||||
*
|
||||
* @return List of recipes
|
||||
*/
|
||||
public Map<Input, FluidStack> getRecipes();
|
||||
|
||||
|
||||
public static class Input {
|
||||
public Input(FluidStack fluid1, IRecipeInput additive1) {
|
||||
this.fluid = fluid1;
|
||||
this.additive = additive1;
|
||||
}
|
||||
|
||||
public boolean matches(FluidStack fluid1, ItemStack additive1) {
|
||||
return (this.fluid == null || this.fluid.isFluidEqual(fluid1)) &&
|
||||
this.additive.matches(additive1);
|
||||
}
|
||||
|
||||
public final FluidStack fluid;
|
||||
public final IRecipeInput additive;
|
||||
}
|
||||
}
|
26
src/main/java/ic2/api/recipe/ICraftingRecipeManager.java
Normal file
26
src/main/java/ic2/api/recipe/ICraftingRecipeManager.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Recipe manager interface for crafting recipes.
|
||||
*
|
||||
* @author Richard
|
||||
*/
|
||||
public interface ICraftingRecipeManager {
|
||||
/**
|
||||
* Adds a shaped crafting recipe.
|
||||
*
|
||||
* @param output Recipe output
|
||||
* @param input Recipe input format
|
||||
*/
|
||||
public void addRecipe(ItemStack output, Object... input);
|
||||
|
||||
/**
|
||||
* Adds a shapeless crafting recipe.
|
||||
*
|
||||
* @param output Recipe output
|
||||
* @param input Recipe input
|
||||
*/
|
||||
public void addShapelessRecipe(ItemStack output, Object... input);
|
||||
}
|
10
src/main/java/ic2/api/recipe/ILiquidAcceptManager.java
Normal file
10
src/main/java/ic2/api/recipe/ILiquidAcceptManager.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public interface ILiquidAcceptManager {
|
||||
boolean acceptsFluid(Fluid fluid);
|
||||
Set<Fluid> getAcceptedFluids();
|
||||
}
|
41
src/main/java/ic2/api/recipe/IListRecipeManager.java
Normal file
41
src/main/java/ic2/api/recipe/IListRecipeManager.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Recipe manager interface for basic lists.
|
||||
*
|
||||
* @author Richard
|
||||
*/
|
||||
public interface IListRecipeManager extends Iterable<IRecipeInput> {
|
||||
/**
|
||||
* Adds a stack to the list.
|
||||
*
|
||||
* @param stack Stack to add
|
||||
*/
|
||||
public void add(IRecipeInput input);
|
||||
|
||||
/**
|
||||
* Checks whether the specified stack is in the list.
|
||||
*
|
||||
* @param stack Stack to check
|
||||
* @return Whether the stack is in the list
|
||||
*/
|
||||
public boolean contains(ItemStack stack);
|
||||
|
||||
/**
|
||||
* @return if the List is Empty
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Gets the list of stacks.
|
||||
*
|
||||
* You're a mad evil scientist if you ever modify this.
|
||||
*
|
||||
* @return List of stacks
|
||||
*/
|
||||
public List<IRecipeInput> getInputs();
|
||||
}
|
44
src/main/java/ic2/api/recipe/IMachineRecipeManager.java
Normal file
44
src/main/java/ic2/api/recipe/IMachineRecipeManager.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Recipe manager interface for basic machines.
|
||||
*
|
||||
* @author RichardG, Player
|
||||
*/
|
||||
public interface IMachineRecipeManager {
|
||||
/**
|
||||
* Adds a recipe to the machine.
|
||||
*
|
||||
* @param input Recipe input
|
||||
* @param metadata meta data for additional recipe properties, may be null
|
||||
* @param outputs Recipe outputs, zero or more depending on the machine
|
||||
*
|
||||
* For the thermal centrifuge @param metadata meta data {"minHeat": 1-xxx}
|
||||
* For the ore washing plant @param metadata meta data {"amount": 1-8000}
|
||||
*
|
||||
*/
|
||||
public void addRecipe(IRecipeInput input, NBTTagCompound metadata, ItemStack... outputs);
|
||||
|
||||
/**
|
||||
* Gets the recipe output for the given input.
|
||||
*
|
||||
* @param input Recipe input
|
||||
* @param adjustInput modify the input according to the recipe's requirements
|
||||
* @return Recipe output, or null if none
|
||||
*/
|
||||
public RecipeOutput getOutputFor(ItemStack input, boolean adjustInput);
|
||||
|
||||
/**
|
||||
* Gets a list of recipes.
|
||||
*
|
||||
* You're a mad evil scientist if you ever modify this.
|
||||
*
|
||||
* @return List of recipes
|
||||
*/
|
||||
public Map<IRecipeInput, RecipeOutput> getRecipes();
|
||||
}
|
11
src/main/java/ic2/api/recipe/IPatternStorage.java
Normal file
11
src/main/java/ic2/api/recipe/IPatternStorage.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IPatternStorage {
|
||||
boolean addPattern(ItemStack itemstack);
|
||||
|
||||
List<ItemStack> getPatterns();
|
||||
}
|
31
src/main/java/ic2/api/recipe/IRecipeInput.java
Normal file
31
src/main/java/ic2/api/recipe/IRecipeInput.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IRecipeInput {
|
||||
/**
|
||||
* Check if subject matches this recipe input, ignoring the amount.
|
||||
*
|
||||
* @param subject ItemStack to check
|
||||
* @return true if it matches the requirement
|
||||
*/
|
||||
boolean matches(ItemStack subject);
|
||||
|
||||
/**
|
||||
* Determine the minimum input stack size.
|
||||
*
|
||||
* @return input amount required
|
||||
*/
|
||||
int getAmount();
|
||||
|
||||
/**
|
||||
* List all possible inputs (best effort).
|
||||
*
|
||||
* The stack size is undefined, use getAmount to get the correct one.
|
||||
*
|
||||
* @return list of inputs, may be incomplete
|
||||
*/
|
||||
List<ItemStack> getInputs();
|
||||
}
|
13
src/main/java/ic2/api/recipe/IScrapboxManager.java
Normal file
13
src/main/java/ic2/api/recipe/IScrapboxManager.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IScrapboxManager {
|
||||
void addDrop(ItemStack drop, float rawChance);
|
||||
|
||||
ItemStack getDrop(ItemStack input, boolean adjustInput);
|
||||
|
||||
Map<ItemStack, Float> getDrops();
|
||||
}
|
32
src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java
Normal file
32
src/main/java/ic2/api/recipe/ISemiFluidFuelManager.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
|
||||
public interface ISemiFluidFuelManager extends ILiquidAcceptManager {
|
||||
/**
|
||||
* Add a new fluid to the semi fluid generator.
|
||||
*
|
||||
* @param fluidName the fluid to burn
|
||||
* @param amount amount of fluid to consume per tick
|
||||
* @param power amount of energy generated per tick
|
||||
*/
|
||||
void addFluid(String fluidName, int amount, double power);
|
||||
|
||||
BurnProperty getBurnProperty(Fluid fluid);
|
||||
|
||||
Map<String, BurnProperty> getBurnProperties();
|
||||
|
||||
|
||||
public static class BurnProperty {
|
||||
public BurnProperty(int amount1, double power1) {
|
||||
this.amount = amount1;
|
||||
this.power = power1;
|
||||
}
|
||||
|
||||
public final int amount;
|
||||
public final double power;
|
||||
}
|
||||
}
|
54
src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java
Normal file
54
src/main/java/ic2/api/recipe/RecipeInputFluidContainer.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class RecipeInputFluidContainer implements IRecipeInput {
|
||||
public RecipeInputFluidContainer(Fluid fluid) {
|
||||
this(fluid, FluidContainerRegistry.BUCKET_VOLUME);
|
||||
}
|
||||
|
||||
public RecipeInputFluidContainer(Fluid fluid, int amount) {
|
||||
this.fluid = fluid;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack subject) {
|
||||
FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);
|
||||
if (fs == null) return false;
|
||||
|
||||
return fs.getFluid() == fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
|
||||
if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RInputFluidContainer<"+amount+"x"+fluid.getName()+">";
|
||||
}
|
||||
|
||||
public final Fluid fluid;
|
||||
public final int amount;
|
||||
}
|
46
src/main/java/ic2/api/recipe/RecipeInputItemStack.java
Normal file
46
src/main/java/ic2/api/recipe/RecipeInputItemStack.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipeInputItemStack implements IRecipeInput {
|
||||
public RecipeInputItemStack(ItemStack aInput) {
|
||||
this(aInput, aInput.stackSize);
|
||||
}
|
||||
|
||||
public RecipeInputItemStack(ItemStack aInput, int aAmount) {
|
||||
if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied");
|
||||
|
||||
input = aInput.copy(); // Never forget to copy.
|
||||
amount = aAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack subject) {
|
||||
return subject.getItem() == input.getItem() && (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
return Arrays.asList(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ItemStack stack = input.copy();
|
||||
input.stackSize = amount;
|
||||
return "RInputItemStack<"+stack+">";
|
||||
}
|
||||
|
||||
public final ItemStack input;
|
||||
public final int amount;
|
||||
}
|
71
src/main/java/ic2/api/recipe/RecipeInputOreDict.java
Normal file
71
src/main/java/ic2/api/recipe/RecipeInputOreDict.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipeInputOreDict implements IRecipeInput {
|
||||
public RecipeInputOreDict(String input1) {
|
||||
this(input1, 1);
|
||||
}
|
||||
|
||||
public RecipeInputOreDict(String input1, int amount1) {
|
||||
this(input1, amount1, null);
|
||||
}
|
||||
|
||||
public RecipeInputOreDict(String input1, int amount1, Integer meta) {
|
||||
this.input = input1;
|
||||
this.amount = amount1;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack subject) {
|
||||
List<ItemStack> inputs = OreDictionary.getOres(input);
|
||||
|
||||
for (ItemStack input1 : inputs) {
|
||||
if (input1.getItem() == null) continue; // ignore invalid
|
||||
int metaRequired = meta == null ? input1.getItemDamage() : meta;
|
||||
|
||||
if (subject.getItem() == input1.getItem() &&
|
||||
(subject.getItemDamage() == metaRequired || metaRequired == OreDictionary.WILDCARD_VALUE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getInputs() {
|
||||
List<ItemStack> ores = OreDictionary.getOres(input);
|
||||
List<ItemStack> ret = new ArrayList<ItemStack>(ores.size());
|
||||
|
||||
for (ItemStack stack : ores) {
|
||||
if (stack.getItem() != null) ret.add(stack); // ignore invalid
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (meta == null) {
|
||||
return "RInputOreDict<"+amount+"x"+input+">";
|
||||
} else {
|
||||
return "RInputOreDict<"+amount+"x"+input+"@"+meta+">";
|
||||
}
|
||||
}
|
||||
|
||||
public final String input;
|
||||
public final int amount;
|
||||
public final Integer meta;
|
||||
}
|
21
src/main/java/ic2/api/recipe/RecipeOutput.java
Normal file
21
src/main/java/ic2/api/recipe/RecipeOutput.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public final class RecipeOutput {
|
||||
public RecipeOutput(NBTTagCompound metadata1, List<ItemStack> items1) {
|
||||
this.metadata = metadata1;
|
||||
this.items = items1;
|
||||
}
|
||||
|
||||
public RecipeOutput(NBTTagCompound metadata1, ItemStack... items1) {
|
||||
this(metadata1, Arrays.asList(items1));
|
||||
}
|
||||
|
||||
public final List<ItemStack> items;
|
||||
public final NBTTagCompound metadata;
|
||||
}
|
59
src/main/java/ic2/api/recipe/Recipes.java
Normal file
59
src/main/java/ic2/api/recipe/Recipes.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* General recipe registry.
|
||||
*
|
||||
* @author Richard
|
||||
*/
|
||||
public class Recipes {
|
||||
public static IMachineRecipeManager macerator;
|
||||
public static IMachineRecipeManager extractor;
|
||||
public static IMachineRecipeManager compressor;
|
||||
public static IMachineRecipeManager centrifuge;
|
||||
public static IMachineRecipeManager recycler;
|
||||
public static IMachineRecipeManager metalformerExtruding;
|
||||
public static IMachineRecipeManager metalformerCutting;
|
||||
public static IMachineRecipeManager metalformerRolling;
|
||||
public static IMachineRecipeManager oreWashing;
|
||||
public static ICannerBottleRecipeManager cannerBottle;
|
||||
public static ICannerEnrichRecipeManager cannerEnrich;
|
||||
|
||||
/**
|
||||
* Reference amplifier values:
|
||||
*
|
||||
* 5000: Scrap
|
||||
* 45000: Scrapbox
|
||||
*
|
||||
* As Parameter for the Amplification Value you have to use the NBTTagCompound
|
||||
*
|
||||
* NBTTagCompound nbt = new NBTTagCompound();
|
||||
* nbt.setInteger("amplification", aValue);
|
||||
* matterAmplifier.addRecipe(yourStack, nbt);
|
||||
*/
|
||||
public static IMachineRecipeManager matterAmplifier;
|
||||
/**
|
||||
* Reference scrap box chance values:
|
||||
*
|
||||
* 0.1: Diamond
|
||||
* 0.5: Cake, Gold Helmet, Iron Ore, Gold Ore
|
||||
* 1.0: Wooden tools, Soul Sand, Sign, Leather, Feather, Bone
|
||||
* 1.5: Apple, Bread
|
||||
* 2.0: Netherrack, Rotten Flesh
|
||||
* 3.0: Grass, Gravel
|
||||
* 4.0: Stick
|
||||
* 5.0: Dirt, Wooden Hoe
|
||||
*/
|
||||
public static IScrapboxManager scrapboxDrops;
|
||||
public static IListRecipeManager recyclerBlacklist;
|
||||
/**
|
||||
* Do not add anything to this Whitelist. This is for Configuration only.
|
||||
* You may need this if you have an own Recycler in your Mod, just to check if something can be recycled. but don't add anything to this List
|
||||
*/
|
||||
public static IListRecipeManager recyclerWhitelist;
|
||||
public static ICraftingRecipeManager advRecipes;
|
||||
|
||||
public static ISemiFluidFuelManager semiFluidGenerator;
|
||||
|
||||
}
|
47
src/main/java/ic2/api/tile/ExplosionWhitelist.java
Normal file
47
src/main/java/ic2/api/tile/ExplosionWhitelist.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package ic2.api.tile;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Blocks on this whitelist will not resist an explosion but won't be destroyed.
|
||||
*
|
||||
* The explosion code by default ignores blocks which absorb more than 1000 explosion power to
|
||||
* prevent abusing personal safes, Trade-O-Mats and other blocks to serve as a cheap and
|
||||
* invulnerable reactor chambers. Said blocks will not shield the explosion and won't get
|
||||
* destroyed.
|
||||
*/
|
||||
public final class ExplosionWhitelist {
|
||||
/**
|
||||
* Add a block to the whitelist.
|
||||
*
|
||||
* @param block block to add
|
||||
*/
|
||||
public static void addWhitelistedBlock(Block block) {
|
||||
whitelist.add(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a block from the whitelist.
|
||||
*
|
||||
* @param block block to remove
|
||||
*/
|
||||
public static void removeWhitelistedBlock(Block block) {
|
||||
whitelist.remove(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a block is on the whitelist.
|
||||
*
|
||||
* @param block block to check if whitelisted
|
||||
* @return Whether the block is whitelisted
|
||||
*/
|
||||
public static boolean isBlockWhitelisted(Block block) {
|
||||
return whitelist.contains(block);
|
||||
}
|
||||
|
||||
private static Set<Block> whitelist = new HashSet<Block>();
|
||||
}
|
||||
|
61
src/main/java/ic2/api/tile/IEnergyStorage.java
Normal file
61
src/main/java/ic2/api/tile/IEnergyStorage.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package ic2.api.tile;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Interface implemented by the tile entity of energy storage blocks.
|
||||
*/
|
||||
public interface IEnergyStorage {
|
||||
/**
|
||||
* Get the amount of energy currently stored in the block.
|
||||
*
|
||||
* @return Energy stored in the block
|
||||
*/
|
||||
public int getStored();
|
||||
|
||||
/**
|
||||
* Set the amount of energy currently stored in the block.
|
||||
*
|
||||
* @param energy stored energy
|
||||
*/
|
||||
public void setStored(int energy);
|
||||
|
||||
/**
|
||||
* Add the specified amount of energy.
|
||||
*
|
||||
* Use negative values to decrease.
|
||||
*
|
||||
* @param amount of energy to add
|
||||
* @return Energy stored in the block after adding the specified amount
|
||||
*/
|
||||
public int addEnergy(int amount);
|
||||
|
||||
/**
|
||||
* Get the maximum amount of energy the block can store.
|
||||
*
|
||||
* @return Maximum energy stored
|
||||
*/
|
||||
public int getCapacity();
|
||||
|
||||
/**
|
||||
* Get the block's energy output.
|
||||
*
|
||||
* @return Energy output in EU/t
|
||||
*/
|
||||
public int getOutput();
|
||||
|
||||
/**
|
||||
* Get the block's energy output.
|
||||
*
|
||||
* @return Energy output in EU/t
|
||||
*/
|
||||
public double getOutputEnergyUnitsPerTick();
|
||||
|
||||
/**
|
||||
* Get whether this block can have its energy used by an adjacent teleporter.
|
||||
*
|
||||
* @param side side the teleporter is draining energy from
|
||||
* @return Whether the block is teleporter compatible
|
||||
*/
|
||||
public boolean isTeleporterCompatible(ForgeDirection side);
|
||||
}
|
61
src/main/java/ic2/api/tile/IWrenchable.java
Normal file
61
src/main/java/ic2/api/tile/IWrenchable.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package ic2.api.tile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Allows a tile entity to make use of the wrench's removal and rotation functions.
|
||||
*/
|
||||
public interface IWrenchable {
|
||||
/**
|
||||
* Determine if the wrench can be used to set the block's facing.
|
||||
* Called before wrenchCanRemove().
|
||||
*
|
||||
* @param entityPlayer player using the wrench, may be null
|
||||
* @param side block's side the wrench was clicked on
|
||||
* @return Whether the wrenching was done and the wrench should be damaged
|
||||
*/
|
||||
boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side);
|
||||
|
||||
/**
|
||||
* Get the block's facing.
|
||||
*
|
||||
* @return Block facing
|
||||
*/
|
||||
short getFacing();
|
||||
|
||||
/**
|
||||
* Set the block's facing
|
||||
*
|
||||
* @param facing facing to set the block to
|
||||
*/
|
||||
void setFacing(short facing);
|
||||
|
||||
/**
|
||||
* Determine if the wrench can be used to remove the block.
|
||||
* Called if wrenchSetFacing fails.
|
||||
*
|
||||
* @param entityPlayer player using the wrench, may be null
|
||||
* @return Whether the wrenching was done and the wrench should be damaged
|
||||
*/
|
||||
boolean wrenchCanRemove(EntityPlayer entityPlayer);
|
||||
|
||||
/**
|
||||
* Determine the probability to drop the block as it is.
|
||||
* The first entry in getDrops will be replaced by blockid:meta if the drop is successful.
|
||||
*
|
||||
* @return Probability from 0 to 1
|
||||
*/
|
||||
float getWrenchDropRate();
|
||||
|
||||
/**
|
||||
* Determine the item the block will drop when the wrenching is successful.
|
||||
*
|
||||
* The ItemStack will be copied before creating the EntityItem.
|
||||
*
|
||||
* @param entityPlayer player using the wrench, may be null
|
||||
* @return ItemStack to drop, may be null
|
||||
*/
|
||||
ItemStack getWrenchDrop(EntityPlayer entityPlayer);
|
||||
}
|
||||
|
14
src/main/java/ic2/api/util/IKeyboard.java
Normal file
14
src/main/java/ic2/api/util/IKeyboard.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ic2.api.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IKeyboard {
|
||||
boolean isAltKeyDown(EntityPlayer player);
|
||||
boolean isBoostKeyDown(EntityPlayer player);
|
||||
boolean isForwardKeyDown(EntityPlayer player);
|
||||
boolean isJumpKeyDown(EntityPlayer player);
|
||||
boolean isModeSwitchKeyDown(EntityPlayer player);
|
||||
boolean isSideinventoryKeyDown(EntityPlayer player);
|
||||
boolean isHudModeKeyDown(EntityPlayer player);
|
||||
boolean isSneakKeyDown(EntityPlayer player);
|
||||
}
|
6
src/main/java/ic2/api/util/Keys.java
Normal file
6
src/main/java/ic2/api/util/Keys.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package ic2.api.util;
|
||||
|
||||
|
||||
public class Keys {
|
||||
public static IKeyboard instance;
|
||||
}
|
|
@ -3,6 +3,7 @@ package mekanism.api;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
@ -68,16 +69,6 @@ public class Coord4D
|
|||
return world.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block ID of the block representing this Coord4D.
|
||||
* @param world - world this Coord4D is in
|
||||
* @return the block ID of this Coord4D's block
|
||||
*/
|
||||
public int getBlockId(IBlockAccess world)
|
||||
{
|
||||
return world.getBlockId(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the TileEntity of the block representing this Coord4D.
|
||||
* @param world - world this Coord4D is in
|
||||
|
@ -90,7 +81,7 @@ public class Coord4D
|
|||
return null;
|
||||
}
|
||||
|
||||
return world.getBlockTileEntity(xCoord, yCoord, zCoord);
|
||||
return world.getTileEntity(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +96,7 @@ public class Coord4D
|
|||
return null;
|
||||
}
|
||||
|
||||
return Block.blocksList[getBlockId(world)];
|
||||
return world.getBlock(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +164,7 @@ public class Coord4D
|
|||
*/
|
||||
public static Coord4D get(TileEntity tileEntity)
|
||||
{
|
||||
return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId);
|
||||
return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.getWorldObj().provider.dimensionId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
package mekanism.api;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemInfo
|
||||
{
|
||||
public int id;
|
||||
public Item item;
|
||||
public int meta;
|
||||
|
||||
public ItemInfo(int i, int j)
|
||||
public ItemInfo(Item i, int j)
|
||||
{
|
||||
id = i;
|
||||
item = i;
|
||||
meta = j;
|
||||
}
|
||||
|
||||
public static ItemInfo get(ItemStack stack)
|
||||
{
|
||||
return new ItemInfo(stack.itemID, stack.getItemDamage());
|
||||
return new ItemInfo(stack.getItem(), stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof ItemInfo &&
|
||||
((ItemInfo)obj).id == id &&
|
||||
((ItemInfo)obj).item == item &&
|
||||
((ItemInfo)obj).meta == meta;
|
||||
}
|
||||
|
||||
|
@ -30,7 +31,7 @@ public class ItemInfo
|
|||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + id;
|
||||
code = 31 * code + item.getUnlocalizedName().hashCode();
|
||||
code = 31 * code + meta;
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package mekanism.api;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraftforge.event.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class MekanismAPI
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package mekanism.api.gas;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
@ -19,7 +19,7 @@ public class Gas
|
|||
|
||||
private Fluid fluid;
|
||||
|
||||
private Icon icon;
|
||||
private IIcon icon;
|
||||
|
||||
private boolean visible = true;
|
||||
|
||||
|
@ -106,10 +106,10 @@ public class Gas
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the Icon associated with this Gas.
|
||||
* @return associated Icon
|
||||
* Gets the IIcon associated with this Gas.
|
||||
* @return associated IIcon
|
||||
*/
|
||||
public Icon getIcon()
|
||||
public IIcon getIcon()
|
||||
{
|
||||
if(from_fluid)
|
||||
{
|
||||
|
@ -120,10 +120,10 @@ public class Gas
|
|||
|
||||
/**
|
||||
* Sets this gas's icon.
|
||||
* @param i - Icon to associate with this Gas
|
||||
* @param i - IIcon to associate with this Gas
|
||||
* @return this Gas object
|
||||
*/
|
||||
public Gas setIcon(Icon i)
|
||||
public Gas setIcon(IIcon i)
|
||||
{
|
||||
icon = i;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import mekanism.api.transmitters.TransmissionType;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
/**
|
||||
|
|
|
@ -190,7 +190,7 @@ public class GasTank
|
|||
{
|
||||
if(stored != null)
|
||||
{
|
||||
nbtTags.setCompoundTag("stored", stored.write(new NBTTagCompound()));
|
||||
nbtTags.setTag("stored", stored.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
nbtTags.setInteger("maxGas", maxGas);
|
||||
|
|
|
@ -25,7 +25,7 @@ public final class GasTransmission
|
|||
|
||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tube = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
|
||||
TileEntity tube = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, tileEntity))
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public final class GasTransmission
|
|||
|
||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
|
||||
TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
||||
|
||||
if(acceptor instanceof IGasHandler)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ public final class GasTransmission
|
|||
|
||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
|
||||
TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
||||
|
||||
if(canConnect(connection, orientation))
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ public final class GasTransmission
|
|||
*/
|
||||
public static int emitGasToNetwork(GasStack stack, TileEntity sender, ForgeDirection facing)
|
||||
{
|
||||
TileEntity pointer = Coord4D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
|
||||
TileEntity pointer = Coord4D.get(sender).getFromSide(facing).getTileEntity(sender.getWorldObj());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender))
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implements ITransmitterNetwork<A, N>, IClientTicker
|
||||
|
@ -75,7 +75,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
if(aTransmitter instanceof TileEntity)
|
||||
{
|
||||
if(!((TileEntity)aTransmitter).worldObj.isRemote)
|
||||
if(!((TileEntity)aTransmitter).getWorldObj().isRemote)
|
||||
{
|
||||
TransmitterNetworkRegistry.getInstance().registerNetwork(this);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
for(Coord4D node : partNetwork)
|
||||
{
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj);
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).getWorldObj());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity)transmitter))
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity sideTile = Coord4D.get((TileEntity)splitPoint).getFromSide(side).getTileEntity(((TileEntity)splitPoint).worldObj);
|
||||
TileEntity sideTile = Coord4D.get((TileEntity)splitPoint).getFromSide(side).getTileEntity(((TileEntity)splitPoint).getWorldObj());
|
||||
|
||||
if(sideTile != null)
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
if(TransmissionType.checkTransmissionType(connectedBlockA, getTransmissionType()) && !dealtWith[count])
|
||||
{
|
||||
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Coord4D.get(connectedBlockA), Coord4D.get((TileEntity)splitPoint));
|
||||
NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).getWorldObj(), getTransmissionType(), Coord4D.get(connectedBlockA), Coord4D.get((TileEntity)splitPoint));
|
||||
List<Coord4D> partNetwork = finder.exploreNetwork();
|
||||
|
||||
for(int check = count; check < connectedBlocks.length; check++)
|
||||
|
@ -271,7 +271,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
|||
|
||||
for(Coord4D node : finder.iterated)
|
||||
{
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj);
|
||||
TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).getWorldObj());
|
||||
|
||||
if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType()))
|
||||
{
|
||||
|
|
|
@ -11,11 +11,12 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
|
@ -123,7 +124,7 @@ public class TransmitterNetworkRegistry implements ITickHandler
|
|||
|
||||
public static class NetworkLoader
|
||||
{
|
||||
@ForgeSubscribe
|
||||
@SubscribeEvent
|
||||
public void onChunkLoad(ChunkEvent.Load event)
|
||||
{
|
||||
if(event.getChunk() != null && !event.world.isRemote)
|
||||
|
|
|
@ -131,7 +131,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
|
@ -228,7 +228,7 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z)
|
||||
{
|
||||
TileEntityElectricChest tileEntity = (TileEntityElectricChest)entityplayer.worldObj.getBlockTileEntity(x, y, z);
|
||||
TileEntityElectricChest tileEntity = (TileEntityElectricChest)entityplayer.getWorldObj().getTileEntity(x, y, z);
|
||||
|
||||
if(id == 0)
|
||||
{
|
||||
|
@ -361,7 +361,7 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
|
||||
switch(ID)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ThreadTankSparkle extends Thread
|
|||
try {
|
||||
if(Mekanism.dynamicTankEasterEgg)
|
||||
{
|
||||
MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(8)+1) + ".ogg", pointer.worldObj, Coord4D.get(pointer));
|
||||
MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(8)+1) + ".ogg", pointer.getWorldObj(), Coord4D.get(pointer));
|
||||
}
|
||||
|
||||
loop(pointer);
|
||||
|
@ -42,7 +42,7 @@ public class ThreadTankSparkle extends Thread
|
|||
|
||||
public void loop(TileEntityDynamicTank tileEntity)
|
||||
{
|
||||
World world = pointer.worldObj;
|
||||
World world = pointer.getWorldObj();
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ public class ThreadTankSparkle extends Thread
|
|||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.worldObj);
|
||||
TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.getWorldObj());
|
||||
|
||||
if(tile instanceof TileEntityDynamicTank && !iteratedNodes.contains(tile))
|
||||
{
|
||||
|
|
|
@ -64,8 +64,8 @@ public class GuiAdvancedElectricMachine extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), (xSize/2)-(fontRenderer.getStringWidth(tileEntity.getInvName())/2), 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInvName())/2), 6, 0x404040);
|
||||
fontRendererObj.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
if(xAxis >= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49)
|
||||
{
|
||||
|
|
|
@ -57,8 +57,8 @@ public class GuiChanceMachine extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -92,15 +92,15 @@ public class GuiChemicalCrystallizer extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 37, 4, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 37, 4, 0x404040);
|
||||
|
||||
if(tileEntity.inputTank.getGas() != null)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.inputTank.getGas().getGas().getLocalizedName(), 29, 15, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.inputTank.getGas().getGas().getLocalizedName(), 29, 15, 0x00CD00);
|
||||
|
||||
if(tileEntity.inputTank.getGas().getGas() instanceof OreGas)
|
||||
{
|
||||
fontRenderer.drawString("(" + ((OreGas)tileEntity.inputTank.getGas().getGas()).getOreName() + ")", 29, 24, 0x00CD00);
|
||||
fontRendererObj.drawString("(" + ((OreGas)tileEntity.inputTank.getGas().getGas()).getOreName() + ")", 29, 24, 0x00CD00);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class GuiChemicalCrystallizer extends GuiMekanism
|
|||
try {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), renderStack, 131, 14);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 131, 14);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
} catch(Exception e) {}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class GuiChemicalDissolutionChamber extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040);
|
||||
|
||||
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
|
||||
{
|
||||
|
|
|
@ -99,8 +99,8 @@ public class GuiChemicalInfuser extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public class GuiChemicalOxidizer extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class GuiChemicalWasher extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 4, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 4, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -156,12 +156,12 @@ public class GuiConfiguration extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.configuration"), 60, 5, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getEjector().isEjecting() ? "On" : "Off"), 53, 17, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.configuration"), 60, 5, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getEjector().isEjecting() ? "On" : "Off"), 53, 17, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.input") + " (" + (configurable.getEjector().hasStrictInput() ? "On" : "Off") + ")", 18, 81, 0x787878);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.output"), 72, 68, 0x787878);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.slots"), 122, 81, 0x787878);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.input") + " (" + (configurable.getEjector().hasStrictInput() ? "On" : "Off") + ")", 18, 81, 0x787878);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.output"), 72, 68, 0x787878);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.slots"), 122, 81, 0x787878);
|
||||
|
||||
if(configurable.getEjector().getOutputColor() != null)
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ public class GuiConfiguration extends GuiMekanism
|
|||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
itemRenderer.renderIcon(80, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), 16, 16);
|
||||
itemRender.renderIcon(80, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), 16, 16);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
|
@ -234,7 +234,7 @@ public class GuiConfiguration extends GuiMekanism
|
|||
|
||||
TileEntity tile = (TileEntity)configurable;
|
||||
|
||||
if(tile == null || mc.theWorld.getBlockTileEntity(tile.xCoord, tile.yCoord, tile.zCoord) == null)
|
||||
if(tile == null || mc.theWorld.getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord) == null)
|
||||
{
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public class GuiConfiguration extends GuiMekanism
|
|||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType().blockID, tile.getBlockMetadata()).guiId;
|
||||
int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId;
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketSimpleGui().setParams(Coord4D.get(tile), guiId));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class GuiCredits extends GuiScreen
|
|||
|
||||
public void writeText(String text, int yAxis)
|
||||
{
|
||||
drawString(fontRenderer, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0);
|
||||
drawString(fontRendererObj, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +67,7 @@ public class GuiCredits extends GuiScreen
|
|||
public void drawScreen(int mouseX, int mouseY, float partialTick)
|
||||
{
|
||||
drawDefaultBackground();
|
||||
drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff);
|
||||
drawCenteredString(fontRendererObj, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff);
|
||||
|
||||
if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null"))
|
||||
{
|
||||
|
|
|
@ -34,8 +34,8 @@ public class GuiDictionary extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
if(itemType != null)
|
||||
{
|
||||
|
@ -45,12 +45,12 @@ public class GuiDictionary extends GuiMekanism
|
|||
|
||||
for(String name : oreDictNames)
|
||||
{
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + name, 9, currentY, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + name, 9, currentY, 0x00CD00);
|
||||
currentY += 9;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class GuiDictionary extends GuiMekanism
|
|||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), itemType, 80, 23);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemType, 80, 23);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import mekanism.common.util.MekanismUtils.ResourceType;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -159,24 +160,24 @@ public class GuiDigitalMiner extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 69, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 69, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
fontRenderer.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.idle"), 9, 10, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.idle"), 9, 10, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + MekanismUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.pull") + ": " + MekanismUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.silk") + ": " + MekanismUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.eject") + ": " + MekanismUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.digitalMiner.pull") + ": " + MekanismUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.digitalMiner.silk") + ": " + MekanismUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00);
|
||||
fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00);
|
||||
fontRendererObj.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00);
|
||||
|
||||
if(tileEntity.replaceStack != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), tileEntity.replaceStack, 144, 27);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), tileEntity.replaceStack, 144, 27);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
@ -341,7 +342,7 @@ public class GuiDigitalMiner extends GuiMekanism
|
|||
{
|
||||
if(stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if(stack.itemID != Block.bedrock.blockID)
|
||||
if(Block.getBlockFromItem(stack.getItem()) == Blocks.bedrock)
|
||||
{
|
||||
toUse = stack.copy();
|
||||
toUse.stackSize = 1;
|
||||
|
|
|
@ -266,15 +266,15 @@ public class GuiDigitalMinerConfig extends GuiMekanism
|
|||
String prevMin = minField != null ? minField.getText() : "";
|
||||
String prevMax = maxField != null ? maxField.getText() : "";
|
||||
|
||||
radiusField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 67, 26, 11);
|
||||
radiusField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 67, 26, 11);
|
||||
radiusField.setMaxStringLength(2);
|
||||
radiusField.setText(prevRad);
|
||||
|
||||
minField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 92, 26, 11);
|
||||
minField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 92, 26, 11);
|
||||
minField.setMaxStringLength(3);
|
||||
minField.setText(prevMin);
|
||||
|
||||
maxField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 117, 26, 11);
|
||||
maxField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 117, 26, 11);
|
||||
maxField.setMaxStringLength(3);
|
||||
maxField.setText(prevMax);
|
||||
}
|
||||
|
@ -296,19 +296,19 @@ public class GuiDigitalMinerConfig extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.digitalMinerConfig"), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.digitalMinerConfig"), 43, 6, 0x404040);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00);
|
||||
fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 28, 0x00CD00);
|
||||
fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 37, 0x00CD00);
|
||||
fontRenderer.drawString("M: " + getMaterialFilters().size(), 11, 46, 0x00CD00);
|
||||
fontRenderer.drawString("I: " + (tileEntity.inverse ? MekanismUtils.localize("gui.on") : MekanismUtils.localize("gui.off")), 11, 131, 0x00CD00);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00);
|
||||
fontRendererObj.drawString("IS: " + getItemStackFilters().size(), 11, 28, 0x00CD00);
|
||||
fontRendererObj.drawString("OD: " + getOreDictFilters().size(), 11, 37, 0x00CD00);
|
||||
fontRendererObj.drawString("M: " + getMaterialFilters().size(), 11, 46, 0x00CD00);
|
||||
fontRendererObj.drawString("I: " + (tileEntity.inverse ? MekanismUtils.localize("gui.on") : MekanismUtils.localize("gui.off")), 11, 131, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString("Radi: " + tileEntity.radius, 11, 58, 0x00CD00);
|
||||
fontRendererObj.drawString("Radi: " + tileEntity.radius, 11, 58, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString("Min: " + tileEntity.minY, 11, 83, 0x00CD00);
|
||||
fontRendererObj.drawString("Min: " + tileEntity.minY, 11, 83, 0x00CD00);
|
||||
|
||||
fontRenderer.drawString("Max: " + tileEntity.maxY, 11, 108, 0x00CD00);
|
||||
fontRendererObj.drawString("Max: " + tileEntity.maxY, 11, 108, 0x00CD00);
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -325,12 +325,12 @@ public class GuiDigitalMinerConfig extends GuiMekanism
|
|||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040);
|
||||
}
|
||||
else if(filter instanceof MOreDictFilter)
|
||||
{
|
||||
|
@ -346,13 +346,13 @@ public class GuiDigitalMinerConfig extends GuiMekanism
|
|||
try {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), oreDictStacks.get(filter).renderStack, 59, yStart + 3);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), oreDictStacks.get(filter).renderStack, 59, yStart + 3);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040);
|
||||
}
|
||||
else if(filter instanceof MMaterialFilter)
|
||||
{
|
||||
|
@ -362,12 +362,12 @@ public class GuiDigitalMinerConfig extends GuiMekanism
|
|||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), itemFilter.materialItem, 59, yStart + 3);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.materialItem, 59, yStart + 3);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00);
|
||||
|
||||
if(tileEntity.structure.fluidStored != null)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
|
||||
}
|
||||
|
||||
if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72)
|
||||
|
|
|
@ -96,9 +96,9 @@ public class GuiElectricChest extends GuiMekanism
|
|||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
fontRenderer.drawString(MekanismUtils.localize("tile.MachineBlock.ElectricChest.name"), 8, 6, 0x404040);
|
||||
fontRenderer.drawString(getLocked() ? EnumColor.DARK_RED + "Locked" : EnumColor.BRIGHT_GREEN + "Unlocked", 97, 137, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("tile.MachineBlock.ElectricChest.name"), 8, 6, 0x404040);
|
||||
fontRendererObj.drawString(getLocked() ? EnumColor.DARK_RED + "Locked" : EnumColor.BRIGHT_GREEN + "Unlocked", 97, 137, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
if(xAxis >= 180 && xAxis <= 184 && yAxis >= 32 && yAxis <= 84)
|
||||
{
|
||||
|
|
|
@ -60,8 +60,8 @@ public class GuiElectricMachine extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ public class GuiElectricPump extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : MekanismUtils.localize("gui.noFluid"), 51, 35, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
|
||||
fontRendererObj.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : MekanismUtils.localize("gui.noFluid"), 51, 35, 0x00CD00);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -117,13 +117,13 @@ public class GuiElectrolyticSeparator extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
||||
|
||||
String name = tileEntity.dumpLeft ? "Dumping..." : tileEntity.leftTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.leftTank.getGas().getGas().getLocalizedName();
|
||||
fontRenderer.drawString(name, 21, 73, 0x404040);
|
||||
fontRendererObj.drawString(name, 21, 73, 0x404040);
|
||||
|
||||
name = tileEntity.dumpRight ? "Dumping..." : tileEntity.rightTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.rightTank.getGas().getGas().getLocalizedName();
|
||||
fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040);
|
||||
fontRendererObj.drawString(name, 156-fontRendererObj.getStringWidth(name), 73, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ public class GuiEnergyCube extends GuiMekanism
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString(tileEntity.getInvName(), 43, 6, 0x404040);
|
||||
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
fontRendererObj.drawString(tileEntity.getInvName(), 43, 6, 0x404040);
|
||||
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import mekanism.client.render.MekanismRenderer;
|
|||
import mekanism.common.util.MekanismUtils;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiEnergyGauge extends GuiGauge
|
||||
|
@ -26,7 +26,7 @@ public class GuiEnergyGauge extends GuiGauge
|
|||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon()
|
||||
public IIcon getIcon()
|
||||
{
|
||||
return MekanismRenderer.energyIcon;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue