2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.entity.projectile;
|
|
|
|
|
|
2014-01-10 17:03:06 -05:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-01-21 18:01:00 -05:00
|
|
|
import net.minecraft.block.Block;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-01-21 18:01:00 -05:00
|
|
|
import net.minecraft.init.Blocks;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
|
import net.minecraft.world.World;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.library.tools.AbilityHelper;
|
2014-02-02 11:35:00 -05:00
|
|
|
import cpw.mods.fml.common.network.ByteBufUtils;
|
2013-07-26 21:18:53 -07:00
|
|
|
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
|
|
|
|
|
|
|
|
|
public class RotatingBase extends Entity implements IEntityAdditionalSpawnData
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public RotatingBase(World world)
|
|
|
|
|
{
|
|
|
|
|
super(world);
|
|
|
|
|
texID = 0;
|
|
|
|
|
tex2ID = 16 * 3;
|
|
|
|
|
returnStackSlot = -1;
|
|
|
|
|
hasHitGround = false;
|
|
|
|
|
hasHitMob = false;
|
|
|
|
|
damageDealt = 4;
|
|
|
|
|
maxGroundTicks = 2400;
|
|
|
|
|
xTile = -1;
|
|
|
|
|
yTile = -1;
|
|
|
|
|
zTile = -1;
|
2014-01-21 18:01:00 -05:00
|
|
|
inTile = Blocks.air;
|
2013-07-26 21:18:53 -07:00
|
|
|
onGround = false;
|
|
|
|
|
arrowShake = 0;
|
|
|
|
|
ticksInAir = 0;
|
|
|
|
|
setSize(0.5F, 0.5F);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
this(world);
|
|
|
|
|
owner = entityliving;
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* 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; }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void entityInit ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void damageItem (int i, boolean flag)
|
|
|
|
|
{
|
|
|
|
|
if (!flag)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (returnStack.stackSize < 1)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < 8; j++)
|
|
|
|
|
{
|
|
|
|
|
worldObj.spawnParticle("snowballpoof", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// kill();
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
2014-02-16 14:23:50 -05:00
|
|
|
* public void returnToPlayer() { damageDagger(0, true);
|
|
|
|
|
* if(returnStack.stackSize < 1) { return; } if(returnStackSlot > 0) {
|
|
|
|
|
* mod_Infi2x2.forceAddToInv((EntityPlayer)returnsTo, returnStack,
|
|
|
|
|
* returnStackSlot, true); } else {
|
|
|
|
|
* mod_Infi2x2.addToInv((EntityPlayer)returnsTo, returnStack, true); } }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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 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;
|
|
|
|
|
d2 /= f2;
|
|
|
|
|
d += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
|
|
|
|
d1 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
|
|
|
|
d2 += rand.nextGaussian() * 0.0074999998323619366D * (double) f1;
|
|
|
|
|
d *= f;
|
|
|
|
|
d1 *= f;
|
|
|
|
|
d2 *= f;
|
|
|
|
|
motionX = d;
|
|
|
|
|
motionY = d1;
|
|
|
|
|
motionZ = d2;
|
|
|
|
|
float f3 = MathHelper.sqrt_double(d * d + d2 * d2);
|
|
|
|
|
prevRotationYaw = rotationYaw = (float) ((Math.atan2(d, d2) * 180D) / 3.1415927410125732D);
|
|
|
|
|
prevRotationPitch = rotationPitch = (float) ((Math.atan2(d1, f3) * 180D) / 3.1415927410125732D);
|
|
|
|
|
ticksInGround = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setVelocity (double d, double d1, double d2)
|
|
|
|
|
{
|
|
|
|
|
motionX = d;
|
|
|
|
|
motionY = d1;
|
|
|
|
|
motionZ = d2;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onUpdate ()
|
|
|
|
|
{
|
|
|
|
|
super.onUpdate();
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
arrowShake--;
|
|
|
|
|
}
|
|
|
|
|
if (onGround)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
Block i = worldObj.getBlock(xTile, yTile, zTile);
|
2013-07-26 21:18:53 -07:00
|
|
|
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
|
|
|
|
|
{
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* this.motionX = 0; this.motionY = 0; this.motionZ = 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* ticksInGround++; if (ticksInGround == 1200) { setDead(); } if
|
|
|
|
|
* (ticksInGround == maxGroundTicks) { setDead(); }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
if (!hasHitGround)
|
|
|
|
|
{
|
|
|
|
|
hasHitGround = true;
|
|
|
|
|
damageItem(1, true);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ticksInAir++;
|
|
|
|
|
}
|
|
|
|
|
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
|
|
|
|
|
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
2014-02-05 10:22:35 -05:00
|
|
|
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
|
2013-07-26 21:18:53 -07:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
Entity entity = null;
|
|
|
|
|
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++)
|
|
|
|
|
{
|
|
|
|
|
Entity entity1 = (Entity) list.get(j);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
double d1 = vec3d.distanceTo(movingobjectposition2.hitVec);
|
|
|
|
|
if (d1 < d || d == 0.0D)
|
|
|
|
|
{
|
|
|
|
|
entity = entity1;
|
|
|
|
|
d = d1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (entity != null)
|
|
|
|
|
{
|
|
|
|
|
MovingObjectPosition movingobjectposition1 = new MovingObjectPosition(entity);
|
|
|
|
|
onHit(movingobjectposition1);
|
|
|
|
|
}
|
|
|
|
|
if (movingobjectposition != null)
|
|
|
|
|
{
|
|
|
|
|
onHit(movingobjectposition);
|
|
|
|
|
}
|
|
|
|
|
posX += motionX;
|
|
|
|
|
posY += motionY;
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
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++)
|
|
|
|
|
{
|
|
|
|
|
float f5 = 0.25F;
|
|
|
|
|
worldObj.spawnParticle("bubble", posX - motionX * (double) f5, posY - motionY * (double) f5, posZ - motionZ * (double) f5, motionX, motionY, motionZ);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
f2 = 0.8F;
|
|
|
|
|
}
|
|
|
|
|
motionX *= f2;
|
|
|
|
|
motionY *= f2;
|
|
|
|
|
motionZ *= f2;
|
|
|
|
|
motionY -= f4;
|
|
|
|
|
setPosition(posX, posY, posZ);
|
|
|
|
|
if (!onGround)
|
|
|
|
|
{
|
|
|
|
|
prevBoomerangRotation = boomerangRotation;
|
|
|
|
|
for (boomerangRotation += 36F; boomerangRotation > 360F; boomerangRotation -= 360F)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* 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) {
|
|
|
|
|
*
|
|
|
|
|
* } }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public void writeEntityToNBT (NBTTagCompound tags)
|
|
|
|
|
{
|
2014-01-10 17:03:06 -05:00
|
|
|
tags.setTag("Throwable", this.returnStack.writeToNBT(new NBTTagCompound()));
|
2013-07-26 21:18:53 -07:00
|
|
|
tags.setShort("xTile", (short) xTile);
|
|
|
|
|
tags.setShort("yTile", (short) yTile);
|
|
|
|
|
tags.setShort("zTile", (short) zTile);
|
2014-02-05 08:28:53 -05:00
|
|
|
tags.setString("inTile", (String) inTile.getUnlocalizedName());
|
2013-07-26 21:18:53 -07:00
|
|
|
tags.setByte("shake", (byte) arrowShake);
|
|
|
|
|
tags.setByte("onGround", (byte) (onGround ? 1 : 0));
|
2013-08-27 18:11:13 -07:00
|
|
|
tags.setBoolean("Retrieval", doNotRetrieve);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public void readEntityFromNBT (NBTTagCompound tags)
|
|
|
|
|
{
|
2014-02-16 14:23:50 -05:00
|
|
|
// super.readEntityFromNBT(tags);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
this.returnStack = ItemStack.loadItemStackFromNBT(tags.getCompoundTag("Throwable"));
|
|
|
|
|
xTile = tags.getShort("xTile");
|
|
|
|
|
yTile = tags.getShort("yTile");
|
|
|
|
|
zTile = tags.getShort("zTile");
|
2014-02-16 14:23:50 -05:00
|
|
|
// TODO fix this\/
|
|
|
|
|
// inTile = tags.getString("inTile");
|
2013-07-26 21:18:53 -07:00
|
|
|
arrowShake = tags.getByte("shake") & 0xff;
|
|
|
|
|
onGround = tags.getByte("onGround") == 1;
|
2013-08-27 18:11:13 -07:00
|
|
|
doNotRetrieve = tags.getBoolean("Retrieval");
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public void onCollideWithPlayer (EntityPlayer entityplayer)
|
|
|
|
|
{
|
|
|
|
|
onCollideWithPlayer(entityplayer, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-08-27 18:11:13 -07:00
|
|
|
if (!doNotRetrieve)
|
|
|
|
|
AbilityHelper.addToInv(entityplayer, returnStack, true);
|
2013-07-26 21:18:53 -07:00
|
|
|
worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
|
|
|
|
entityplayer.onItemPickup(this, 1);
|
|
|
|
|
kill();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public float getShadowSize ()
|
|
|
|
|
{
|
|
|
|
|
return 0.0F;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemStack getEntityItem ()
|
|
|
|
|
{
|
|
|
|
|
return returnStack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int age = 0;
|
|
|
|
|
public int hoverStart = 0;
|
|
|
|
|
public int texID;
|
|
|
|
|
public int tex2ID;
|
|
|
|
|
public ItemStack returnStack;
|
|
|
|
|
public int returnStackSlot;
|
|
|
|
|
public boolean hasHitGround;
|
|
|
|
|
public boolean hasHitMob;
|
|
|
|
|
public float prevBoomerangRotation;
|
|
|
|
|
public float boomerangRotation;
|
|
|
|
|
public Entity returnsTo;
|
|
|
|
|
public int damageDealt;
|
|
|
|
|
public int maxGroundTicks;
|
|
|
|
|
protected int xTile;
|
|
|
|
|
protected int yTile;
|
|
|
|
|
protected int zTile;
|
2014-01-21 18:01:00 -05:00
|
|
|
protected Block inTile;
|
2013-07-26 21:18:53 -07:00
|
|
|
public int arrowShake;
|
|
|
|
|
public EntityPlayer owner;
|
|
|
|
|
protected int ticksInGround;
|
|
|
|
|
protected int ticksInAir;
|
2013-08-27 18:11:13 -07:00
|
|
|
public boolean doNotRetrieve;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
@Override
|
2014-01-10 17:03:06 -05:00
|
|
|
public void writeSpawnData (ByteBuf data)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
|
2014-02-02 11:35:00 -05:00
|
|
|
ByteBufUtils.writeItemStack(data, returnStack);
|
2013-07-26 21:18:53 -07:00
|
|
|
data.writeFloat(rotationYaw);
|
|
|
|
|
data.writeInt(tags.getInteger("RenderHandle"));
|
|
|
|
|
data.writeInt(tags.getInteger("RenderHead"));
|
|
|
|
|
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++;
|
|
|
|
|
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"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-01-10 17:03:06 -05:00
|
|
|
public void readSpawnData (ByteBuf data)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-02-02 11:35:00 -05:00
|
|
|
returnStack = ByteBufUtils.readItemStack(data);
|
2013-07-26 21:18:53 -07:00
|
|
|
rotationYaw = data.readFloat();
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
NBTTagCompound toolTag = new NBTTagCompound();
|
|
|
|
|
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());
|
|
|
|
|
}
|
2014-01-10 17:03:06 -05:00
|
|
|
compound.setTag("InfiTool", toolTag);
|
2013-07-26 21:18:53 -07:00
|
|
|
returnStack.setTagCompound(compound);
|
|
|
|
|
}
|
|
|
|
|
}
|