Exemplo n.º 1
0
 @Override
 public boolean onBlockDestroyed(
     ItemStack par1ItemStack,
     World world,
     int block,
     int x,
     int y,
     int z,
     EntityLivingBase par7EntityLivingBase) {
   world.newExplosion(par7EntityLivingBase, x, y, z, 3F, false, true);
   par1ItemStack.damageItem(3, par7EntityLivingBase);
   /*ByteArrayOutputStream bt = new ByteArrayOutputStream();
   DataOutputStream out = new DataOutputStream(bt);
   try
   {
   	//System.out.println("Building packet...");
   	out.writeInt(7);
   	out.writeInt(-1);
   	out.writeInt(x);
   	out.writeInt(y);
   	out.writeInt(z);
   	//out.writeFloat(par3EntityPlayer.getHealth()+1);
   	Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
   	Player player = (Player)par7EntityLivingBase;
   	//System.out.println("Sending packet..." + player);
   	PacketDispatcher.sendPacketToServer(packet);
   	par1ItemStack.damageItem(3, par7EntityLivingBase);
   	return true;
   }
   catch (IOException ex)
   {
   	System.out.println("couldnt send packet!");
   }*/
   return false;
 }
 public void destroy(World world, int x, int y, int z) {
   tickcount++;
   int n = 8;
   int count = 32;
   double rx = x + 0.5 + rand.nextInt(2 * n + 1) - n;
   double ry = y + 0.5 + rand.nextInt(2 * n + 1) - n;
   double rz = z + 0.5 + rand.nextInt(2 * n + 1) - n;
   world.createExplosion(null, rx, ry, rz, 4F, tickcount > count);
   for (int i = 0; i < 32; i++)
     world.spawnParticle(
         "lava",
         rx + rand.nextInt(7) - 3,
         ry + rand.nextInt(7) - 3,
         rz + rand.nextInt(7) - 3,
         0,
         0,
         0);
   if (tickcount > count) {
     world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 12F, true, true);
     ReikaWorldHelper.temperatureEnvironment(world, x, y, z, 1000);
   } /*
     EntityCreeper e = new EntityCreeper(world);
     e.posX = rx;
     e.posZ = rz;
     e.posY = world.getTopSolidOrLiquidBlock((int)rx, (int)rz)+1;
     e.addPotionEffect(new PotionEffect(Potion.resistance.id, 10, 10));
     world.spawnEntityInWorld(e);*/
 }
