use of net.minecraft.world.chunk.WorldChunk in project CustomHUD by Minenash.
the class ComplexData method update.
@SuppressWarnings("ConstantConditions")
public static void update(Profile profile) {
if (profile.enabled.serverWorld) {
IntegratedServer integratedServer = client.getServer();
serverWorld = integratedServer != null ? integratedServer.getWorld(client.world.getRegistryKey()) : null;
}
if (profile.enabled.clientChunk) {
ChunkPos newPos = new ChunkPos(client.getCameraEntity().getBlockPos());
if (!Objects.equals(ComplexData.pos, newPos)) {
pos = newPos;
chunkFuture = null;
clientChunk = null;
}
if (clientChunk == null)
clientChunk = client.world.getChunk(pos.x, pos.z);
}
if (profile.enabled.serverChunk) {
if (chunkFuture == null) {
if (serverWorld != null)
chunkFuture = serverWorld.getChunkManager().getChunkFutureSyncOnMainThread(pos.x, pos.z, ChunkStatus.FULL, false).thenApply((either) -> either.map((chunk) -> (WorldChunk) chunk, (unloaded) -> null));
if (chunkFuture == null)
chunkFuture = CompletableFuture.completedFuture(clientChunk);
}
serverChunk = chunkFuture.getNow(null);
}
if (profile.enabled.targetBlock) {
HitResult hit = client.cameraEntity.raycast(profile.targetDistance, 0.0F, false);
targetBlockPos = hit.getType() == HitResult.Type.BLOCK ? ((BlockHitResult) hit).getBlockPos() : null;
}
if (profile.enabled.world)
world = DataFixUtils.orElse(Optional.ofNullable(client.getServer()).flatMap((integratedServer) -> Optional.ofNullable(integratedServer.getWorld(client.world.getRegistryKey()))), client.world);
if (profile.enabled.localDifficulty)
localDifficulty = new LocalDifficulty(world.getDifficulty(), world.getTimeOfDay(), serverChunk == null ? 0 : serverChunk.getInhabitedTime(), world.getMoonSize());
if (profile.enabled.sound)
sounds = client.getSoundManager().getDebugString().substring(8).replace(" + ", "/").split("/");
if (profile.enabled.clientChunkCache)
clientChunkCache = client.worldRenderer.getChunksDebugString().substring(20).split(", ");
if (profile.enabled.time) {
timeOfDay = (int) ((client.world.getTimeOfDay() + 6000) % 24000);
}
if (profile.enabled.velocity) {
if (velocityWaitCounter > 0) {
velocityWaitCounter--;
return;
}
velocityWaitCounter = 4;
ClientPlayerEntity p = client.player;
final double changeXZ = Math.sqrt(Math.pow(Math.abs(p.getX() - x1), 2) + Math.pow(Math.abs(p.getZ() - z1), 2));
final double changeY = Math.abs(p.getY() - y1);
final double changeXYZ = Math.sqrt(changeXZ * changeXZ + changeY * changeY);
x1 = p.getX();
y1 = p.getY();
z1 = p.getZ();
velocityXZ = ((int) (changeXZ * 40)) / 10.0;
velocityY = ((int) (changeY * 40)) / 10.0;
velocityXYZ = ((int) (changeXYZ * 40)) / 10.0;
}
}
use of net.minecraft.world.chunk.WorldChunk in project BleachHack by BleachDrinker420.
the class WorldUtils method getLoadedChunks.
public static List<WorldChunk> getLoadedChunks() {
List<WorldChunk> chunks = new ArrayList<>();
int viewDist = mc.options.viewDistance;
for (int x = -viewDist; x <= viewDist; x++) {
for (int z = -viewDist; z <= viewDist; z++) {
WorldChunk chunk = mc.world.getChunkManager().getWorldChunk((int) mc.player.getX() / 16 + x, (int) mc.player.getZ() / 16 + z);
if (chunk != null) {
chunks.add(chunk);
}
}
}
return chunks;
}
use of net.minecraft.world.chunk.WorldChunk in project EdenClient by HahaOO7.
the class ChestShopMod method checkForShops.
private void checkForShops(ChunkManager cm, ChunkPos chunk) {
if (!cm.isChunkLoaded(chunk.x, chunk.z))
return;
WorldChunk c = cm.getWorldChunk(chunk.x, chunk.z, false);
if (c == null)
return;
shops.remove(chunk);
ChestShopSet cs = new ChestShopSet();
c.getBlockEntities().values().stream().filter(t -> t instanceof SignBlockEntity).map(t -> (SignBlockEntity) t).map(ChestShopEntry::new).filter(ChestShopEntry::isShop).forEach(cs::add);
shops.put(chunk, cs);
}
use of net.minecraft.world.chunk.WorldChunk in project EdenClient by HahaOO7.
the class TileEntityEsp method tick.
private void tick(ClientPlayerEntity player) {
if (!enabled) {
tileEntities = new ArrayList<>();
return;
}
ChunkPos chunkPos = player.getChunkPos();
ClientChunkManager cm = player.clientWorld.getChunkManager();
BlockPos pp = player.getBlockPos();
tileEntities = ChunkPos.stream(chunkPos, distance).flatMap(cp -> {
WorldChunk wc = cm.getWorldChunk(cp.x, cp.z, false);
if (wc == null)
return null;
return wc.getBlockEntities().entrySet().stream();
}).filter(e -> types.contains(e.getValue().getType())).map(Map.Entry::getKey).sorted(Comparator.comparingDouble(pos -> pos.getSquaredDistance(pp))).limit(maxCount).map(v -> (Vec3i) v).toList();
}
use of net.minecraft.world.chunk.WorldChunk in project meteor-client by MeteorDevelopment.
the class ClientPlayNetworkHandlerMixin method onChunkData.
@Inject(method = "onChunkData", at = @At("TAIL"))
private void onChunkData(ChunkDataS2CPacket packet, CallbackInfo info) {
WorldChunk chunk = client.world.getChunk(packet.getX(), packet.getZ());
MeteorClient.EVENT_BUS.post(ChunkDataEvent.get(chunk));
}
Aggregations