Package net.minecraft.world

Examples of net.minecraft.world.WorldServer


        if (this.targetVec != null)
        {
            if (this.targetDimension != this.worldObj.provider.dimensionId)
            {
                WorldServer worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(this.targetDimension);

                if (!this.worldObj.isRemote && worldServer != null)
                {
                    this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + 800, this.targetVec.z + 0.5F);
                    Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, worldServer, false, null);
View Full Code Here


            ShortRangeTelepadHandler.TelepadEntry addressResult = ShortRangeTelepadHandler.getLocationFromAddress(this.targetAddress);
            TileEntityShortRangeTelepad foundTelepad = null;

            if (addressResult != null)
            {
                WorldServer world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(addressResult.dimensionID);

                TileEntity tile2 = addressResult.position.getTileEntity(world);

                if (tile2 == null)
                {
View Full Code Here

            {
                WorldServer[] worlds = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;

                for (int i = 0; i < worlds.length; i++)
                {
                    WorldServer world = worlds[i];
                    ChunkProviderServer chunkProviderServer = world.theChunkProviderServer;

                    Map<Long, List<Footprint>> footprintMap = TickHandlerServer.serverFootprintMap.get(world.provider.dimensionId);

                    if (footprintMap != null)
                    {
                        boolean mapChanged = false;

                        if (chunkProviderServer != null)
                        {
                            Iterator iterator = chunkProviderServer.loadedChunks.iterator();

                            while (iterator.hasNext())
                            {
                                Chunk chunk = (Chunk) iterator.next();
                                long chunkKey = ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition);

                                List<Footprint> footprints = footprintMap.get(chunkKey);

                                if (footprints != null)
                                {
                                    List<Footprint> toRemove = new ArrayList<Footprint>();

                                    for (int j = 0; j < footprints.size(); j++)
                                    {
                                        footprints.get(j).age += 100;

                                        if (footprints.get(j).age >= Footprint.MAX_AGE)
                                        {
                                            toRemove.add(footprints.get(j));
                                        }
                                    }

                                    if (!toRemove.isEmpty())
                                    {
                                        footprints.removeAll(toRemove);
                                    }

                                    footprintMap.put(chunkKey, footprints);
                                    mapChanged = true;

                                    GalacticraftCore.packetPipeline.sendToDimension(new PacketSimple(EnumSimplePacket.C_UPDATE_FOOTPRINT_LIST, new Object[] { chunkKey, footprints.toArray(new Footprint[footprints.size()]) }), worlds[i].provider.dimensionId);
                                }
                            }
                        }

                        if (mapChanged)
                        {
                            TickHandlerServer.serverFootprintMap.put(world.provider.dimensionId, footprintMap);
                        }
                    }
                }
            }
            else if (!footprintRefreshList.isEmpty())
            {
                for (NetworkRegistry.TargetPoint targetPoint : footprintRefreshList)
                {
                    WorldServer[] worlds = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;

                    for (int i = 0; i < worlds.length; i++)
                    {
                        WorldServer world = worlds[i];

                        if (world.provider.dimensionId == targetPoint.dimension)
                        {
                            long chunkKey = ChunkCoordIntPair.chunkXZ2Int((int)targetPoint.x >> 4, (int)targetPoint.z >> 4);
                            Map<Long, List<Footprint>> footprintMap = TickHandlerServer.serverFootprintMap.get(world.provider.dimensionId);
View Full Code Here

    @SubscribeEvent
    public void onWorldTick(WorldTickEvent event)
    {
        if (event.phase == Phase.START)
        {
            final WorldServer world = (WorldServer) event.world;

            CopyOnWriteArrayList<ScheduledBlockChange> changeList = TickHandlerServer.scheduledBlockChanges.get(world.provider.dimensionId);

            if (changeList != null && !changeList.isEmpty())
            {
                for (ScheduledBlockChange change : changeList)
                {
                    if (change != null)
                    {
                        BlockVec3 changePosition = change.getChangePosition();
                        if (changePosition != null)
                        {
                            world.setBlock(changePosition.x, changePosition.y, changePosition.z, change.getChangeID(), change.getChangeMeta(), 2);
                        }
                    }
                }

                changeList.clear();
                TickHandlerServer.scheduledBlockChanges.remove(world.provider.dimensionId);
            }

            CopyOnWriteArrayList<BlockVec3> torchList = TickHandlerServer.scheduledTorchUpdates.get(world.provider.dimensionId);

            if (torchList != null && !torchList.isEmpty())
            {
                for (BlockVec3 torch : torchList)
                {
                    if (torch != null)
                    {
                        if (world.getBlock(torch.x, torch.y, torch.z) == GCBlocks.unlitTorch)
                        {
                            world.scheduleBlockUpdateWithPriority(torch.x, torch.y, torch.z, GCBlocks.unlitTorch, 2 + world.rand.nextInt(30), 0);
                        }
                        else if (world.getBlock(torch.x, torch.y, torch.z) == GCBlocks.unlitTorchLit)
                        {
                            world.scheduleBlockUpdateWithPriority(torch.x, torch.y, torch.z, GCBlocks.unlitTorchLit, 2 + world.rand.nextInt(30), 0);
                        }
                    }
                }

                torchList.clear();
                TickHandlerServer.scheduledTorchUpdates.remove(world.provider.dimensionId);
            }

            if (world.provider instanceof IOrbitDimension)
            {
                final Object[] entityList = world.loadedEntityList.toArray();

                for (final Object o : entityList)
                {
                    if (o instanceof Entity)
                    {
                        final Entity e = (Entity) o;

                        if (e.worldObj.provider instanceof IOrbitDimension)
                        {
                            final IOrbitDimension dimension = (IOrbitDimension) e.worldObj.provider;

                            if (e.posY <= dimension.getYCoordToTeleportToPlanet())
                            {
                                final Integer dim = WorldUtil.getProviderForName(dimension.getPlanetToOrbit()).dimensionId;

                                WorldUtil.transferEntityToDimension(e, dim, world, false, null);
                            }
                        }
                    }
                }
            }
        }
        else if (event.phase == Phase.END)
        {
            final WorldServer world = (WorldServer) event.world;

            List<BlockVec3> edgesList = TickHandlerServer.edgeChecks.get(world.provider.dimensionId);
            final HashSet<BlockVec3> checkedThisTick = new HashSet();

            if (edgesList != null && !edgesList.isEmpty())
View Full Code Here

                if (this.targetDimension != this.worldObj.provider.dimensionId)
                {
                    WorldProvider targetDim = WorldUtil.getProviderForDimension(this.targetDimension);                  
                    if (targetDim != null)
                    {
                      WorldServer worldServer = mcserver.worldServerForDimension(this.targetDimension);
                        if (worldServer != null)
                        {
                          boolean dimensionAllowed = this.targetDimension == 0;
 
                          if (targetDim instanceof IGalacticraftWorldProvider)
View Full Code Here

        WorldServer[] servers = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;

        for (int i = 0; i < servers.length; i++)
        {
            WorldServer world = servers[i];

            for (TileEntity tile : new ArrayList<TileEntity>(world.loadedTileEntityList))
            {
              if (tile != null)
                {
                    tile = world.getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord);
                    if (tile == null) continue;

                    try
                    {
                        Class<?> controllerClass = Class.forName("micdoodle8.mods.galacticraft.planets.mars.tile.TileEntityLaunchController");

                        try
                        {
                            controllerClass.cast(tile);
                        }
                        catch (ClassCastException e)
                        {
                            continue;
                        }

                        int controllerFrequency = controllerClass.getField("frequency").getInt(tile);

                        if (destFreq == controllerFrequency)
                        {
                            boolean targetSet = false;

                            blockLoop:
                            for (int x = -2; x <= 2; x++)
                            {
                                for (int z = -2; z <= 2; z++)
                                {
                                    Block block = world.getBlock(tile.xCoord + x, tile.yCoord, tile.zCoord + z);

                                    if (block instanceof BlockLandingPadFull)
                                    {
                                        if (doSet)
                                        {
View Full Code Here

    dimension = Integer.valueOf(sender.dimension);
    if (( chunkX == null ) || ( chunkZ == null )) {
      chunkX = Integer.valueOf((int) sender.posX >> 4);
      chunkZ = Integer.valueOf((int) sender.posZ >> 4);
    }
    WorldServer worldObj = DimensionManager.getWorld(0);
    if (worldObj == null) {
      LogHelper.warning("Target dimension 0 is not loaded for genesis?!");
    }
    ChunkProviderServer providerServer = (ChunkProviderServer) worldObj.getChunkProvider();
    GenesisChunkProvider providerGenesis = new GenesisChunkProvider(world, newBiome);

    // clear players from the danger zone and force unload chunks in
    // question
    List<EntityPlayerMP> players = new ArrayList<EntityPlayerMP>();
    Map<EntityPlayerMP, Vec3> playerOrigPositions = new HashMap<EntityPlayerMP, Vec3>();
    players.addAll(worldObj.playerEntities);

    final int safePad = 2;
    final double safeX = ( ( chunkX.intValue() - range - safePad ) << 4 ) - 8.0;
    final double safeZ = ( ( chunkZ.intValue() - range - safePad ) << 4 ) - 8.0;
    LogHelper.info("Safe position = " + safeX + "," + safeZ);

    Map<Pair<Integer, Integer>, Chunk> chunks = new HashMap<Pair<Integer, Integer>, Chunk>();
    for (int x1 = chunkX.intValue() - range; x1 <= chunkX.intValue() + range; x1++) {
      for (int z1 = chunkZ.intValue() - range; z1 <= chunkZ.intValue() + range; z1++) {
        for (EntityPlayerMP player : players) {
          if (worldObj.getPlayerManager().isPlayerWatchingChunk(player, x1, z1) && !playerOrigPositions.containsKey(player)) {
            final Vec3 origPosition = Vec3.createVectorHelper(player.posX, player.posY,player.posZ);
            playerOrigPositions.put(player, origPosition);
            LogHelper.info("Moving player " + player);
            player.setLocationAndAngles(safeX, player.posY, safeZ, 0.0F, 0.0F);
            worldObj.updateEntityWithOptionalForce(player, true);
          }
        }
        final Chunk chunk = world.getChunkFromBlockCoords(x, z);
        chunks.put(Pair.of(x1, z1), chunk); // save map of chunks
        providerServer.unloadChunksIfNotNearSpawn(x1, z1);
View Full Code Here

    @SubscribeEvent
    public void onWorldLoad(WorldEvent.Load event)
    {
        if(FMLCommonHandler.instance().getEffectiveSide().isServer() && event.world.provider.dimensionId == 0)
        {
            WorldServer world = (WorldServer)event.world;
            MorphSaveData saveData = (MorphSaveData)world.perWorldStorage.loadData(MorphSaveData.class, "MorphSaveData");

            if(saveData == null)
            {
                saveData = new MorphSaveData("MorphSaveData");
View Full Code Here

    public void worldTick(TickEvent.WorldTickEvent event)
    {
        if(event.phase == TickEvent.Phase.END && event.side.isServer())
        {
            //Post world tick
            WorldServer world = (WorldServer)event.world;
            if(clock != world.getWorldTime() || !world.getGameRules().getGameRuleBooleanValue("doDaylightCycle"))
            {
                clock = world.getWorldTime();
                //            for(int i = 0 ; i < world.loadedEntityList.size(); i++)
                //            {
                //              if(world.loadedEntityList.get(i) instanceof EntityCow)
                //              {
                //                ((EntityCow)world.loadedEntityList.get(i)).setDead();
View Full Code Here

            d10 += 1.0D / b0;
          }
        }

        if (!this.worldObj.isRemote && d10 > 0.0D) {
          WorldServer worldserver = (WorldServer) this.worldObj;
          int k = 1;

          if (this.rand.nextFloat() < 0.25F
              && this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1,
                  MathHelper.floor_double(this.posZ))) {
            k = 2;
          }

          if (this.rand.nextFloat() < 0.5F
              && !this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1,
                  MathHelper.floor_double(this.posZ))) {
            --k;
          }

          if (this.field_146045_ax > 0) {
            --this.field_146045_ax;

            if (this.field_146045_ax <= 0) {
              this.field_146040_ay = 0;
              this.field_146038_az = 0;
            }
          } else {
            float f1;
            float f2;
            double d5;
            double d6;
            float f7;
            double d11;

            if (this.field_146038_az > 0) {
              this.field_146038_az -= k;

              if (this.field_146038_az <= 0) {
                this.motionY -= 0.20000000298023224D;
                this.playSound("random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
                f1 = MathHelper.floor_double(this.boundingBox.minY);
                worldserver.func_147487_a("bubble", this.posX, f1 + 1.0F, this.posZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D,
                    this.width, 0.20000000298023224D);
                worldserver.func_147487_a("wake", this.posX, f1 + 1.0F, this.posZ, (int) (1.0F + this.width * 20.0F), this.width, 0.0D,
                    this.width, 0.20000000298023224D);
                this.field_146045_ax = MathHelper.getRandomIntegerInRange(this.rand, 10, 30);
              } else {
                this.field_146054_aA = (float) (this.field_146054_aA + this.rand.nextGaussian() * 4.0D);
                f1 = this.field_146054_aA * 0.017453292F;
                f7 = MathHelper.sin(f1);
                f2 = MathHelper.cos(f1);
                d11 = this.posX + f7 * this.field_146038_az * 0.1F;
                d5 = MathHelper.floor_double(this.boundingBox.minY) + 1.0F;
                d6 = this.posZ + f2 * this.field_146038_az * 0.1F;

                if (this.rand.nextFloat() < 0.15F) {
                  worldserver.func_147487_a("bubble", d11, d5 - 0.10000000149011612D, d6, 1, f7, 0.1D, f2, 0.0D);
                }

                float f3 = f7 * 0.04F;
                float f4 = f2 * 0.04F;
                worldserver.func_147487_a("wake", d11, d5, d6, 0, f4, 0.01D, (-f3), 1.0D);
                worldserver.func_147487_a("wake", d11, d5, d6, 0, (-f4), 0.01D, f3, 1.0D);
              }
            } else if (this.field_146040_ay > 0) {
              this.field_146040_ay -= k;
              f1 = 0.15F;

              if (this.field_146040_ay < 20) {
                f1 = (float) (f1 + (20 - this.field_146040_ay) * 0.05D);
              } else if (this.field_146040_ay < 40) {
                f1 = (float) (f1 + (40 - this.field_146040_ay) * 0.02D);
              } else if (this.field_146040_ay < 60) {
                f1 = (float) (f1 + (60 - this.field_146040_ay) * 0.01D);
              }

              if (this.rand.nextFloat() < f1) {
                f7 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F;
                f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F);
                d11 = this.posX + MathHelper.sin(f7) * f2 * 0.1F;
                d5 = MathHelper.floor_double(this.boundingBox.minY) + 1.0F;
                d6 = this.posZ + MathHelper.cos(f7) * f2 * 0.1F;
                worldserver.func_147487_a("splash", d11, d5, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D,
                    0.0D);
              }

              if (this.field_146040_ay <= 0) {
                this.field_146054_aA = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F);
View Full Code Here

TOP

Related Classes of net.minecraft.world.WorldServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.