Rewriting staves. Air staff has a charge time and its charge time increasing its throwing power.

This commit is contained in:
allstar69 2013-07-23 05:59:03 -07:00
commit dea87d08bd
6 changed files with 103 additions and 56 deletions

View file

@ -1,5 +1,6 @@
package MysticWorld.Client; package MysticWorld.Client;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
@ -77,7 +78,7 @@ public class ClientProxy extends CommonProxy {
//particles //particles
@Override @Override
public void airFX(World worldObj, double x, double y, double z, float scale) public void airFeetFX(World worldObj, double x, double y, double z, float scale)
{ {
PowerAirFX airFX = new PowerAirFX(worldObj, x, y, z, scale); PowerAirFX airFX = new PowerAirFX(worldObj, x, y, z, scale);
ModLoader.getMinecraftInstance().effectRenderer.addEffect(airFX); ModLoader.getMinecraftInstance().effectRenderer.addEffect(airFX);

View file

@ -7,6 +7,7 @@ import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -19,12 +20,12 @@ public class PowerAirFX extends EntityFX
public PowerAirFX(World world, double x, double y, double z, float scale){ public PowerAirFX(World world, double x, double y, double z, float scale){
super(world, x, y, z); super(world, x, y, z);
this.motionX *= 0.019999999552965164D;
this.motionY *= 0.019999999552965164D;
this.motionZ *= 0.019999999552965164D;
this.motionX += motionX; this.motionX += motionX;
this.motionY += motionY; this.motionY += motionY;
this.motionZ += motionZ; this.motionZ += motionZ;
this.motionX *= 0.019999999552965164D;
this.motionY *= 0.019999999552965164D;
this.motionZ *= 0.019999999552965164D;
this.particleRed = 1.0F; this.particleRed = 1.0F;
this.particleGreen = 1.0F; this.particleGreen = 1.0F;
this.particleBlue = 1.0F; this.particleBlue = 1.0F;
@ -33,6 +34,21 @@ public class PowerAirFX extends EntityFX
this.particleMaxAge = 15; this.particleMaxAge = 15;
} }
public PowerAirFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float rotPitch, float rotYaw){
super(world, x, y, z);
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.motionY = (double)(-MathHelper.sin((this.rotationPitch) / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.particleRed = 1.0F;
this.particleGreen = 1.0F;
this.particleBlue = 1.0F;
this.particleScale = 1.0F;
this.noClip = true;
this.particleMaxAge = 120;
this.rotationPitch = rotPitch;
this.rotationYaw = rotYaw;
}
public void onUpdate() public void onUpdate()
{ {
this.prevPosX = this.posX; this.prevPosX = this.posX;
@ -62,6 +78,12 @@ public class PowerAirFX extends EntityFX
this.motionX *= 0.699999988079071D; this.motionX *= 0.699999988079071D;
this.motionZ *= 0.699999988079071D; this.motionZ *= 0.699999988079071D;
} }
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
this.setPosition(this.posX, this.posY, this.posZ);
} }
public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7) public void renderParticle(Tessellator tessellator, float par2, float par3, float par4, float par5, float par6, float par7)

View file

@ -1,5 +1,6 @@
package MysticWorld; package MysticWorld;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.src.ModLoader; import net.minecraft.src.ModLoader;
import net.minecraft.world.World; import net.minecraft.world.World;
import MysticWorld.Client.FX.PowerAirFX; import MysticWorld.Client.FX.PowerAirFX;
@ -17,7 +18,7 @@ public class CommonProxy {
return 0; return 0;
} }
public void airFX(World worldObj, double x, double y, double z, float scale){ public void airFeetFX(World worldObj, double x, double y, double z, float scale){
} }
public void earthFX(World worldObj, double x, double y, double z, float scale){ public void earthFX(World worldObj, double x, double y, double z, float scale){

View file

@ -36,10 +36,9 @@ import MysticWorld.MysticWorld;
public class EntityChargeAir extends Entity { public class EntityChargeAir extends Entity {
public EntityPlayer shootingEntity; public EntityPlayer shootingEntity;
public EntityPlayer entityPlayer;
public EntityDragon entityDragon;
public EntityWither entityWither;
private boolean inGround = false; private boolean inGround = false;
private int xTile = -1; private int xTile = -1;
private int yTile = -1; private int yTile = -1;
private int zTile = -1; private int zTile = -1;
@ -47,12 +46,16 @@ public class EntityChargeAir extends Entity {
private int ticksAlive; private int ticksAlive;
private int ticksInAir = 0; private int ticksInAir = 0;
private float particleScale = 1.0f;
private double powerHeight = 0.75D;
public EntityChargeAir(World par1World) public EntityChargeAir(World par1World)
{ {
super(par1World); super(par1World);
} }
public EntityChargeAir(World par1World, EntityPlayer par2EntityPlayer) public EntityChargeAir(World par1World, EntityPlayer par2EntityPlayer, float pScale, double pHeight)
{ {
super(par1World); super(par1World);
this.setSize(0.25F, 0.25F); this.setSize(0.25F, 0.25F);
@ -62,6 +65,8 @@ public class EntityChargeAir extends Entity {
this.motionY = (double)(-MathHelper.sin((this.rotationPitch) / 180.0F * (float)Math.PI)); this.motionY = (double)(-MathHelper.sin((this.rotationPitch) / 180.0F * (float)Math.PI));
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
this.shootingEntity = par2EntityPlayer; this.shootingEntity = par2EntityPlayer;
this.particleScale = pScale;
this.powerHeight = pHeight;
} }
public void onUpdate() public void onUpdate()
@ -139,7 +144,9 @@ public class EntityChargeAir extends Entity {
f2 = 0.8F; f2 = 0.8F;
} }
MysticWorld.proxy.airFX(this.worldObj, this.posX + (rand.nextDouble()/2), this.posY + 0.5D, this.posZ + (rand.nextDouble()/2), 1.0F); MysticWorld.proxy.airFeetFX(this.worldObj, this.posX + (rand.nextDouble()/2), this.posY + 0.5D, this.posZ + (rand.nextDouble()/2), particleScale);
MysticWorld.proxy.airFeetFX(this.worldObj, this.posX + (rand.nextDouble()/2), this.posY + 0.5D, this.posZ + (rand.nextDouble()/2), particleScale);
this.setPosition(this.posX, this.posY, this.posZ); this.setPosition(this.posX, this.posY, this.posZ);
} }
} }
@ -157,14 +164,14 @@ public class EntityChargeAir extends Entity {
{ {
this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
if (par1MovingObjectPosition.entityHit != entityPlayer && par1MovingObjectPosition.entityHit != entityDragon && par1MovingObjectPosition.entityHit != entityWither) if (par1MovingObjectPosition.entityHit != null)
{ {
double f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); double f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F) if (f3 > 0.0F)
{ {
par1MovingObjectPosition.entityHit.addVelocity(this.motionX * (double)2 * 0.6000000238418579D / (double)f3, 2.5, this.motionZ * (double)2 * 0.6000000238418579D / (double)f3); par1MovingObjectPosition.entityHit.addVelocity(this.motionX * (double)2 * 0.6000000238418579D / (double)f3, 1.0D + powerHeight, this.motionZ * (double)2 * 0.6000000238418579D / (double)f3);
} }
} }
else else
{ {

View file

@ -32,7 +32,7 @@ public class ItemOrbAir extends ItemOrb
if (currentItem.itemID == itemStack.itemID) if (currentItem.itemID == itemStack.itemID)
{ {
player.fallDistance = 0.0F; 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.posZ - 0.5D) + rand.nextDouble(), 1.0F);
} }
} }
} }

View file

@ -1,22 +1,15 @@
package MysticWorld.Items; 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 org.lwjgl.input.Mouse;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import MysticWorld.MysticWorld; import MysticWorld.MysticWorld;
import MysticWorld.Entity.EntityChargeAir; 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 { public class ItemStaffAir extends ItemStaff {
@ -28,9 +21,14 @@ public class ItemStaffAir extends ItemStaff {
@Override @Override
public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) 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; EntityPlayer player = (EntityPlayer)entity;
ItemStack currentItem = player.inventory.getCurrentItem(); ItemStack currentItem = player.inventory.getCurrentItem();
itemStack.stackTagCompound.setInteger("maxChargeTime", 3 * 20);
if (!world.isRemote) if (!world.isRemote)
{ {
if (currentItem != null) if (currentItem != null)
@ -38,39 +36,57 @@ public class ItemStaffAir extends ItemStaff {
if (currentItem.itemID == itemStack.itemID) if (currentItem.itemID == itemStack.itemID)
{ {
player.fallDistance = 0.0F; 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) 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) itemStack.stackTagCompound.setBoolean("charging", true);
{
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;
}
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;
} }
} }