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();
}
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);
}
}
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;
}
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();
}
}
}
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());
}
}
}
}
Aggregations