Search in sources :

Example 11 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project sodium-fabric by CaffeineMC.

the class ChunkRenderManager method update.

public void update(Camera camera, Frustum frustum, boolean hasForcedFrustum, int frame, boolean spectator) {
    Vec3d cameraPos = camera.getPos();
    if (this.client.options.viewDistance != this.renderDistance) {
        this.reload();
    }
    this.world.getProfiler().push("camera");
    ClientPlayerEntity player = this.client.player;
    if (player == null) {
        throw new IllegalStateException("Client instance has no active player entity");
    }
    this.chunkBuilder.setCameraPosition(cameraPos.x, cameraPos.y, cameraPos.z);
    this.world.getProfiler().swap("cull");
    this.client.getProfiler().swap("culling");
    float pitch = camera.getPitch();
    float yaw = camera.getYaw();
    this.isRenderGraphDirty = this.isRenderGraphDirty || !this.chunksToRebuild.isEmpty() || cameraPos.x != this.lastCameraX || cameraPos.y != this.lastCameraY || cameraPos.z != this.lastCameraZ || pitch != this.lastCameraPitch || yaw != this.lastCameraYaw;
    this.lastCameraX = cameraPos.x;
    this.lastCameraY = cameraPos.y;
    this.lastCameraZ = cameraPos.z;
    this.lastCameraPitch = pitch;
    this.lastCameraYaw = yaw;
    this.client.getProfiler().swap("update");
    BlockPos blockPos = camera.getBlockPos();
    if (!hasForcedFrustum && this.isRenderGraphDirty) {
        this.isRenderGraphDirty = false;
        this.client.getProfiler().push("iteration");
        this.chunkGraph.calculateVisible(camera, cameraPos, blockPos, frame, frustum, spectator);
        this.client.getProfiler().pop();
    }
    Entity.setRenderDistanceMultiplier(MathHelper.clamp((double) client.options.viewDistance / 8.0D, 1.0D, 2.5D));
    this.client.getProfiler().swap("rebuildNear");
    this.performRebuilds(blockPos);
    this.client.getProfiler().pop();
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 12 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project wildmod by Osmiooo.

the class BackgroundRendererMixin method applyFog.

@Inject(at = @At("TAIL"), method = "applyFog")
private static void applyFog(Camera camera, BackgroundRenderer.FogType fogType, float viewDistance, boolean thickFog, CallbackInfo ci) {
    Entity entity = camera.getFocusedEntity();
    CameraSubmersionType cameraSubmersionType = camera.getSubmersionType();
    float y;
    if (cameraSubmersionType == CameraSubmersionType.WATER) {
        y = 192.0F;
        if (entity instanceof ClientPlayerEntity) {
            ClientPlayerEntity clientPlayerEntity = (ClientPlayerEntity) entity;
            y *= Math.max(0.25F, clientPlayerEntity.getUnderwaterVisibility());
            Biome biome = clientPlayerEntity.world.getBiome(clientPlayerEntity.getBlockPos());
            if (biome.getCategory() == Biome.Category.SWAMP) {
                y *= 0.85F;
            }
        }
        RenderSystem.setShaderFogStart(-8.0F);
        RenderSystem.setShaderFogEnd(y * 0.5F);
    } else {
        float ab;
        if (cameraSubmersionType == CameraSubmersionType.LAVA) {
            if (entity.isSpectator()) {
                y = -8.0F;
                ab = viewDistance * 0.5F;
            } else if (entity instanceof LivingEntity && ((LivingEntity) entity).hasStatusEffect(StatusEffects.FIRE_RESISTANCE)) {
                y = 0.0F;
                ab = 3.0F;
            } else {
                y = 0.25F;
                ab = 1.0F;
            }
        } else if (entity instanceof LivingEntity && ((LivingEntity) entity).hasStatusEffect(StatusEffects.BLINDNESS)) {
            int m = ((LivingEntity) entity).getStatusEffect(StatusEffects.BLINDNESS).getDuration();
            float n = MathHelper.lerp(Math.min(1.0F, (float) m / 20.0F), viewDistance, 5.0F);
            if (fogType == BackgroundRenderer.FogType.FOG_SKY) {
                y = 0.0F;
                ab = n * 0.8F;
            } else {
                y = n * 0.25F;
                ab = n;
            }
        } else if (cameraSubmersionType == CameraSubmersionType.POWDER_SNOW) {
            if (entity.isSpectator()) {
                y = -8.0F;
                ab = viewDistance * 0.5F;
            } else {
                y = 0.0F;
                ab = 2.0F;
            }
        } else if (thickFog) {
            y = viewDistance * 0.05F;
            ab = Math.min(viewDistance, 192.0F) * 0.5F;
        } else if (fogType == BackgroundRenderer.FogType.FOG_SKY) {
            y = 0.0F;
            ab = viewDistance;
        } else {
            y = (viewDistance * 0.75f);
            ab = viewDistance;
        }
        float math;
        if (entity instanceof LivingEntity && ((LivingEntity) entity).hasStatusEffect(RegisterStatusEffects.DARKNESS)) {
            float offset = 0.5f;
            float multiplier = viewDistance * 1.4f;
            float equation = (float) MathAddon.cutCos(MathAddon.time, offset, true);
            math = (equation * multiplier) - offset * (multiplier);
        } else {
            math = 0;
        }
        y = y - math;
        ab = ab - math;
        RenderSystem.setShaderFogStart(y);
        RenderSystem.setShaderFogEnd(ab);
    // RenderSystem.setShaderFogColor(math, math, math);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Biome(net.minecraft.world.biome.Biome) CameraSubmersionType(net.minecraft.client.render.CameraSubmersionType) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 13 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project meteor-client by MeteorDevelopment.

the class DropCommand method drop.

private int drop(PlayerConsumer consumer) throws CommandSyntaxException {
    ClientPlayerEntity player = mc.player;
    assert player != null;
    if (player.isSpectator())
        throw NOT_SPECTATOR.create();
    consumer.accept(player);
    return SINGLE_SUCCESS;
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 14 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project tweakermore by Fallen-Breath.

the class ContainerProcessor method process.

public static void process(Container container) {
    if (hasTweakEnabled()) {
        Screen screen = MinecraftClient.getInstance().currentScreen;
        ClientPlayerEntity player = MinecraftClient.getInstance().player;
        // not inventory and not crafting table
        if (player != null && screen instanceof ContainerScreen<?> && !(screen instanceof AbstractInventoryScreen) && !(screen instanceof CraftingTableScreen)) {
            ContainerScreen<?> containerScreen = (ContainerScreen<?>) screen;
            if (containerScreen.getContainer() != container || !((AutoProcessableScreen) screen).shouldProcess()) {
                return;
            }
            ((AutoProcessableScreen) screen).setShouldProcess(false);
            List<Slot> allSlots = container.slots;
            List<Slot> playerInvSlots = allSlots.stream().filter(slot -> slot.inventory instanceof PlayerInventory).collect(Collectors.toList());
            if (allSlots.isEmpty() || playerInvSlots.isEmpty()) {
                return;
            }
            List<Slot> containerInvSlots = allSlots.stream().filter(slot -> ItemScrollerInventoryUtilsAccessor.areSlotsInSameInventory(slot, allSlots.get(0))).collect(Collectors.toList());
            if (containerInvSlots.isEmpty()) {
                return;
            }
            for (Processor processor : CONTAINER_PROCESSORS) {
                if (processor.isEnabled()) {
                    boolean success = processor.process(player, containerScreen, allSlots, playerInvSlots, containerInvSlots);
                    if (success) {
                        break;
                    }
                }
            }
            player.closeContainer();
        }
    }
}
Also used : PlayerInventory(net.minecraft.entity.player.PlayerInventory) AbstractInventoryScreen(net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen) ContainerScreen(net.minecraft.client.gui.screen.ingame.ContainerScreen) Slot(net.minecraft.container.Slot) Collectors(java.util.stream.Collectors) List(java.util.List) Screen(net.minecraft.client.gui.screen.Screen) ImmutableList(com.google.common.collect.ImmutableList) CraftingTableScreen(net.minecraft.client.gui.screen.ingame.CraftingTableScreen) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ItemScrollerInventoryUtilsAccessor(me.fallenbreath.tweakermore.mixins.tweaks.tweakmAutoContainerProcess.ItemScrollerInventoryUtilsAccessor) Container(net.minecraft.container.Container) AbstractInventoryScreen(net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen) ContainerScreen(net.minecraft.client.gui.screen.ingame.ContainerScreen) Screen(net.minecraft.client.gui.screen.Screen) CraftingTableScreen(net.minecraft.client.gui.screen.ingame.CraftingTableScreen) PlayerInventory(net.minecraft.entity.player.PlayerInventory) ContainerScreen(net.minecraft.client.gui.screen.ingame.ContainerScreen) Slot(net.minecraft.container.Slot) CraftingTableScreen(net.minecraft.client.gui.screen.ingame.CraftingTableScreen) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) AbstractInventoryScreen(net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen)

Example 15 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project visuality by PinkGoosik.

the class CirclesOnWaterEvent method onStartTick.

@Override
public void onStartTick(ClientWorld world) {
    if (!VisualityMod.CONFIG.getBoolean("water_circle"))
        return;
    if (MinecraftClient.getInstance().options.particles == ParticlesMode.MINIMAL)
        return;
    ClientPlayerEntity player = MinecraftClient.getInstance().player;
    if (player == null)
        return;
    if (player.isSubmergedInWater() || !world.getRegistryKey().equals(World.OVERWORLD))
        return;
    if (!world.isRaining())
        return;
    Biome biome = world.getBiome(player.getBlockPos());
    if (!(biome.getPrecipitation().equals(Biome.Precipitation.RAIN)) || !(biome.getTemperature(player.getBlockPos()) >= 0.15F))
        return;
    for (int i = 0; i <= random.nextInt(10) + 5; i++) {
        int x = random.nextInt(15) - 7;
        int z = random.nextInt(15) - 7;
        BlockPos playerPos = new BlockPos((int) player.getX() + x, (int) player.getY(), (int) player.getZ() + z);
        BlockPos pos = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING, playerPos);
        if (world.getBlockState(pos.down()).isOf(Blocks.WATER) && world.getBlockState(pos).isAir()) {
            if (world.getFluidState(pos.down()).getLevel() == 8) {
                ParticleUtils.add(world, VisualityParticles.WATER_CIRCLE, pos.getX() + random.nextDouble(), pos.getY() + 0.05D, pos.getZ() + random.nextDouble(), biome.getWaterColor());
            }
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) BlockPos(net.minecraft.util.math.BlockPos) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Aggregations

ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)58 Identifier (net.minecraft.util.Identifier)11 Inject (org.spongepowered.asm.mixin.injection.Inject)10 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)9 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)9 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)9 MinecraftClient (net.minecraft.client.MinecraftClient)9 ClientCommandSource (net.minecraft.client.network.ClientCommandSource)9 CommandManager (at.haha007.edenclient.command.CommandManager)8 Registry (net.minecraft.util.registry.Registry)8 ChatColor (at.haha007.edenclient.utils.ChatColor)7 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)7 List (java.util.List)7 ClientWorld (net.minecraft.client.world.ClientWorld)7 ItemStack (net.minecraft.item.ItemStack)7 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)6 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)5 CommandContext (com.mojang.brigadier.context.CommandContext)5 Comparator (java.util.Comparator)5