/**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  @SuppressWarnings("unchecked")
  public void onLivingUpdate() {
    if (!(this.dimension == Config.dimensionID && ECUtils.isEventActive("ec3.event.fumes")))
      this.setDead();

    if (!this.worldObj.isRemote) {
      --this.heightOffsetUpdateTime;

      if (this.heightOffsetUpdateTime <= 0) {
        this.heightOffsetUpdateTime = 100;
        this.mX = MathUtils.randomDouble(this.worldObj.rand);
        this.mY = MathUtils.randomDouble(this.worldObj.rand);
        this.mZ = MathUtils.randomDouble(this.worldObj.rand);
        this.setHeightOffset(0.5F + (float) this.rand.nextGaussian() * 3.0F);
      }
      this.motionX = mX / 10;
      this.motionY = mY / 10;
      this.motionZ = mZ / 10;
      if (this.ticksExisted > 1000) this.setDead();
    }
    EssentialCraftCore.proxy.spawnParticle(
        "fogFX", (float) posX, (float) posY + 2, (float) posZ, 0.0F, 1.0F, 0.0F);
    List<EntityPlayer> players =
        this.worldObj.getEntitiesWithinAABB(
            EntityPlayer.class,
            AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1)
                .expand(6, 3, 6));
    for (int i = 0; i < players.size(); ++i) {
      EntityPlayer p = players.get(i);
      boolean ignorePoison = false;
      IInventory b = BaublesApi.getBaubles(p);
      if (b != null) {
        for (int i1 = 0; i1 < b.getSizeInventory(); ++i1) {
          ItemStack is = b.getStackInSlot(i1);
          if (is != null
              && is.getItem() != null
              && is.getItem() instanceof BaublesModifier
              && is.getItemDamage() == 19) ignorePoison = true;
        }
      }
      if (!p.worldObj.isRemote && !ignorePoison) {
        RadiationManager.increasePlayerRadiation(p, 10);
        p.addPotionEffect(new PotionEffect(Potion.poison.id, 200, 1));
      }
    }
    super.onLivingUpdate();
  }
  @SuppressWarnings("unchecked")
  public void updateEntity() {
    if (!this.worldObj.isRemote && tickTime == 0)
      MiscUtils.sendPacketToAllAround(
          worldObj,
          getDescriptionPacket(),
          xCoord,
          yCoord,
          zCoord,
          worldObj.provider.dimensionId,
          16);

    int additionalStability = 0;

    if (hasAir) ++additionalStability;
    if (hasWater) ++additionalStability;
    if (hasFire) ++additionalStability;
    if (hasEarth) ++additionalStability;
    if (hasOrdo) ++additionalStability;
    if (hasEntropy) ++additionalStability;

    if (placerName == null || placerName.isEmpty() || placerName.contains("no placer")) return;

    List<Entity> entities =
        this.worldObj.getEntitiesWithinAABB(
            Entity.class,
            AxisAlignedBB.getBoundingBox(
                xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1));
    if (!entities.isEmpty()) {
      Entity e = entities.get(0);
      if (e != null && !e.isDead) {
        if (e instanceof EntityItem) {
          if (additionalStability >= 6) {
            EntityItem itm = (EntityItem) e;
            ItemStack stk = itm.getEntityItem();
            if (stk != null) {
              AspectList aspectsCompound = ThaumcraftCraftingManager.getObjectTags(stk);
              aspectsCompound = ThaumcraftCraftingManager.getBonusTags(stk, aspectsCompound);
              if (aspectsCompound != null && aspectsCompound.size() > 0) {
                ++tickTime;
                if (tickTime == 40) {
                  tickTime = 0;

                  --stk.stackSize;
                  if (stk.stackSize <= 0) itm.setDead();

                  AspectList primals = ResearchManager.reduceToPrimals(aspectsCompound);
                  Aspect a = null;
                  if (this.worldObj.rand.nextInt(40) < primals.visSize())
                    a =
                        primals
                            .getAspects()[this.worldObj.rand.nextInt(primals.getAspects().length)];

                  if (!this.worldObj.isRemote && a != null) {
                    EntityPlayerMP player =
                        MinecraftServer.getServer()
                            .getConfigurationManager()
                            .func_152612_a(placerName);
                    if (player != null) {
                      double distance = player.getDistance(xCoord + 0.5D, yCoord, zCoord + 0.5D);
                      if (additionalStability < 6)
                        if (this.worldObj.rand.nextInt(
                                MathHelper.floor_double(
                                    Math.max(1, (128 + additionalStability * 10) - distance)))
                            == 0) TBUtils.addWarpToPlayer(EntityPlayerMP.class.cast(e), 1, 0);

                      TBUtils.addAspectToKnowledgePool(player, a, (short) 1);
                    }
                  }
                }
              }
              Thaumcraft.proxy.blockRunes(
                  worldObj,
                  xCoord,
                  yCoord + MathUtils.randomDouble(this.worldObj.rand) * 0.5D,
                  zCoord,
                  1,
                  0.5F,
                  0.5F,
                  8,
                  0);
              return;
            }
          }
        } else {
          AspectList aspectsCompound = ScanManager.generateEntityAspects(e);
          if (aspectsCompound != null && aspectsCompound.size() > 0) {
            ++tickTime;

            tickTime += MathHelper.floor_double(additionalStability / 2);

            if (tickTime == 40) {
              tickTime = 0;
              e.attackEntityFrom(DamageSource.outOfWorld, 1);

              if (e instanceof EntityPlayerMP) {
                TBUtils.addWarpToPlayer(EntityPlayerMP.class.cast(e), 1, 0);
              }

              Aspect a =
                  aspectsCompound.getAspects()[this.worldObj.rand.nextInt(aspectsCompound.size())];

              if (!this.worldObj.isRemote) {
                EntityPlayerMP player =
                    MinecraftServer.getServer().getConfigurationManager().func_152612_a(placerName);
                if (player != null) {
                  double distance = player.getDistance(xCoord + 0.5D, yCoord, zCoord + 0.5D);
                  if (additionalStability < 6)
                    if (this.worldObj.rand.nextInt(
                            MathHelper.floor_double(
                                Math.max(1, (128 + additionalStability * 10) - distance)))
                        == 0) TBUtils.addWarpToPlayer(EntityPlayerMP.class.cast(e), 1, 0);

                  TBUtils.addAspectToKnowledgePool(player, a, (short) 1);
                }
              }
            }
            Thaumcraft.proxy.blockRunes(
                worldObj,
                xCoord,
                yCoord + MathUtils.randomDouble(this.worldObj.rand) * 0.5D,
                zCoord,
                1,
                0.5F,
                0.5F,
                8,
                0);
            return;
          }
        }
      }
    }

    tickTime = 0;
  }