Package net.minecraft.client.multiplayer

Examples of net.minecraft.client.multiplayer.WorldClient


                ForgeWorld.restoreBiomes();

                if (stream.readableBytes() > 4)
                {
                    // If the packet wasn't empty, add the new biomes
                    WorldClient worldMC = FMLClientHandler.instance().getClient().theWorld;

                    DataInputStream wrappedStream = new DataInputStream(new ByteBufInputStream(stream));
                    String worldName = ConfigFile.readStringFromStream(wrappedStream);
                    ForgeWorld worldTC = new ForgeWorld(worldName);
                    WorldSettings config = new WorldSettings(wrappedStream, worldTC);
View Full Code Here


    private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<EntityItem>();
    private World lastworld;
    private GuiScreen lastGui;

    public void addSMPMagneticItem(int i, World world) {
        WorldClient cworld = (WorldClient) world;
        Entity e = cworld.getEntityByID(i);
        if (e == null || !(e instanceof EntityItem)) {
            return;
        }
        SMPmagneticItems.add((EntityItem) e);
    }
View Full Code Here

    @SideOnly(Side.CLIENT)
    @SubscribeEvent
    public void onClientTick(ClientTickEvent event)
    {
        Minecraft minecraft = Minecraft.getMinecraft();
        WorldClient world = minecraft.theWorld;

        if (world != null)
        {
            if (world.provider instanceof WorldProviderAsteroids)
            {
View Full Code Here

        @SubscribeEvent
        public void onClientTick(ClientTickEvent event)
        {
            final Minecraft minecraft = FMLClientHandler.instance().getClient();

            final WorldClient world = minecraft.theWorld;

            if (world != null)
            {
                if (world.provider instanceof WorldProviderMars)
                {
View Full Code Here

    @SubscribeEvent
    public void onClientTick(ClientTickEvent event)
    {
        final Minecraft minecraft = FMLClientHandler.instance().getClient();
        final WorldClient world = minecraft.theWorld;
        final EntityClientPlayerMP player = minecraft.thePlayer;

        if (event.phase == Phase.START)
        {
            if (TickHandlerClient.tickCount >= Long.MAX_VALUE)
            {
                TickHandlerClient.tickCount = 0;
            }

            TickHandlerClient.tickCount++;

            if (TickHandlerClient.tickCount % 20 == 0)
            {
                if (player != null && player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof ItemSensorGlasses)
                {
                    ClientProxyCore.valueableBlocks.clear();

                    for (int i = -4; i < 5; i++)
                    {
                        for (int j = -4; j < 5; j++)
                        {
                            for (int k = -4; k < 5; k++)
                            {
                                int x = MathHelper.floor_double(player.posX + i);
                                int y = MathHelper.floor_double(player.posY + j);
                                int z = MathHelper.floor_double(player.posZ + k);

                                final Block block = player.worldObj.getBlock(x, y, z);

                                if (block.getMaterial() != Material.air)
                                {
                                    int metadata = world.getBlockMetadata(x, y, z);
                                    boolean isDetectable = false;

                                    for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks)
                                    {
                                        if (blockMetaList.getBlock() == block && blockMetaList.getMetaList().contains(metadata))
                                        {
                                            isDetectable = true;
                                            break;
                                        }
                                    }

                                    if (isDetectable)
                                    {
                                        if (!this.alreadyContainsBlock(x, y, z))
                                        {
                                            ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z));
                                        }
                                    }
                                    else if (block instanceof IDetectableResource && ((IDetectableResource) block).isValueable(metadata))
                                    {
                                        if (!this.alreadyContainsBlock(x, y, z))
                                        {
                                            ClientProxyCore.valueableBlocks.add(new Vector3(x, y, z));
                                        }

                                        List<Integer> metaList = null;

                                        for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks)
                                        {
                                            if (blockMetaList.getBlock() == block)
                                            {
                                                metaList = blockMetaList.getMetaList();
                                                if (!metaList.contains(metadata))
                                                {
                                                    metaList.add(metadata);
                                                }
                                                break;
                                            }
                                        }

                                        if (metaList == null)
                                        {
                                            metaList = Lists.newArrayList();
                                            metaList.add(metadata);
                                            ClientProxyCore.detectableBlocks.add(new BlockMetaList(block, metaList));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (minecraft.currentScreen != null && minecraft.currentScreen instanceof GuiMainMenu)
            {
                ClientProxyCore.playerItemData.clear();

                if (TickHandlerClient.missingRequirementThread == null)
                {
                    TickHandlerClient.missingRequirementThread = new ThreadRequirementMissing(FMLCommonHandler.instance().getEffectiveSide());
                    TickHandlerClient.missingRequirementThread.start();
                }
            }

            if (world != null && TickHandlerClient.spaceRaceGuiScheduled && minecraft.currentScreen == null)
            {
                player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
                TickHandlerClient.spaceRaceGuiScheduled = false;
            }

            if (world != null && TickHandlerClient.checkedVersion)
            {
                ThreadVersionCheck.startCheck();
                TickHandlerClient.checkedVersion = false;
            }

            if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntitySpaceshipBase)
            {
                GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(player.ridingEntity));
            }

            if (world != null)
            {
                if (world.provider instanceof WorldProviderSurface)
                {
                    if (world.provider.getSkyRenderer() == null && player.ridingEntity != null && player.ridingEntity.posY >= 200)
                    {
                        world.provider.setSkyRenderer(new SkyProviderOverworld());
                    }
                    else if (world.provider.getSkyRenderer() != null && world.provider.getSkyRenderer() instanceof SkyProviderOverworld && (player.ridingEntity == null || player.ridingEntity.posY < 200))
                    {
                        world.provider.setSkyRenderer(null);
                    }
                }
                else if (world.provider instanceof WorldProviderOrbit)
                {
                    if (world.provider.getSkyRenderer() == null)
                    {
                        world.provider.setSkyRenderer(new SkyProviderOrbit(new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/celestialbodies/earth.png"), true, true));
                        ((SkyProviderOrbit) world.provider.getSkyRenderer()).spinDeltaPerTick = ((WorldProviderOrbit) world.provider).getSpinRate();
                        GCPlayerStatsClient.get(player).inFreefallFirstCheck = false;
                    }

                    if (world.provider.getCloudRenderer() == null)
                    {
                        world.provider.setCloudRenderer(new CloudRenderer());
                    }
                }
                else if (world.provider instanceof WorldProviderMoon)
                {
                    if (world.provider.getSkyRenderer() == null)
                    {
                        world.provider.setSkyRenderer(new SkyProviderMoon());
                    }

                    if (world.provider.getCloudRenderer() == null)
                    {
                        world.provider.setCloudRenderer(new CloudRenderer());
                    }
                }
            }

            if (player != null && player.ridingEntity != null && player.ridingEntity instanceof EntitySpaceshipBase)
            {
                final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
                boolean hasChanged = false;

                if (minecraft.gameSettings.keyBindLeft.getIsKeyPressed())
                {
                    ship.turnYaw(-1.0F);
                    hasChanged = true;
                }

                if (minecraft.gameSettings.keyBindRight.getIsKeyPressed())
                {
                    ship.turnYaw(1.0F);
                    hasChanged = true;
                }

                if (minecraft.gameSettings.keyBindForward.getIsKeyPressed())
                {
                    if (ship.getLaunched())
                    {
                        ship.turnPitch(-0.7F);
                        hasChanged = true;
                    }
                }

                if (minecraft.gameSettings.keyBindBack.getIsKeyPressed())
                {
                    if (ship.getLaunched())
                    {
                        ship.turnPitch(0.7F);
                        hasChanged = true;
                    }
                }

                if (hasChanged)
                {
                    GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(ship));
                }
            }

            if (world != null)
            {
                List entityList = world.loadedEntityList;            
                for (Object e : entityList)
                {
                    if (e instanceof EntityAutoRocket)
                    {
                        if (((EntityAutoRocket) e).rocketSoundUpdater == null)
                        {
                          EntityAutoRocket eship = (EntityAutoRocket) e;
                          eship.rocketSoundUpdater = new SoundUpdaterRocket(FMLClientHandler.instance().getClient().thePlayer, eship);
              FMLClientHandler.instance().getClient().getSoundHandler().playSound((ISound) eship.rocketSoundUpdater);
                        }
                    }
                }
            }

            if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection)
            {
                player.motionY = 0;
            }

            if (world != null && world.provider instanceof IGalacticraftWorldProvider)
            {
                world.setRainStrength(0.0F);
            }

            if (!KeyHandlerClient.spaceKey.getIsKeyPressed())
            {
                ClientProxyCore.lastSpacebarDown = false;
View Full Code Here

    public void worldTick(TickEvent.ClientTickEvent event)
    {
        if(event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().theWorld != null)
        {
            Minecraft mc = Minecraft.getMinecraft();
            WorldClient world = mc.theWorld;

            abilityScroll++;
            if(mc.currentScreen != null)
            {
                if(selectorShow)
                {
                    if(mc.currentScreen instanceof GuiIngameMenu)
                    {
                        mc.displayGuiScreen(null);
                    }
                    selectorShow = false;
                    selectorTimer = selectorShowTime - selectorTimer;
                    scrollTimerHori = scrollTime;
                }
                if(radialShow)
                {
                    radialShow = false;
                }
            }
            if(selectorTimer > 0)
            {
                selectorTimer--;
                if(selectorTimer == 0 && !selectorShow)
                {
                    selectorSelected = 0;

                    MorphInfoClient info = playerMorphInfo.get(mc.thePlayer.getCommandSenderName());
                    if(info != null)
                    {
                        MorphState state = info.nextState;
                        String entName = state.entInstance.getCommandSenderName();

                        int i = 0;

                        Iterator<Entry<String, ArrayList<MorphState>>> ite = playerMorphCatMap.entrySet().iterator();

                        while(ite.hasNext())
                        {
                            Entry<String, ArrayList<MorphState>> e = ite.next();
                            if(e.getKey().equalsIgnoreCase(entName))
                            {
                                selectorSelected = i;
                                ArrayList<MorphState> states = e.getValue();

                                for(int j = 0; j < states.size(); j++)
                                {
                                    if(states.get(j).identifier.equalsIgnoreCase(state.identifier))
                                    {
                                        selectorSelectedHori = j;
                                        break;
                                    }
                                }

                                break;
                            }
                            i++;
                        }

                    }
                }
            }
            if(scrollTimer > 0)
            {
                scrollTimer--;
            }
            if(scrollTimerHori > 0)
            {
                scrollTimerHori--;
            }
            if(radialTime > 0)
            {
                radialTime--;
            }

            if(clock != world.getWorldTime() || !world.getGameRules().getGameRuleBooleanValue("doDaylightCycle"))
            {
                clock = world.getWorldTime();

                for(Entry<String, MorphInfoClient> e : playerMorphInfo.entrySet())
                {
                    MorphInfoClient info = e.getValue();

                    if(info.getMorphing())
                    {
                        info.morphProgress++;
                        if(info.morphProgress > 80)
                        {
                            info.morphProgress = 80;
                            info.setMorphing(false);
                            if(info.player != null)
                            {
                                info.player.setSize(info.nextState.entInstance.width, info.nextState.entInstance.height);
                                info.player.setPosition(info.player.posX, info.player.posY, info.player.posZ);
                                info.player.eyeHeight = info.nextState.entInstance instanceof EntityPlayer ? ((EntityPlayer)info.nextState.entInstance).getCommandSenderName().equalsIgnoreCase(mc.thePlayer.getCommandSenderName()) || info.player == mc.thePlayer ? mc.thePlayer.getDefaultEyeHeight() : ((EntityPlayer)info.nextState.entInstance).getDefaultEyeHeight() : info.nextState.entInstance.getEyeHeight() - info.player.yOffset;

                                ArrayList<Ability> newAbilities = AbilityHandler.getEntityAbilities(info.nextState.entInstance.getClass());
                                ArrayList<Ability> oldAbilities = info.morphAbilities;
                                info.morphAbilities = new ArrayList<Ability>();
                                for(Ability ability : newAbilities)
                                {
                                    try
                                    {
                                        Ability clone = ability.clone();
                                        clone.setParent(info.player);
                                        info.morphAbilities.add(clone);
                                    }
                                    catch(Exception e1)
                                    {
                                    }
                                }
                                for(Ability ability : oldAbilities)
                                {
                                    if(ability.inactive)
                                    {
                                        continue;
                                    }
                                    boolean isRemoved = true;
                                    for(Ability newAbility : info.morphAbilities)
                                    {
                                        if(newAbility.getType().equalsIgnoreCase(ability.getType()))
                                        {
                                            isRemoved = false;
                                            break;
                                        }
                                    }
                                    if(isRemoved && ability.getParent() != null)
                                    {
                                        ability.kill();
                                    }
                                }
                            }
                        }
                        else if(info.prevState != null && info.player != null)
                        {
                            info.player.setSize(info.prevState.entInstance.width + (info.nextState.entInstance.width - info.prevState.entInstance.width) * ((float)info.morphProgress / 80F), info.prevState.entInstance.height + (info.nextState.entInstance.height - info.prevState.entInstance.height) * ((float)info.morphProgress / 80F));
                            info.player.setPosition(info.player.posX, info.player.posY, info.player.posZ);
                            float prevEyeHeight = info.prevState.entInstance instanceof EntityPlayer ? ((EntityPlayer)info.prevState.entInstance).getCommandSenderName().equalsIgnoreCase(mc.thePlayer.getCommandSenderName()) || info.player == mc.thePlayer ? mc.thePlayer.getDefaultEyeHeight() : ((EntityPlayer)info.prevState.entInstance).getDefaultEyeHeight() : info.prevState.entInstance.getEyeHeight() - info.player.yOffset;
                            float nextEyeHeight = info.nextState.entInstance instanceof EntityPlayer ? ((EntityPlayer)info.nextState.entInstance).getCommandSenderName().equalsIgnoreCase(mc.thePlayer.getCommandSenderName()) || info.player == mc.thePlayer ? mc.thePlayer.getDefaultEyeHeight() : ((EntityPlayer)info.nextState.entInstance).getDefaultEyeHeight() : info.nextState.entInstance.getEyeHeight() - info.player.yOffset;
                            info.player.eyeHeight = prevEyeHeight + (nextEyeHeight - prevEyeHeight) * ((float)info.morphProgress / 80F);
                        }
                    }
                    //TODO make sure that the lack of sleep timer doesn't affect anything.
                    //if(info.player != null && (info.player.dimension != mc.thePlayer.dimension || !info.player.isEntityAlive() || !world.playerEntities.contains(info.player) || !info.player.isPlayerSleeping() && info.player.sleepTimer > 0))
                    if(info.player != null && (info.player.dimension != mc.thePlayer.dimension || !info.player.isEntityAlive() || !world.playerEntities.contains(info.player) || (info.player.isPlayerSleeping() || info.player.getSleepTimer() > 0)))
                    {
                        info.player = null;
                    }
                    if(info.player == null)
                    {
                        info.player = world.getPlayerEntityByName(e.getKey());
                        if(info.player != null)
                        {
                            if(!info.getMorphing())
                            {
                                info.player.setSize(info.nextState.entInstance.width, info.nextState.entInstance.height);
View Full Code Here

    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);
        }
View Full Code Here

      this.pz - (this.updateZ << 4)
    );
   
    int cxMax = this.updateX + 2;
    int czMax = this.updateZ + 2;
    WorldClient world = this.mw.mc.theWorld;
    int flagOffset = 0;
    for (int cz = this.updateZ; cz <= czMax; cz++) {
      for (int cx = this.updateX; cx <= cxMax; cx++) {
        if (this.isChunkInTexture(cx, cz)) {
          Chunk chunk = world.getChunkFromChunkCoords(cx, cz);
          int tx = (cx << 4) & (this.textureSize - 1);
          int tz = (cz << 4) & (this.textureSize - 1);
          int pixelOffset = (tz * this.textureSize) + tx;
          byte[] mask = this.updateFlags[flagOffset];
          ChunkRender.renderUnderground(
View Full Code Here

        int columnOffset = (columnZi << 4) + columnXi;
        byte columnFlag = this.updateFlags[chunkOffset][columnOffset];
       
        if (columnFlag == ChunkRender.FLAG_UNPROCESSED) {
          // if column not yet processed
          WorldClient world = this.mw.mc.theWorld;
          Block block = world.getBlock(x, y, z);
          if ((block == null) || !block.isOpaqueCube()) {
            // if block is not opaque
            this.updateFlags[chunkOffset][columnOffset] = (byte) ChunkRender.FLAG_NON_OPAQUE;
            this.processBlock(xi + 1, y, zi);
            this.processBlock(xi - 1, y, zi);
View Full Code Here

TOP

Related Classes of net.minecraft.client.multiplayer.WorldClient

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.