Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

@@ -18,21 +18,18 @@ import net.minecraft.util.*;
import net.minecraft.world.World;
@Deprecated
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData
{
public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnData {
public ItemStack returnStack;
public float mass;
public int baseDamage;
private float knockbackStrengthMod;
Random random = new Random();
public ArrowEntity(World par1World)
{
public ArrowEntity(World par1World) {
super(par1World);
}
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack)
{
public ArrowEntity(World world, EntityLivingBase living, float baseSpeed, ItemStack stack) {
super(world, living, baseSpeed);
this.returnStack = stack;
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
@@ -40,8 +37,7 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.baseDamage = toolTag.getInteger("Attack");
}
public ArrowEntity(World world, double x, double y, double z, ItemStack stack)
{
public ArrowEntity(World world, double x, double y, double z, ItemStack stack) {
super(world, x, y, z);
this.returnStack = stack;
NBTTagCompound toolTag = stack.getTagCompound().getCompoundTag("InfiTool");
@@ -50,76 +46,66 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
@Override
public void onCollideWithPlayer (EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) {
boolean flag =
this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack))
{
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(returnStack)) {
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (flag) {
this.playSound(
"random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
if(returnStack.stackSize <= 0 || this.canBePickedUp == 2)
this.setDead();
if (returnStack.stackSize <= 0 || this.canBePickedUp == 2) this.setDead();
}
}
}
@Override
public void onUpdate ()
{
public void onUpdate() {
this.onEntityUpdate();
if (returnStack == null || returnStack.stackSize < 1)
{
if (returnStack == null || returnStack.stackSize < 1) {
this.setDead();
}
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
this.prevRotationYaw =
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch =
this.rotationPitch = (float) (Math.atan2(this.motionY, (double) f) * 180.0D / Math.PI);
}
Block i = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
i.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
AxisAlignedBB axisalignedbb = i.getCollisionBoundingBoxFromPool(
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
{
if (axisalignedbb != null
&& axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) {
this.inGround = true;
}
if (this.arrowShake > 0)
{
if (this.arrowShake > 0) {
--this.arrowShake;
}
if (this.inGround)
{
if (!worldObj.isRemote)
{
if (this.inGround) {
if (!worldObj.isRemote) {
Block j = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
int k = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (j == this.field_145790_g && k == this.inData)
{
if (j == this.field_145790_g && k == this.inData) {
++this.ticksInGround;
if (this.ticksInGround == 120000)
{
if (this.ticksInGround == 120000) {
this.setDead();
}
}
else
{
} else {
this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
@@ -128,43 +114,46 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.ticksInAir = 0;
}
}
}
else
{
} else {
++this.ticksInAir;
Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
Vec3 vec31 = Vec3.createVectorHelper(
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec3, vec31, false, true, false);
vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
vec31 = Vec3.createVectorHelper(
this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (movingobjectposition != null)
{
vec31 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
if (movingobjectposition != null) {
vec31 = Vec3.createVectorHelper(
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));
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 ySpeed;
for (l = 0; l < list.size(); ++l)
{
for (l = 0; l < list.size(); ++l) {
Entity entity1 = (Entity) list.get(l);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
{
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
ySpeed = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
AxisAlignedBB axisalignedbb1 =
entity1.boundingBox.expand((double) ySpeed, (double) ySpeed, (double) ySpeed);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
if (movingobjectposition1 != null) {
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
@@ -172,17 +161,18 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
if (entity != null)
{
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
{
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).canAttackPlayer(entityplayer))
{
if (entityplayer.capabilities.disableDamage
|| this.shootingEntity instanceof EntityPlayer
&& !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
movingobjectposition = null;
}
}
@@ -190,50 +180,40 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
float speed;
float f3;
if (movingobjectposition != null)
{
if (movingobjectposition.entityHit != null)
{
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
if (movingobjectposition != null) {
if (movingobjectposition.entityHit != null) {
speed = MathHelper.sqrt_double(
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
double damageSpeed = (double) speed * this.getDamage();
damageSpeed *= baseDamage;
damageSpeed /= 5D;
int damageInflicted = MathHelper.ceiling_double_int(damageSpeed);
if (this.getIsCritical())
{
if (this.getIsCritical()) {
damageInflicted += this.rand.nextInt(damageInflicted / 2 + 2);
}
DamageSource damagesource = null;
if (this.shootingEntity == null)
{
if (this.shootingEntity == null) {
damagesource = DamageSource.causeArrowDamage(this, this);
}
else
{
} else {
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
{
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
movingobjectposition.entityHit.setFire(5);
}
if (returnStack.hasTagCompound())
{
if (returnStack.hasTagCompound()) {
int fireAspect = 0;
NBTTagCompound toolTags = returnStack.getTagCompound().getCompoundTag("InfiTool");
if (toolTags.hasKey("Fiery") || toolTags.hasKey("Lava"))
{
if (toolTags.hasKey("Fiery") || toolTags.hasKey("Lava")) {
fireAspect *= 4;
if (toolTags.hasKey("Fiery"))
{
if (toolTags.hasKey("Fiery")) {
fireAspect += toolTags.getInteger("Fiery") / 5 + 1;
}
if (toolTags.getBoolean("Lava"))
{
if (toolTags.getBoolean("Lava")) {
fireAspect += 3;
}
entity.setFire(fireAspect);
@@ -244,40 +224,41 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
((EntityLiving) shootingEntity).heal(random.nextInt(drain + 1));
}
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted))
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, damageInflicted)) {
if (movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase entityliving = (EntityLivingBase) movingobjectposition.entityHit;
if (!this.worldObj.isRemote)
{
if (!this.worldObj.isRemote) {
entityliving.setArrowCountInEntity(entityliving.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0)
{
if (this.knockbackStrength > 0 || this.knockbackStrengthMod > 0) {
f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f3 > 0.0F)
{
if (f3 > 0.0F) {
float knockback = knockbackStrength + knockbackStrengthMod;
movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f3, 0.1D, this.motionZ * (double) knockback * 0.6000000238418579D / (double) f3);
movingobjectposition.entityHit.addVelocity(
this.motionX
* (double) this.knockbackStrength
* 0.6000000238418579D
/ (double) f3,
0.1D,
this.motionZ * (double) knockback * 0.6000000238418579D / (double) f3);
}
}
if (this.shootingEntity != null)
{
if (this.shootingEntity != null) {
damagesource = DamageSource.causeArrowDamage(this, this);
}
else
{
} else {
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
{
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0));
if (this.shootingEntity != null
&& movingobjectposition.entityHit != this.shootingEntity
&& movingobjectposition.entityHit instanceof EntityPlayer
&& this.shootingEntity instanceof EntityPlayerMP) {
((EntityPlayerMP) this.shootingEntity)
.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0));
// TConstruct.packetPipeline.sendTo(new
// S2BPacketChangeGameState(6, 0),
// (EntityPlayerMP) this.shootingEntity);
@@ -286,26 +267,19 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
if (!(movingobjectposition.entityHit instanceof EntityEnderman))
{
if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
this.motionX = 0;
this.motionZ = 0;
if (movingobjectposition.entityHit instanceof EntityPlayer)
{
if (movingobjectposition.entityHit instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) movingobjectposition.entityHit;
if (canBePickedUp == 2 || player.inventory.addItemStackToInventory(returnStack))
this.setDead();
}
else if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
} else if (movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) movingobjectposition.entityHit;
if (canBePickedUp == 2 || addItemStackToInventory(returnStack, living))
this.setDead();
if (canBePickedUp == 2 || addItemStackToInventory(returnStack, living)) this.setDead();
}
}
}
else
{
} else {
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
@@ -313,18 +287,19 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
}
else
{
} else {
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.field_145790_g =
this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.inData = this.worldObj.getBlockMetadata(
this.field_145791_d, this.field_145792_e, this.field_145789_f);
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));
speed = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
speed = MathHelper.sqrt_double(
this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / (double) speed * 0.05000000074505806D;
this.posY -= this.motionY / (double) speed * 0.05000000074505806D;
this.posZ -= this.motionZ / (double) speed * 0.05000000074505806D;
@@ -333,18 +308,23 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
this.arrowShake = 0;
this.setIsCritical(false);
if (this.field_145790_g != Blocks.air)
{
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
if (this.field_145790_g != Blocks.air) {
this.field_145790_g.onEntityCollidedWithBlock(
this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
if (this.getIsCritical())
{
for (l = 0; l < 4; ++l)
{
this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double) l / 4.0D, this.posY + this.motionY * (double) l / 4.0D, this.posZ + this.motionZ * (double) l / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
if (this.getIsCritical()) {
for (l = 0; l < 4; ++l) {
this.worldObj.spawnParticle(
"crit",
this.posX + this.motionX * (double) l / 4.0D,
this.posY + this.motionY * (double) l / 4.0D,
this.posZ + this.motionZ * (double) l / 4.0D,
-this.motionX,
-this.motionY + 0.2D,
-this.motionZ);
}
}
@@ -354,23 +334,21 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
speed = 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) speed) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) speed) * 180.0D / Math.PI);
this.rotationPitch - this.prevRotationPitch < -180.0F;
this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
@@ -380,12 +358,17 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
float speedMod = 1.05f + (mass / 1.26F) / 6F;
ySpeed = 0.05F * speedMod;
if (this.isInWater())
{
for (int j1 = 0; j1 < 4; ++j1)
{
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);
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);
}
dropSpeed = 0.8F;
@@ -400,28 +383,20 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
public boolean addItemStackToInventory (ItemStack par1ItemStack, EntityLivingBase living)
{
if (par1ItemStack == null)
{
public boolean addItemStackToInventory(ItemStack par1ItemStack, EntityLivingBase living) {
if (par1ItemStack == null) {
return false;
}
else
{
try
{
} else {
try {
int stackSize;
do
{
do {
stackSize = par1ItemStack.stackSize;
par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack, living);
} while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < stackSize);
return par1ItemStack.stackSize < stackSize;
}
catch (Throwable throwable)
{
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
// TODO is this needed???
@@ -435,12 +410,9 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
public int getFirstEmptyStack (EntityLivingBase living)
{
for (int i = 0; i < 5; ++i)
{
if (living.getEquipmentInSlot(i) == null)
{
public int getFirstEmptyStack(EntityLivingBase living) {
for (int i = 0; i < 5; ++i) {
if (living.getEquipmentInSlot(i) == null) {
return i;
}
}
@@ -448,72 +420,51 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
return -1;
}
private int storePartialItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
private int storePartialItemStack(ItemStack par1ItemStack, EntityLivingBase living) {
int stackSize = par1ItemStack.stackSize;
int slotID;
if (!par1ItemStack.isStackable())
{
if (!par1ItemStack.isStackable()) {
slotID = this.getFirstEmptyStack(living);
if (slotID < 0)
{
if (slotID < 0) {
return stackSize;
}
else
{
} else {
living.setCurrentItemOrArmor(slotID, par1ItemStack.copy());
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
if (living instanceof EntityLiving) ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return 0;
}
}
else
{
} else {
slotID = this.storeItemStack(par1ItemStack, living);
if (slotID < 0)
{
if (slotID < 0) {
slotID = this.getFirstEmptyStack(living);
}
if (slotID < 0)
{
if (slotID < 0) {
return stackSize;
}
else
{
} else {
ItemStack stack = living.getEquipmentInSlot(slotID);
if (stack == null)
{
if (stack == null) {
living.setCurrentItemOrArmor(slotID, par1ItemStack.copy());
if (living instanceof EntityLiving)
((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
if (living instanceof EntityLiving) ((EntityLiving) living).setEquipmentDropChance(slotID, 2.0f);
return 0;
}
else
{
} else {
int l = stackSize;
if (stackSize > stack.getMaxStackSize() - stack.stackSize)
{
if (stackSize > stack.getMaxStackSize() - stack.stackSize) {
l = stack.getMaxStackSize() - stack.stackSize;
}
if (l > 64 - stack.stackSize)
{
if (l > 64 - stack.stackSize) {
l = 64 - stack.stackSize;
}
if (l == 0)
{
if (l == 0) {
return stackSize;
}
else
{
} else {
stackSize -= l;
stack.stackSize += l;
living.setCurrentItemOrArmor(slotID, stack);
@@ -527,13 +478,14 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
}
}
private int storeItemStack (ItemStack par1ItemStack, EntityLivingBase living)
{
for (int slotID = 0; slotID < 5; ++slotID)
{
private int storeItemStack(ItemStack par1ItemStack, EntityLivingBase living) {
for (int slotID = 0; slotID < 5; ++slotID) {
ItemStack stack = living.getEquipmentInSlot(slotID);
if (stack != null && stack.isItemEqual(par1ItemStack) && ItemStack.areItemStackTagsEqual(stack, par1ItemStack) && stack.isStackable() && stack.stackSize < stack.getMaxStackSize())
{
if (stack != null
&& stack.isItemEqual(par1ItemStack)
&& ItemStack.areItemStackTagsEqual(stack, par1ItemStack)
&& stack.isStackable()
&& stack.stackSize < stack.getMaxStackSize()) {
return slotID;
}
}
@@ -541,30 +493,25 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
return -1;
}
public void setKnockbackModStrength (float par1)
{
public void setKnockbackModStrength(float par1) {
this.knockbackStrengthMod = par1;
}
@Override
public void writeEntityToNBT (NBTTagCompound tags)
{
public void writeEntityToNBT(NBTTagCompound tags) {
super.writeEntityToNBT(tags);
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
}
@Override
public void readEntityFromNBT (NBTTagCompound tags)
{
public void readEntityFromNBT(NBTTagCompound tags) {
super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
}
@Override
public void writeSpawnData (ByteBuf data)
{
if (!returnStack.hasTagCompound())
this.kill();
public void writeSpawnData(ByteBuf data) {
if (!returnStack.hasTagCompound()) this.kill();
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
ByteBufUtils.writeItemStack(data, returnStack);
data.writeFloat(rotationYaw);
@@ -574,40 +521,32 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
data.writeInt(tags.getInteger("RenderAccessory"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
if (tags.hasKey("Effect1")) effects++;
if (tags.hasKey("Effect2")) effects++;
if (tags.hasKey("Effect3")) effects++;
if (tags.hasKey("Effect4")) effects++;
if (tags.hasKey("Effect5")) effects++;
if (tags.hasKey("Effect6")) effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
switch (effects) {
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteBuf data)
{
public void readSpawnData(ByteBuf data) {
returnStack = ByteBufUtils.readItemStack(data);
rotationYaw = data.readFloat();
mass = data.readFloat();
@@ -616,27 +555,25 @@ public class ArrowEntity extends EntityArrow implements IEntityAdditionalSpawnDa
toolTag.setInteger("RenderHandle", data.readInt());
toolTag.setInteger("RenderHead", data.readInt());
toolTag.setInteger("RenderAccessory", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
switch (data.readInt()) {
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);
}
public ItemStack getEntityItem ()
{
public ItemStack getEntityItem() {
return returnStack;
}
}
@@ -1,16 +1,13 @@
package tconstruct.tools.entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.World;
import tconstruct.items.tools.Dagger;
import tconstruct.library.entity.ProjectileBase;
import tconstruct.library.tools.*;
public class DaggerEntity extends ProjectileBase
{
public class DaggerEntity extends ProjectileBase {
public int roll;
public DaggerEntity(World world) {
@@ -26,31 +23,35 @@ public class DaggerEntity extends ProjectileBase
float pitch = Math.max(-90f, player.rotationPitch - 20f);
// same as in the others, but with pitch upped
this.setLocationAndAngles(player.posX, player.posY + (double)player.getEyeHeight(), player.posZ, player.rotationYaw, pitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.setLocationAndAngles(
player.posX, player.posY + (double) player.getEyeHeight(), player.posZ, player.rotationYaw, pitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.posY -= 0.10000000149011612D;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI);
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI)
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionZ = +MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI)
* MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, speed, accuracy);
}
@Override
public void onUpdate() {
// you turn me right round baby
if(this.ticksInGround == 0)
roll = (roll + 20) % 360;
if (this.ticksInGround == 0) roll = (roll + 20) % 360;
super.onUpdate();
}
@Override
public void onHitEntity(MovingObjectPosition movingobjectposition) {
AbilityHelper.onLeftClickEntity(returnStack, (EntityPlayer)shootingEntity, movingobjectposition.entityHit, (ToolCore)returnStack.getItem());
//super.onHitEntity(movingobjectposition);
AbilityHelper.onLeftClickEntity(
returnStack, (EntityPlayer) shootingEntity, movingobjectposition.entityHit, (ToolCore)
returnStack.getItem());
// super.onHitEntity(movingobjectposition);
}
@Override
@@ -6,31 +6,28 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class FancyEntityItem extends EntityItem
{
public FancyEntityItem(World par1World, double par2, double par4, double par6)
{
public class FancyEntityItem extends EntityItem {
public FancyEntityItem(World par1World, double par2, double par4, double par6) {
super(par1World, par2, par4, par6);
this.isImmuneToFire = true;
this.lifespan = 72000;
}
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
public FancyEntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) {
this(par1World, par2, par4, par6);
this.setEntityItemStack(par8ItemStack);
this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
this.lifespan = (par8ItemStack.getItem() == null
? 6000
: par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World));
}
public FancyEntityItem(World par1World)
{
public FancyEntityItem(World par1World) {
super(par1World);
this.isImmuneToFire = true;
this.lifespan = 72000;
}
public FancyEntityItem(World world, Entity original, ItemStack stack)
{
public FancyEntityItem(World world, Entity original, ItemStack stack) {
this(world, original.posX, original.posY, original.posZ);
this.delayBeforeCanPickup = 20;
this.motionX = original.motionX;
@@ -39,10 +36,8 @@ public class FancyEntityItem extends EntityItem
this.setEntityItemStack(stack);
}
public boolean attackEntityFrom (DamageSource par1DamageSource, float par2)
{
if (par1DamageSource.getDamageType().equals("outOfWorld"))
return true;
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
if (par1DamageSource.getDamageType().equals("outOfWorld")) return true;
return false;
}
}
@@ -11,37 +11,31 @@ import net.minecraft.potion.*;
import net.minecraft.util.*;
import net.minecraft.world.World;
public class LaunchedPotion extends EntityThrowable
{
public class LaunchedPotion extends EntityThrowable {
/**
* The damage value of the thrown potion that this EntityPotion represents.
*/
private ItemStack potionDamage;
public LaunchedPotion(World par1World)
{
public LaunchedPotion(World par1World) {
super(par1World);
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3)
{
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, int par3) {
this(par1World, par2EntityLiving, new ItemStack(Items.potionitem, 1, par3));
}
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack)
{
public LaunchedPotion(World par1World, EntityLivingBase par2EntityLiving, ItemStack par3ItemStack) {
super(par1World, par2EntityLiving);
this.potionDamage = par3ItemStack;
}
@SideOnly(Side.CLIENT)
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8)
{
public LaunchedPotion(World par1World, double par2, double par4, double par6, int par8) {
this(par1World, par2, par4, par6, new ItemStack(Items.potionitem, 1, par8));
}
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack)
{
public LaunchedPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) {
super(par1World, par2, par4, par6);
this.potionDamage = par8ItemStack;
}
@@ -50,27 +44,22 @@ public class LaunchedPotion extends EntityThrowable
* Gets the amount of gravity to apply to the thrown entity with each tick.
*/
@Override
protected float getGravityVelocity ()
{
protected float getGravityVelocity() {
return 0.05F;
}
@Override
protected float func_70182_d ()
{
protected float func_70182_d() {
return 1.0F;
}
@Override
protected float func_70183_g ()
{
protected float func_70183_g() {
return -10.0F;
}
public void setPotionDamage (int par1)
{
if (this.potionDamage == null)
{
public void setPotionDamage(int par1) {
if (this.potionDamage == null) {
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
}
@@ -81,10 +70,8 @@ public class LaunchedPotion extends EntityThrowable
* Returns the damage value of the thrown potion that this EntityPotion
* represents.
*/
public int getPotionDamage ()
{
if (this.potionDamage == null)
{
public int getPotionDamage() {
if (this.potionDamage == null) {
this.potionDamage = new ItemStack(Items.potionitem, 1, 0);
}
@@ -95,53 +82,43 @@ public class LaunchedPotion extends EntityThrowable
* Called when this EntityThrowable hits a block or entity.
*/
@Override
protected void onImpact (MovingObjectPosition par1MovingObjectPosition)
{
if (!this.worldObj.isRemote)
{
protected void onImpact(MovingObjectPosition par1MovingObjectPosition) {
if (!this.worldObj.isRemote) {
List list = Items.potionitem.getEffects(this.potionDamage);
if (list != null && !list.isEmpty())
{
if (list != null && !list.isEmpty()) {
AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
if (list1 != null && !list1.isEmpty())
{
if (list1 != null && !list1.isEmpty()) {
Iterator iterator = list1.iterator();
while (iterator.hasNext())
{
while (iterator.hasNext()) {
EntityLivingBase entityliving = (EntityLivingBase) iterator.next();
double d0 = this.getDistanceSqToEntity(entityliving);
if (d0 < 16.0D)
{
if (d0 < 16.0D) {
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
if (entityliving == par1MovingObjectPosition.entityHit)
{
if (entityliving == par1MovingObjectPosition.entityHit) {
d1 = 1.0D;
}
Iterator iterator1 = list.iterator();
while (iterator1.hasNext())
{
while (iterator1.hasNext()) {
PotionEffect potioneffect = (PotionEffect) iterator1.next();
int i = potioneffect.getPotionID();
if (Potion.potionTypes[i].isInstant())
{
Potion.potionTypes[i].affectEntity(this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
}
else
{
if (Potion.potionTypes[i].isInstant()) {
Potion.potionTypes[i].affectEntity(
this.getThrower(), entityliving, potioneffect.getAmplifier(), d1);
} else {
int j = (int) (d1 * (double) potioneffect.getDuration() + 0.5D);
if (j > 20)
{
entityliving.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
if (j > 20) {
entityliving.addPotionEffect(
new PotionEffect(i, j, potioneffect.getAmplifier()));
}
}
}
@@ -150,7 +127,12 @@ public class LaunchedPotion extends EntityThrowable
}
}
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionDamage());
this.worldObj.playAuxSFX(
2002,
(int) Math.round(this.posX),
(int) Math.round(this.posY),
(int) Math.round(this.posZ),
this.getPotionDamage());
this.setDead();
}
}
@@ -159,21 +141,16 @@ public class LaunchedPotion extends EntityThrowable
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT (NBTTagCompound par1NBTTagCompound)
{
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
super.readEntityFromNBT(par1NBTTagCompound);
if (par1NBTTagCompound.hasKey("Potion"))
{
if (par1NBTTagCompound.hasKey("Potion")) {
this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion"));
}
else
{
} else {
this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue"));
}
if (this.potionDamage == null)
{
if (this.potionDamage == null) {
this.setDead();
}
}
@@ -182,12 +159,10 @@ public class LaunchedPotion extends EntityThrowable
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT (NBTTagCompound par1NBTTagCompound)
{
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
super.writeEntityToNBT(par1NBTTagCompound);
if (this.potionDamage != null)
{
if (this.potionDamage != null) {
par1NBTTagCompound.setTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound()));
}
}
@@ -15,11 +15,9 @@ import net.minecraft.world.World;
import tconstruct.library.tools.AbilityHelper;
@Deprecated
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
{
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData {
public RotatingBase(World world)
{
public RotatingBase(World world) {
super(world);
texID = 0;
tex2ID = 16 * 3;
@@ -38,24 +36,28 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
setSize(0.5F, 0.5F);
}
public RotatingBase(World world, double d, double d1, double d2)
{
public RotatingBase(World world, double d, double d1, double d2) {
this(world);
setPosition(d, d1, d2);
yOffset = 0.0F;
}
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1)
{
public RotatingBase(World world, EntityPlayer entityliving, float f, float f1) {
this(world);
owner = entityliving;
setLocationAndAngles(entityliving.posX, entityliving.posY + (double) entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch);
setLocationAndAngles(
entityliving.posX,
entityliving.posY + (double) entityliving.getEyeHeight(),
entityliving.posZ,
entityliving.rotationYaw,
entityliving.rotationPitch);
posX -= MathHelper.cos((rotationYaw / 180F) * 3.141593F) * 0.16F;
posY -= 0.10000000149011612D;
posZ -= MathHelper.sin((rotationYaw / 180F) * 3.141593F) * 0.16F;
setPosition(posX, posY, posZ);
yOffset = 0.0F;
motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionX =
-MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F);
motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F - 0.2f);
setArrowHeading(motionX, motionY, motionZ, f, f1);
@@ -65,26 +67,20 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* public void setOnGround(boolean flag) { onGround = flag;
* this.dataWatcher.updateObject(6, Byte.valueOf((byte) (flag == true ? 1 :
* 0))); }
*
*
* public boolean getOnGround() { return
* this.dataWatcher.getWatchableObjectByte(0) == 1 ? true : false; }
*/
@Override
protected void entityInit ()
{
}
protected void entityInit() {}
public void damageItem (int i, boolean flag)
{
if (!flag)
{
public void damageItem(int i, boolean flag) {
if (!flag) {
return;
}
if (returnStack.stackSize < 1)
{
for (int j = 0; j < 8; j++)
{
if (returnStack.stackSize < 1) {
for (int j = 0; j < 8; j++) {
worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
}
@@ -100,19 +96,15 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true); } }
*/
public void determineRotation ()
{
public void determineRotation() {
rotationPitch = -57.29578F * (float) Math.atan2(motionY, motionX);
double d = Math.sqrt((double) (rotationYaw * rotationYaw) + motionY * motionY);
prevRotationYaw = -57.29578F * (float) Math.atan2(motionZ, d);
}
public void onHit (MovingObjectPosition movingobjectposition)
{
}
public void onHit(MovingObjectPosition movingobjectposition) {}
public void setArrowHeading (double d, double d1, double d2, float f, float f1)
{
public void setArrowHeading(double d, double d1, double d2, float f, float f1) {
float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2);
d /= f2;
d1 /= f2;
@@ -133,13 +125,11 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void setVelocity (double d, double d1, double d2)
{
public void setVelocity(double d, double d1, double d2) {
motionX = d;
motionY = d1;
motionZ = d2;
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(d * d + d2 * d2);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f) * 180D) / 3.1415927410125732D);
@@ -147,33 +137,26 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void onUpdate ()
{
public void onUpdate() {
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
{
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
}
if (arrowShake > 0)
{
if (arrowShake > 0) {
arrowShake--;
}
if (onGround)
{
if (onGround) {
Block i = worldObj.getBlock(xTile, yTile, zTile);
if (i != inTile)
{
if (i != inTile) {
onGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
}
else
{
} else {
/*
* this.motionX = 0; this.motionY = 0; this.motionZ = 0;
*/
@@ -181,17 +164,14 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
* ticksInGround++; if (ticksInGround == 1200) { setDead(); } if
* (ticksInGround == maxGroundTicks) { setDead(); }
*/
if (!hasHitGround)
{
if (!hasHitGround) {
hasHitGround = true;
damageItem(1, true);
}
return;
}
return;
}
else
{
} else {
ticksInAir++;
}
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
@@ -199,42 +179,39 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null)
{
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(
movingobjectposition.hitVec.xCoord,
movingobjectposition.hitVec.yCoord,
movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
List list = worldObj.getEntitiesWithinAABBExcludingEntity(
this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++)
{
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5)
{
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) {
continue;
}
float f3 = 0.3F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f3, f3, f3);
MovingObjectPosition movingobjectposition2 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition2 == null)
{
if (movingobjectposition2 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition2.hitVec);
if (d1 < d || d == 0.0D)
{
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null)
{
if (entity != null) {
MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity);
onHit(movingobjectposition1);
}
if (movingobjectposition != null)
{
if (movingobjectposition != null) {
onHit(movingobjectposition);
}
posX += motionX;
@@ -242,28 +219,27 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
posZ += motionZ;
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F)
{
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F)
{
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F)
{
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F)
{
}
for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D);
rotationPitch - prevRotationPitch < -180F;
prevRotationPitch -= 360F) {}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f2 = 0.99F;
float f4 = 0.03F;
if (isInWater())
{
for (int k = 0; k < 4; k++)
{
if (isInWater()) {
for (int k = 0; k < 4; k++) {
float f5 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ);
worldObj.spawnParticle(
"bubble",
posX - motionX * (double) f5,
posY - motionY * (double) f5,
posZ - motionZ * (double) f5,
motionX,
motionY,
motionZ);
}
f2 = 0.8F;
@@ -273,37 +249,33 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
motionZ *= f2;
motionY -= f4;
setPosition(posX, posY, posZ);
if (!onGround)
{
if (!onGround) {
prevBoomerangRotation = boomerangRotation;
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F)
{
}
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F) {}
}
}
/*
* public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
* super.readEntityFromNBT(par1NBTTagCompound);
*
*
* if (par1NBTTagCompound.hasKey("Potion")) { this.potionDamage =
* ItemStack.loadItemStackFromNBT
* (par1NBTTagCompound.getCompoundTag("Potion")); } else {
* this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); }
*
*
* if (this.potionDamage == null) { this.setDead(); } }
*
*
* public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
* super.writeEntityToNBT(par1NBTTagCompound);
*
*
* if (this.potionDamage != null) {
*
*
* } }
*/
@Override
public void writeEntityToNBT (NBTTagCompound tags)
{
public void writeEntityToNBT(NBTTagCompound tags) {
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
tags.setShort("xTile", (short) xTile);
tags.setShort("yTile", (short) yTile);
@@ -315,8 +287,7 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void readEntityFromNBT (NBTTagCompound tags)
{
public void readEntityFromNBT(NBTTagCompound tags) {
// super.readEntityFromNBT(tags);
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
@@ -331,39 +302,32 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
}
@Override
public void onCollideWithPlayer (EntityPlayer entityplayer)
{
public void onCollideWithPlayer(EntityPlayer entityplayer) {
onCollideWithPlayer(entityplayer, true);
}
public void onCollideWithPlayer (EntityPlayer entityplayer, boolean flag)
{
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote)
{
public void onCollideWithPlayer(EntityPlayer entityplayer, boolean flag) {
if (returnStack == null || returnStack.stackSize == 0 || worldObj.isRemote) {
return;
}
if (!flag || onGround && arrowShake <= 0)
{
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer)
{
if (!flag || onGround && arrowShake <= 0) {
if (!flag || returnsTo != null && !returnsTo.isDead && returnsTo != entityplayer) {
return;
}
if (!doNotRetrieve)
AbilityHelper.addToInv(entityplayer, returnStack, true);
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (!doNotRetrieve) AbilityHelper.addToInv(entityplayer, returnStack, true);
worldObj.playSoundAtEntity(
this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityplayer.onItemPickup(this, 1);
kill();
}
}
@Override
public float getShadowSize ()
{
public float getShadowSize() {
return 0.0F;
}
public ItemStack getEntityItem ()
{
public ItemStack getEntityItem() {
return returnStack;
}
@@ -391,8 +355,7 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
public boolean doNotRetrieve;
@Override
public void writeSpawnData (ByteBuf data)
{
public void writeSpawnData(ByteBuf data) {
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
ByteBufUtils.writeItemStack(data, returnStack);
data.writeFloat(rotationYaw);
@@ -402,40 +365,32 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
data.writeInt(tags.getInteger("RenderExtra"));
int effects = 0;
if (tags.hasKey("Effect1"))
effects++;
if (tags.hasKey("Effect2"))
effects++;
if (tags.hasKey("Effect3"))
effects++;
if (tags.hasKey("Effect4"))
effects++;
if (tags.hasKey("Effect5"))
effects++;
if (tags.hasKey("Effect6"))
effects++;
if (tags.hasKey("Effect1")) effects++;
if (tags.hasKey("Effect2")) effects++;
if (tags.hasKey("Effect3")) effects++;
if (tags.hasKey("Effect4")) effects++;
if (tags.hasKey("Effect5")) effects++;
if (tags.hasKey("Effect6")) effects++;
data.writeInt(effects);
switch (effects)
{
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
switch (effects) {
case 6:
data.writeInt(tags.getInteger("Effect6"));
case 5:
data.writeInt(tags.getInteger("Effect5"));
case 4:
data.writeInt(tags.getInteger("Effect4"));
case 3:
data.writeInt(tags.getInteger("Effect3"));
case 2:
data.writeInt(tags.getInteger("Effect2"));
case 1:
data.writeInt(tags.getInteger("Effect1"));
}
}
@Override
public void readSpawnData (ByteBuf data)
{
public void readSpawnData(ByteBuf data) {
returnStack = ByteBufUtils.readItemStack(data);
rotationYaw = data.readFloat();
NBTTagCompound compound = new NBTTagCompound();
@@ -445,20 +400,19 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
toolTag.setInteger("RenderAccessory", data.readInt());
toolTag.setInteger("RenderExtra", data.readInt());
switch (data.readInt())
{
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
switch (data.readInt()) {
case 6:
toolTag.setInteger("Effect6", data.readInt());
case 5:
toolTag.setInteger("Effect5", data.readInt());
case 4:
toolTag.setInteger("Effect4", data.readInt());
case 3:
toolTag.setInteger("Effect3", data.readInt());
case 2:
toolTag.setInteger("Effect2", data.readInt());
case 1:
toolTag.setInteger("Effect1", data.readInt());
}
compound.setTag("InfiTool", toolTag);
returnStack.setTagCompound(compound);