-
Notifications
You must be signed in to change notification settings - Fork 270
/
SigilAir.java
144 lines (124 loc) · 4.45 KB
/
SigilAir.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package WayofTime.alchemicalWizardry.common.items.sigil;
import java.util.List;
import WayofTime.alchemicalWizardry.api.items.interfaces.ISigil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SigilAir extends EnergyItems implements ArmourUpgrade, ISigil
{
public SigilAir()
{
super();
this.maxStackSize = 1;
//setMaxDamage(1000);
setEnergyUsed(AlchemicalWizardry.sigilAirCost);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add(StatCollector.translateToLocal("tooltip.airsigil.desc"));
if (!(par1ItemStack.getTagCompound() == null))
{
par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + par1ItemStack.getTagCompound().getString("ownerName"));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AirSigil");
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.isSneaking())
{
return par1ItemStack;
}
if(par2World.isRemote && this.isItemUnusable(par1ItemStack))
{
return par1ItemStack;
}
Vec3 vec = par3EntityPlayer.getLookVec();
double wantedVelocity = 1.7;
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost))
{
int i = par3EntityPlayer.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier();
wantedVelocity += (1 + i) * (0.35);
}
par3EntityPlayer.motionX = vec.xCoord * wantedVelocity;
par3EntityPlayer.motionY = vec.yCoord * wantedVelocity;
par3EntityPlayer.motionZ = vec.zCoord * wantedVelocity;
par2World.playSoundEffect((double) ((float) par3EntityPlayer.posX + 0.5F), (double) ((float) par3EntityPlayer.posY + 0.5F), (double) ((float) par3EntityPlayer.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F);
par3EntityPlayer.fallDistance = 0;
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
if(!par2World.isRemote)
{
this.setIsItemUnusable(par1ItemStack, true);
}
}else
{
if(!par2World.isRemote)
{
this.setIsItemUnusable(par1ItemStack, false);
}
}
} else
{
return par1ItemStack;
}
return par1ItemStack;
}
public boolean isItemUnusable(ItemStack stack)
{
NBTTagCompound tag = stack.getTagCompound();
if(tag == null)
{
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
return tag.getBoolean("unusable");
}
public void setIsItemUnusable(ItemStack stack, boolean bool)
{
NBTTagCompound tag = stack.getTagCompound();
if(tag == null)
{
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
tag.setBoolean("unusable", bool);
}
@Override
public void onArmourUpdate(World world, EntityPlayer player,
ItemStack thisItemStack)
{
// TODO Auto-generated method stub
player.fallDistance = 0;
}
@Override
public boolean isUpgrade()
{
// TODO Auto-generated method stub
return true;
}
@Override
public int getEnergyForTenSeconds()
{
// TODO Auto-generated method stub
return 50;
}
}