Exemplo n.º 3
0
 private void doIgnition(World world, int x, int y, int z) {
   world.setBlockToAir(x, y, z);
   world.newExplosion(null, x, y, z, 4.0F, true, true);
   BlockCoord c = new BlockCoord(x, y, z);
   for (BlockCoord n : c.getAdjacent()) {
     if (n.getBlock(world).equals(ArtificeBlocks.blockFuel)) doIgnition(world, n.x, n.y, n.z);
   }
 }
  @Override
  public Map<EntityPlayer, Object> ApplyIllEffect(World world, int x, int y, int z) {
    HashMap<EntityPlayer, Object> toReturn = new HashMap<EntityPlayer, Object>();
    if (world.isRemote) return new HashMap<EntityPlayer, Object>();

    world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 7, true, true);

    return new HashMap<EntityPlayer, Object>();
  }
  @Override
  public void updateEntity(World world, int x, int y, int z, int meta) {
    if (rand.nextInt(20) == 0) this.sickenMobs(world, x, y, z);

    this.decayWaste(this.getAccelerationFactor(world, x, y, z));

    if (!world.isRemote) this.feed();

    if (world.provider.isHellWorld
        || ReikaWorldHelper.getAmbientTemperatureAt(world, x, y, z) > 100) {
      if (this.hasWaste()) {
        ReikaParticleHelper.SMOKE.spawnAroundBlock(world, x, y, z, 3);
        if (rand.nextInt(4) == 0) ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
        if (rand.nextInt(200) == 0) {
          world.setBlockToAir(x, y, z);
          world.newExplosion(null, x + 0.5, y + 0.5, y + 0.5, 4F, true, true);
        }
      }
    }
  }
 @Override
 public void fire(World world, double[] xyz) {
   if (world.isRemote) return;
   for (float i = 0; i <= this.getMaxRange(); i += 0.5F) {
     double dx = i * Math.cos(Math.toRadians(theta)) * Math.cos(Math.toRadians(-phi + 90));
     double dy = i * Math.sin(Math.toRadians(theta));
     double dz = i * Math.cos(Math.toRadians(theta)) * Math.sin(Math.toRadians(-phi + 90));
     int r = 1;
     AxisAlignedBB light =
         AxisAlignedBB.getBoundingBox(
                 xCoord + dx, yCoord + dy, zCoord + dz, xCoord + dx, yCoord + dy, zCoord + dz)
             .expand(r, r, r);
     List<Entity> in = world.getEntitiesWithinAABB(Entity.class, light);
     for (Entity e : in) {
       if (e instanceof TargetEntity) {
         ((TargetEntity) e).onLaserBeam(this);
       }
       if (e instanceof EntityLivingBase) {
         e.attackEntityFrom(DamageSource.lava, 4);
         e.setFire(7);
       }
     }
     int x = xCoord + (int) dx;
     int y = yCoord + (int) dy;
     int z = zCoord + (int) dz;
     Block id = world.getBlock(x, y, z);
     int meta = world.getBlockMetadata(x, y, z);
     Block id2 = this.getAffectedID(id, meta);
     int meta2 = this.getAffectedMetadata(id2, meta);
     // ReikaJavaLibrary.pConsole(id+"  to  "+id2+"  @  "+x+", "+y+", "+z);
     // ReikaJavaLibrary.pConsole(theta);
     if (ConfigRegistry.ATTACKBLOCKS.getState()) {
       if (id2 != id || meta2 != meta) {
         world.setBlock(x, y, z, id2, meta2, 3);
         world.markBlockForUpdate(x, y, z);
         this.setRange((int) i + 1);
         return;
       }
       if (id == Blocks.netherrack) {
         world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 3F, true, true);
         world.markBlockForUpdate(x, y, z);
         this.setRange((int) i + 1);
         return;
       }
       if (id == Blocks.tnt) {
         world.setBlockToAir(x, y, z);
         EntityTNTPrimed var6 = new EntityTNTPrimed(world, x + 0.5D, y + 0.5D, z + 0.5D, null);
         world.spawnEntityInWorld(var6);
         world.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F);
         world.spawnParticle(
             "lava", x + rand.nextFloat(), y + rand.nextFloat(), z + rand.nextFloat(), 0, 0, 0);
         this.setRange((int) i + 1);
         return;
       }
     }
     if (id != Blocks.air && id.isOpaqueCube()) {
       this.setRange((int) i + 1);
       return;
     }
     if (i == this.getMaxRange()) {
       this.setRange(this.getMaxRange());
     }
   }
 }
