コード例 #1
0
 @Override
 public void execute() {
   if (t != null && p != null && t.getWorldObj() != null)
     if (t.getWorldObj().blockExists(t.xCoord, t.yCoord, t.zCoord))
       if (t.getWorldObj().getTileEntity(t.xCoord, t.yCoord, t.zCoord) == t)
         MiscUtils.sendPacketToPlayer(t.getWorldObj(), t.getDescriptionPacket(), p);
 }
コード例 #2
0
  @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;
  }
コード例 #3
0
  @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;
      }
    }
  }