@Override
 public void onEventEnd(World w) {
   ECUtils.sendChatMessageToAllPlayersInDim(
       Config.dimensionID, EnumChatFormatting.GREEN + "The lights are back!");
   if (w.provider.dimensionId == Config.dimensionID)
     ((WorldProviderFirstWorld) w.provider).generateLightBrightnessTable();
 }
  /**
   * 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();
  }
 public boolean getCanSpawnHere() {
   return this.dimension == Config.dimensionID && ECUtils.isEventActive("ec3.event.fumes");
 }
 @Override
 public void onEventBeginning(World w) {
   ECUtils.sendChatMessageToAllPlayersInDim(
       Config.dimensionID, EnumChatFormatting.RED + "Why is it so dark?!");
   ((WorldProviderFirstWorld) w.provider).generateLightBrightnessTable();
 }
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (syncTick == 0) {
      if (this.tracker == null)
        Notifier.notifyCustomMod(
            "EssentialCraft",
            "[WARNING][SEVERE]TileEntity "
                + this
                + " at pos "
                + this.xCoord
                + ","
                + this.yCoord
                + ","
                + this.zCoord
                + " tries to sync itself, but has no TileTracker attached to it! SEND THIS MESSAGE TO THE DEVELOPER OF THE MOD!");
      else if (!this.worldObj.isRemote && this.tracker.tileNeedsSyncing()) {
        MiscUtils.sendPacketToAllAround(
            worldObj,
            getDescriptionPacket(),
            xCoord,
            yCoord,
            zCoord,
            this.worldObj.provider.dimensionId,
            32);
      }
      syncTick = 60;
    } else --this.syncTick;

    if (requestSync && this.worldObj.isRemote) {
      requestSync = false;
      ECUtils.requestScheduledTileSync(this, EssentialCraftCore.proxy.getClientPlayer());
    }

    if (++ticksSinceSync % 20 * 4 == 0) {
      worldObj.addBlockEvent(
          xCoord,
          yCoord,
          zCoord,
          this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord),
          1,
          numUsingPlayers);
    }

    prevLidAngle = lidAngle;
    float angleIncrement = 0.1F;

    if (numUsingPlayers > 0 && lidAngle == 0.0F) {
      worldObj.playSoundEffect(
          xCoord + 0.5D,
          yCoord + 0.5D,
          zCoord + 0.5D,
          "random.chestopen",
          0.5F,
          worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }

    if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) {
      float var8 = lidAngle;

      if (numUsingPlayers > 0) {
        lidAngle += angleIncrement;
      } else {
        lidAngle -= angleIncrement;
      }

      if (lidAngle > 1.0F) {
        lidAngle = 1.0F;
      }

      if (lidAngle < 0.5F && var8 >= 0.5F) {
        worldObj.playSoundEffect(
            xCoord + 0.5D,
            yCoord + 0.5D,
            zCoord + 0.5D,
            "random.chestclosed",
            0.5F,
            worldObj.rand.nextFloat() * 0.1F + 0.9F);
      }

      if (lidAngle < 0.0F) {
        lidAngle = 0.0F;
      }
    }
  }