Some stuff

Api derpage apparently...
Some new drills, and chainsaws. Started working on omnitools, but I got
distracted.
I NEED TEXTURES :(
This commit is contained in:
Tombenpotter committed 2014-09-29 21:24:50 +02:00
1 parent f927d596d5
commit 104ecb66bb
196 files changed
+8231 -8092

No files matched your search

+42 -42
View File
@@ -1,59 +1,59 @@
package ic2.api.item;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
/**
* Allows for charging, discharging and using electric items (IElectricItem).
*/
public final class ElectricItem {
/**
* IElectricItemManager to use for interacting with IElectricItem ItemStacks.
*
* This manager will act as a gateway and delegate the tasks to the final implementation
* (rawManager or a custom one) as necessary.
*/
public static IElectricItemManager manager;
/**
* IElectricItemManager to use for interacting with IElectricItem ItemStacks.
* <p/>
* This manager will act as a gateway and delegate the tasks to the final implementation
* (rawManager or a custom one) as necessary.
*/
public static IElectricItemManager manager;
/**
* Standard IElectricItemManager implementation, only call it directly from another
* IElectricItemManager. Use manager instead.
*/
public static IElectricItemManager rawManager;
/**
* Standard IElectricItemManager implementation, only call it directly from another
* IElectricItemManager. Use manager instead.
*/
public static IElectricItemManager rawManager;
/**
* Register an electric item manager for items not implementing IElectricItem.
*
* This method is only designed for special purposes, implementing IElectricItem or
* ISpecialElectricItem instead of using this is faster.
*
* Managers used with ISpecialElectricItem shouldn't be registered.
*
* @param manager Manager to register.
*/
public static void registerBackupManager(IBackupElectricItemManager manager) {
backupManagers.add(manager);
}
/**
* Register an electric item manager for items not implementing IElectricItem.
* <p/>
* This method is only designed for special purposes, implementing IElectricItem or
* ISpecialElectricItem instead of using this is faster.
* <p/>
* Managers used with ISpecialElectricItem shouldn't be registered.
*
* @param manager Manager to register.
*/
public static void registerBackupManager(IBackupElectricItemManager manager) {
backupManagers.add(manager);
}
/**
* Get the electric item manager suitable for the supplied item stack.
*
* This method is for internal use only.
*
* @param stack ItemStack to be handled.
* @return First suitable electric item manager.
*/
public static IBackupElectricItemManager getBackupManager(ItemStack stack) {
for (IBackupElectricItemManager manager : backupManagers) {
if (manager.handles(stack)) return manager;
}
/**
* Get the electric item manager suitable for the supplied item stack.
* <p/>
* This method is for internal use only.
*
* @param stack ItemStack to be handled.
* @return First suitable electric item manager.
*/
public static IBackupElectricItemManager getBackupManager(ItemStack stack) {
for (IBackupElectricItemManager manager : backupManagers) {
if (manager.handles(stack)) return manager;
}
return null;
}
return null;
}
private static final List<IBackupElectricItemManager> backupManagers = new ArrayList<IBackupElectricItemManager>();
private static final List<IBackupElectricItemManager> backupManagers = new ArrayList<IBackupElectricItemManager>();
}
@@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack;
/**
* This interface specifies a manager applicable to items not implementing IElectricItem.
*
* <p/>
* The manager implementing this has to be registered with ElectricItem.registerBackupManager().
*/
public interface IBackupElectricItemManager extends IElectricItemManager {
boolean handles(ItemStack stack);
boolean handles(ItemStack stack);
}
@@ -2,5 +2,5 @@ package ic2.api.item;
public interface IBlockCuttingBlade {
int gethardness();
int gethardness();
}
+7 -7
View File
@@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack;
public interface IBoxable {
/**
* Determine whether an item can be stored in a toolbox or not.
*
* @param itemstack item to be stored
* @return Whether to store the item in the toolbox or not
*/
public abstract boolean canBeStoredInToolbox(ItemStack itemstack);
/**
* Determine whether an item can be stored in a toolbox or not.
*
* @param itemstack item to be stored
* @return Whether to store the item in the toolbox or not
*/
public abstract boolean canBeStoredInToolbox(ItemStack itemstack);
}
+39 -39
View File
@@ -4,40 +4,40 @@ import net.minecraft.item.ItemStack;
/**
* Provides access to IC2 blocks and items.
*
* <p/>
* 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.
*
* <p/>
* Getting the associated Block/Item for an ItemStack x:
* Blocks: Block.blocksList[x.itemID]
* Items: x.getItem()
* Blocks: Block.blocksList[x.itemID]
* Items: x.getItem()
*/
public final class IC2Items {
/**
* Get an ItemStack for a specific item name, example: Items.getItem("resin")
* See the list below for item names.
* Make sure to copy() the ItemStack if you want to modify it.
*
* @param name item name
* @return The item or null if the item does not exist or an error occurred
*/
public static ItemStack getItem(String name) {
try {
if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items");
/**
* Get an ItemStack for a specific item name, example: Items.getItem("resin")
* See the list below for item names.
* Make sure to copy() the ItemStack if you want to modify it.
*
* @param name item name
* @return The item or null if the item does not exist or an error occurred
*/
public static ItemStack getItem(String name) {
try {
if (Ic2Items == null) Ic2Items = Class.forName(getPackage() + ".core.Ic2Items");
Object ret = Ic2Items.getField(name).get(null);
Object ret = Ic2Items.getField(name).get(null);
if (ret instanceof ItemStack) {
return (ItemStack) ret;
}
return null;
} catch (Exception e) {
System.out.println("IC2 API: Call getItem failed for "+name);
if (ret instanceof ItemStack) {
return (ItemStack) ret;
}
return null;
} catch (Exception e) {
System.out.println("IC2 API: Call getItem failed for " + name);
return null;
}
}
return null;
}
}
/* Possible values:
@@ -576,23 +576,23 @@ public final class IC2Items {
*/
/**
* Get the base IC2 package name, used internally.
*
* @return IC2 package name, if unable to be determined defaults to ic2
*/
private static String getPackage() {
Package pkg = IC2Items.class.getPackage();
/**
* Get the base IC2 package name, used internally.
*
* @return IC2 package name, if unable to be determined defaults to ic2
*/
private static String getPackage() {
Package pkg = IC2Items.class.getPackage();
if (pkg != null) {
String packageName = pkg.getName();
if (pkg != null) {
String packageName = pkg.getName();
return packageName.substring(0, packageName.length() - ".api.item".length());
}
return packageName.substring(0, packageName.length() - ".api.item".length());
}
return "ic2";
}
return "ic2";
}
private static Class<?> Ic2Items;
private static Class<?> Ic2Items;
}
+38 -38
View File
@@ -5,51 +5,51 @@ import net.minecraft.item.ItemStack;
/**
* Provides the ability to store energy on the implementing item.
*
* <p/>
* The item should have a maximum damage of 13.
*/
public interface IElectricItem {
/**
* Determine if the item can be used in a machine or as an armor part to supply energy.
*
* @return Whether the item can supply energy
*/
boolean canProvideEnergy(ItemStack itemStack);
/**
* Determine if the item can be used in a machine or as an armor part to supply energy.
*
* @return Whether the item can supply energy
*/
boolean canProvideEnergy(ItemStack itemStack);
/**
* Get the item ID to use for a charge energy greater than 0.
*
* @return Item ID to use
*/
Item getChargedItem(ItemStack itemStack);
/**
* Get the item ID to use for a charge energy greater than 0.
*
* @return Item ID to use
*/
Item getChargedItem(ItemStack itemStack);
/**
* Get the item ID to use for a charge energy of 0.
*
* @return Item ID to use
*/
Item getEmptyItem(ItemStack itemStack);
/**
* Get the item ID to use for a charge energy of 0.
*
* @return Item ID to use
*/
Item getEmptyItem(ItemStack itemStack);
/**
* Get the item's maximum charge energy in EU.
*
* @return Maximum charge energy
*/
double getMaxCharge(ItemStack itemStack);
/**
* Get the item's maximum charge energy in EU.
*
* @return Maximum charge energy
*/
double getMaxCharge(ItemStack itemStack);
/**
* Get the item's tier, lower tiers can't send energy to higher ones.
* Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3.
*
* @return Item's tier
*/
int getTier(ItemStack itemStack);
/**
* Get the item's tier, lower tiers can't send energy to higher ones.
* Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3.
*
* @return Item's tier
*/
int getTier(ItemStack itemStack);
/**
* Get the item's transfer limit in EU per transfer operation.
*
* @return Transfer limit
*/
double getTransferLimit(ItemStack itemStack);
/**
* Get the item's transfer limit in EU per transfer operation.
*
* @return Transfer limit
*/
double getTransferLimit(ItemStack itemStack);
}
@@ -5,91 +5,91 @@ import net.minecraft.item.ItemStack;
/**
* This interface specifies a manager to handle the various tasks for electric items.
*
* <p/>
* The default implementation does the following:
* - store and retrieve the charge
* - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account
* - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId())
* - update and manage the damage value for the visual charge indicator
*
*
* @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the
* default implementations through ElectricItem.rawManager. The default implementation is designed
* to minimize its dependency on its own constraints/structure and delegates most work back to the
* more atomic features in the gateway manager.
*/
public interface IElectricItemManager {
/**
* Charge an item with a specified amount of energy.
*
* @param itemStack electric item's stack
* @param amount amount of energy to charge in EU
* @param tier tier of the charging device, has to be at least as high as the item to charge
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
* @param simulate don't actually change the item, just determine the return value
* @return Energy transferred into the electric item
*/
double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate);
/**
* Charge an item with a specified amount of energy.
*
* @param itemStack electric item's stack
* @param amount amount of energy to charge in EU
* @param tier tier of the charging device, has to be at least as high as the item to charge
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
* @param simulate don't actually change the item, just determine the return value
* @return Energy transferred into the electric item
*/
double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate);
/**
* Discharge an item by a specified amount of energy
*
* @param itemStack electric item's stack
* @param amount amount of energy to discharge in EU
* @param tier tier of the discharging device, has to be at least as high as the item to discharge
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
* @param externally use the supplied item externally, i.e. to power something else as if it was a battery
* @param simulate don't actually discharge the item, just determine the return value
* @return Energy retrieved from the electric item
*/
double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate);
/**
* Discharge an item by a specified amount of energy
*
* @param itemStack electric item's stack
* @param amount amount of energy to discharge in EU
* @param tier tier of the discharging device, has to be at least as high as the item to discharge
* @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit()
* @param externally use the supplied item externally, i.e. to power something else as if it was a battery
* @param simulate don't actually discharge the item, just determine the return value
* @return Energy retrieved from the electric item
*/
double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate);
/**
* Determine the charge level for the specified item.
*
* @param itemStack ItemStack containing the electric item
* @return charge level in EU
*/
double getCharge(ItemStack stack);
/**
* Determine the charge level for the specified item.
*
* @param itemStack ItemStack containing the electric item
* @return charge level in EU
*/
double getCharge(ItemStack stack);
/**
* Determine if the specified electric item has at least a specific amount of EU.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
* BatPacks are not taken into account.
*
* @param itemStack electric item's stack
* @param amount minimum amount of energy required
* @return true if there's enough energy
*/
boolean canUse(ItemStack stack, double amount);
/**
* Determine if the specified electric item has at least a specific amount of EU.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
* BatPacks are not taken into account.
*
* @param itemStack electric item's stack
* @param amount minimum amount of energy required
* @return true if there's enough energy
*/
boolean canUse(ItemStack stack, double amount);
/**
* Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
*
* @param itemStack electric item's stack
* @param amount amount of energy to discharge in EU
* @param entity entity holding the item
* @return true if the operation succeeded
*/
boolean use(ItemStack stack, double amount, EntityLivingBase entity);
/**
* Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
*
* @param itemStack electric item's stack
* @param amount amount of energy to discharge in EU
* @param entity entity holding the item
* @return true if the operation succeeded
*/
boolean use(ItemStack stack, double amount, EntityLivingBase entity);
/**
* Charge an item from the BatPack a player is wearing.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
* use() already contains this functionality.
*
* @param itemStack electric item's stack
* @param entity entity holding the item
*/
void chargeFromArmor(ItemStack stack, EntityLivingBase entity);
/**
* Charge an item from the BatPack a player is wearing.
* This is supposed to be used in the item code during operation, for example if you want to implement your own electric item.
* use() already contains this functionality.
*
* @param itemStack electric item's stack
* @param entity entity holding the item
*/
void chargeFromArmor(ItemStack stack, EntityLivingBase entity);
/**
* Get the tool tip to display for electric items.
*
* @param itemStack ItemStack to determine the tooltip for
* @return tool tip string or null for none
*/
String getToolTip(ItemStack stack);
/**
* Get the tool tip to display for electric items.
*
* @param itemStack ItemStack to determine the tooltip for
* @return tool tip string or null for none
*/
String getToolTip(ItemStack stack);
// TODO: add tier getter
// TODO: add tier getter
}
+4 -4
View File
@@ -1,11 +1,11 @@
package ic2.api.item;
import java.util.List;
import net.minecraft.item.ItemStack;
import java.util.List;
public interface IItemHudInfo {
/*
/*
Add Info to Nano- and Quantum-Suit Helm Hud
for itemStack
@@ -20,5 +20,5 @@ public interface IItemHudInfo {
*/
public List<String> getHudInfo(ItemStack itemStack);
public List<String> getHudInfo(ItemStack itemStack);
}
@@ -3,13 +3,13 @@ package ic2.api.item;
import net.minecraft.util.ResourceLocation;
public interface IKineticWindRotor {
public int getDiameter();
public int getDiameter();
public ResourceLocation getRotorRenderTexture();
public ResourceLocation getRotorRenderTexture();
public float getefficiency();
public float getefficiency();
int getminWindStrength();
int getminWindStrength();
int getmaxWindStrength();
int getmaxWindStrength();
}
+9 -9
View File
@@ -5,16 +5,16 @@ import net.minecraft.item.ItemStack;
/**
* Armor items implementing this can be considered metal armor.
*
* <p/>
* Currently used for determining which boots can be used to slide up a magnetic pole.
*/
public interface IMetalArmor {
/**
* Determine if the given armor piece is metal armor.
*
* @param itemstack Armor piece as worn by the player
* @param player The player
* @return Whether the armor piece is metal armor
*/
public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player);
/**
* Determine if the given armor piece is metal armor.
*
* @param itemstack Armor piece as worn by the player
* @param player The player
* @return Whether the armor piece is metal armor
*/
public boolean isMetalArmor(ItemStack itemstack, EntityPlayer player);
}
@@ -3,11 +3,11 @@ package ic2.api.item;
import net.minecraft.item.ItemStack;
public interface ISpecialElectricItem extends IElectricItem {
/**
* Supply a custom IElectricItemManager.
*
* @param itemStack ItemStack to get the manager for
* @return IElectricItemManager instance
*/
IElectricItemManager getManager(ItemStack itemStack);
/**
* Supply a custom IElectricItemManager.
*
* @param itemStack ItemStack to get the manager for
* @return IElectricItemManager instance
*/
IElectricItemManager getManager(ItemStack itemStack);
}
+25 -25
View File
@@ -6,29 +6,29 @@ import net.minecraft.world.World;
* Allows an item to act as a terraformer blueprint.
*/
public interface ITerraformingBP {
/**
* Get the energy consumption per operation of the blueprint.
*
* @return Energy consumption in EU
*/
public abstract int getConsume();
/**
* Get the maximum range of the blueprint.
* Should be a divisor of 5.
*
* @return Maximum range in blocks
*/
public abstract int getRange();
/**
* Perform the terraforming operation.
*
* @param world world to terraform
* @param x X position to terraform
* @param z Z position to terraform
* @param yCoord Y position of the terraformer
* @return Whether the operation was successful and the terraformer should consume energy.
*/
public abstract boolean terraform(World world, int x, int z, int yCoord);
/**
* Get the energy consumption per operation of the blueprint.
*
* @return Energy consumption in EU
*/
public abstract int getConsume();
/**
* Get the maximum range of the blueprint.
* Should be a divisor of 5.
*
* @return Maximum range in blocks
*/
public abstract int getRange();
/**
* Perform the terraforming operation.
*
* @param world world to terraform
* @param x X position to terraform
* @param z Z position to terraform
* @param yCoord Y position of the terraformer
* @return Whether the operation was successful and the terraformer should consume energy.
*/
public abstract boolean terraform(World world, int x, int z, int yCoord);
}
+37 -38
View File
@@ -1,50 +1,49 @@
package ic2.api.item;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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;
}
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;
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
@API(apiVersion="1.0", owner="IC2", provides="IC2API")
package ic2.api.item;
@API(apiVersion = "1.0", owner = "IC2", provides = "IC2API") package ic2.api.item;
import cpw.mods.fml.common.API;