Search in sources :

Example 11 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method updatePreRenderInfo.

public static void updatePreRenderInfo(float partialTicks_) {
    Entity cameraEntity = MinecraftClient.getInstance().cameraEntity;
    if (cameraEntity == null) {
        return;
    }
    MyRenderHelper.originalPlayerDimension = cameraEntity.dimension;
    MyRenderHelper.originalPlayerPos = cameraEntity.getPos();
    MyRenderHelper.originalPlayerLastTickPos = McHelper.lastTickPosOf(cameraEntity);
    PlayerListEntry entry = CHelper.getClientPlayerListEntry();
    MyRenderHelper.originalGameMode = entry != null ? entry.getGameMode() : GameMode.CREATIVE;
    partialTicks = partialTicks_;
    renderedDimensions.clear();
    lastPortalRenderInfos = portalRenderInfos;
    portalRenderInfos = new ArrayList<>();
}
Also used : Entity(net.minecraft.entity.Entity) PlayerListEntry(net.minecraft.client.network.PlayerListEntry)

Example 12 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project ImmersivePortalsMod by qouteall.

the class MyGameRenderer method renderWorld.

public void renderWorld(float partialTicks, WorldRenderer newWorldRenderer, ClientWorld newWorld, Vec3d oldCameraPos) {
    ChunkRenderDispatcher chunkRenderDispatcher = ((IEWorldRenderer) newWorldRenderer).getChunkRenderDispatcher();
    chunkRenderDispatcher.updateCameraPosition(mc.player.x, mc.player.z);
    IEGameRenderer ieGameRenderer = (IEGameRenderer) mc.gameRenderer;
    DimensionRenderHelper helper = CGlobal.clientWorldLoader.getDimensionRenderHelper(newWorld.dimension.getType());
    PlayerListEntry playerListEntry = CHelper.getClientPlayerListEntry();
    Camera newCamera = new Camera();
    // store old state
    WorldRenderer oldWorldRenderer = mc.worldRenderer;
    ClientWorld oldWorld = mc.world;
    LightmapTextureManager oldLightmap = ieGameRenderer.getLightmapTextureManager();
    BackgroundRenderer oldFogRenderer = ieGameRenderer.getBackgroundRenderer();
    GameMode oldGameMode = playerListEntry.getGameMode();
    boolean oldNoClip = mc.player.noClip;
    boolean oldDoRenderHand = ieGameRenderer.getDoRenderHand();
    List oldChunkInfos = ((IEWorldRenderer) mc.worldRenderer).getChunkInfos();
    IEChunkRenderList oldChunkRenderList = (IEChunkRenderList) ((IEWorldRenderer) oldWorldRenderer).getChunkRenderList();
    // List<ChunkRenderer> oldChunkRenderers = oldChunkRenderList.getChunkRenderers();
    OFInterface.createNewRenderInfosNormal.accept(newWorldRenderer);
    // switch
    mc.worldRenderer = newWorldRenderer;
    mc.world = newWorld;
    ieGameRenderer.setBackgroundRenderer(helper.fogRenderer);
    ieGameRenderer.setLightmapTextureManager(helper.lightmapTexture);
    helper.lightmapTexture.update(0);
    helper.lightmapTexture.enable();
    BlockEntityRenderDispatcher.INSTANCE.world = newWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(GameMode.SPECTATOR);
    mc.player.noClip = true;
    ieGameRenderer.setDoRenderHand(false);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.pushMatrix();
    CGlobal.renderInfoNumMap.put(newWorld.dimension.getType(), ((IEWorldRenderer) mc.worldRenderer).getChunkInfos().size());
    updateCullingPlane();
    // this is important
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GuiLighting.disable();
    ((GameRenderer) ieGameRenderer).disableLightmap();
    mc.getProfiler().push("render_portal_content");
    CGlobal.switchedFogRenderer = ieGameRenderer.getBackgroundRenderer();
    // invoke it!
    OFInterface.beforeRenderCenter.accept(partialTicks);
    ieGameRenderer.renderCenter_(partialTicks, getChunkUpdateFinishTime());
    OFInterface.afterRenderCenter.run();
    mc.getProfiler().pop();
    // recover
    mc.worldRenderer = oldWorldRenderer;
    mc.world = oldWorld;
    ieGameRenderer.setBackgroundRenderer(oldFogRenderer);
    ieGameRenderer.setLightmapTextureManager(oldLightmap);
    BlockEntityRenderDispatcher.INSTANCE.world = oldWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(oldGameMode);
    mc.player.noClip = oldNoClip;
    ieGameRenderer.setDoRenderHand(oldDoRenderHand);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    ((IEWorldRenderer) mc.worldRenderer).setChunkInfos(oldChunkInfos);
    oldChunkRenderList.setCameraPos(oldCameraPos.x, oldCameraPos.y, oldCameraPos.z);
}
Also used : IEWorldRenderer(com.qouteall.immersive_portals.ducks.IEWorldRenderer) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer) IEWorldRenderer(com.qouteall.immersive_portals.ducks.IEWorldRenderer) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) GameMode(net.minecraft.world.GameMode) IEChunkRenderList(com.qouteall.immersive_portals.ducks.IEChunkRenderList) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer) List(java.util.List) IEChunkRenderList(com.qouteall.immersive_portals.ducks.IEChunkRenderList) ClientWorld(net.minecraft.client.world.ClientWorld)

