@Override
 public void onUpdate() {
   // Copied from Hookshot: avoiding entityThrowable's update while in ground
   if (isInGround()) {
     lastTickPosX = posX;
     lastTickPosY = posY;
     lastTickPosZ = posZ;
     super.onEntityUpdate();
   } else {
     super.onUpdate();
   }
   if (canUpdate()) {
     // can hold onto whip for five minutes
     if (isInGround() && ticksExisted < 6000) {
       ++ticksInGround;
       if (shouldSwing()) {
         swingThrower();
       }
     } else if (ticksExisted > getMaxDistance()) {
       WorldUtils.playSoundAtEntity(this, Sounds.WHIP_CRACK, 0.5F, 0.2F);
       setDead();
     }
   } else {
     setDead();
   }
 }
 @Override
 protected void entityInit() {
   super.entityInit();
   dataManager.register(BOUNCES, 0);
   dataManager.register(FLARE, false);
   dataManager.register(RETURN_TO, -1);
 }
  @Override
  public void onUpdate() {
    if (getIsOpen() && openAngle > (float) (-Math.PI / 2)) {
      flash();
      openAngle -= (float) (Math.PI / 20);
    }
    if (!getIsOpen() && openAngle < 0) openAngle += (float) (Math.PI / 20);

    super.onUpdate();
    if (!getIsOnGround()) {
      rotationYaw += 50;
    } else {
      motionY = 0;
    }
    rotationPitch = 0;
    if (getIsOnGround() && worldObj.isRemote) {
      // rotationYaw = endRotationYaw;
      flashCounter++;
      if (flashCounter < 15) flashRed = true;
      else flashRed = false;
      if (flashCounter == 30) flashCounter = -1;
    }
    if (getIsCaptured()) {
      if (waitTime > 20) {
        p.setTamed(true);
        p.setOwner(((EntityPlayer) thrower).username);
        p.caughtBall = getType();
        p.clearAttackTarget();
        PokeballTypeHelper.doAfterEffect(getType(), p);
        PixelmonStorage.PokeballManager.getPlayerStorage((EntityPlayerMP) thrower).addToParty(p);
        p.catchInPokeball();
        p.friendship.initFromCapture();
        if (mode == Mode.battle) {
          battleController.endBattleWithoutXP();
        }
        setIsWaiting(false);
        setDead();
      }
    } else {
      if (waitTime >= initialDelay && waitTime < initialDelay + wobbleTime) {
        p.setScale(initialScale);
        if (numShakes == 0) catchPokemon();
        this.rotationPitch = ((float) (waitTime - initialDelay)) / wobbleTime * (float) 35;
      } else if (waitTime >= initialDelay + wobbleTime
          && waitTime < initialDelay + 3 * wobbleTime) {
        this.rotationPitch =
            -1 * ((float) (waitTime - (initialDelay + wobbleTime))) / wobbleTime * (float) 35 + 35;
      } else if (waitTime >= initialDelay + 3 * wobbleTime
          && waitTime < initialDelay + 4 * wobbleTime) {
        this.rotationPitch =
            ((float) (waitTime - (initialDelay + 3 * wobbleTime))) / wobbleTime * (float) 35 - 35;
      } else if (waitTime == initialDelay + 4 * wobbleTime + initialDelay) {
        waitTime = 0;
        shakeCount++;
        if (shakeCount == numShakes - 1 || numShakes == 1) {
          catchPokemon();
        }
      }
    }
  }
 @Override
 public void readEntityFromNBT(NBTTagCompound compound) {
   super.readEntityFromNBT(compound);
   if (compound.hasKey("fly_stack")) {
     stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("fly_stack"));
   }
   setFire(compound.getBoolean("flare"));
 }
 @Override
 public void writeEntityToNBT(NBTTagCompound compound) {
   super.writeEntityToNBT(compound);
   if (stack != null) {
     compound.setTag("fly_stack", stack.writeToNBT(new NBTTagCompound()));
   }
   compound.setBoolean("flare", isFire());
 }
 @Override
 public void onUpdate() {
   super.onUpdate();
   if (rotationticks < 360F) {
     rotationticks = rotationticks + 20F;
     if (rotationticks >= 360F) rotationticks = 0;
   }
 }
 /** Use method instead of 'this.dead = true' to clear the player's item in use. */
 @Override
 public void setDead() {
   super.setDead();
   if (getThrower() instanceof EntityPlayer) {
     if (getThrower() instanceof EntityPlayerMP && !worldObj.isRemote) {
       PacketDispatcher.sendTo(
           new UnpressKeyPacket(UnpressKeyPacket.RMB), (EntityPlayerMP) getThrower());
     }
   }
 }
 @Override
 protected void entityInit() {
   super.entityInit();
   setSize(0.25F, 0.25F);
   dataWatcher.addObject(THROWER_INDEX, "");
   dataWatcher.addObject(WHIP_TYPE_INDEX, WhipType.WHIP_SHORT.ordinal());
   dataWatcher.addObject(IN_GROUND_INDEX, (byte) 0);
   dataWatcher.addObject(HIT_POS_X, 0.0F);
   dataWatcher.addObject(HIT_POS_Y, 0.0F);
   dataWatcher.addObject(HIT_POS_Z, 0.0F);
 }
  @Override
  public void onUpdate() {
    // Standard motion
    double mx = motionX;
    double my = motionY;
    double mz = motionZ;

    super.onUpdate();

    if (!bounced) {
      // Reset the drag applied by super
      motionX = mx;
      motionY = my;
      motionZ = mz;
    }

    bounced = false;

    // Returning motion
    if (isReturning()) {
      Entity thrower = worldObj.getEntityByID(getEntityToReturnTo());
      Vector3 motion =
          Vector3.fromEntityCenter(thrower).subtract(Vector3.fromEntityCenter(this)).normalize();
      motionX = motion.x;
      motionY = motion.y;
      motionZ = motion.z;
    }

    // Client FX
    if (worldObj.isRemote && isFire()) {
      double r = 0.1;
      double m = 0.1;
      for (int i = 0; i < 3; i++)
        worldObj.spawnParticle(
            EnumParticleTypes.FLAME,
            posX + r * (Math.random() - 0.5),
            posY + r * (Math.random() - 0.5),
            posZ + r * (Math.random() - 0.5),
            m * (Math.random() - 0.5),
            m * (Math.random() - 0.5),
            m * (Math.random() - 0.5));
    }

    // Server state control
    if (!worldObj.isRemote && (getTimesBounced() >= MAX_BOUNCES || ticksExisted > 60)) {
      EntityLivingBase thrower = getThrower();
      if (thrower == null) {
        dropAndKill();
      } else {
        setEntityToReturnTo(thrower.getEntityId());
        if (getDistanceSqToEntity(thrower) < 2) dropAndKill();
      }
    }
  }
 @Override
 public void writeEntityToNBT(NBTTagCompound compound) {
   super.writeEntityToNBT(compound);
   compound.setFloat("hitPosX", dataWatcher.getWatchableObjectFloat(HIT_POS_X));
   compound.setFloat("hitPosY", dataWatcher.getWatchableObjectFloat(HIT_POS_Y));
   compound.setFloat("hitPosZ", dataWatcher.getWatchableObjectFloat(HIT_POS_Z));
   compound.setInteger("hitX", hitX);
   compound.setInteger("hitY", hitY);
   compound.setInteger("hitZ", hitZ);
   compound.setByte("customInGround", (byte) (isInGround() ? 1 : 0));
   compound.setInteger("whipType", getType().ordinal());
 }
 @Override
 public void readEntityFromNBT(NBTTagCompound compound) {
   super.readEntityFromNBT(compound);
   dataWatcher.updateObject(HIT_POS_X, compound.getFloat("hitPosX"));
   dataWatcher.updateObject(HIT_POS_Y, compound.getFloat("hitPosY"));
   dataWatcher.updateObject(HIT_POS_Z, compound.getFloat("hitPosZ"));
   hitX = compound.getInteger("hitX");
   hitY = compound.getInteger("hitY");
   hitZ = compound.getInteger("hitZ");
   // retrieving owner name saved by super-class EntityThrowable
   dataWatcher.updateObject(THROWER_INDEX, compound.getString("ownerName"));
   dataWatcher.updateObject(
       WHIP_TYPE_INDEX,
       WhipType.values()[compound.getInteger("whipType") % WhipType.values().length]);
   dataWatcher.updateObject(IN_GROUND_INDEX, compound.getByte("customInGround"));
 }
 public static void eventTeleport(EntityThrowable e) {
   if (e.getThrower() != null && e.getThrower() instanceof EntityPlayerMP) {
     EntityPlayerMP entityplayermp = (EntityPlayerMP) e.getThrower();
     EnderTeleportEvent event =
         new EnderTeleportEvent(entityplayermp, e.posX, e.posY, e.posZ, 5.0F);
     if (!MinecraftForge.EVENT_BUS.post(event)) {
       if (e.getThrower().isRiding()) e.getThrower().mountEntity((Entity) null);
       e.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
     }
   }
 }
 @Override
 public void onUpdate() {
   super.onUpdate();
   if (this.worldObj.isRemote) {
     int rgbIndex = mID;
     if (isRandom) {
       rgbIndex = this.worldObj.rand.nextInt(5);
     }
     worldObj.spawnParticle(
         "mobSpell",
         this.posX,
         this.posY,
         this.posZ,
         spellRGB[rgbIndex][0],
         spellRGB[rgbIndex][1],
         spellRGB[rgbIndex][2]);
   }
 }