Exemplo n.º 7
0
 public boolean makeBeam(
     World world, int x, int y, int z, int metadata, int step, int id, int maxdist) {
   boolean value = false;
   if (ConfigRegistry.BLOCKDAMAGE.getState()) {
     if (id == Block.stone.blockID
         || id == Block.cobblestone.blockID
         || id == Block.stoneBrick.blockID
         || id == Block.sandStone.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 32));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world,
               x + step * xstep,
               y + step * ystep,
               z + step * zstep,
               Block.lavaMoving.blockID);
       world.spawnParticle(
           "lava",
           x + step * xstep + rand.nextFloat(),
           y + step * ystep + rand.nextFloat(),
           z + step * zstep + rand.nextFloat(),
           0,
           0,
           0);
     }
     if (id == Block.sand.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 16));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world, x + step * xstep, y + step * ystep, z + step * zstep, Block.glass.blockID);
     }
     if (id == Block.gravel.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 16));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world,
               x + step * xstep,
               y + step * ystep,
               z + step * zstep,
               Block.cobblestone.blockID);
     } /*
       if (id == Block.netherrack.blockID) {
       	if (world.getBlockId(x+step*xstep, 1+y+step*ystep, z+step*zstep) == 0) {
       		ReikaWorldHelper.legacySetBlockWithNotify(world, x+step*xstep, 1+y+step*ystep, z+step*zstep, Block.fire.blockID);
       	}
       }*/
     if (id == Block.netherrack.blockID && tickcount >= 6) {
       world.newExplosion(
           null,
           x + step * xstep + 0.5,
           y + step * ystep + 0.5,
           z + step * zstep + 0.5,
           3F,
           true,
           true);
       if (step >= 500) RotaryAchievements.NETHERHEATRAY.triggerAchievement(this.getPlacer());
       step = maxdist;
       value = true;
     }
     if (id == Block.dirt.blockID || id == Block.tilledField.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 16));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world, x + step * xstep, y + step * ystep, z + step * zstep, Block.sand.blockID);
     }
     if (id == Block.grass.blockID || id == Block.mycelium.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 16));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world, x + step * xstep, y + step * ystep, z + step * zstep, Block.dirt.blockID);
     }
     if (id == Block.ice.blockID || id == Block.blockSnow.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 4));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0)
           ReikaWorldHelper.legacySetBlockWithNotify(
               world,
               x + step * xstep,
               y + step * ystep,
               z + step * zstep,
               Block.waterMoving.blockID);
     }
     if (id == Block.tallGrass.blockID
         || id == Block.web.blockID
         || id == Block.plantYellow.blockID
         || id == Block.snow.blockID
         || id == Block.plantRed.blockID
         || id == Block.mushroomRed.blockID
         || id == Block.mushroomBrown.blockID
         || id == Block.deadBush.blockID
         || id == Block.crops.blockID
         || id == 142
         || id == 141
         || id == Block.vine.blockID
         || id == Block.melonStem.blockID
         || id == Block.pumpkinStem.blockID
         || id == Block.waterlily.blockID) {
       int chance = (int) ((power - MINPOWER) / (1024 * step * 2));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0) {
           ReikaWorldHelper.legacySetBlockWithNotify(
               world, x + step * xstep, y + step * ystep, z + step * zstep, 0);
           if (id == Block.snow.blockID)
             world.playSoundEffect(
                 x + step * xstep + 0.5D,
                 y + step * ystep + 0.5D,
                 z + step * zstep + 0.5D,
                 "random.fizz",
                 0.5F,
                 2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F);
         }
     }
     if (id == Block.waterMoving.blockID || id == Block.waterStill.blockID) {
       // ModLoader.getMinecraftInstance().thePlayer.addChatMessage(String.format("%d", id));
       int chance = (int) ((power - MINPOWER) / (1024 * step * 2));
       chance = ReikaMathLibrary.extrema(chance, 1, "max");
       if (rand.nextInt(chance) != 0)
         if (rand.nextInt(step) == 0) {
           ReikaWorldHelper.legacySetBlockWithNotify(
               world, x + step * xstep, y + step * ystep, z + step * zstep, 0);
           world.playSoundEffect(
               x + step * xstep + 0.5D,
               y + step * ystep + 0.5D,
               z + step * zstep + 0.5D,
               "random.fizz",
               0.5F,
               2.6F + (rand.nextFloat() - rand.nextFloat()) * 0.8F);
         }
     }
     if (id == Block.tnt.blockID) {
       ReikaWorldHelper.legacySetBlockWithNotify(
           world, x + step * xstep, y + step * ystep, z + step * zstep, 0);
       EntityTNTPrimed var6 =
           new EntityTNTPrimed(
               world,
               x + step * xstep + 0.5D,
               y + step * ystep + 0.5D,
               z + step * zstep + 0.5D,
               null);
       world.spawnEntityInWorld(var6);
       world.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F);
       world.spawnParticle(
           "lava",
           x + step * xstep + rand.nextFloat(),
           y + step * ystep + rand.nextFloat(),
           z + step * zstep + rand.nextFloat(),
           0,
           0,
           0);
     } /*
       if (id == 0) {
       	if (world.getBlockId(x+step*xstep, -1+y+step*ystep, z+step*zstep) == Block.netherrack.blockID) {
       		ReikaWorldHelper.legacySetBlockWithNotify(world, x+step*xstep, y+step*ystep, z+step*zstep, Block.fire.blockID);
       	}
       }*/
   }
   return value;
 }