Example 13 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project FZMM-Mod by Zailer43.

the class FzmmItemGroup method register.

public static void register() {
    FabricItemGroupBuilder.create(new Identifier(FzmmClient.MOD_ID, "unobtainable_items")).icon(() -> new ItemStack(Items.JIGSAW)).appendItems((stacks, itemGroup) -> {
        for (Item item : Registry.ITEM) {
            if (item.getGroup() == null && item != Items.AIR && item != Items.LIGHT) {
                stacks.add(new ItemStack(item));
            }
        }
        stacks.add(new ItemStack(Items.POTION));
        stacks.add(new ItemStack(Items.SPLASH_POTION));
        stacks.add(new ItemStack(Items.LINGERING_POTION));
        stacks.add(new ItemStack(Items.TIPPED_ARROW));
        addArmorStand(stacks);
        addItemFrames(stacks);
        addNameTags(stacks);
        addCrossbows(stacks);
        stacks.add(Raid.getOminousBanner());
        ItemStack elytra = new ItemStack(Items.ELYTRA);
        elytra.setDamage(431);
        stacks.add(elytra);
        addLightBlock(stacks);
    }).build();
    FabricItemGroupBuilder.create(new Identifier(FzmmClient.MOD_ID, "useful_block_states")).icon(() -> new ItemStack(Items.REDSTONE_LAMP)).appendItems((stacks, itemGroup) -> {
        stacks.add(new BlockStateTagItem(Items.REDSTONE_LAMP, "Lit redstone lamp").add("lit", true).get());
        stacks.add(new BlockStateTagItem(Items.FURNACE, "Lit furnace").add("lit", true).get());
        stacks.add(new BlockStateTagItem(Items.SMOKER, "Lit smoker").add("lit", true).get());
        stacks.add(new BlockStateTagItem(Items.BLAST_FURNACE, "Lit blast furnace").add("lit", true).get());
        stacks.add(new BlockStateTagItem(Items.CAMPFIRE, "Off campfire").add("lit", false).get());
        stacks.add(new BlockStateTagItem(Items.CAMPFIRE, "Signal fire of campfire").add("signal_fire", true).get());
        stacks.add(new BlockStateTagItem(Items.SOUL_CAMPFIRE, "Off soul campfire").add("lit", false).get());
        stacks.add(new BlockStateTagItem(Items.SOUL_CAMPFIRE, "Signal fire of soul campfire").add("signal_fire", true).get());
        stacks.add(new BlockStateTagItem(Items.GRASS_BLOCK, "Snowy grass block").add("snowy", true).get());
        stacks.add(new BlockStateTagItem(Items.MYCELIUM, "Snowy mycelium").add("snowy", true).get());
        stacks.add(new BlockStateTagItem(Items.PODZOL, "Snowy podzol").add("snowy", true).get());
        stacks.add(new BlockStateTagItem(Items.SNOW, "Snow block").add("layers", 8).get());
        stacks.add(new BlockStateTagItem(Items.BARREL, "Open barrel").add("open", true).get());
        stacks.add(new BlockStateTagItem(Items.IRON_TRAPDOOR, "Open iron trapdoor").add("open", true).get());
        stacks.add(new BlockStateTagItem(Items.IRON_DOOR, "Open iron door").add("open", true).get());
        stacks.add(new BlockStateTagItem(Items.END_PORTAL_FRAME, "End portal frame with eye").add("eye", true).get());
        stacks.add(new BlockStateTagItem(Items.LANTERN, "Hanging lantern").add("hanging", true).get());
        stacks.add(new BlockStateTagItem(Items.LANTERN, "Lantern on the floor").add("hanging", false).get());
        stacks.add(new BlockStateTagItem(Items.SOUL_LANTERN, "Hanging soul lantern").add("hanging", true).get());
        stacks.add(new BlockStateTagItem(Items.SOUL_LANTERN, "Soul lantern on the floor").add("hanging", false).get());
        stacks.add(new BlockStateTagItem(Items.COMPOSTER, "Full composter").add("level", 8).get());
        stacks.add(new BlockStateTagItem(Items.RESPAWN_ANCHOR, "Full respawn anchor").add("charges", 4).get());
        stacks.add(new BlockStateTagItem(Items.BAMBOO, "Bamboo with leaves").add("leaves", "large").get());
        stacks.add(new BlockStateTagItem(Items.WHEAT_SEEDS, "Full grown wheat").add("age", 7).get());
        stacks.add(new BlockStateTagItem(Items.PUMPKIN_SEEDS, "Full grown pumpkin").add("age", 7).get());
        stacks.add(new BlockStateTagItem(Items.MELON_SEEDS, "Full grown melon").add("age", 7).get());
        stacks.add(new BlockStateTagItem(Items.CARROT, "Full grown carrot").add("age", 7).get());
        stacks.add(new BlockStateTagItem(Items.POTATO, "Full grown potatoes").add("age", 7).get());
        stacks.add(new BlockStateTagItem(Items.BEETROOT_SEEDS, "Full grown beetroots").add("age", 3).get());
        stacks.add(new BlockStateTagItem(Items.COCOA_BEANS, "Full grown cocoa").add("age", 2).get());
        stacks.add(new BlockStateTagItem(Items.REPEATER, "Repeater (2 ticks)").add("delay", 2).get());
        stacks.add(new BlockStateTagItem(Items.REPEATER, "Repeater (3 ticks)").add("delay", 3).get());
        stacks.add(new BlockStateTagItem(Items.REPEATER, "Repeater (4 ticks)").add("delay", 4).get());
        stacks.add(new BlockStateTagItem(Items.BEE_NEST, "Bee nest filled with honey").add("honey_level", 5).get());
        stacks.add(new BlockStateTagItem(Items.BEEHIVE, "Beehive filled with honey").add("honey_level", 5).get());
        stacks.add(new BlockStateTagItem(Items.SEA_PICKLE, "Sea pickle (4)").add("pickles", 4).get());
        stacks.add(new BlockStateTagItem(Items.TURTLE_EGG, "Turtle egg (4)").add("eggs", 4).get());
        stacks.add(new BlockStateTagItem(Items.CAKE, "A slice of cake").add("bites", 6).get());
        stacks.add(new BlockStateTagItem(Items.REDSTONE, "Powered redstone").add("power", 15).get());
        addHalfDoors(stacks);
        addTallFlowers(stacks);
        addLeaves(stacks);
        addLitCandles(stacks);
        addHalfBed(stacks);
    }).build();
    FabricItemGroupBuilder.create(new Identifier(FzmmClient.MOD_ID, "loot_chests")).icon(() -> new ItemStack(Items.CHEST)).appendItems((stacks, itemGroup) -> {
        List<String> lootTablesPath = LootTables.getAll().stream().map(Identifier::getPath).sorted().toList();
        for (String path : lootTablesPath) {
            if (path.startsWith("entities"))
                continue;
            ItemStack chest = new ItemStack(Items.CHEST);
            NbtCompound blockEntityTag = new NbtCompound();
            blockEntityTag.putString("LootTable", path);
            chest.setCustomName(new LiteralText("LootChest: " + path));
            chest.setSubNbt(TagsConstant.BLOCK_ENTITY, blockEntityTag);
            stacks.add(chest);
        }
    }).build();
    FabricItemGroupBuilder.create(new Identifier(FzmmClient.MOD_ID, "player_heads")).icon(() -> new ItemStack(Items.PLAYER_HEAD)).appendItems((stacks, itemGroup) -> {
        stacks.clear();
        ClientPlayerEntity clientPlayer = MinecraftClient.getInstance().player;
        if (clientPlayer != null) {
            List<GameProfile> profileList = clientPlayer.networkHandler.getPlayerList().stream().map(PlayerListEntry::getProfile).toList();
            for (GameProfile profile : profileList) {
                stacks.add(FzmmUtils.getPlayerHead(profile));
            }
        }
    }).build();
}
Also used : EntityType(net.minecraft.entity.EntityType) ItemTags(net.minecraft.tag.ItemTags) LiteralText(net.minecraft.text.LiteralText) Item(net.minecraft.item.Item) TagKey(net.minecraft.tag.TagKey) GameProfile(com.mojang.authlib.GameProfile) Items(net.minecraft.item.Items) ItemPredicate(net.minecraft.predicate.item.ItemPredicate) fzmm.zailer.me.utils(fzmm.zailer.me.utils) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) FireworkRocketItem(net.minecraft.item.FireworkRocketItem) Registry(net.minecraft.util.registry.Registry) ItemStack(net.minecraft.item.ItemStack) NbtCompound(net.minecraft.nbt.NbtCompound) Style(net.minecraft.text.Style) List(java.util.List) Identifier(net.minecraft.util.Identifier) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Raid(net.minecraft.village.raid.Raid) FabricItemGroupBuilder(net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder) LootTables(net.minecraft.loot.LootTables) Item(net.minecraft.item.Item) FireworkRocketItem(net.minecraft.item.FireworkRocketItem) Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) GameProfile(com.mojang.authlib.GameProfile) List(java.util.List) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) ItemStack(net.minecraft.item.ItemStack) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) LiteralText(net.minecraft.text.LiteralText)

