Rewriting staves. Air staff has a charge time and its charge time increasing its throwing power.
This commit is contained in:
parent
3ced3691cb
commit
dea87d08bd
6 changed files with 103 additions and 56 deletions
|
|
@ -1,22 +1,15 @@
|
|||
package MysticWorld.Items;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import MysticWorld.MysticWorld;
|
||||
import MysticWorld.Entity.EntityChargeAir;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemStaffAir extends ItemStaff {
|
||||
|
||||
|
|
@ -28,9 +21,14 @@ public class ItemStaffAir extends ItemStaff {
|
|||
@Override
|
||||
public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
|
||||
itemStack.stackTagCompound.setInteger("maxChargeTime", 3 * 20);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (currentItem != null)
|
||||
|
|
@ -38,39 +36,57 @@ public class ItemStaffAir extends ItemStaff {
|
|||
if (currentItem.itemID == itemStack.itemID)
|
||||
{
|
||||
player.fallDistance = 0.0F;
|
||||
MysticWorld.proxy.airFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY, (player.posZ - 0.5D) + rand.nextDouble(), 1.0F);
|
||||
MysticWorld.proxy.airFeetFX(world, (player.posX - 0.5D) + rand.nextDouble(), player.posY + (player.height/itemStack.stackTagCompound.getInteger("maxChargeTime") * itemStack.stackTagCompound.getInteger("chargeTime")), (player.posZ - 0.5D) + rand.nextDouble(), 1.0f + ((float)(itemStack.stackTagCompound.getInteger("chargeTime")) * (5.0f * (1 / (float)itemStack.stackTagCompound.getInteger("maxChargeTime")))));
|
||||
|
||||
if (!Mouse.isButtonDown(1))
|
||||
{
|
||||
if (itemStack.stackTagCompound.getInteger("chargeTime") > 0)
|
||||
{
|
||||
world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)player.posX, (int)player.posY, (int)player.posZ, 0);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityChargeAir(world, player, 1.0f + ((float)(itemStack.stackTagCompound.getInteger("chargeTime")) * (5.0f * (1 / (float)itemStack.stackTagCompound.getInteger("maxChargeTime")))), (float)(itemStack.stackTagCompound.getInteger("chargeTime")) * (2.5D * (1.0D / (double)itemStack.stackTagCompound.getInteger("maxChargeTime")))));
|
||||
|
||||
itemStack.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Mouse.isButtonDown(1))
|
||||
{
|
||||
if (itemStack.stackTagCompound.getBoolean("charging") == true)
|
||||
{
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", itemStack.stackTagCompound.getInteger("chargeTime") + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", 0);
|
||||
itemStack.stackTagCompound.setBoolean("charging", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack.stackTagCompound.getInteger("chargeTime") > itemStack.stackTagCompound.getInteger("maxChargeTime"))
|
||||
{
|
||||
itemStack.stackTagCompound.setInteger("chargeTime", itemStack.stackTagCompound.getInteger("maxChargeTime"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
|
||||
{
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
if (itemStack.stackTagCompound.getBoolean("charging") == false)
|
||||
{
|
||||
if (entityPlayer.onGround)
|
||||
{
|
||||
world.playSoundEffect(entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
|
||||
itemStack.damageItem(1, entityPlayer);
|
||||
entityPlayer.addVelocity(0, 2.5, 0);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
itemStack.stackTagCompound.setBoolean("charging", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityChargeAir(world, entityPlayer));
|
||||
|
||||
itemStack.damageItem(1, entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue