コード例 #1
0
  /** Render the mob inside the mob spawner. */
  public static void renderMob(
      MobSpawnerBaseLogic mobSpawnerLogic,
      double posX,
      double posY,
      double posZ,
      float partialTicks) {
    Entity entity = mobSpawnerLogic.func_180612_a(mobSpawnerLogic.getSpawnerWorld());

    if (entity != null) {
      float f = 0.4375F;
      GlStateManager.translate(0.0F, 0.4F, 0.0F);
      GlStateManager.rotate(
          (float)
                  (mobSpawnerLogic.getPrevMobRotation()
                      + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation())
                          * (double) partialTicks)
              * 10.0F,
          0.0F,
          1.0F,
          0.0F);
      GlStateManager.rotate(-30.0F, 1.0F, 0.0F, 0.0F);
      GlStateManager.translate(0.0F, -0.4F, 0.0F);
      GlStateManager.scale(f, f, f);
      entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
      Minecraft.getMinecraft()
          .getRenderManager()
          .renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
    }
  }
コード例 #2
0
  private void spawnMob() {
    // TODO Check how many mobs are in the local area and don't spawn if > configurable amount

    @SuppressWarnings("unchecked")
    Iterator<EntityEggInfo> iterator = EntityList.entityEggs.values().iterator();
    List<Integer> ids = new ArrayList<Integer>();
    while (iterator.hasNext()) {
      EntityEggInfo entityegginfo = iterator.next();
      ids.add(entityegginfo.spawnedID);
    }
    // shuffle and pick from IDs
    Collections.shuffle(ids);
    int id = ids.get(0);
    Entity entity = null;
    entity = EntityList.createEntityByID(id, worldObj);

    if (entity != null && entity instanceof EntityLivingBase) {
      EntityLiving entityliving = (EntityLiving) entity;
      entity.setLocationAndAngles(
          xCoord + 2 + MathHelper.randomDoubleInRange(0, xLength - 3),
          yCoord + 1.0,
          zCoord + 2 + MathHelper.randomDoubleInRange(0, zLength - 3),
          net.minecraft.util.MathHelper.wrapAngleTo180_float(worldObj.rand.nextFloat() * 360.0f),
          0.0f);
      worldObj.spawnEntityInWorld(entity);
      entityliving.playLivingSound();
    }
  }
コード例 #3
0
 /**
  * Sets an entity's location near x/y/z so that it doesn't spawn inside of walls.
  *
  * @return false if no suitable location found
  */
 public static boolean setEntityInStructure(World world, Entity entity, int x, int y, int z) {
   if (entity == null) {
     return false;
   }
   int i = 0;
   entity.setLocationAndAngles(x, y, z, 0.0F, 0.0F);
   while (entity.isEntityInsideOpaqueBlock() && i < 8) {
     if (i == 4) {
       entity.setPosition(x + 1, y, z + 1);
     }
     switch (i % 4) {
       case 0:
         entity.setPosition(entity.posX + 0.5D, entity.posY, entity.posZ + 0.5D);
         break;
       case 1:
         entity.setPosition(entity.posX, entity.posY, entity.posZ - 1.0D);
         break;
       case 2:
         entity.setPosition(entity.posX - 1.0D, entity.posY, entity.posZ);
         break;
       case 3:
         entity.setPosition(entity.posX, entity.posY, entity.posZ + 1.0D);
         break;
     }
     ++i;
   }
   if (entity.isEntityInsideOpaqueBlock()) {
     entity.setPosition(entity.posX + 0.5D, entity.posY, entity.posZ + 0.5D);
     return false;
   }
   return true;
 }
コード例 #4
0
  /** Place an entity in a nearby portal, creating one if necessary. */
  public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) {
    if (this.worldServerInstance.provider.dimensionId != 1) {
      if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) {
        this.makePortal(par1Entity);
        this.placeInExistingPortal(par1Entity, par2, par4, par6, par8);
      }
    } else {
      int i = MathHelper.floor_double(par1Entity.posX);
      int j = MathHelper.floor_double(par1Entity.posY) - 1;
      int k = MathHelper.floor_double(par1Entity.posZ);
      byte b0 = 1;
      byte b1 = 0;

      for (int l = -2; l <= 2; ++l) {
        for (int i1 = -2; i1 <= 2; ++i1) {
          for (int j1 = -1; j1 < 3; ++j1) {
            int k1 = i + i1 * b0 + l * b1;
            int l1 = j + j1;
            int i2 = k + i1 * b1 - l * b0;
            boolean flag = j1 < 0;
            this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.sandstone : Blocks.air);
          }
        }
      }

      par1Entity.setLocationAndAngles(
          (double) i, (double) j, (double) k, par1Entity.rotationYaw, 0.0F);
      par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
    }
  }
コード例 #5
0
 /** Place an entity in a nearby portal which already exists. */
 public boolean placeInExistingPortal(
     Entity par1Entity, double par2, double par4, double par6, float par8) {
   par1Entity.setLocationAndAngles(
       ScourgeCraftCore.configDimensions.eventXPos,
       ScourgeCraftCore.configDimensions.eventYPos,
       ScourgeCraftCore.configDimensions.eventZPos,
       par1Entity.rotationYaw,
       par1Entity.rotationPitch);
   return true;
 }
コード例 #6
0
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
コード例 #7
0
  /** Teleports the entity to another dimension. Params: Dimension number to teleport to */
  public static void travelEntityToDimension(Entity entity, int dimensionId, int x, int y, int z) {
    if (!entity.worldObj.isRemote && !entity.isDead) {
      entity.worldObj.theProfiler.startSection("changeDimension");
      MinecraftServer minecraftserver = MinecraftServer.getServer();
      int j = entity.dimension;
      WorldServer worldserver = minecraftserver.worldServerForDimension(j);
      WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
      entity.dimension = dimensionId;

      if (j == 1 && dimensionId == 1) {
        worldserver1 = minecraftserver.worldServerForDimension(0);
        entity.dimension = 0;
      }

      entity.worldObj.removeEntity(entity);
      entity.isDead = false;
      entity.worldObj.theProfiler.startSection("reposition");
      minecraftserver
          .getConfigurationManager()
          .transferEntityToWorld(entity, j, worldserver, worldserver1);
      entity.worldObj.theProfiler.endStartSection("reloading");
      Entity newEntity =
          EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

      if (newEntity != null) {
        newEntity.copyDataFrom(entity, true);

        if (j == 1 && dimensionId == 1) {
          ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint();
          chunkcoordinates.posY =
              entity.worldObj.getTopSolidOrLiquidBlock(
                  chunkcoordinates.posX, chunkcoordinates.posZ);
          newEntity.setLocationAndAngles(
              (double) chunkcoordinates.posX,
              (double) chunkcoordinates.posY,
              (double) chunkcoordinates.posZ,
              newEntity.rotationYaw,
              newEntity.rotationPitch);
        }

        worldserver1.spawnEntityInWorld(newEntity);
        newEntity.setPosition(x + 0.5D, y, z + 0.5D);
      }

      entity.isDead = true;
      entity.worldObj.theProfiler.endSection();
      worldserver.resetUpdateEntityTick();
      worldserver1.resetUpdateEntityTick();
      entity.worldObj.theProfiler.endSection();
    }
  }
コード例 #8
0
  public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (worldIn.isAirBlock(position)
        && worldIn.getBlockState(position.down()).getBlock() == this.baseBlockRequired) {
      int i = rand.nextInt(32) + 6;
      int j = rand.nextInt(4) + 1;
      BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

      for (int k = position.getX() - j; k <= position.getX() + j; ++k) {
        for (int l = position.getZ() - j; l <= position.getZ() + j; ++l) {
          int i1 = k - position.getX();
          int j1 = l - position.getZ();

          if (i1 * i1 + j1 * j1 <= j * j + 1
              && worldIn
                      .getBlockState(blockpos$mutableblockpos.set(k, position.getY() - 1, l))
                      .getBlock()
                  != this.baseBlockRequired) {
            return false;
          }
        }
      }

      for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 256; ++l1) {
        for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2) {
          for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2) {
            int k2 = i2 - position.getX();
            int k1 = j2 - position.getZ();

            if (k2 * k2 + k1 * k1 <= j * j + 1) {
              worldIn.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2);
            }
          }
        }
      }

      Entity entity = new EntityEnderCrystal(worldIn);
      entity.setLocationAndAngles(
          (double) ((float) position.getX() + 0.5F),
          (double) (position.getY() + i),
          (double) ((float) position.getZ() + 0.5F),
          rand.nextFloat() * 360.0F,
          0.0F);
      worldIn.spawnEntityInWorld(entity);
      worldIn.setBlockState(position.up(i), Blocks.bedrock.getDefaultState(), 2);
      return true;
    } else {
      return false;
    }
  }
コード例 #9
0
ファイル: Portal.java プロジェクト: goeiecool9999/Portals
  @Override
  public void update() {
    AxisAlignedBB bbox =
        PortalgunMod.portalBlock
            .getCollisionBoundingBox(worldObj, this.getPos(), worldObj.getBlockState(this.getPos()))
            .expand(0, 1, 0.1);
    List<Entity> ents = worldObj.getEntitiesWithinAABB(Entity.class, bbox);

    for (Entity entityIn : ents) {
      Portal portal = this;
      if (portal.linked != null) {
        Vec3 thisPortal = new Vec3(pos.getX(), pos.getY(), pos.getZ());
        BlockPos otherPortalBP = portal.linked.getPos();
        Vec3 otherPortal =
            new Vec3(otherPortalBP.getX(), otherPortalBP.getY(), otherPortalBP.getZ());
        Vec3 diff = otherPortal.subtract(thisPortal);

        Vec3 newPos = entityIn.getPositionVector().add(diff);
        entityIn.motionZ = -entityIn.motionZ;
        entityIn.setLocationAndAngles(
            newPos.xCoord,
            newPos.yCoord,
            newPos.zCoord + 0.2,
            entityIn.getRotationYawHead() + 180,
            entityIn.rotationPitch);
        entityIn.prevRotationYaw = entityIn.rotationYaw;
        entityIn.prevRotationPitch = entityIn.rotationPitch;

        if (entityIn instanceof EntityPlayerSP) {
          EntityPlayerSP SPplayer = (EntityPlayerSP) entityIn;
          SPplayer.prevRenderArmYaw = SPplayer.renderArmYaw += 180;
          SPplayer.prevRotationYawHead = SPplayer.rotationYawHead += 180;
        }
      }
    }
  }
コード例 #10
0
  /** Transfers an entity from a world to another world. */
  public void transferEntityToWorld(
      Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_) {
    double var5 = entityIn.posX;
    double var7 = entityIn.posZ;
    double var9 = 8.0D;
    float var11 = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

    if (entityIn.dimension == -1) {
      var5 =
          MathHelper.clamp_double(
              var5 / var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 / var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else if (entityIn.dimension == 0) {
      var5 =
          MathHelper.clamp_double(
              var5 * var9,
              p_82448_4_.getWorldBorder().minX() + 16.0D,
              p_82448_4_.getWorldBorder().maxX() - 16.0D);
      var7 =
          MathHelper.clamp_double(
              var7 * var9,
              p_82448_4_.getWorldBorder().minZ() + 16.0D,
              p_82448_4_.getWorldBorder().maxZ() - 16.0D);
      entityIn.setLocationAndAngles(
          var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    } else {
      BlockPos var12;

      if (p_82448_2_ == 1) {
        var12 = p_82448_4_.getSpawnPoint();
      } else {
        var12 = p_82448_4_.func_180504_m();
      }

      var5 = (double) var12.getX();
      entityIn.posY = (double) var12.getY();
      var7 = (double) var12.getZ();
      entityIn.setLocationAndAngles(var5, entityIn.posY, var7, 90.0F, 0.0F);

      if (entityIn.isEntityAlive()) {
        p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
      }
    }

    p_82448_3_.theProfiler.endSection();

    if (p_82448_2_ != 1) {
      p_82448_3_.theProfiler.startSection("placing");
      var5 = (double) MathHelper.clamp_int((int) var5, -29999872, 29999872);
      var7 = (double) MathHelper.clamp_int((int) var7, -29999872, 29999872);

      if (entityIn.isEntityAlive()) {
        entityIn.setLocationAndAngles(
            var5, entityIn.posY, var7, entityIn.rotationYaw, entityIn.rotationPitch);
        p_82448_4_.getDefaultTeleporter().func_180266_a(entityIn, var11);
        p_82448_4_.spawnEntityInWorld(entityIn);
        p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
      }

      p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
  }
コード例 #11
0
 public static void doTeleportEntity(Entity entity, WarpPoint point) {
   if (entity.dimension != point.getDimension()) entity.travelToDimension(point.getDimension());
   entity.setLocationAndAngles(
       point.getX(), point.getY(), point.getZ(), point.getYaw(), point.getPitch());
 }
コード例 #12
0
ファイル: CommandSummon.java プロジェクト: EvilKanoa/KClient
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1) {
      String var3 = par2ArrayOfStr[0];
      double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D;
      double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY;
      double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D;

      if (par2ArrayOfStr.length >= 4) {
        var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]);
        var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]);
        var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]);
      }

      World var10 = par1ICommandSender.getEntityWorld();

      if (!var10.blockExists((int) var4, (int) var6, (int) var8)) {
        notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]);
      } else {
        NBTTagCompound var11 = new NBTTagCompound();
        boolean var12 = false;

        if (par2ArrayOfStr.length >= 5) {
          IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4);

          try {
            NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText());

            if (!(var14 instanceof NBTTagCompound)) {
              notifyAdmins(
                  par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"});
              return;
            }

            var11 = (NBTTagCompound) var14;
            var12 = true;
          } catch (NBTException var17) {
            notifyAdmins(
                par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()});
            return;
          }
        }

        var11.setString("id", var3);
        Entity var18 = EntityList.createEntityFromNBT(var11, var10);

        if (var18 != null) {
          var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch);

          if (!var12 && var18 instanceof EntityLiving) {
            ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null);
          }

          var10.spawnEntityInWorld(var18);
          Entity var19 = var18;

          for (NBTTagCompound var15 = var11;
              var15.func_150297_b("Riding", 10);
              var15 = var15.getCompoundTag("Riding")) {
            Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10);

            if (var16 != null) {
              var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch);
              var10.spawnEntityInWorld(var16);
              var19.mountEntity(var16);
            }

            var19 = var16;
          }

          notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]);
        } else {
          notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]);
        }
      }
    } else {
      throw new WrongUsageException("commands.summon.usage", new Object[0]);
    }
  }
コード例 #13
0
  public void updateSpawner() {
    if (isActivated() && !powered) {
      double d2;

      if (this.getSpawnerWorld().isRemote) {
        double d0 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat());
        double d1 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat());
        d2 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat());
        this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
        this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);

        if (this.spawnDelay > 0) {
          --this.spawnDelay;
        }

        this.renderRotation1 = this.renderRotation0;
        this.renderRotation0 =
            (this.renderRotation0 + (double) (1000.0F / ((float) this.spawnDelay + 200.0F)))
                % 360.0D;
      } else {
        if (this.spawnDelay == -1) {
          this.resetTimer();
        }

        if (this.spawnDelay > 0) {
          --this.spawnDelay;
          return;
        }

        boolean flag = false;

        for (int i = 0; i < this.spawnCount; ++i) {
          Entity entity =
              EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld());

          if (entity == null) {
            return;
          }

          int j =
              this.getSpawnerWorld()
                  .getEntitiesWithinAABB(
                      entity.getClass(),
                      AxisAlignedBB.getBoundingBox(
                              (double) this.getSpawnerX(),
                              (double) this.getSpawnerY(),
                              (double) this.getSpawnerZ(),
                              (double) (this.getSpawnerX() + 1),
                              (double) (this.getSpawnerY() + 1),
                              (double) (this.getSpawnerZ() + 1))
                          .expand(
                              (double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2)))
                  .size();

          if (j >= this.maxNearbyEntities) {
            this.resetTimer();
            return;
          }

          int x =
              this.getSpawnerX()
                  + (int)
                      ((this.getSpawnerWorld().rand.nextDouble()
                              - this.getSpawnerWorld().rand.nextDouble())
                          * (double) this.spawnRange);
          int y = this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1;
          int z =
              this.getSpawnerZ()
                  + (int)
                      ((this.getSpawnerWorld().rand.nextDouble()
                              - this.getSpawnerWorld().rand.nextDouble())
                          * (double) this.spawnRange);
          EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null;
          entity.setLocationAndAngles(
              x + 0.5, y + 0.5, z + 0.5, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);

          if (entityliving == null
              || (entityliving.getCanSpawnHere()
                  || ignoreSpawnRequirements
                      && getSpawnerWorld().getBlock(x, y, z) == Blocks.air)) {
            this.spawnEntity(entity);
            this.getSpawnerWorld()
                .playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0);

            if (entityliving != null) {
              entityliving.spawnExplosionParticle();
            }

            flag = true;
          }
        }

        if (flag) {
          this.resetTimer();
        }
      }
    }
  }
コード例 #14
0
  public void updateSpawner() {
    if (this.canRun()) {
      double var5;

      if (this.getSpawnerWorld().isClient) {
        double var1 =
            (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat());
        double var3 =
            (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat());
        var5 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat());
        this.getSpawnerWorld().spawnParticle("smoke", var1, var3, var5, 0.0D, 0.0D, 0.0D);
        this.getSpawnerWorld().spawnParticle("flame", var1, var3, var5, 0.0D, 0.0D, 0.0D);

        if (this.spawnDelay > 0) {
          --this.spawnDelay;
        }

        this.field_98284_d = this.field_98287_c;
        this.field_98287_c =
            (this.field_98287_c + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D;
      } else {
        if (this.spawnDelay == -1) {
          this.resetTimer();
        }

        if (this.spawnDelay > 0) {
          --this.spawnDelay;
          return;
        }

        boolean var12 = false;

        for (int var2 = 0; var2 < this.spawnCount; ++var2) {
          Entity var13 =
              EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld());

          if (var13 == null) {
            return;
          }

          int var4 =
              this.getSpawnerWorld()
                  .getEntitiesWithinAABB(
                      var13.getClass(),
                      AxisAlignedBB.getBoundingBox(
                              (double) this.getSpawnerX(),
                              (double) this.getSpawnerY(),
                              (double) this.getSpawnerZ(),
                              (double) (this.getSpawnerX() + 1),
                              (double) (this.getSpawnerY() + 1),
                              (double) (this.getSpawnerZ() + 1))
                          .expand(
                              (double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2)))
                  .size();

          if (var4 >= this.maxNearbyEntities) {
            this.resetTimer();
            return;
          }

          var5 =
              (double) this.getSpawnerX()
                  + (this.getSpawnerWorld().rand.nextDouble()
                          - this.getSpawnerWorld().rand.nextDouble())
                      * (double) this.spawnRange;
          double var7 = (double) (this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1);
          double var9 =
              (double) this.getSpawnerZ()
                  + (this.getSpawnerWorld().rand.nextDouble()
                          - this.getSpawnerWorld().rand.nextDouble())
                      * (double) this.spawnRange;
          EntityLiving var11 = var13 instanceof EntityLiving ? (EntityLiving) var13 : null;
          var13.setLocationAndAngles(
              var5, var7, var9, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);

          if (var11 == null || var11.getCanSpawnHere()) {
            this.func_98265_a(var13);
            this.getSpawnerWorld()
                .playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0);

            if (var11 != null) {
              var11.spawnExplosionParticle();
            }

            var12 = true;
          }
        }

        if (var12) {
          this.resetTimer();
        }
      }
    }
  }
コード例 #15
0
  private static Entity sendEntityToWorld(
      Entity entity, int newDimension, Vector3 newPos, Facing3 newLook) {
    MinecraftServer server = MinecraftServer.getServer();
    Entity currentEntity = entity;
    if (entity.dimension != newDimension) {
      if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        ServerConfigurationManager scm = server.getConfigurationManager();
        int oldDimension = player.dimension;
        player.dimension = newDimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);

        DimensionRegisterMessage packet =
            new DimensionRegisterMessage(
                newDimension, DimensionManager.getProviderType(newDimension));
        LCRuntime.runtime.network().getPreferredPipe().sendForgeMessageTo(packet, player);

        player.closeScreen();
        player.playerNetServerHandler.sendPacket(
            new S07PacketRespawn(
                player.dimension,
                player.worldObj.difficultySetting,
                newWorld.getWorldInfo().getTerrainType(),
                player.theItemInWorldManager.getGameType()));
        oldWorld.removePlayerEntityDangerously(player);
        player.isDead = false;
        player.setLocationAndAngles(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        newWorld.spawnEntityInWorld(player);
        player.setWorld(newWorld);
        scm.func_72375_a(player, oldWorld);
        player.playerNetServerHandler.setPlayerLocation(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        player.theItemInWorldManager.setWorld(newWorld);
        scm.updateTimeAndWeatherForPlayer(player, newWorld);
        scm.syncPlayerInventory(player);
        Iterator<?> var6 = player.getActivePotionEffects().iterator();
        while (var6.hasNext())
          player.playerNetServerHandler.sendPacket(
              new S1DPacketEntityEffect(player.getEntityId(), (PotionEffect) var6.next()));
        player.playerNetServerHandler.sendPacket(
            new S1FPacketSetExperience(
                player.experience, player.experienceTotal, player.experienceLevel));
      } else {
        int oldDimension = entity.dimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);
        entity.dimension = newDimension;

        entity.worldObj.removeEntity(entity);
        entity.isDead = false;
        server
            .getConfigurationManager()
            .transferEntityToWorld(entity, oldDimension, oldWorld, newWorld);
        currentEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), newWorld);

        if (currentEntity != null) {
          currentEntity.copyDataFrom(entity, true);
          currentEntity.setLocationAndAngles(
              newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
          newWorld.spawnEntityInWorld(currentEntity);
        }

        entity.isDead = true;
        oldWorld.resetUpdateEntityTick();
        newWorld.resetUpdateEntityTick();
      }
    } else {
      currentEntity.setLocationAndAngles(
          newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
      if (currentEntity instanceof EntityPlayerMP) {
        EntityPlayerMP mpEnt = (EntityPlayerMP) currentEntity;
        mpEnt.rotationYaw = (float) newLook.yaw;
        mpEnt.setPositionAndUpdate(newPos.x, newPos.y, newPos.z);
        mpEnt.worldObj.updateEntityWithOptionalForce(entity, false);
      }
    }
    return currentEntity;
  }
コード例 #16
0
 @Override
 public void placeInPortal(Entity e, double x, double y, double z, float facing) {
   e.setLocationAndAngles(0, 1024, 0, 0, 0);
   this.placeInExistingPortal(e, x, y, z, facing);
 }
コード例 #17
0
  /** Place an entity in a nearby portal which already exists. */
  @SuppressWarnings("unchecked")
  public boolean placeInExistingPortal(
      Entity par1Entity, double par2, double par4, double par6, float par8) {
    short short1 = 128;
    double d3 = -1.0D;
    int i = 0;
    int j = 0;
    int k = 0;
    int l = MathHelper.floor_double(par1Entity.posX);
    int i1 = MathHelper.floor_double(par1Entity.posZ);
    long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1);
    boolean flag = true;
    double d4;
    int k1;

    if (this.field_85191_c.containsItem(j1)) {
      PortalPosition portalposition = (PortalPosition) this.field_85191_c.getValueByKey(j1);
      d3 = 0.0D;
      i = portalposition.posX;
      j = portalposition.posY;
      k = portalposition.posZ;
      portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
      flag = false;
    } else {
      for (k1 = l - short1; k1 <= l + short1; ++k1) {
        double d5 = (double) k1 + 0.5D - par1Entity.posX;

        for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) {
          double d6 = (double) l1 + 0.5D - par1Entity.posZ;

          for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) {
            if (this.worldServerInstance.getBlock(k1, i2, l1) == DimBlocks.BlockDebug) {
              while (this.worldServerInstance.getBlock(k1, i2 - 1, l1) == DimBlocks.BlockDebug) {
                --i2;
              }

              d4 = (double) i2 + 0.5D - par1Entity.posY;
              double d7 = d5 * d5 + d4 * d4 + d6 * d6;

              if (d3 < 0.0D || d7 < d3) {
                d3 = d7;
                i = k1;
                j = i2;
                k = l1;
              }
            }
          }
        }
      }
    }

    if (d3 >= 0.0D) {
      if (flag) {
        // TODO ERROR?
        this.field_85191_c.add(
            j1, new PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime()));
        this.field_85190_d.add(Long.valueOf(j1));
      }

      double d8 = (double) i + 0.5D;
      double d9 = (double) j + 0.5D;
      d4 = (double) k + 0.5D;
      int j2 = -1;

      if (this.worldServerInstance.getBlock(i - 1, j, k) == DimBlocks.BlockDebug) {
        j2 = 2;
      }

      if (this.worldServerInstance.getBlock(i + 1, j, k) == DimBlocks.BlockDebug) {
        j2 = 0;
      }

      if (this.worldServerInstance.getBlock(i, j, k - 1) == DimBlocks.BlockDebug) {
        j2 = 3;
      }

      if (this.worldServerInstance.getBlock(i, j, k + 1) == DimBlocks.BlockDebug) {
        j2 = 1;
      }

      int k2 = par1Entity.getTeleportDirection();

      if (j2 > -1) {
        int l2 = Direction.rotateLeft[j2];
        int i3 = Direction.offsetX[j2];
        int j3 = Direction.offsetZ[j2];
        int k3 = Direction.offsetX[l2];
        int l3 = Direction.offsetZ[l2];
        boolean flag1 =
            !this.worldServerInstance.isAirBlock(i + i3 + k3, j, k + j3 + l3)
                || !this.worldServerInstance.isAirBlock(i + i3 + k3, j + 1, k + j3 + l3);
        boolean flag2 =
            !this.worldServerInstance.isAirBlock(i + i3, j, k + j3)
                || !this.worldServerInstance.isAirBlock(i + i3, j + 1, k + j3);

        if (flag1 && flag2) {
          j2 = Direction.rotateOpposite[j2];
          l2 = Direction.rotateOpposite[l2];
          i3 = Direction.offsetX[j2];
          j3 = Direction.offsetZ[j2];
          k3 = Direction.offsetX[l2];
          l3 = Direction.offsetZ[l2];
          k1 = i - k3;
          d8 -= (double) k3;
          int i4 = k - l3;
          d4 -= (double) l3;
          flag1 =
              !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j, i4 + j3 + l3)
                  || !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j + 1, i4 + j3 + l3);
          flag2 =
              !this.worldServerInstance.isAirBlock(k1 + i3, j, i4 + j3)
                  || !this.worldServerInstance.isAirBlock(k1 + i3, j + 1, i4 + j3);
        }

        float f1 = 0.5F;
        float f2 = 0.5F;

        if (!flag1 && flag2) {
          f1 = 1.0F;
        } else if (flag1 && !flag2) {
          f1 = 0.0F;
        } else if (flag1 && flag2) {
          f2 = 0.0F;
        }

        d8 += (double) ((float) k3 * f1 + f2 * (float) i3);
        d4 += (double) ((float) l3 * f1 + f2 * (float) j3);
        float f3 = 0.0F;
        float f4 = 0.0F;
        float f5 = 0.0F;
        float f6 = 0.0F;

        if (j2 == k2) {
          f3 = 1.0F;
          f4 = 1.0F;
        } else if (j2 == Direction.rotateOpposite[k2]) {
          f3 = -1.0F;
          f4 = -1.0F;
        } else if (j2 == Direction.rotateRight[k2]) {
          f5 = 1.0F;
          f6 = -1.0F;
        } else {
          f5 = -1.0F;
          f6 = 1.0F;
        }

        double d10 = par1Entity.motionX;
        double d11 = par1Entity.motionZ;
        par1Entity.motionX = d10 * (double) f3 + d11 * (double) f6;
        par1Entity.motionZ = d10 * (double) f5 + d11 * (double) f4;
        par1Entity.rotationYaw = par8 - (float) (k2 * 90) + (float) (j2 * 90);
      } else {
        par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
      }

      par1Entity.setLocationAndAngles(d8, d9, d4, par1Entity.rotationYaw, par1Entity.rotationPitch);
      return true;
    } else {
      return false;
    }
  }
コード例 #18
0
  private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg) {
    ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId);
    EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId);
    WorldClient wc = FMLClientHandler.instance().getWorldClient();
    Class<? extends Entity> cls = er.getEntityClass();
    try {
      Entity entity;
      if (er.hasCustomSpawning()) {
        entity = er.doCustomSpawning(spawnMsg);
      } else {
        entity = (Entity) (cls.getConstructor(World.class).newInstance(wc));

        int offset = spawnMsg.entityId - entity.getEntityId();
        entity.setEntityId(spawnMsg.entityId);
        entity.setLocationAndAngles(
            spawnMsg.scaledX,
            spawnMsg.scaledY,
            spawnMsg.scaledZ,
            spawnMsg.scaledYaw,
            spawnMsg.scaledPitch);
        if (entity instanceof EntityLiving) {
          ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw;
        }

        Entity parts[] = entity.getParts();
        if (parts != null) {
          for (int j = 0; j < parts.length; j++) {
            parts[j].setEntityId(parts[j].getEntityId() + offset);
          }
        }
      }

      entity.serverPosX = spawnMsg.rawX;
      entity.serverPosY = spawnMsg.rawY;
      entity.serverPosZ = spawnMsg.rawZ;

      EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity();
      if (entity instanceof IThrowableEntity) {
        Entity thrower =
            clientPlayer.getEntityId() == spawnMsg.throwerId
                ? clientPlayer
                : wc.getEntityByID(spawnMsg.throwerId);
        ((IThrowableEntity) entity).setThrower(thrower);
      }

      if (spawnMsg.dataWatcherList != null) {
        entity.getDataWatcher().updateWatchedObjectsFromList((List<?>) spawnMsg.dataWatcherList);
      }

      if (spawnMsg.throwerId > 0) {
        entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ);
      }

      if (entity instanceof IEntityAdditionalSpawnData) {
        ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
      }
      wc.addEntityToWorld(spawnMsg.entityId, entity);
    } catch (Exception e) {
      FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity");
      throw Throwables.propagate(e);
    }
  }
