Fixed dart blower and darts.
This commit is contained in:
parent
f8d378f4bc
commit
561eaaa315
4 changed files with 240 additions and 236 deletions
|
@ -4,15 +4,12 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.particle.EntityBreakingFX;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.entity.RenderSnowball;
|
||||
import net.minecraft.world.World;
|
||||
import biomesoplenty.api.Items;
|
||||
import biomesoplenty.blocks.renderers.FoliageRenderer;
|
||||
import biomesoplenty.blocks.renderers.PlantsRenderer;
|
||||
import biomesoplenty.items.projectiles.EntityDart;
|
||||
import biomesoplenty.items.projectiles.EntityMudball;
|
||||
import biomesoplenty.items.projectiles.EntityPoisonDart;
|
||||
import biomesoplenty.items.projectiles.RenderDart;
|
||||
import biomesoplenty.items.projectiles.RenderPoisonDart;
|
||||
import biomesoplenty.particles.EntityDandelionFX;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
|
@ -25,7 +22,7 @@ public class ClientProxy extends CommonProxy {
|
|||
{
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(Items.mudball.get(), 0));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPoisonDart.class, new RenderPoisonDart());
|
||||
//RenderingRegistry.registerEntityRenderingHandler(EntityPoisonDart.class, new RenderPoisonDart());
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new FoliageRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new PlantsRenderer());
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package biomesoplenty.items;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import biomesoplenty.BiomesOPlenty;
|
||||
import biomesoplenty.api.Items;
|
||||
import biomesoplenty.items.projectiles.EntityDart;
|
||||
import biomesoplenty.items.projectiles.EntityPoisonDart;
|
||||
import biomesoplenty.items.projectiles.EntityDart.DartType;
|
||||
|
||||
public class ItemDartBlower extends Item
|
||||
{
|
||||
|
@ -33,21 +30,43 @@ public class ItemDartBlower extends Item
|
|||
{
|
||||
boolean flag = par3EntityPlayer.capabilities.isCreativeMode;
|
||||
|
||||
if (par3EntityPlayer.inventory.hasItem(Items.dart.get().itemID))
|
||||
if (flag || par3EntityPlayer.inventory.hasItem(Items.dart.get().itemID))
|
||||
{
|
||||
//EntityArrow entitydart = new EntityArrow(par2World, par3EntityPlayer, 2.0F);
|
||||
EntityDart entityDart = new EntityDart(par2World, par3EntityPlayer, 1.25F);
|
||||
|
||||
itemStack.damageItem(1, par3EntityPlayer);
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 2.0F / (1.0F * 0.4F + 1.2F) + 1.0F * 0.5F);
|
||||
|
||||
if (!flag)
|
||||
par3EntityPlayer.inventory.consumeInventoryItem(Items.dart.get().itemID);
|
||||
|
||||
if (!par2World.isRemote)
|
||||
if (par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.dart.get().itemID, 1, 0)))
|
||||
par2World.spawnEntityInWorld(new EntityDart(par2World, par3EntityPlayer, 1.0F));
|
||||
else
|
||||
par2World.spawnEntityInWorld(new EntityPoisonDart(par2World, par3EntityPlayer, 1.0F));
|
||||
int slot = -1;
|
||||
if (par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.dart.get().itemID, 1, 1)))
|
||||
{
|
||||
entityDart.setDartType(DartType.POISON);
|
||||
|
||||
for (int k = 0; k < par3EntityPlayer.inventory.mainInventory.length; ++k)
|
||||
if (par3EntityPlayer.inventory.mainInventory[k] != null && par3EntityPlayer.inventory.mainInventory[k].itemID == Items.dart.get().itemID && par3EntityPlayer.inventory.mainInventory[k].getItemDamage() == 1)
|
||||
{
|
||||
slot = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (par3EntityPlayer.inventory.hasItemStack(new ItemStack(Items.dart.get().itemID, 1, 0)))
|
||||
{
|
||||
entityDart.setDartType(DartType.NORMAL);
|
||||
|
||||
for (int k = 0; k < par3EntityPlayer.inventory.mainInventory.length; ++k)
|
||||
if (par3EntityPlayer.inventory.mainInventory[k] != null && par3EntityPlayer.inventory.mainInventory[k].itemID == Items.dart.get().itemID && par3EntityPlayer.inventory.mainInventory[k].getItemDamage() == 0)
|
||||
{
|
||||
slot = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!par2World.isRemote)
|
||||
par2World.spawnEntityInWorld(entityDart);
|
||||
|
||||
if (!flag && slot >= 0)
|
||||
par3EntityPlayer.inventory.decrStackSize(slot, 1);
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
|
|
|
@ -3,10 +3,8 @@ package biomesoplenty.items.projectiles;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentThorns;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
|
@ -24,17 +22,19 @@ import biomesoplenty.ClientProxy;
|
|||
|
||||
public class EntityDart extends EntityArrow
|
||||
{
|
||||
public static enum DartType
|
||||
{
|
||||
NORMAL, POISON;
|
||||
}
|
||||
|
||||
boolean isClient = BiomesOPlenty.proxy instanceof ClientProxy;
|
||||
|
||||
private int xTile = -1;
|
||||
private int yTile = -1;
|
||||
private int zTile = -1;
|
||||
private int inTile = 0;
|
||||
private int inData = 0;
|
||||
private boolean inGround = false;
|
||||
private int ticksInGround;
|
||||
private int ticksInAir = 0;
|
||||
private double damage = 0.1D;
|
||||
private int damage = 2;
|
||||
private DartType type = DartType.NORMAL;
|
||||
|
||||
public EntityDart(World par1World)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ public class EntityDart extends EntityArrow
|
|||
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
super.onEntityUpdate();
|
||||
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
|
||||
{
|
||||
|
@ -71,227 +71,211 @@ public class EntityDart extends EntityArrow
|
|||
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ)))
|
||||
{
|
||||
this.inGround = true;
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.inGround)
|
||||
++this.ticksInAir;
|
||||
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
|
||||
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
|
||||
int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
|
||||
if (j == this.inTile && k == this.inData)
|
||||
Entity entity = null;
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
int l;
|
||||
float f1;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity1 = (Entity)list.get(l);
|
||||
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
|
||||
{
|
||||
++this.ticksInGround;
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
|
||||
|
||||
if (this.ticksInGround == 1)
|
||||
if (movingobjectposition1 != null)
|
||||
{
|
||||
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
|
||||
|
||||
if (d1 < d0 || d0 == 0.0D)
|
||||
{
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
|
||||
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).func_96122_a(entityplayer))
|
||||
{
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
|
||||
float f2;
|
||||
float f3;
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
if (movingobjectposition.entityHit != null)
|
||||
{
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
|
||||
DamageSource damagesource = null;
|
||||
|
||||
if (this.shootingEntity == null)
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
}
|
||||
|
||||
if (this.type == DartType.POISON)
|
||||
{
|
||||
this.damage = 1;
|
||||
if (movingobjectposition.entityHit instanceof EntityLiving)
|
||||
((EntityLiving)movingobjectposition.entityHit).addPotionEffect(new PotionEffect(Potion.poison.id, 100));
|
||||
}
|
||||
|
||||
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, this.damage))
|
||||
{
|
||||
if (movingobjectposition.entityHit instanceof EntityLiving)
|
||||
{
|
||||
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
|
||||
}
|
||||
}
|
||||
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.setDead();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.motionX *= -0.10000000149011612D;
|
||||
this.motionY *= -0.10000000149011612D;
|
||||
this.motionZ *= -0.10000000149011612D;
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inGround = false;
|
||||
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
this.xTile = movingobjectposition.blockX;
|
||||
this.yTile = movingobjectposition.blockY;
|
||||
this.zTile = movingobjectposition.blockZ;
|
||||
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
|
||||
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
|
||||
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
|
||||
|
||||
for (int p = 0; p < 16; ++p)
|
||||
{
|
||||
BiomesOPlenty.proxy.spawnParticle("dart", this.posX, this.posY, this.posZ);
|
||||
}
|
||||
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
{
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
{
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
{
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
float f4 = 0.99F;
|
||||
f1 = 0.05F;
|
||||
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int j1 = 0; j1 < 4; ++j1)
|
||||
{
|
||||
f3 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ);
|
||||
}
|
||||
|
||||
f4 = 0.8F;
|
||||
}
|
||||
|
||||
this.motionX *= (double)f4;
|
||||
this.motionY *= (double)f4;
|
||||
this.motionZ *= (double)f4;
|
||||
this.motionY -= (double)f1;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.doBlockCollisions();
|
||||
}
|
||||
|
||||
public void setDartType(DartType par1)
|
||||
{
|
||||
this.type = par1;
|
||||
|
||||
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
||||
|
||||
if (par1 == DartType.POISON)
|
||||
{
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
++this.ticksInAir;
|
||||
Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks_do_do(vec3, vec31, false, true);
|
||||
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
int l;
|
||||
float f1;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity1 = (Entity)list.get(l);
|
||||
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
|
||||
{
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
|
||||
|
||||
if (movingobjectposition1 != null)
|
||||
{
|
||||
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
|
||||
|
||||
if (d1 < d0 || d0 == 0.0D)
|
||||
{
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
|
||||
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).func_96122_a(entityplayer))
|
||||
{
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
|
||||
float f2;
|
||||
float f3;
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
if (movingobjectposition.entityHit != null)
|
||||
{
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
int i1 = MathHelper.ceiling_double_int((double)f2 * this.damage);
|
||||
|
||||
if (this.getIsCritical())
|
||||
{
|
||||
i1 += this.rand.nextInt(i1 / 2 + 2);
|
||||
}
|
||||
|
||||
DamageSource damagesource = null;
|
||||
|
||||
if (this.shootingEntity == null)
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
}
|
||||
|
||||
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
|
||||
{
|
||||
movingobjectposition.entityHit.setFire(5);
|
||||
//movingobjectposition.entityHit.addPotionEffect(new PotionEffect(Potion.poison.id, 100));
|
||||
}
|
||||
|
||||
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1))
|
||||
{
|
||||
if (movingobjectposition.entityHit instanceof EntityLiving)
|
||||
{
|
||||
EntityLiving entityliving = (EntityLiving)movingobjectposition.entityHit;
|
||||
|
||||
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacketToPlayer(new Packet70GameEvent(6, 0));
|
||||
}
|
||||
}
|
||||
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.setDead();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.motionX *= -0.10000000149011612D;
|
||||
this.motionY *= -0.10000000149011612D;
|
||||
this.motionZ *= -0.10000000149011612D;
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xTile = movingobjectposition.blockX;
|
||||
this.yTile = movingobjectposition.blockY;
|
||||
this.zTile = movingobjectposition.blockZ;
|
||||
this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
|
||||
this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
|
||||
this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
|
||||
this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
|
||||
this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
|
||||
|
||||
for (int p = 0; i < 16; ++i)
|
||||
{
|
||||
BiomesOPlenty.proxy.spawnParticle("dart", this.posX, this.posY, this.posZ);
|
||||
}
|
||||
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.setDead();
|
||||
|
||||
if (this.inTile != 0)
|
||||
{
|
||||
Block.blocksList[this.inTile].onEntityCollidedWithBlock(this.worldObj, this.xTile, this.yTile, this.zTile, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
|
||||
for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
|
||||
{
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
|
||||
{
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
|
||||
{
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
float f4 = 0.99F;
|
||||
f1 = 0.05F;
|
||||
|
||||
if (this.isInWater())
|
||||
{
|
||||
for (int j1 = 0; j1 < 4; ++j1)
|
||||
{
|
||||
f3 = 0.25F;
|
||||
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ);
|
||||
}
|
||||
|
||||
f4 = 0.8F;
|
||||
}
|
||||
|
||||
this.motionX *= (double)f4;
|
||||
this.motionY *= (double)f4;
|
||||
this.motionZ *= (double)f4;
|
||||
this.motionY -= (double)f1;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.doBlockCollisions();
|
||||
this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the arrow has a stream of critical hit particles flying behind it.
|
||||
*/
|
||||
public boolean isPoisonous()
|
||||
{
|
||||
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
||||
return (b0 & 1) != 0;
|
||||
}
|
||||
}
|
|
@ -1,23 +1,27 @@
|
|||
package biomesoplenty.items.projectiles;
|
||||
|
||||
import biomesoplenty.BiomesOPlenty;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderDart extends Render
|
||||
{
|
||||
|
||||
public void renderArrow(EntityArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9)
|
||||
public void renderArrow(EntityDart par1EntityArrow, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.loadTexture("/mods/BiomesOPlenty/textures/projectiles/dart.png");
|
||||
if (!par1EntityArrow.isPoisonous())
|
||||
this.loadTexture("/mods/BiomesOPlenty/textures/projectiles/dart.png");
|
||||
else
|
||||
this.loadTexture("/mods/BiomesOPlenty/textures/projectiles/poisondart.png");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
|
||||
GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
|
||||
|
@ -84,6 +88,6 @@ public class RenderDart extends Render
|
|||
*/
|
||||
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.renderArrow((EntityArrow)par1Entity, par2, par4, par6, par8, par9);
|
||||
this.renderArrow((EntityDart)par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue