Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.examplemod.entity;
- import java.util.Arrays;
- import java.util.List;
- import net.minecraft.block.Block;
- import net.minecraft.block.material.Material;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.entity.item.EntityXPOrb;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityFishHook;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.Items;
- import net.minecraft.item.ItemFishFood;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.stats.StatList;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.MovingObjectPosition;
- import net.minecraft.util.Vec3;
- import net.minecraft.util.WeightedRandom;
- import net.minecraft.util.WeightedRandomFishable;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldServer;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- public class EntityExampleFishHook extends EntityFishHook
- {
- @SuppressWarnings("rawtypes")
- private static final List trashCatches = Arrays.asList(new WeightedRandomFishable[] {(new WeightedRandomFishable(new ItemStack(Items.leather_boots), 10)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.leather), 10), new WeightedRandomFishable(new ItemStack(Items.bone), 10), new WeightedRandomFishable(new ItemStack(Items.potionitem), 10), new WeightedRandomFishable(new ItemStack(Items.string), 5), (new WeightedRandomFishable(new ItemStack(Items.fishing_rod), 2)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.bowl), 10), new WeightedRandomFishable(new ItemStack(Items.stick), 5), new WeightedRandomFishable(new ItemStack(Items.dye, 10, 0), 1), new WeightedRandomFishable(new ItemStack(Blocks.tripwire_hook), 10), new WeightedRandomFishable(new ItemStack(Items.rotten_flesh), 10)});
- @SuppressWarnings("rawtypes")
- private static final List treasureCatches = Arrays.asList(new WeightedRandomFishable[] {new WeightedRandomFishable(new ItemStack(Blocks.waterlily), 1), new WeightedRandomFishable(new ItemStack(Items.name_tag), 1), new WeightedRandomFishable(new ItemStack(Items.saddle), 1), (new WeightedRandomFishable(new ItemStack(Items.bow), 1)).func_150709_a(0.25F).func_150707_a(), (new WeightedRandomFishable(new ItemStack(Items.fishing_rod), 1)).func_150709_a(0.25F).func_150707_a(), (new WeightedRandomFishable(new ItemStack(Items.book), 1)).func_150707_a()});
- @SuppressWarnings("rawtypes")
- private static final List fishCatches = Arrays.asList(new WeightedRandomFishable[] {new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.func_150976_a()), 60), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.SALMON.func_150976_a()), 25), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.CLOWNFISH.func_150976_a()), 2), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.PUFFERFISH.func_150976_a()), 13)});
- private int xTile;
- private int yTile;
- private int zTile;
- private Block tileID;
- private boolean inGround;
- public int shakeTime;
- public EntityPlayer playerObj;
- private int groundTime;
- private int airTime;
- private int hasCatchedFish;
- private int fishSpeed;
- private int hookedTicks;
- private float swayTicks;
- public Entity hookedEntity;
- private int thrownDirection;
- private double headedX;
- private double headedY;
- private double headedZ;
- private double renderYaw;
- private double renderPitch;
- @SideOnly(Side.CLIENT)
- private double velocityX;
- @SideOnly(Side.CLIENT)
- private double velocityY;
- @SideOnly(Side.CLIENT)
- private double velocityZ;
- public EntityExampleFishHook(World par1World)
- {
- super(par1World);
- this.xTile = -1;
- this.yTile = -1;
- this.zTile = -1;
- this.setSize(0.25F, 0.25F);
- this.ignoreFrustumCheck = true;
- }
- @SideOnly(Side.CLIENT)
- public EntityExampleFishHook(World par1World, double par2, double par4, double par6, EntityPlayer par8EntityPlayer)
- {
- this(par1World);
- this.setPosition(par2, par4, par6);
- this.ignoreFrustumCheck = true;
- this.playerObj = par8EntityPlayer;
- par8EntityPlayer.fishEntity = this;
- }
- public EntityExampleFishHook(World par1World, EntityPlayer par2EntityPlayer)
- {
- super(par1World);
- this.xTile = -1;
- this.yTile = -1;
- this.zTile = -1;
- this.ignoreFrustumCheck = true;
- this.playerObj = par2EntityPlayer;
- this.playerObj.fishEntity = this;
- this.setSize(0.25F, 0.25F);
- this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + 1.62D - (double)par2EntityPlayer.yOffset, par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
- this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
- this.posY -= 0.10000000149011612D;
- this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
- this.setPosition(this.posX, this.posY, this.posZ);
- this.yOffset = 0.0F;
- float f = 0.4F;
- this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
- this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
- this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f);
- this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F);
- }
- protected void entityInit() {}
- public void setThrowableHeading(double x, double y, double z, float ry, float rp)
- {
- float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);
- x /= (double)f2;
- y /= (double)f2;
- z /= (double)f2;
- x += this.rand.nextGaussian() * 0.007499999832361937D * (double)rp;
- y += this.rand.nextGaussian() * 0.007499999832361937D * (double)rp;
- z += this.rand.nextGaussian() * 0.007499999832361937D * (double)rp;
- x *= (double)ry;
- y *= (double)ry;
- z *= (double)ry;
- this.motionX = x;
- this.motionY = y;
- this.motionZ = z;
- float f3 = MathHelper.sqrt_double(x * x + z * z);
- this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
- this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
- this.groundTime = 0;
- }
- /**
- * 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
- */
- @SideOnly(Side.CLIENT)
- public boolean isInRangeToRenderDist(double par1)
- {
- double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D;
- d1 *= 64.0D;
- return par1 < d1 * d1;
- }
- /**
- * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
- * posY, posZ, yaw, pitch
- */
- @SideOnly(Side.CLIENT)
- public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
- {
- this.headedX = par1;
- this.headedY = par3;
- this.headedZ = par5;
- this.renderYaw = (double)par7;
- this.renderPitch = (double)par8;
- this.thrownDirection = par9;
- this.motionX = this.velocityX;
- this.motionY = this.velocityY;
- this.motionZ = this.velocityZ;
- }
- /**
- * Sets the velocity to the args. Args: x, y, z
- */
- @SideOnly(Side.CLIENT)
- public void setVelocity(double par1, double par3, double par5)
- {
- this.velocityX = this.motionX = par1;
- this.velocityY = this.motionY = par3;
- this.velocityZ = this.motionZ = par5;
- }
- /**
- * Called to update the entity's position/logic.
- */
- @SuppressWarnings("rawtypes")
- public void onUpdate()
- {
- super.onUpdate();
- if (this.thrownDirection > 0)
- {
- double d7 = this.posX + (this.headedX - this.posX) / (double)this.thrownDirection;
- double d8 = this.posY + (this.headedY - this.posY) / (double)this.thrownDirection;
- double d9 = this.posZ + (this.headedZ - this.posZ) / (double)this.thrownDirection;
- double d1 = MathHelper.wrapAngleTo180_double(this.renderYaw - (double)this.rotationYaw);
- this.rotationYaw = (float)((double)this.rotationYaw + d1 / (double)this.thrownDirection);
- this.rotationPitch = (float)((double)this.rotationPitch + (this.renderPitch - (double)this.rotationPitch) / (double)this.thrownDirection);
- --this.thrownDirection;
- this.setPosition(d7, d8, d9);
- this.setRotation(this.rotationYaw, this.rotationPitch);
- }
- else
- {
- if (!this.worldObj.isRemote)
- {
- ItemStack itemstack = this.playerObj.getCurrentEquippedItem();
- if (this.playerObj.isDead || !this.playerObj.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.playerObj) > 1024.0D)
- {
- this.setDead();
- this.playerObj.fishEntity = null;
- return;
- }
- if (this.hookedEntity != null)
- {
- if (!this.hookedEntity.isDead)
- {
- this.posX = this.hookedEntity.posX;
- this.posY = this.hookedEntity.boundingBox.minY + (double)this.hookedEntity.height * 0.8D;
- this.posZ = this.hookedEntity.posZ;
- return;
- }
- this.hookedEntity = null;
- }
- }
- if (this.shakeTime > 0)
- {
- --this.shakeTime;
- }
- if (this.inGround)
- {
- if (this.worldObj.getBlock(this.xTile, this.yTile, this.zTile) == this.tileID)
- {
- ++this.groundTime;
- if (this.groundTime == 1200)
- {
- this.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.groundTime = 0;
- this.airTime = 0;
- }
- else
- {
- ++this.airTime;
- }
- Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
- Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
- MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3);
- vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
- vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
- if (movingobjectposition != null)
- {
- vec3 = 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;
- double d2;
- for (int i = 0; i < list.size(); ++i)
- {
- Entity entity1 = (Entity)list.get(i);
- if (entity1.canBeCollidedWith() && (entity1 != this.playerObj || this.airTime >= 5))
- {
- float f = 0.3F;
- AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f);
- MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec31, vec3);
- if (movingobjectposition1 != null)
- {
- d2 = vec31.distanceTo(movingobjectposition1.hitVec);
- if (d2 < d0 || d0 == 0.0D)
- {
- entity = entity1;
- d0 = d2;
- }
- }
- }
- }
- if (entity != null)
- {
- movingobjectposition = new MovingObjectPosition(entity);
- }
- if (movingobjectposition != null)
- {
- if (movingobjectposition.entityHit != null)
- {
- if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.playerObj), 0.0F))
- {
- this.hookedEntity = movingobjectposition.entityHit;
- }
- }
- else
- {
- this.inGround = true;
- }
- }
- if (!this.inGround)
- {
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
- float f5 = 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)f5) * 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 f6 = 0.92F;
- if (this.onGround || this.isCollidedHorizontally)
- {
- f6 = 0.5F;
- }
- byte b0 = 5;
- double d10 = 0.0D;
- for (int j = 0; j < b0; ++j)
- {
- double d3 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(j + 0) / (double)b0 - 0.125D + 0.125D;
- double d4 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(j + 1) / (double)b0 - 0.125D + 0.125D;
- AxisAlignedBB axisalignedbb1 = AxisAlignedBB.getAABBPool().getAABB(this.boundingBox.minX, d3, this.boundingBox.minZ, this.boundingBox.maxX, d4, this.boundingBox.maxZ);
- if (this.worldObj.isAABBInMaterial(axisalignedbb1, Material.water))
- {
- d10 += 1.0D / (double)b0;
- }
- }
- if (!this.worldObj.isRemote && d10 > 0.0D)
- {
- WorldServer worldserver = (WorldServer)this.worldObj;
- int k = 1;
- if (this.rand.nextFloat() < 0.25F && this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ)))
- {
- k = 2;
- }
- if (this.rand.nextFloat() < 0.5F && !this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ)))
- {
- --k;
- }
- if (this.hasCatchedFish > 0)
- {
- --this.hasCatchedFish;
- if (this.hasCatchedFish <= 0)
- {
- this.fishSpeed = 0;
- this.hookedTicks = 0;
- }
- }
- else
- {
- float f1;
- float f2;
- double d5;
- double d6;
- float f7;
- double d11;
- if (this.hookedTicks > 0)
- {
- this.hookedTicks -= k;
- if (this.hookedTicks <= 0)
- {
- this.motionY -= 0.20000000298023224D;
- this.playSound("random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
- f1 = (float)MathHelper.floor_double(this.boundingBox.minY);
- worldserver.func_147487_a("bubble", this.posX, (double)(f1 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D);
- worldserver.func_147487_a("wake", this.posX, (double)(f1 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D);
- this.hasCatchedFish = MathHelper.getRandomIntegerInRange(this.rand, 10, 30);
- }
- else
- {
- this.swayTicks = (float)((double)this.swayTicks + this.rand.nextGaussian() * 4.0D);
- f1 = this.swayTicks * 0.017453292F;
- f7 = MathHelper.sin(f1);
- f2 = MathHelper.cos(f1);
- d11 = this.posX + (double)(f7 * (float)this.hookedTicks * 0.1F);
- d5 = (double)((float)MathHelper.floor_double(this.boundingBox.minY) + 1.0F);
- d6 = this.posZ + (double)(f2 * (float)this.hookedTicks * 0.1F);
- if (this.rand.nextFloat() < 0.15F)
- {
- worldserver.func_147487_a("bubble", d11, d5 - 0.10000000149011612D, d6, 1, (double)f7, 0.1D, (double)f2, 0.0D);
- }
- float f3 = f7 * 0.04F;
- float f4 = f2 * 0.04F;
- worldserver.func_147487_a("wake", d11, d5, d6, 0, (double)f4, 0.01D, (double)(-f3), 1.0D);
- worldserver.func_147487_a("wake", d11, d5, d6, 0, (double)(-f4), 0.01D, (double)f3, 1.0D);
- }
- }
- else if (this.fishSpeed > 0)
- {
- this.fishSpeed -= k;
- f1 = 0.15F;
- if (this.fishSpeed < 20)
- {
- f1 = (float)((double)f1 + (double)(20 - this.fishSpeed) * 0.05D);
- }
- else if (this.fishSpeed < 40)
- {
- f1 = (float)((double)f1 + (double)(40 - this.fishSpeed) * 0.02D);
- }
- else if (this.fishSpeed < 60)
- {
- f1 = (float)((double)f1 + (double)(60 - this.fishSpeed) * 0.01D);
- }
- if (this.rand.nextFloat() < f1)
- {
- f7 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F;
- f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F);
- d11 = this.posX + (double)(MathHelper.sin(f7) * f2 * 0.1F);
- d5 = (double)((float)MathHelper.floor_double(this.boundingBox.minY) + 1.0F);
- d6 = this.posZ + (double)(MathHelper.cos(f7) * f2 * 0.1F);
- worldserver.func_147487_a("splash", d11, d5, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D);
- }
- if (this.fishSpeed <= 0)
- {
- this.swayTicks = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F);
- this.hookedTicks = MathHelper.getRandomIntegerInRange(this.rand, 20, 80);
- }
- }
- else
- {
- this.fishSpeed = MathHelper.getRandomIntegerInRange(this.rand, 100, 900);
- this.fishSpeed -= EnchantmentHelper.func_151387_h(this.playerObj) * 20 * 5;
- }
- }
- if (this.hasCatchedFish > 0)
- {
- this.motionY -= (double)(this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat()) * 0.2D;
- }
- }
- d2 = d10 * 2.0D - 1.0D;
- this.motionY += 0.03999999910593033D * d2;
- if (d10 > 0.0D)
- {
- f6 = (float)((double)f6 * 0.9D);
- this.motionY *= 0.8D;
- }
- this.motionX *= (double)f6;
- this.motionY *= (double)f6;
- this.motionZ *= (double)f6;
- this.setPosition(this.posX, this.posY, this.posZ);
- }
- }
- }
- /**
- * (abstract) Protected helper method to write subclass entity data to NBT.
- */
- public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
- {
- par1NBTTagCompound.setShort("xTile", (short)this.xTile);
- par1NBTTagCompound.setShort("yTile", (short)this.yTile);
- par1NBTTagCompound.setShort("zTile", (short)this.zTile);
- par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.tileID));
- par1NBTTagCompound.setByte("shake", (byte)this.shakeTime);
- par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
- }
- /**
- * (abstract) Protected helper method to read subclass entity data from NBT.
- */
- public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
- {
- this.xTile = par1NBTTagCompound.getShort("xTile");
- this.yTile = par1NBTTagCompound.getShort("yTile");
- this.zTile = par1NBTTagCompound.getShort("zTile");
- this.tileID = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
- this.shakeTime = par1NBTTagCompound.getByte("shake") & 255;
- this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
- }
- @SideOnly(Side.CLIENT)
- public float getShadowSize()
- {
- return 0.0F;
- }
- public int throwEntityOrHookFish()
- {
- if (this.worldObj.isRemote)
- {
- return 0;
- }
- else
- {
- byte b0 = 0;
- if (this.hookedEntity != null)
- {
- double d0 = this.playerObj.posX - this.posX;
- double d2 = this.playerObj.posY - this.posY;
- double d4 = this.playerObj.posZ - this.posZ;
- double d6 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2 + d4 * d4);
- double d8 = 0.1D;
- this.hookedEntity.motionX += d0 * d8;
- this.hookedEntity.motionY += d2 * d8 + (double)MathHelper.sqrt_double(d6) * 0.08D;
- this.hookedEntity.motionZ += d4 * d8;
- b0 = 3;
- }
- else if (this.hasCatchedFish > 0)
- {
- EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.getFishOrTreasure());
- double d1 = this.playerObj.posX - this.posX;
- double d3 = this.playerObj.posY - this.posY;
- double d5 = this.playerObj.posZ - this.posZ;
- double d7 = (double)MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5);
- double d9 = 0.1D;
- entityitem.motionX = d1 * d9;
- entityitem.motionY = d3 * d9 + (double)MathHelper.sqrt_double(d7) * 0.08D;
- entityitem.motionZ = d5 * d9;
- this.worldObj.spawnEntityInWorld(entityitem);
- this.playerObj.worldObj.spawnEntityInWorld(new EntityXPOrb(this.playerObj.worldObj, this.playerObj.posX, this.playerObj.posY + 0.5D, this.playerObj.posZ + 0.5D, this.rand.nextInt(6) + 1));
- b0 = 1;
- }
- if (this.inGround)
- {
- b0 = 2;
- }
- this.setDead();
- this.playerObj.fishEntity = null;
- return b0;
- }
- }
- private ItemStack getFishOrTreasure()
- {
- float f = this.worldObj.rand.nextFloat();
- int i = EnchantmentHelper.func_151386_g(this.playerObj);
- int j = EnchantmentHelper.func_151387_h(this.playerObj);
- float f1 = 0.1F - (float)i * 0.025F - (float)j * 0.01F;
- float f2 = 0.05F + (float)i * 0.01F - (float)j * 0.01F;
- f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
- f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F);
- if (f < f1)
- {
- this.playerObj.addStat(StatList.field_151183_A, 1);
- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, trashCatches)).func_150708_a(this.rand);
- }
- else
- {
- f -= f1;
- if (f < f2)
- {
- this.playerObj.addStat(StatList.field_151184_B, 1);
- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, treasureCatches)).func_150708_a(this.rand);
- }
- else
- {
- float f3 = f - f2;
- this.playerObj.addStat(StatList.fishCaughtStat, 1);
- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, fishCatches)).func_150708_a(this.rand);
- }
- }
- }
- /**
- * Will get destroyed next tick.
- */
- public void setDead()
- {
- super.setDead();
- if (this.playerObj != null)
- {
- this.playerObj.fishEntity = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement