net.minecraft.client.network.NetHandlerPlayClient Java Examples
The following examples show how to use
net.minecraft.client.network.NetHandlerPlayClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinNetHandlerPlayClient.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true) private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) { if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning()) return; PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this); this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this)); this.gameController.thePlayer.setEntityId(packetIn.getEntityId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); callbackInfo.cancel(); }
Example #2
Source File: MixinNetHandlerPlayClient.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
@Inject(method = "handleJoinGame", at = @At("HEAD"), cancellable = true) private void handleJoinGameWithAntiForge(S01PacketJoinGame packetIn, final CallbackInfo callbackInfo) { if(!AntiForge.enabled || !AntiForge.blockFML || Minecraft.getMinecraft().isIntegratedServerRunning()) return; PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); this.gameController.playerController = new PlayerControllerMP(gameController, (NetHandlerPlayClient) (Object) this); this.clientWorldController = new WorldClient((NetHandlerPlayClient) (Object) this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler); this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = packetIn.getDimension(); this.gameController.displayGuiScreen(new GuiDownloadTerrain((NetHandlerPlayClient) (Object) this)); this.gameController.thePlayer.setEntityId(packetIn.getEntityId()); this.currentServerMaxPlayers = packetIn.getMaxPlayers(); this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo()); this.gameController.playerController.setGameType(packetIn.getGameType()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); callbackInfo.cancel(); }
Example #3
Source File: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) @SuppressWarnings("unchecked") public void onClientPacket(FMLNetworkEvent.ClientCustomPacketEvent event) { Packet packet = proxy2packet(event.getPacket()); if (clientExecutors.containsKey(packet.getClass())) { PacketExecutor<Packet, NetHandlerPlayClient> executor = (PacketExecutor<Packet, NetHandlerPlayClient>) clientExecutors.get(packet.getClass()); NetHandlerPlayClient handler = (NetHandlerPlayClient) event.getHandler(); IThreadListener threadListener = FMLCommonHandler.instance().getWorldThread(handler); if(threadListener.isCallingFromMinecraftThread()) { executor.execute(packet, handler); } else { threadListener.addScheduledTask(() -> executor.execute(packet, handler)); } } }
Example #4
Source File: MixinNetHandlerPlayClient.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
/** * Allows detection of incoming chat packets from the server (includes actionbars) * <p> * Byte values for the event * 0 : Standard Text Message, displayed in chat * 1 : 'System' message, displayed as standard text in the chat. * 2 : 'Status' message, displayed as an action bar above the hotbar * * @author boomboompower * @reason Detect incoming chat packets being sent from the server */ @Overwrite public void handleChat(S02PacketChat packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); ServerChatEvent event = new ServerChatEvent(packetIn.getType(), packetIn.getChatComponent()); EventBus.INSTANCE.post(event); // If the event is cancelled or the message is empty, we'll ignore the packet. if (event.isCancelled() || event.getChat().getFormattedText().isEmpty()) return; if (packetIn.getType() == 2) { gameController.ingameGUI.setRecordPlaying(event.getChat(), false); } else { // This will then trigger the other chat event gameController.ingameGUI.getChatGUI().printChatMessage(event.getChat()); } }
Example #5
Source File: NickHider.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@InvokeEvent public void profileCheck(TickEvent event) { if (nickHiderConfig.isMasterEnabled()) { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player == null) return; NetHandlerPlayClient sendQueue = player.sendQueue; if (sendQueue == null) return; sendQueue.getPlayerInfoMap().stream().map(NetworkPlayerInfo::getGameProfile).forEach(gameProfile -> { if (gameProfile.getId() != null && gameProfile.getId().equals(Minecraft.getMinecraft().getSession().getProfile().getId())) { if (!gameProfile.getName().equalsIgnoreCase(Minecraft.getMinecraft().getSession().getProfile().getName())) { remap(gameProfile.getName(), override == null ? Minecraft.getMinecraft().getSession().getProfile().getName() : override); } } else if (nickHiderConfig.isHideOtherNames()) { remap(gameProfile.getName(), getPseudo(gameProfile.getName())); } }); } }
Example #6
Source File: OpenClientProxy.java From OpenModsLib with MIT License | 5 votes |
@Override public EntityPlayer getPlayerFromHandler(INetHandler handler) { if (handler instanceof NetHandlerPlayServer) return ((NetHandlerPlayServer)handler).player; if (handler instanceof NetHandlerPlayClient) return getThePlayer(); return null; }
Example #7
Source File: BlockUtils.java From ForgeWurst with GNU General Public License v3.0 | 5 votes |
public static void breakBlocksPacketSpam(Iterable<BlockPos> blocks) { Vec3d eyesPos = RotationUtils.getEyesPos(); NetHandlerPlayClient connection = WMinecraft.getPlayer().connection; for(BlockPos pos : blocks) { Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5); double distanceSqPosVec = eyesPos.squareDistanceTo(posVec); for(EnumFacing side : EnumFacing.values()) { Vec3d hitVec = posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5)); // check if side is facing towards player if(eyesPos.squareDistanceTo(hitVec) >= distanceSqPosVec) continue; // break block connection.sendPacket(new CPacketPlayerDigging( Action.START_DESTROY_BLOCK, pos, side)); connection.sendPacket(new CPacketPlayerDigging( Action.STOP_DESTROY_BLOCK, pos, side)); break; } } }
Example #8
Source File: MixinNetHandlerPlayClient.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
/** * Renders a specified animation: Waking up a player, a living entity swinging its currently held item, being hurt * or receiving a critical hit by normal or magical means * * @author boomboompower * @reason Fixes internal NPE */ @Overwrite public void handleAnimation(S0BPacketAnimation packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); // Stops the code if the world is null, usually due to a weird packet from the server if (clientWorldController == null) return; Entity entity = clientWorldController.getEntityByID(packetIn.getEntityID()); if (entity != null) { switch (packetIn.getAnimationType()) { case 0: EntityLivingBase entitylivingbase = (EntityLivingBase) entity; entitylivingbase.swingItem(); break; case 1: entity.performHurtAnimation(); break; case 2: EntityPlayer entityplayer = (EntityPlayer) entity; entityplayer.wakeUpPlayer(false, false, false); break; case 4: gameController.effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT); break; case 5: gameController.effectRenderer.emitParticleAtEntity(entity, EnumParticleTypes.CRIT_MAGIC); break; } } }
Example #9
Source File: MixinNetHandlerPlayClient.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
/** * The actual logic of the packet, may be spoofed. * * @param packetIn the packet */ private void handleActualPacket(S03PacketTimeUpdate packetIn) { if (gameController == null || gameController.theWorld == null) return; PacketThreadUtil.checkThreadAndEnqueue(packetIn, (NetHandlerPlayClient) (Object) this, gameController); gameController.theWorld.setTotalWorldTime(packetIn.getTotalWorldTime()); gameController.theWorld.setWorldTime(packetIn.getWorldTime()); }
Example #10
Source File: HyperiumNetwork.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@InvokeEvent public void joinHypixel(ServerJoinEvent event) { Multithreading.runAsync(() -> { NetHandlerPlayClient netHandler = Minecraft.getMinecraft().getNetHandler(); if (netHandler != null) { netHandler.addToSendQueue( new C17PacketCustomPayload("hyperium", new PacketBuffer(Unpooled.buffer()).writeString(new JsonHolder() .put("id", Metadata.getModid()) .put("optifine", HyperiumTweaker.INSTANCE.isUsingOptifine()) .put("version", Metadata.getVersion()).toString()))); } }); }
Example #11
Source File: WrapperNetHandlerPlayClient.java From ClientBase with MIT License | 4 votes |
public NetHandlerPlayClient unwrap() { return this.real; }
Example #12
Source File: WrapperNetHandlerPlayClient.java From ClientBase with MIT License | 4 votes |
public WrapperNetHandlerPlayClient(NetHandlerPlayClient var1) { this.real = var1; }
Example #13
Source File: WorldSchematic.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public WorldSchematic(NetHandlerPlayClient netHandler, WorldSettings settings, int dimension, EnumDifficulty difficulty, Profiler profilerIn) { super(netHandler, settings, dimension, difficulty, profilerIn); }
Example #14
Source File: FakeWorldClient.java From Framez with GNU General Public License v3.0 | 4 votes |
private FakeWorldClient() { super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, GameType.NOT_SET, false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler); }
Example #15
Source File: GuiEntityRender.java From WearableBackpacks with MIT License | 4 votes |
public DummyPlayerSP(World world) { super(getMC(), world, new NetHandlerPlayClient( getMC(), null, null, getMC().getSession().getProfile() ), null, null); }
Example #16
Source File: NetworkHandler.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@SideOnly(Side.CLIENT) public static <T extends Packet> void registerClientExecutor(Class<T> packet, PacketExecutor<T, NetHandlerPlayClient> executor) { clientExecutors.put(packet, executor); }
Example #17
Source File: MixinMinecraft.java From VanillaFix with MIT License | votes |
@Shadow @Nullable public abstract NetHandlerPlayClient getConnection();