use of net.minecraft.client.network.ClientPlayerEntity in project Skyblocker by LifeIsAParadox.
the class Reparty method reparty.
private void reparty() {
ClientPlayerEntity playerEntity = client.player;
assert playerEntity != null;
sendCommand(playerEntity, "/p disband", 1);
StringBuilder sb = new StringBuilder();
int invites = (players.length - 1) / 5 + 1;
for (int i = 0; i < invites; i++) {
sb.setLength(0);
sb.append("/p invite");
for (int j = 0; j < 5 && i * 5 + j < players.length; j++) {
sb.append(' ');
sb.append(players[i * 5 + j]);
}
sendCommand(playerEntity, sb.toString(), i + 2);
}
skyblocker.scheduler.schedule(() -> repartying = false, invites + 2);
}
use of net.minecraft.client.network.ClientPlayerEntity in project MasaGadget by plusls.
the class SearchMobSpawnPointUtil method search.
public static void search() {
ClientWorld world = MinecraftClient.getInstance().world;
ClientPlayerEntity player = MinecraftClient.getInstance().player;
if (world == null || player == null) {
return;
}
ShapeDespawnSphere shapeDespawnSphere = getShapeDespawnSphere();
if (shapeDespawnSphere == null) {
return;
}
Vec3d centerPos = shapeDespawnSphere.getCenter();
BlockPos pos = new BlockPos((int) centerPos.x, (int) centerPos.y, (int) centerPos.z);
ModInfo.LOGGER.warn("shape: {}", shapeDespawnSphere.getCenter());
BlockPos spawnPos = null;
int maxX = pos.getX() + 129;
int maxZ = pos.getZ() + 129;
BlockPos.Mutable currentPos = new BlockPos.Mutable();
int maxSpawnLightLevel = fi.dy.masa.minihud.config.Configs.Generic.LIGHT_LEVEL_THRESHOLD_SAFE.getIntegerValue();
LightingProvider lightingProvider = world.getChunkManager().getLightingProvider();
EntityType<?> entityType = world.getDimension().isUltrawarm() ? EntityType.ZOMBIFIED_PIGLIN : EntityType.CREEPER;
EntityType<?> entityType2 = world.getDimension().isUltrawarm() ? null : EntityType.SPIDER;
for (int x = pos.getX() - 129; x <= maxX; ++x) {
for (int z = pos.getZ() - 129; z <= maxZ; ++z) {
WorldChunk chunk = world.getChunk(x >> 4, z >> 4);
if (chunk == null) {
continue;
}
int maxY = Math.min(pos.getY() + 129, chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE, x, z) + 1);
for (int y = Math.max(pos.getY() - 129, world.getBottomY() + 1); y <= maxY; ++y) {
if (squaredDistanceTo(x, y, z, centerPos) > 16384) {
if (y > centerPos.y) {
break;
} else {
continue;
}
} else if (spawnPos != null && player.squaredDistanceTo(x, y, z) > player.squaredDistanceTo(spawnPos.getX(), spawnPos.getY(), spawnPos.getZ())) {
continue;
}
currentPos.set(x, y, z);
if (SpawnHelper.canSpawn(SpawnRestriction.getLocation(entityType), world, currentPos, entityType) && lightingProvider.get(LightType.BLOCK).getLightLevel(currentPos) < maxSpawnLightLevel) {
Block block = world.getBlockState(currentPos.down()).getBlock();
String blockId = Registry.BLOCK.getId(world.getBlockState(currentPos.down()).getBlock()).toString();
String blockName = block.getName().getString();
if (Configs.Generic.SEARCH_MOB_SPAWN_POINT_BLACK_LIST.getStrings().stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s))) {
if (world.isSpaceEmpty(entityType.createSimpleBoundingBox(currentPos.getX() + 0.5D, currentPos.getY(), currentPos.getZ() + 0.5D))) {
spawnPos = currentPos.mutableCopy();
} else if (entityType2 != null && world.isSpaceEmpty(entityType2.createSimpleBoundingBox(currentPos.getX() + 0.5D, currentPos.getY(), currentPos.getZ() + 0.5D))) {
spawnPos = currentPos.mutableCopy();
}
}
}
}
}
}
Text text;
if (spawnPos == null) {
text = new TranslatableText("masa_gadget_mod.message.noBlockCanSpawn").setStyle(Style.EMPTY.withColor(TextColor.fromFormatting(Formatting.GREEN)));
} else {
// for ommc parser
text = new LiteralText(I18n.translate("masa_gadget_mod.message.spawnPos", spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()));
player.sendChatMessage(String.format("/highlightWaypoint %d %d %d", spawnPos.getX(), spawnPos.getY(), spawnPos.getZ()));
}
Objects.requireNonNull(MinecraftClient.getInstance().player).sendMessage(text, false);
}
use of net.minecraft.client.network.ClientPlayerEntity in project Polymorph by TheIllusiveC4.
the class PolymorphClientNetwork method sendRecipesList.
private static void sendRecipesList(MinecraftClient pClient, ClientPlayNetworkHandler pHandler, PacketByteBuf pBuf, PacketSender pSender) {
SortedSet<RecipePair> recipeDataset = new TreeSet<>();
Identifier selected = null;
if (pBuf.isReadable()) {
int size = pBuf.readInt();
for (int i = 0; i < size; i++) {
recipeDataset.add(new RecipePairImpl(pBuf.readIdentifier(), pBuf.readItemStack()));
}
if (pBuf.isReadable()) {
selected = pBuf.readIdentifier();
}
}
Identifier finalSelected = selected;
pClient.execute(() -> {
ClientPlayerEntity player = pClient.player;
if (player != null) {
Optional<RecipesWidget> maybeWidget = RecipesWidgetControl.get();
maybeWidget.ifPresent(widget -> widget.setRecipesList(recipeDataset, finalSelected));
if (!maybeWidget.isPresent()) {
RecipesWidgetControl.enqueueRecipesList(recipeDataset, finalSelected);
}
}
});
}
use of net.minecraft.client.network.ClientPlayerEntity 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.client.network.ClientPlayerEntity in project fabricskyboxes by AMereBagatelle.
the class AbstractSkybox method checkWeather.
/**
* @return Whether the current weather is valid for this skybox.
*/
protected boolean checkWeather() {
ClientWorld world = Objects.requireNonNull(MinecraftClient.getInstance().world);
ClientPlayerEntity player = Objects.requireNonNull(MinecraftClient.getInstance().player);
Biome.Precipitation precipitation = world.getBiome(player.getBlockPos()).value().getPrecipitation();
if (weather.size() > 0) {
if (weather.contains("thunder") && world.isThundering()) {
return true;
} else if (weather.contains("snow") && world.isRaining() && precipitation == Biome.Precipitation.SNOW) {
return true;
} else if (weather.contains("rain") && world.isRaining() && !world.isThundering()) {
return true;
} else
return weather.contains("clear");
} else {
return true;
}
}
Aggregations