Cleanup. Looks like it's been a while since this was run eh?

This commit is contained in:
Vasco Lavos committed 2016-10-02 21:29:35 +01:00
1 parent e862939b7b
commit e38556d265
870 files changed
+7429 -7424

No files matched your search

@@ -2,14 +2,19 @@
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*
* File Created @ [Aug 16, 2015, 4:01:43 PM (GMT)]
*/
package vazkii.botania.common.entity;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -29,10 +34,6 @@ import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.UUID;
// A copy of the vanilla EntityThrowable class
// Doing this because if I didn't do this it'd be an EntityThrowable
// And we all know how much mods like deflecting EntityThrowables
@@ -48,31 +49,31 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
private EntityLivingBase thrower;
private String throwerName;
private int ticksInGround;
private int ticksInAir;
public Entity field_184539_c;
private int field_184540_av;
public EntityThrowableCopy(World worldIn)
{
super(worldIn);
this.xTile = -1;
this.yTile = -1;
this.zTile = -1;
this.setSize(0.25F, 0.25F);
xTile = -1;
yTile = -1;
zTile = -1;
setSize(0.25F, 0.25F);
}
public EntityThrowableCopy(World worldIn, double x, double y, double z)
{
this(worldIn);
this.setPosition(x, y, z);
setPosition(x, y, z);
}
public EntityThrowableCopy(World worldIn, EntityLivingBase throwerIn)
{
this(worldIn, throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight() - 0.10000000149011612D, throwerIn.posZ);
this.thrower = throwerIn;
this(worldIn, throwerIn.posX, throwerIn.posY + throwerIn.getEyeHeight() - 0.10000000149011612D, throwerIn.posZ);
thrower = throwerIn;
}
@Override
protected void entityInit()
{
}
@@ -81,10 +82,11 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
* Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
* length * 64 * renderDistanceWeight Args: distance
*/
@Override
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
double d0 = getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
if (Double.isNaN(d0))
{
@@ -100,104 +102,105 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
float f = -MathHelper.sin(p_184538_3_ * 0.017453292F) * MathHelper.cos(p_184538_2_ * 0.017453292F);
float f1 = -MathHelper.sin((p_184538_2_ + p_184538_4_) * 0.017453292F);
float f2 = MathHelper.cos(p_184538_3_ * 0.017453292F) * MathHelper.cos(p_184538_2_ * 0.017453292F);
this.setThrowableHeading((double)f, (double)f1, (double)f2, p_184538_5_, p_184538_6_);
this.motionX += p_184538_1_.motionX;
this.motionZ += p_184538_1_.motionZ;
setThrowableHeading(f, f1, f2, p_184538_5_, p_184538_6_);
motionX += p_184538_1_.motionX;
motionZ += p_184538_1_.motionZ;
if (!p_184538_1_.onGround)
{
this.motionY += p_184538_1_.motionY;
motionY += p_184538_1_.motionY;
}
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
@Override
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
{
float f = MathHelper.sqrt_double(x * x + y * y + z * z);
x = x / (double)f;
y = y / (double)f;
z = z / (double)f;
x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
x = x * (double)velocity;
y = y * (double)velocity;
z = z * (double)velocity;
this.motionX = x;
this.motionY = y;
this.motionZ = z;
x = x / f;
y = y / f;
z = z / f;
x = x + rand.nextGaussian() * 0.007499999832361937D * inaccuracy;
y = y + rand.nextGaussian() * 0.007499999832361937D * inaccuracy;
z = z + rand.nextGaussian() * 0.007499999832361937D * inaccuracy;
x = x * velocity;
y = y * velocity;
z = z * velocity;
motionX = x;
motionY = y;
motionZ = z;
float f1 = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
this.ticksInGround = 0;
prevRotationYaw = rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
prevRotationPitch = rotationPitch = (float)(MathHelper.atan2(y, f1) * (180D / Math.PI));
ticksInGround = 0;
}
/**
* Updates the velocity of the entity to a new value.
*/
@Override
@SideOnly(Side.CLIENT)
public void setVelocity(double x, double y, double z)
{
this.motionX = x;
this.motionY = y;
this.motionZ = z;
motionX = x;
motionY = y;
motionZ = z;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
float f = MathHelper.sqrt_double(x * x + z * z);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (180D / Math.PI));
prevRotationYaw = rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
prevRotationPitch = rotationPitch = (float)(MathHelper.atan2(y, f) * (180D / Math.PI));
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
lastTickPosX = posX;
lastTickPosY = posY;
lastTickPosZ = posZ;
super.onUpdate();
if (this.throwableShake > 0)
if (throwableShake > 0)
{
--this.throwableShake;
--throwableShake;
}
if (this.inGround)
if (inGround)
{
if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile)
if (worldObj.getBlockState(new BlockPos(xTile, yTile, zTile)).getBlock() == inTile)
{
++this.ticksInGround;
++ticksInGround;
if (this.ticksInGround == 1200)
if (ticksInGround == 1200)
{
this.setDead();
setDead();
}
return;
}
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;
inGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
}
else
{
++this.ticksInAir;
}
Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult raytraceresult = this.worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(this.posX, this.posY, this.posZ);
vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
Vec3d vec3d = new Vec3d(posX, posY, posZ);
Vec3d vec3d1 = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ);
RayTraceResult raytraceresult = worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(posX, posY, posZ);
vec3d1 = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ);
if (raytraceresult != null)
{
@@ -205,23 +208,23 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
}
Entity entity = null;
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expandXyz(1.0D));
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ).expandXyz(1.0D));
double d0 = 0.0D;
boolean flag = false;
for (int i = 0; i < list.size(); ++i)
{
Entity entity1 = (Entity)list.get(i);
Entity entity1 = list.get(i);
if (entity1.canBeCollidedWith())
{
if (entity1 == this.field_184539_c)
if (entity1 == field_184539_c)
{
flag = true;
}
else if (this.ticksExisted < 2 && this.field_184539_c == null)
else if (ticksExisted < 2 && field_184539_c == null)
{
this.field_184539_c = entity1;
field_184539_c = entity1;
flag = true;
}
else
@@ -244,15 +247,15 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
}
}
if (this.field_184539_c != null)
if (field_184539_c != null)
{
if (flag)
{
this.field_184540_av = 2;
field_184540_av = 2;
}
else if (this.field_184540_av-- <= 0)
else if (field_184540_av-- <= 0)
{
this.field_184539_c = null;
field_184539_c = null;
}
}
@@ -263,63 +266,63 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
if (raytraceresult != null)
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && this.worldObj.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.PORTAL)
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && worldObj.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.PORTAL)
{
this.setPortal(raytraceresult.getBlockPos());
setPortal(raytraceresult.getBlockPos());
}
else
{
this.onImpact(raytraceresult);
onImpact(raytraceresult);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));
posX += motionX;
posY += motionY;
posZ += motionZ;
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float)(MathHelper.atan2(motionX, motionZ) * (180D / Math.PI));
for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
for (rotationPitch = (float)(MathHelper.atan2(motionY, f) * (180D / Math.PI)); rotationPitch - prevRotationPitch < -180.0F; prevRotationPitch -= 360.0F)
{
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
while (rotationPitch - prevRotationPitch >= 180.0F)
{
this.prevRotationPitch += 360.0F;
prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
while (rotationYaw - prevRotationYaw < -180.0F)
{
this.prevRotationYaw -= 360.0F;
prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
while (rotationYaw - prevRotationYaw >= 180.0F)
{
this.prevRotationYaw += 360.0F;
prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f1 = 0.99F;
float f2 = this.getGravityVelocity();
float f2 = getGravityVelocity();
if (this.isInWater())
if (isInWater())
{
for (int j = 0; j < 4; ++j)
{
float f3 = 0.25F;
this.worldObj.spawnParticle(EnumParticleTypes.WATER_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);
worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, posX - motionX * f3, posY - motionY * f3, posZ - motionZ * f3, motionX, motionY, motionZ);
}
f1 = 0.8F;
}
this.motionX *= (double)f1;
this.motionY *= (double)f1;
this.motionZ *= (double)f1;
this.motionY -= (double)f2;
this.setPosition(this.posX, this.posY, this.posZ);
motionX *= f1;
motionY *= f1;
motionZ *= f1;
motionY -= f2;
setPosition(posX, posY, posZ);
}
/**
@@ -338,79 +341,81 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(@Nonnull NBTTagCompound compound)
{
compound.setInteger("xTile", this.xTile);
compound.setInteger("yTile", this.yTile);
compound.setInteger("zTile", this.zTile);
ResourceLocation resourcelocation = (ResourceLocation)Block.REGISTRY.getNameForObject(this.inTile);
compound.setInteger("xTile", xTile);
compound.setInteger("yTile", yTile);
compound.setInteger("zTile", zTile);
ResourceLocation resourcelocation = Block.REGISTRY.getNameForObject(inTile);
compound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
compound.setByte("shake", (byte)this.throwableShake);
compound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
compound.setByte("shake", (byte)throwableShake);
compound.setByte("inGround", (byte)(inGround ? 1 : 0));
if ((this.throwerName == null || this.throwerName.isEmpty()) && this.thrower instanceof EntityPlayer)
if ((throwerName == null || throwerName.isEmpty()) && thrower instanceof EntityPlayer)
{
this.throwerName = this.thrower.getName();
throwerName = thrower.getName();
}
compound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
compound.setString("ownerName", throwerName == null ? "" : throwerName);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(@Nonnull NBTTagCompound compound)
{
this.xTile = compound.getInteger("xTile");
this.yTile = compound.getInteger("yTile");
this.zTile = compound.getInteger("zTile");
xTile = compound.getInteger("xTile");
yTile = compound.getInteger("yTile");
zTile = compound.getInteger("zTile");
if (compound.hasKey("inTile", 8))
{
this.inTile = Block.getBlockFromName(compound.getString("inTile"));
inTile = Block.getBlockFromName(compound.getString("inTile"));
}
else
{
this.inTile = Block.getBlockById(compound.getByte("inTile") & 255);
inTile = Block.getBlockById(compound.getByte("inTile") & 255);
}
this.throwableShake = compound.getByte("shake") & 255;
this.inGround = compound.getByte("inGround") == 1;
this.thrower = null;
this.throwerName = compound.getString("ownerName");
throwableShake = compound.getByte("shake") & 255;
inGround = compound.getByte("inGround") == 1;
thrower = null;
throwerName = compound.getString("ownerName");
if (this.throwerName != null && this.throwerName.isEmpty())
if (throwerName != null && throwerName.isEmpty())
{
this.throwerName = null;
throwerName = null;
}
this.thrower = this.getThrower();
thrower = getThrower();
}
public EntityLivingBase getThrower()
{
if (this.thrower == null && this.throwerName != null && !this.throwerName.isEmpty())
if (thrower == null && throwerName != null && !throwerName.isEmpty())
{
this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);
thrower = worldObj.getPlayerEntityByName(throwerName);
if (this.thrower == null && this.worldObj instanceof WorldServer)
if (thrower == null && worldObj instanceof WorldServer)
{
try
{
Entity entity = ((WorldServer)this.worldObj).getEntityFromUuid(UUID.fromString(this.throwerName));
Entity entity = ((WorldServer)worldObj).getEntityFromUuid(UUID.fromString(throwerName));
if (entity instanceof EntityLivingBase)
{
this.thrower = (EntityLivingBase)entity;
thrower = (EntityLivingBase)entity;
}
}
catch (Throwable var2)
{
this.thrower = null;
thrower = null;
}
}
}
return this.thrower;
return thrower;
}
}