Exemplo n.º 8
0
  /** Called upon block activation (right click on the block.) */
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (world.isRemote) {
      return true;
    } else {
      int i1 = world.getBlockMetadata(x, y, z);

      if (!isBlockHeadOfBed(i1)) {
        int j1 = getDirection(i1);
        x += footBlockToHeadBlockMap[j1][0];
        z += footBlockToHeadBlockMap[j1][1];

        if (world.getBlock(x, y, z) != this) return true;

        i1 = world.getBlockMetadata(x, y, z);
      }

      if (world.provider.canRespawnHere() && world.getBiomeGenForCoords(x, z) != TFCBiome.hell) {
        if (isBedOccupied(i1)) {
          EntityPlayer entityplayer1 = null;
          Iterator iterator = world.playerEntities.iterator();

          while (iterator.hasNext()) {
            EntityPlayer entityplayer2 = (EntityPlayer) iterator.next();

            if (entityplayer2.isPlayerSleeping()) {
              ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;

              if (chunkcoordinates.posX == x
                  && chunkcoordinates.posY == y
                  && chunkcoordinates.posZ == z) {
                entityplayer1 = entityplayer2;
              }
            }
          }

          if (entityplayer1 != null) {
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.occupied"));
            return true;
          }

          setBedOccupied(world, x, y, z, false);
        }

        EnumStatus enumstatus = player.sleepInBedAt(x, y, z);

        if (enumstatus == EnumStatus.OK) {
          TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.customBed.sleep"));
          setBedOccupied(world, x, y, z, true);
          return true;
        } else {
          if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.noSleep"));
          else if (enumstatus == EnumStatus.NOT_SAFE)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.notSafe"));

          return true;
        }
      } else {
        double d0 = x + 0.5D;
        double d1 = y + 0.5D;
        double d2 = z + 0.5D;
        world.setBlockToAir(x, y, z);
        int k1 = getDirection(i1);
        x += footBlockToHeadBlockMap[k1][0];
        z += footBlockToHeadBlockMap[k1][1];

        if (world.getBlock(x, y, z) == this) {
          world.setBlockToAir(x, y, z);
          d0 = (d0 + x + 0.5D) / 2.0D;
          d1 = (d1 + y + 0.5D) / 2.0D;
          d2 = (d2 + z + 0.5D) / 2.0D;
        }

        world.newExplosion((Entity) null, x + 0.5F, y + 0.5F, z + 0.5F, 5.0F, true, true);
        return true;
      }
    }
  }
  @Override
  public void tick(World worldObj, Chunk chunk) {
    // int s = worldObj.calculateSkylightSubtracted(0);
    if (!worldObj.isRemote && chunk.hasEntities) {
      int foundblinkdog = 0;
      boolean foundempyreal = false;
      // if (worldObj.rand.nextInt(10) < level)
      // {
      for (int var3 = chunk.entityLists.length - 1; var3 >= 0; var3--) {
        // int var3 = worldObj.rand.nextInt(chunk.entityLists.length);
        List var4 = chunk.entityLists[var3];

        if (var4.size() > 0) {
          for (int entind = var4.size() - 1; entind >= 0; entind--) {
            Entity e = (Entity) var4.get(entind);

            if (e instanceof EntityLiving) {
              EntityLiving var5 = (EntityLiving) e;
              NBTTagCompound nbt = var5.getEntityData();
              float hpo = nbt.getFloat("HealthOverflow");
              int timer = nbt.getInteger("HealthOverflowTimer");
              if (timer < 0) {
                timer = 0;
              }
              timer += level;
              if (DecayingWorld.goodmobs(var5)) {
                timer += (5 - level);
              }
              if (var5 instanceof EntityBlinkDog) {
                foundblinkdog += 1;
              }
              if (var5 instanceof EntityEmpyreal) {
                foundempyreal = true;
              }
              // System.out.println("Timer:  " +timer);
              // System.out.println("HPO:    " +hpo);
              float hp = var5.getHealth();
              if (timer > 180) {
                if (DecayingWorld.evilmobs(var5)) {
                  if (hpo > 0) hpo--;
                  else hp--;
                } else {
                  hpo++;
                  int r = worldObj.rand.nextInt(60);
                  nbt.setInteger("HealthOverflowTimer", r);
                  timer = r;
                }
              }

              float mhp = var5.getMaxHealth();
              float newhp = hp;
              float newhpo = hpo;

              if (hp < mhp && !DecayingWorld.evilmobs(var5)) {
                newhp = Math.min(hp + hpo, mhp);
                newhpo = Math.max(hp + hpo - mhp, 0);
                var5.heal(newhp - hp);
              }
              // System.out.println("newHPO: " +newhpo);

              if (newhpo > mhp * 2) {
                newhpo = mhp * 2;
                if (!(DecayingWorld.goodmobs(var5) || var5 instanceof EntityCreeper))
                // if (!(var5 instanceof EntitySkeleton || var5 instanceof EntityZombie || var5
                // instanceof EntityCreeper || e instanceof EntityGhast || e instanceof
                // EntityPigZombie))
                {
                  worldObj.newExplosion(var5, var5.posX, var5.posY, var5.posZ, 0F, false, true);
                  var5.attackEntityFrom(PositiveDamage.type, mhp * 3);
                }
              }

              nbt.setFloat("HealthOverflow", newhpo);
              nbt.setInteger("HealthOverflowTimer", timer);
              nbt.setBoolean("TempDecay", true);

              if (e instanceof EntityPlayer) {
                ByteArrayOutputStream bt = new ByteArrayOutputStream();
                DataOutputStream out = new DataOutputStream(bt);
                try {
                  out.writeInt(1);
                  out.writeFloat(newhpo);
                  Packet250CustomPayload packet =
                      new Packet250CustomPayload("MoreDecay", bt.toByteArray());
                  Player player = (Player) e;
                  PacketDispatcher.sendPacketToPlayer(packet, player);
                } catch (IOException ex) {
                  System.out.println("couldnt send packet!");
                }
              }
            }
          }
        }
      }
      int chunkX = chunk.xPosition;
      int chunkZ = chunk.zPosition;
      BiomeGenBase b = worldObj.getBiomeGenForCoords(chunkX * 16, chunkZ * 16);
      // if(b.biomeID > 22) {
      int x, y, z, n, ch;
      EntityPlayer p = worldObj.getClosestPlayer(chunkX * 16, 96, chunkZ * 16, 96);
      EntityPlayer p2 = worldObj.getClosestPlayer(chunkX * 16, 24, chunkZ * 16, 24);
      if (p != null && p2 == null) {
        if (foundblinkdog < 2) {
          ch =
              (chunkX * chunkX
                      + chunkZ * chunkZ
                      + worldObj.provider.dimensionId
                      + (int) Math.pow(chunkX * chunkZ, 3))
                  % (17 + chunkX % 5);
          if (ch == 0 && worldObj.rand.nextInt(120) == 0) {
            AxisAlignedBB par2AxisAlignedBB =
                AxisAlignedBB.getBoundingBox(
                    (double) (chunkX * 16) - 32,
                    (double) 0,
                    (double) (chunkZ * 16) - 32,
                    (double) (chunkX * 16) + 32,
                    (double) 96,
                    (double) (chunkZ * 16) + 32);
            // par2AxisAlignedBB.expand(16, 16, 16);
            List<Entity> ents =
                worldObj.getEntitiesWithinAABB(EntityBlinkDog.class, par2AxisAlignedBB);
            if (ents.size() < 4) {
              n = 1 + worldObj.rand.nextInt(2);
              for (; n >= 0; n--) {
                x = worldObj.rand.nextInt(16) + chunkX * 16;
                z = worldObj.rand.nextInt(16) + chunkZ * 16;
                y = getFirstUncoveredBlock(worldObj, x, z);
                if (y > 0) {
                  // System.out.println("Placed blink dog at (" + x + "," + y + "," + z + ")");
                  EntityBlinkDog entitychicken = new EntityBlinkDog(worldObj);
                  entitychicken.setLocationAndAngles(
                      (double) x, (double) y, (double) z, 0.0F, 0.0F);
                  worldObj.spawnEntityInWorld(entitychicken);
                }
              }
            }
          }
        }
        if (!foundempyreal) {
          ch =
              (chunkX * (chunkX + chunkZ)
                      + chunkZ * (chunkZ + chunkX)
                      + worldObj.provider.dimensionId
                      + (int) Math.pow(chunkX * chunkZ, 3))
                  % (17 + chunkX % 5);
          if (ch == 0 && worldObj.rand.nextInt(80) == 0) {
            x = worldObj.rand.nextInt(16) + chunkX * 16;
            z = worldObj.rand.nextInt(16) + chunkZ * 16;
            y = getFirstAirBlock(worldObj, x, z);
            if (y > 0) {
              // System.out.println("Placed blink dog at (" + x + "," + y + "," + z + ")");
              EntityEmpyreal entitychicken = new EntityEmpyreal(worldObj);
              entitychicken.setLocationAndAngles((double) x, (double) y, (double) z, 0.0F, 0.0F);
              worldObj.spawnEntityInWorld(entitychicken);
            }
          }
        }
      }
      // }
    }
  }