コード例 #19
0
  /** Transfers an entity from a world to another world. */
  public void transferEntityToWorld(
      Entity par1Entity, int par2, WorldServer par3WorldServer, WorldServer par4WorldServer) {
    double var5 = par1Entity.posX;
    double var7 = par1Entity.posZ;
    double var9 = 8.0D;
    double var11 = par1Entity.posX;
    double var13 = par1Entity.posY;
    double var15 = par1Entity.posZ;
    float var17 = par1Entity.rotationYaw;
    par3WorldServer.theProfiler.startSection("moving");

    if (par1Entity.dimension == -1) {
      var5 /= var9;
      var7 /= var9;
      par1Entity.setLocationAndAngles(
          var5, par1Entity.posY, var7, par1Entity.rotationYaw, par1Entity.rotationPitch);

      if (par1Entity.isEntityAlive()) {
        par3WorldServer.updateEntityWithOptionalForce(par1Entity, false);
      }
    } else if (par1Entity.dimension == 0) {
      var5 *= var9;
      var7 *= var9;
      par1Entity.setLocationAndAngles(
          var5, par1Entity.posY, var7, par1Entity.rotationYaw, par1Entity.rotationPitch);

      if (par1Entity.isEntityAlive()) {
        par3WorldServer.updateEntityWithOptionalForce(par1Entity, false);
      }
    } else {
      ChunkCoordinates var18;

      if (par2 == 1) {
        var18 = par4WorldServer.getSpawnPoint();
      } else {
        var18 = par4WorldServer.getEntrancePortalLocation();
      }

      var5 = (double) var18.posX;
      par1Entity.posY = (double) var18.posY;
      var7 = (double) var18.posZ;
      par1Entity.setLocationAndAngles(var5, par1Entity.posY, var7, 90.0F, 0.0F);

      if (par1Entity.isEntityAlive()) {
        par3WorldServer.updateEntityWithOptionalForce(par1Entity, false);
      }
    }

    par3WorldServer.theProfiler.endSection();

    if (par2 != 1) {
      par3WorldServer.theProfiler.startSection("placing");
      var5 = (double) MathHelper.clamp_int((int) var5, -29999872, 29999872);
      var7 = (double) MathHelper.clamp_int((int) var7, -29999872, 29999872);

      if (par1Entity.isEntityAlive()) {
        par4WorldServer.spawnEntityInWorld(par1Entity);
        par1Entity.setLocationAndAngles(
            var5, par1Entity.posY, var7, par1Entity.rotationYaw, par1Entity.rotationPitch);
        par4WorldServer.updateEntityWithOptionalForce(par1Entity, false);
        par4WorldServer.func_85176_s().placeInPortal(par1Entity, var11, var13, var15, var17);
      }

      par3WorldServer.theProfiler.endSection();
    }

    par1Entity.setWorld(par4WorldServer);
  }
コード例 #20
0
ファイル: ItemSoulVessel.java プロジェクト: XFRGod/EnderIO
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {

    if (world.isRemote) {
      return true;
    }
    if (!containsSoul(itemstack)) {
      return false;
    }
    if (player == null) {
      return false;
    }

    Entity mob;
    NBTTagCompound root = itemstack.stackTagCompound;
    if (root.hasKey("isStub")) {
      String entityId = root.getString("id");
      mob = EntityList.createEntityByName(entityId, world);
    } else {
      mob = EntityList.createEntityFromNBT(root, world);
    }
    if (mob == null) {
      return true;
    }
    mob.readFromNBT(root);

    Block blk = world.getBlock(x, y, z);
    double spawnX = x + Facing.offsetsXForSide[side] + 0.5;
    double spawnY = y + Facing.offsetsYForSide[side];
    double spawnZ = z + Facing.offsetsZForSide[side] + 0.5;
    if (side == ForgeDirection.UP.ordinal()
        && (blk instanceof BlockFence || blk instanceof BlockWall)) {
      spawnY += 0.5;
    }
    mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);

    boolean spaceClear =
        world.checkNoEntityCollision(mob.boundingBox)
            && world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty();
    if (!spaceClear) {
      return false;
    }

    if (itemstack.hasDisplayName() && mob instanceof EntityLiving) {
      ((EntityLiving) mob).setCustomNameTag(itemstack.getDisplayName());
    }

    world.spawnEntityInWorld(mob);
    if (mob instanceof EntityLiving) {
      ((EntityLiving) mob).playLivingSound();
    }

    Entity riddenByEntity = mob.riddenByEntity;
    while (riddenByEntity != null) {
      riddenByEntity.setLocationAndAngles(
          spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
      world.spawnEntityInWorld(riddenByEntity);
      if (riddenByEntity instanceof EntityLiving) {
        ((EntityLiving) riddenByEntity).playLivingSound();
      }
      riddenByEntity = riddenByEntity.riddenByEntity;
    }

    if (!player.capabilities.isCreativeMode) {
      if (itemstack.stackSize > 1) {
        itemstack.stackSize--;
        player.inventory.addItemStackToInventory(new ItemStack(this));
        player.inventoryContainer.detectAndSendChanges();
      } else {
        itemstack.setTagCompound(null);
      }
    }

    return true;
  }
コード例 #21
0
 public static void travelToPosition(Entity entity, int x, int y, int z) {
   if (!entity.worldObj.isRemote)
     entity.setLocationAndAngles(x + 0.5, y, z + 0.5, entity.rotationYaw, entity.rotationPitch);
 }