use of net.minecraft.client.network.ClientPlayNetworkHandler in project meteor-rejects by AntiCope.
the class GhostCommand method execute.
private void execute(int radius) {
ClientPlayNetworkHandler conn = mc.getNetworkHandler();
if (conn == null)
return;
BlockPos pos = mc.player.getBlockPos();
for (int dx = -radius; dx <= radius; dx++) for (int dy = -radius; dy <= radius; dy++) for (int dz = -radius; dz <= radius; dz++) {
PlayerActionC2SPacket packet = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, new BlockPos(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz), Direction.UP);
conn.sendPacket(packet);
}
}
use of net.minecraft.client.network.ClientPlayNetworkHandler in project KiwiClient by TangyKiwi.
the class MinecraftClientMixin method getWindowTitle.
@Inject(method = "getWindowTitle", at = @At(value = "TAIL"), cancellable = true)
private void getWindowTitle(final CallbackInfoReturnable<String> info) {
MinecraftClient client = (MinecraftClient) (Object) this;
String title = KiwiClient.name + " v" + KiwiClient.version;
ClientPlayNetworkHandler clientPlayNetworkHandler = client.getNetworkHandler();
if (clientPlayNetworkHandler != null && clientPlayNetworkHandler.getConnection().isOpen()) {
title += " - ";
if (client.getServer() != null && !client.getServer().isRemote()) {
title += I18n.translate("title.singleplayer");
discordRPC.update("Playing", "Singleplayer");
} else if (client.isConnectedToRealms()) {
title += I18n.translate("title.multiplayer.realms");
discordRPC.update("Playing", "Realms");
} else if (client.getServer() == null && (client.getCurrentServerEntry() == null || !client.getCurrentServerEntry().isLocal())) {
title += I18n.translate("title.multiplayer.other");
discordRPC.update("Playing", client.getCurrentServerEntry().address);
} else {
title += I18n.translate("title.multiplayer.lan");
discordRPC.update("Playing", "LAN Server");
}
} else {
discordRPC.update("Idle", "Main Menu");
}
info.setReturnValue(title);
}
use of net.minecraft.client.network.ClientPlayNetworkHandler in project ImmersivePortalsMod by qouteall.
the class ClientWorldLoader method createFakedClientWorld.
// fool minecraft using the faked world
private ClientWorld createFakedClientWorld(DimensionType dimension) {
assert mc.world.dimension.getType() == mc.player.dimension;
assert (mc.player.dimension != dimension);
isLoadingFakedWorld = true;
// TODO get load distance
int chunkLoadDistance = 3;
WorldRenderer worldRenderer = new WorldRenderer(mc);
ClientWorld newWorld;
try {
ClientPlayNetworkHandler newNetworkHandler = new ClientPlayNetworkHandler(mc, new ChatScreen("You should not be seeing me. I'm just a faked screen."), new ClientConnection(NetworkSide.CLIENTBOUND), new GameProfile(null, "faked_profiler_id"));
// multiple net handlers share the same playerListEntries object
((IEClientPlayNetworkHandler) newNetworkHandler).setPlayerListEntries(((IEClientPlayNetworkHandler) mc.player.networkHandler).getPlayerListEntries());
newWorld = new ClientWorld(newNetworkHandler, new LevelInfo(0L, GameMode.CREATIVE, true, isHardCore, LevelGeneratorType.FLAT), dimension, chunkLoadDistance, mc.getProfiler(), worldRenderer);
} catch (Exception e) {
throw new IllegalStateException("Creating Faked World " + dimension + " " + clientWorldMap.keySet(), e);
}
worldRenderer.setWorld(newWorld);
worldRenderer.apply(mc.getResourceManager());
((IEClientPlayNetworkHandler) ((IEClientWorld) newWorld).getNetHandler()).setWorld(newWorld);
clientWorldMap.put(dimension, newWorld);
worldRendererMap.put(dimension, worldRenderer);
Helper.log("Faked World Created " + dimension);
isLoadingFakedWorld = false;
return newWorld;
}
use of net.minecraft.client.network.ClientPlayNetworkHandler in project ImmersivePortalsMod by qouteall.
the class MyNetworkClient method processRedirectedPacket.
private static void processRedirectedPacket(DimensionType dimension, Packet packet) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.execute(() -> {
ClientWorld packetWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(dimension);
assert packetWorld != null;
assert packetWorld.getChunkManager() instanceof MyClientChunkManager;
ClientPlayNetworkHandler netHandler = ((IEClientWorld) packetWorld).getNetHandler();
if ((netHandler).getWorld() != packetWorld) {
((IEClientPlayNetworkHandler) netHandler).setWorld(packetWorld);
Helper.err("The world field of client net handler is wrong");
}
ClientWorld originalWorld = mc.world;
// some packet handling may use mc.world so switch it
mc.world = packetWorld;
try {
packet.apply(netHandler);
} catch (Throwable e) {
throw new IllegalStateException("handling packet in " + dimension, e);
} finally {
mc.world = originalWorld;
}
});
}
use of net.minecraft.client.network.ClientPlayNetworkHandler in project quilt-standard-libraries by QuiltMC.
the class ClientPlayNetworkHandlerMixin method initAddon.
@Inject(method = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.addon = new ClientPlayNetworkAddon((ClientPlayNetworkHandler) (Object) this, this.client);
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
ClientNetworkingImpl.setClientPlayAddon(this.addon);
this.addon.lateInit();
}
Aggregations