Exemple #14
0
  public void onUpdate() {
    super.onUpdate();
    float f3 = 0.25F;
    String particle = "";
    if (status == 0) {
      particle = "smoke";
    } else if (status == 1) {
      particle = "flame";
    }

    this.worldObj.spawnParticle(
        particle,
        this.posX - this.motionX * (double) f3 + this.rand.nextDouble() * 0.6D - 0.3D,
        this.posY - this.motionY * (double) f3 - 0.5D,
        this.posZ - this.motionZ * (double) f3 + this.rand.nextDouble() * 0.6D - 0.3D,
        0,
        0,
        0);
  }
Exemple #15
0
  @Override
  public void onEntityUpdate() {

    super.onEntityUpdate();

    if (ticksExisted >= 100) {
      this.setDead();
    }
    if (!worldObj.isRemote) {
      if (isHoming && target != null) {
        double d0 = target.posX - this.posX;
        double d1 = target.posY + (double) target.getEyeHeight() - this.posY;
        double d2 = target.posZ - this.posZ;

        this.setThrowableHeading(d0, d1, d2, speed, 0.0F);
        speed = speed + 0.06F;
      } else if (isHoming && target == null) {
        this.setDead();
      }
    }
  }
 public void readEntityFromNBT(NBTTagCompound tagcompound) {
   super.readEntityFromNBT(tagcompound);
 }
 public void writeEntityToNBT(NBTTagCompound tagcompound) {
   super.writeEntityToNBT(tagcompound);
 }
 @Override
 public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readEntityFromNBT(par1NBTTagCompound);
   this.mID = par1NBTTagCompound.getInteger("metType");
   this.isRandom = par1NBTTagCompound.getBoolean("isRandom");
 }
 @Override
 public void onUpdate() {
   super.onUpdate();
 }
 @Override
 public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
   super.writeEntityToNBT(par1NBTTagCompound);
   par1NBTTagCompound.setInteger("metType", this.mID);
   par1NBTTagCompound.setBoolean("isRandom", this.isRandom);
 }