コード例 #1
0
 public void onRelayPlayerCharge(EntityPlayer player, TileEntityCrystalPylon p) {
   if (!worldObj.isRemote) {
     if (!player.capabilities.isCreativeMode
         && !Chromabilities.PYLON.enabledOn(player)
         && rand.nextInt(60) == 0) p.attackEntityByProxy(player, this);
     CrystalNetworker.instance.makeRequest(this, p.getColor(), 100, this.getReceiveRange(), 1);
   }
 }
コード例 #2
0
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    if (DragonAPICore.debugtest) {
      if (!hasMultiblock) {
        CrystalElement e = CrystalElement.randomElement();
        FilledBlockArray b = ChromaStructures.getPylonStructure(world, x, y - 9, z, e);
        b.place();
        // world.setBlock(x, y+9, z, this.getTile().getBlock(), this.getTile().getBlockMetadata(),
        // 3);
        // TileEntityCrystalPylon te = (TileEntityCrystalPylon)world.getTileEntity(x, y+9, z);
        color = e;
        hasMultiblock = true;
        this.syncAllData(true);
      }
    }

    if (hasMultiblock) {
      // ReikaJavaLibrary.pConsole(energy, Side.SERVER, color == CrystalElement.BLUE);

      int max = this.getCapacity();
      if (world.getTotalWorldTime() != lastWorldTick) {
        this.charge(world, x, y, z, max);
        lastWorldTick = world.getTotalWorldTime();
      }
      energy = Math.min(energy, max);

      if (world.isRemote) {
        this.spawnParticle(world, x, y, z);
      }

      if (!world.isRemote && rand.nextInt(80) == 0) {
        int r = 8 + rand.nextInt(8);
        AxisAlignedBB box = ReikaAABBHelper.getBlockAABB(x, y, z).expand(r, r, r);
        List<EntityLivingBase> li = world.getEntitiesWithinAABB(EntityLivingBase.class, box);
        for (EntityLivingBase e : li) {
          boolean attack = !e.isDead && e.getHealth() > 0;
          if (e instanceof EntityPlayer) {
            EntityPlayer ep = (EntityPlayer) e;
            attack =
                attack && !ep.capabilities.isCreativeMode && !Chromabilities.PYLON.enabledOn(ep);
          } else if (e instanceof EntityBallLightning) {
            attack = ((EntityBallLightning) e).getElement() != color;
          }
          if (attack) {
            this.attackEntity(e);
            this.sendClientAttack(this, e);
          }
        }
      }

      float f = this.isEnhanced() ? 1.125F : 1;

      if (TileEntityCrystalPylon.TUNED_PYLONS)
        f *= CrystalMusicManager.instance.getDingPitchScale(color);

      if (this.getTicksExisted() % (int) (72 / f) == 0) {
        ChromaSounds.POWER.playSoundAtBlock(this, 1, f);
      }

      int n = this.isEnhanced() ? 24 : 36;
      if (world.isRemote && rand.nextInt(n) == 0) {
        this.spawnLightning(world, x, y, z);
      }

      if (!world.isRemote
          && ChromaOptions.BALLLIGHTNING.getState()
          && energy >= this.getCapacity() / 2
          && rand.nextInt(24000) == 0
          && this.isChunkLoaded()) {
        world.spawnEntityInWorld(
            new EntityBallLightning(world, color, x + 0.5, y + 0.5, z + 0.5)
                .setPylon()
                .setNoDrops());
      }
    }
  }