Example 14 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project BleachHack by BleachDrinker420.

the class Nametags method getPlayerLines.

public List<Text> getPlayerLines(PlayerEntity player) {
    List<Text> lines = new ArrayList<>();
    List<Text> mainText = new ArrayList<>();
    PlayerListEntry playerEntry = mc.player.networkHandler.getPlayerListEntry(player.getGameProfile().getId());
    if (getSetting(1).asToggle().getChild(4).asToggle().getState() && playerEntry != null) {
        // Ping
        mainText.add(new LiteralText(playerEntry.getLatency() + "ms").formatted(Formatting.GRAY));
    }
    if (getSetting(1).asToggle().getChild(2).asToggle().getState()) {
        // Name
        mainText.add(((MutableText) player.getName()).formatted(BleachHack.friendMang.has(player) ? Formatting.AQUA : Formatting.RED));
    }
    if (getSetting(1).asToggle().getChild(3).asToggle().getState()) {
        // Health
        if (getSetting(0).asMode().getMode() == 2) {
            lines.add(getHealthText(player));
        } else {
            mainText.add(getHealthText(player));
        }
    }
    if (getSetting(1).asToggle().getChild(5).asToggle().getState() && playerEntry != null) {
        // GM
        mainText.add(new LiteralText("[" + playerEntry.getGameMode().toString().substring(0, playerEntry.getGameMode() == GameMode.SPECTATOR ? 2 : 1) + "]").formatted(Formatting.GOLD));
    }
    if (!mainText.isEmpty())
        lines.add(Texts.join(mainText, new LiteralText(" ")));
    return lines;
}
Also used : PlayerListEntry(net.minecraft.client.network.PlayerListEntry)

Example 15 with PlayerListEntry

use of net.minecraft.client.network.PlayerListEntry in project Client by MatHax.

the class LogoutSpots method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.getNetworkHandler().getPlayerList().size() != lastPlayerList.size()) {
        for (PlayerListEntry entry : lastPlayerList) {
            if (mc.getNetworkHandler().getPlayerList().stream().anyMatch(playerListEntry -> playerListEntry.getProfile().equals(entry.getProfile())))
                continue;
            for (PlayerEntity player : lastPlayers) {
                if (player.getUuid().equals(entry.getProfile().getId())) {
                    add(new Entry(player));
                }
            }
        }
        lastPlayerList.clear();
        lastPlayerList.addAll(mc.getNetworkHandler().getPlayerList());
        updateLastPlayers();
    }
    if (timer <= 0) {
        updateLastPlayers();
        timer = 10;
    } else {
        timer--;
    }
    Dimension dimension = PlayerUtils.getDimension();
    if (dimension != lastDimension)
        players.clear();
    lastDimension = dimension;
}
Also used : PlayerListEntry(net.minecraft.client.network.PlayerListEntry) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) Dimension(mathax.client.utils.world.Dimension) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

PlayerListEntry (net.minecraft.client.network.PlayerListEntry)18 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 MinecraftClient (net.minecraft.client.MinecraftClient)3 Entity (net.minecraft.entity.Entity)3 LiteralText (net.minecraft.text.LiteralText)3 Vec3d (net.minecraft.util.math.Vec3d)3 IEPlayerListEntry (com.qouteall.immersive_portals.ducks.IEPlayerListEntry)2 IEWorldRenderer (com.qouteall.immersive_portals.ducks.IEWorldRenderer)2 List (java.util.List)2 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)2 LivingEntity (net.minecraft.entity.LivingEntity)2 Identifier (net.minecraft.util.Identifier)2 GameMode (net.minecraft.world.GameMode)2 GameProfile (com.mojang.authlib.GameProfile)1 IEChunkRenderList (com.qouteall.immersive_portals.ducks.IEChunkRenderList)1 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 Gender (com.wildfire.main.GenderPlayer.Gender)1 WildfireGender (com.wildfire.main.WildfireGender)1 fzmm.zailer.me.utils (fzmm.zailer.me.utils)1 Color (java.awt.Color)1