Updated newly returned items
This commit is contained in:
parent
8d49b992c1
commit
55bfa23705
2 changed files with 82 additions and 112 deletions
|
@ -1,7 +1,5 @@
|
|||
package cr0s.warpdrive.item;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -9,8 +7,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IAirCanister;
|
||||
import cr0s.warpdrive.api.IBreathingHelmet;
|
||||
|
@ -18,29 +14,28 @@ import cr0s.warpdrive.api.IBreathingHelmet;
|
|||
public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
|
||||
// private static Random ran = new Random();
|
||||
private int slot;
|
||||
|
||||
|
||||
IIcon ic;
|
||||
|
||||
public ItemWarpArmor(int slot) {
|
||||
super(WarpDrive.armorMaterial, 0, slot);
|
||||
|
||||
public ItemWarpArmor(ArmorMaterial mat, int slot) {
|
||||
super(mat, 0, slot);
|
||||
this.slot = slot;
|
||||
setUnlocalizedName("warpdrive.armor.Helmet");
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack is, Entity en, int parSlot, String type) {
|
||||
return "warpdrive:textures/armor/warpArmor_1.png";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
if (slot == 0) {
|
||||
ic = ir.registerIcon("warpdrive:warpArmorHelmet");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return ic;
|
||||
|
@ -57,16 +52,18 @@ public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
|
|||
if (player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP pl = (EntityPlayerMP) player;
|
||||
ItemStack[] plInv = pl.inventory.mainInventory;
|
||||
for(int i = 0; i < plInv.length; i++) {
|
||||
for (int i = 0; i < plInv.length; i++) {
|
||||
ItemStack is = plInv[i];
|
||||
if (is != null && is.getItem() instanceof IAirCanister) {
|
||||
IAirCanister airCanister = (IAirCanister)is.getItem();
|
||||
IAirCanister airCanister = (IAirCanister) is.getItem();
|
||||
if (airCanister.containsAir(is)) {
|
||||
if (is.stackSize > 1) {// unstack
|
||||
is.stackSize--;
|
||||
ItemStack toAdd = is.copy();
|
||||
toAdd.stackSize = 1;
|
||||
toAdd.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment
|
||||
toAdd.setItemDamage(is.getItemDamage() + 1); // bypass
|
||||
// unbreaking
|
||||
// enchantment
|
||||
if (is.getItemDamage() >= is.getMaxDamage()) {
|
||||
toAdd = airCanister.emptyDrop(is);
|
||||
}
|
||||
|
@ -75,7 +72,9 @@ public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
|
|||
pl.worldObj.spawnEntityInWorld(ie);
|
||||
}
|
||||
} else {
|
||||
is.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment
|
||||
is.setItemDamage(is.getItemDamage() + 1); // bypass
|
||||
// unbreaking
|
||||
// enchantment
|
||||
if (is.getItemDamage() >= is.getMaxDamage()) {
|
||||
plInv[i] = airCanister.emptyDrop(is);
|
||||
}
|
||||
|
@ -87,11 +86,9 @@ public class ItemWarpArmor extends ItemArmor implements IBreathingHelmet {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int ticksPerCanDamage()
|
||||
{
|
||||
public int ticksPerCanDamage() {
|
||||
return 40;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,135 +1,108 @@
|
|||
package cr0s.WarpDrive.item;
|
||||
package cr0s.warpdrive.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cr0s.WarpDrive.WarpDrive;
|
||||
import cr0s.WarpDrive.data.EnumUpgradeTypes;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.data.EnumUpgradeTypes;
|
||||
|
||||
public class ItemWarpUpgrade extends Item
|
||||
{
|
||||
public class ItemWarpUpgrade extends Item {
|
||||
private ItemStack[] isCache = new ItemStack[EnumUpgradeTypes.values().length];
|
||||
private Icon[] iconBuffer = new Icon[EnumUpgradeTypes.values().length];
|
||||
|
||||
public ItemWarpUpgrade(int par1)
|
||||
{
|
||||
super(par1);
|
||||
private IIcon[] iconBuffer = new IIcon[EnumUpgradeTypes.values().length];
|
||||
|
||||
public ItemWarpUpgrade() {
|
||||
setHasSubtypes(true);
|
||||
setUnlocalizedName("warpdrive.upgrade.Malformed");
|
||||
setCreativeTab(WarpDrive.warpdriveTab);
|
||||
}
|
||||
|
||||
private boolean isValidDamage(int damage)
|
||||
{
|
||||
|
||||
private boolean isValidDamage(int damage) {
|
||||
return damage >= 0 && damage < EnumUpgradeTypes.values().length;
|
||||
}
|
||||
|
||||
public ItemStack getIS(int damage)
|
||||
{
|
||||
if(!isValidDamage(damage))
|
||||
|
||||
public ItemStack getIS(int damage) {
|
||||
if (!isValidDamage(damage))
|
||||
return null;
|
||||
|
||||
if(isCache[damage] == null)
|
||||
|
||||
if (isCache[damage] == null)
|
||||
isCache[damage] = getISNoCache(damage);
|
||||
return isCache[damage];
|
||||
}
|
||||
|
||||
public ItemStack getISNoCache(int damage)
|
||||
{
|
||||
if(!isValidDamage(damage))
|
||||
|
||||
public ItemStack getISNoCache(int damage) {
|
||||
if (!isValidDamage(damage))
|
||||
return null;
|
||||
|
||||
return new ItemStack(WarpDrive.upgradeItem,1,damage);
|
||||
|
||||
return new ItemStack(WarpDrive.upgradeItem, 1, damage);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
if(is == null)
|
||||
return null;
|
||||
|
||||
public String getUnlocalizedName(ItemStack is) {
|
||||
if (is == null)
|
||||
return null;
|
||||
|
||||
int damage = is.getItemDamage();
|
||||
if(isValidDamage(damage))
|
||||
if (isValidDamage(damage))
|
||||
return "item.warpdrive.upgrade." + EnumUpgradeTypes.values()[damage].toString();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for(int i=0;i<EnumUpgradeTypes.values().length;i++)
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (int i = 0; i < EnumUpgradeTypes.values().length; i++)
|
||||
par3List.add(getIS(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer pl, List list, boolean par4)
|
||||
{
|
||||
if(is == null)
|
||||
public void addInformation(ItemStack is, EntityPlayer pl, List list, boolean par4) {
|
||||
if (is == null)
|
||||
return;
|
||||
|
||||
|
||||
int damage = is.getItemDamage();
|
||||
if(damage == EnumUpgradeTypes.Energy.ordinal())
|
||||
if (damage == EnumUpgradeTypes.Energy.ordinal())
|
||||
list.add("Increases the max energy of the machine");
|
||||
else if(damage == EnumUpgradeTypes.Power.ordinal())
|
||||
list.add( "Decreases the power usage of the machine");
|
||||
else if(damage == EnumUpgradeTypes.Speed.ordinal())
|
||||
list.add( "Increases the speed of the machine");
|
||||
else if(damage == EnumUpgradeTypes.Range.ordinal())
|
||||
list.add( "Increases the range of the machine");
|
||||
else if (damage == EnumUpgradeTypes.Power.ordinal())
|
||||
list.add("Decreases the power usage of the machine");
|
||||
else if (damage == EnumUpgradeTypes.Speed.ordinal())
|
||||
list.add("Increases the speed of the machine");
|
||||
else if (damage == EnumUpgradeTypes.Range.ordinal())
|
||||
list.add("Increases the range of the machine");
|
||||
}
|
||||
|
||||
public void initRecipes()
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Energy.ordinal()),false,"c","e","r",
|
||||
'c', WarpDrive.componentItem.getIS(0),
|
||||
'e', WarpDrive.componentItem.getIS(7),
|
||||
'r', Item.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Power.ordinal()),false,"c","e","r",
|
||||
'c', WarpDrive.componentItem.getIS(0),
|
||||
'e', WarpDrive.componentItem.getIS(6),
|
||||
'r', Item.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Speed.ordinal()),false,"c","e","r",
|
||||
'c', WarpDrive.componentItem.getIS(0),
|
||||
'e', Item.sugar,
|
||||
'r', Item.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Range.ordinal()),false,"c","e","r",
|
||||
'c', WarpDrive.componentItem.getIS(0),
|
||||
'e', WarpDrive.transportBeaconBlock,
|
||||
'r', Item.redstone));
|
||||
|
||||
|
||||
|
||||
public void initRecipes() {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Energy.ordinal()), false, "c", "e", "r", 'c', WarpDrive.componentItem.getIS(0), 'e',
|
||||
WarpDrive.componentItem.getIS(7), 'r', Items.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Power.ordinal()), false, "c", "e", "r", 'c', WarpDrive.componentItem.getIS(0), 'e',
|
||||
WarpDrive.componentItem.getIS(6), 'r', Items.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Speed.ordinal()), false, "c", "e", "r", 'c', WarpDrive.componentItem.getIS(0), 'e',
|
||||
Items.sugar, 'r', Items.redstone));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(getIS(EnumUpgradeTypes.Range.ordinal()), false, "c", "e", "r", 'c', WarpDrive.componentItem.getIS(0), 'e',
|
||||
WarpDrive.transportBeaconBlock, 'r', Items.redstone));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister ir)
|
||||
{
|
||||
for(EnumUpgradeTypes val : EnumUpgradeTypes.values())
|
||||
{
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
for (EnumUpgradeTypes val : EnumUpgradeTypes.values()) {
|
||||
iconBuffer[val.ordinal()] = ir.registerIcon("warpdrive:upgrade" + val.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int damage)
|
||||
{
|
||||
if(damage >= 0 && damage < EnumUpgradeTypes.values().length)
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
if (damage >= 0 && damage < EnumUpgradeTypes.values().length)
|
||||
return iconBuffer[damage];
|
||||
return iconBuffer[0];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue