Fixed air power

This commit is contained in:
GotoLink 2014-03-22 17:07:49 +01:00
commit 39bf9eb782
2 changed files with 53 additions and 64 deletions

View file

@ -1,6 +1,5 @@
package mysticworld.items;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import mysticworld.MysticWorld;
import mysticworld.entity.EntityChargeAir;
import net.minecraft.entity.Entity;
@ -21,18 +20,17 @@ public class ItemStaffAir extends ItemStaff {
@Override
public int getMaxItemUseDuration(ItemStack itemStack){
return 3*20;
return 5*20;
}
@Override
public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer player, int time) {
int charge = getMaxItemUseDuration(itemStack)-time;
if (charge > 0) {
if (!world.isRemote) {
world.playAuxSFXAtEntity(null, 1009, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
world.playAuxSFXAtEntity(player, 1009, (int) player.posX, (int) player.posY, (int) player.posZ, 0);
if (!world.isRemote)
world.spawnEntityInWorld(new EntityChargeAir(world, player, 1.0f + charge * (5.0f * (1 / (float) getMaxItemUseDuration(itemStack))), charge * (2.5D * (1.0D / getMaxItemUseDuration(itemStack)))));
itemStack.damageItem(1, player);
}
itemStack.damageItem(1, player);
}
}
@ -40,19 +38,18 @@ public class ItemStaffAir extends ItemStaff {
public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean current) {
if (current) {
entity.fallDistance = 0.0F;
if(entity instanceof EntityPlayer){
if(((EntityPlayer) entity).isUsingItem()){
int charge = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class,(EntityPlayer) entity, "itemInUseCount", "field_71072_f");
chargeEffect(itemStack, world, entity, getMaxItemUseDuration(itemStack) - charge);
}
}
}
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count){
chargeEffect(stack, player.worldObj, player, getMaxItemUseDuration(stack) - count);
}
private void chargeEffect(ItemStack itemStack, World world, Entity player, int charge) {
double particleX = (player.posX - 0.5D) + rand.nextDouble();
double particleX = (player.posX - 0.5D) + itemRand.nextDouble();
double particleY = player.posY + (charge * player.height / getMaxItemUseDuration(itemStack));
double particleZ = (player.posZ - 0.5D) + rand.nextDouble();
double particleZ = (player.posZ - 0.5D) + itemRand.nextDouble();
float particleScale = charge * (5.0f * (1 / (float) getMaxItemUseDuration(itemStack)));
MysticWorld.proxy.airFeetFX(world, particleX, particleY, particleZ, 1.0f + particleScale, 15);
}