/** * Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(S01PacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(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(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()))); }
/** * Registers some server properties * (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new * WorldClient and sets the player initial dimension */ public void handleJoinGame(S01PacketJoinGame packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(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(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()))); }
@Override protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception { boolean handled = false; if (msg instanceof C17PacketCustomPayload) { handled = handleServerSideCustomPacket((C17PacketCustomPayload) msg, ctx); } else if (msg instanceof S3FPacketCustomPayload) { handled = handleClientSideCustomPacket((S3FPacketCustomPayload)msg, ctx); } else if (state != ConnectionState.CONNECTED && state != ConnectionState.HANDSHAKECOMPLETE) { handled = handleVanilla(msg); } if (!handled) { ctx.fireChannelRead(msg); } }
public void syncGlidingCLIENT(int type, String name){ /*0 - add, 1 - remove*/ PacketBuffer pb = new PacketBuffer(Unpooled.buffer()); try { pb.writeInt("gliderdata".getBytes().length); pb.writeBytes("gliderdata".getBytes()); pb.writeInt(type); pb.writeInt(name.getBytes().length); pb.writeBytes(name.getBytes()); } catch (Exception ex) { ex.printStackTrace(); } C17PacketCustomPayload packet = new C17PacketCustomPayload("AvatarMisc", pb); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(packet); }
private static void sendState(int state){ PacketBuffer pb = new PacketBuffer(Unpooled.buffer()); try { pb.writeInt("keyInput".getBytes().length); pb.writeBytes("keyInput".getBytes()); pb.writeInt(state); pb.writeInt(Minecraft.getMinecraft().thePlayer.getDisplayName().getBytes().length); pb.writeBytes(Minecraft.getMinecraft().thePlayer.getDisplayName().getBytes()); } catch (Exception ex) { ex.printStackTrace(); } C17PacketCustomPayload packet = new C17PacketCustomPayload("AvatarMisc", pb); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(packet); }
/** * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual * contents of that slot. Args: Container, slot number, slot contents */ @Override public void sendSlotContents(Container container, int updateID, ItemStack itemStack) { if (updateID == 0) { this.itemNameField.setText(itemStack == null ? "" : itemStack.getDisplayName()); this.itemNameField.setEnabled(itemStack != null); //set enabled if (itemStack != null) { this.repairContainer.updateItemName(this.itemNameField.getText()); mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", itemNameField.getText().getBytes(Charsets.UTF_8))); } } }
private void renameItem() { String s = this.nameField.getText(); Slot slot = this.anvil.getSlot(0); if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName())) { s = ""; } this.anvil.updateItemName(s); this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s))); }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { boolean flag = false; if (button == this.nextButton) { ++this.selectedMerchantRecipe; MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.thePlayer); if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size()) { this.selectedMerchantRecipe = merchantrecipelist.size() - 1; } flag = true; } else if (button == this.previousButton) { --this.selectedMerchantRecipe; if (this.selectedMerchantRecipe < 0) { this.selectedMerchantRecipe = 0; } flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.selectedMerchantRecipe); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", packetbuffer)); } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.enabled) { if (button.id == 1) { this.localCommandBlock.setTrackOutput(this.field_175389_t); this.mc.displayGuiScreen((GuiScreen)null); } else if (button.id == 0) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeByte(this.localCommandBlock.func_145751_f()); this.localCommandBlock.func_145757_a(packetbuffer); packetbuffer.writeString(this.commandTextField.getText()); packetbuffer.writeBoolean(this.localCommandBlock.shouldTrackOutput()); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", packetbuffer)); if (!this.localCommandBlock.shouldTrackOutput()) { this.localCommandBlock.setLastOutput((IChatComponent)null); } this.mc.displayGuiScreen((GuiScreen)null); } else if (button.id == 4) { this.localCommandBlock.setTrackOutput(!this.localCommandBlock.shouldTrackOutput()); this.func_175388_a(); } } }
public static void sendToServer(RewiModPacket packet) { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.write(packetRegistry.getIdByPacket(packet.getClass())); packet.write(output); ByteBuf byteBuf = Unpooled.buffer(); byteBuf.writeBytes(output.toByteArray()); C17PacketCustomPayload p = new C17PacketCustomPayload("RewiMod", new PacketBuffer(byteBuf)); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(p); }
public static void sendToServer(RewiModPacket packet, NetworkManager manager) { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.write(packetRegistry.getIdByPacket(packet.getClass())); packet.write(output); System.out.println(new String(output.toByteArray())); ByteBuf byteBuf = Unpooled.buffer(); byteBuf.writeBytes(output.toByteArray()); C17PacketCustomPayload p = new C17PacketCustomPayload("RewiMod", new PacketBuffer(byteBuf)); manager.sendPacket(p); }
public void renameItem() { String s = this.nameField.getText(); Slot slot = this.anvil.getSlot(0); if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName())) { s = ""; } this.anvil.updateItemName(s); this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s))); }
private static Packet make(Side side, String channel) { if (FMLCommonHandler.instance().getSide() == Side.SERVER && side == Side.CLIENT) { return null; } if (side == Side.CLIENT) { return new C17PacketCustomPayload(channel, new PacketBuffer(Unpooled.buffer(0))); } else { return new S3FPacketCustomPayload(channel, new PacketBuffer(Unpooled.buffer(0))); } }
public String getChannel(Packet packet) { if (packet instanceof C17PacketCustomPayload) { C17PacketCustomPayload p = (C17PacketCustomPayload) packet; return p.getChannelName(); } return null; }
@Override protected void keyTyped(char c, int i) { if(itemNameField.textboxKeyTyped(c, i)) { repairContainer.updateItemName(itemNameField.getText()); mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", itemNameField.getText().getBytes())); } else { super.keyTyped(c, i); } }
@Override public void sendSlotContents(Container container, int slotID, ItemStack itemstack) { if(slotID == 0) { itemNameField.setText(itemstack == null ? "" : itemstack.getDisplayName()); itemNameField.setEnabled(itemstack != null); if(itemstack != null) { repairContainer.updateItemName(itemNameField.getText()); mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", itemNameField.getText().getBytes(Charsets.UTF_8))); } } }
public void handleJoinGame(S01PacketJoinGame p_147282_1_) { this.gameController.playerController = new HookPlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, p_147282_1_.func_149198_e(), false, p_147282_1_.func_149195_d(), p_147282_1_.func_149196_i()), p_147282_1_.func_149194_f(), p_147282_1_.func_149192_g(), this.gameController.mcProfiler); this.clientWorldController.isClient = true; this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = p_147282_1_.func_149194_f(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); this.gameController.thePlayer.setEntityId(p_147282_1_.func_149197_c()); this.currentServerMaxPlayers = p_147282_1_.func_149193_h(); this.gameController.playerController.setGameType(p_147282_1_.func_149198_e()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.scheduleOutboundPacket(new C17PacketCustomPayload("MC|Brand", ClientBrandRetriever.getClientModName().getBytes(Charsets.UTF_8)), new GenericFutureListener[0]); }
private void func_147090_g() { String var1 = this.field_147091_w.getText(); Slot var2 = this.field_147092_v.getSlot(0); if (var2 != null && var2.getHasStack() && !var2.getStack().hasDisplayName() && var1.equals(var2.getStack().getDisplayName())) { var1 = ""; } this.field_147092_v.updateItemName(var1); this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", var1.getBytes(Charsets.UTF_8))); }
protected void actionPerformed(GuiButton p_146284_1_) { boolean var2 = false; if (p_146284_1_ == this.field_147043_x) { ++this.field_147041_z; var2 = true; } else if (p_146284_1_ == this.field_147042_y) { --this.field_147041_z; var2 = true; } if (var2) { ((ContainerMerchant)this.field_147002_h).setCurrentRecipeIndex(this.field_147041_z); ByteBuf var3 = Unpooled.buffer(); try { var3.writeInt(this.field_147041_z); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", var3)); } catch (Exception var8) { logger.error("Couldn\'t send trade info", var8); } finally { var3.release(); } } }
protected void actionPerformed(GuiButton p_146284_1_) { if (p_146284_1_.enabled) { if (p_146284_1_.id == 1) { this.mc.displayGuiScreen((GuiScreen)null); } else if (p_146284_1_.id == 0) { PacketBuffer var2 = new PacketBuffer(Unpooled.buffer()); try { var2.writeByte(this.field_146489_h.func_145751_f()); this.field_146489_h.func_145757_a(var2); var2.writeStringToBuffer(this.field_146485_f.getText()); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", var2)); } catch (Exception var7) { field_146488_a.error("Couldn\'t send command block info", var7); } finally { var2.release(); } this.mc.displayGuiScreen((GuiScreen)null); } } }
public void handleJoinGame(S01PacketJoinGame p_147282_1_) { this.gameController.playerController = new PlayerControllerMP(this.gameController, this); this.clientWorldController = new WorldClient(this, new WorldSettings(0L, p_147282_1_.func_149198_e(), false, p_147282_1_.func_149195_d(), p_147282_1_.func_149196_i()), p_147282_1_.func_149194_f(), p_147282_1_.func_149192_g(), this.gameController.mcProfiler); this.clientWorldController.isRemote = true; this.gameController.loadWorld(this.clientWorldController); this.gameController.thePlayer.dimension = p_147282_1_.func_149194_f(); this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); this.gameController.thePlayer.setEntityId(p_147282_1_.func_149197_c()); this.currentServerMaxPlayers = p_147282_1_.func_149193_h(); this.gameController.playerController.setGameType(p_147282_1_.func_149198_e()); this.gameController.gameSettings.sendSettingsToServer(); this.netManager.scheduleOutboundPacket(new C17PacketCustomPayload("MC|Brand", ClientBrandRetriever.getClientModName().getBytes(Charsets.UTF_8)), new GenericFutureListener[0]); }
private void func_147090_g() { String s = this.field_147091_w.getText(); Slot slot = this.field_147092_v.getSlot(0); if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName())) { s = ""; } this.field_147092_v.updateItemName(s); this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8))); }
protected void actionPerformed(GuiButton p_146284_1_) { boolean flag = false; if (p_146284_1_ == this.field_147043_x) { ++this.field_147041_z; flag = true; } else if (p_146284_1_ == this.field_147042_y) { --this.field_147041_z; flag = true; } if (flag) { ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.field_147041_z); ByteBuf bytebuf = Unpooled.buffer(); try { bytebuf.writeInt(this.field_147041_z); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", bytebuf)); } catch (Exception exception) { logger.error("Couldn\'t send trade info", exception); } finally { bytebuf.release(); } } }
protected void actionPerformed(GuiButton p_146284_1_) { if (p_146284_1_.enabled) { if (p_146284_1_.id == 1) { this.mc.displayGuiScreen((GuiScreen)null); } else if (p_146284_1_.id == 0) { PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); try { packetbuffer.writeByte(this.localCommandBlock.func_145751_f()); this.localCommandBlock.func_145757_a(packetbuffer); packetbuffer.writeStringToBuffer(this.commandTextField.getText()); this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", packetbuffer)); } catch (Exception exception) { field_146488_a.error("Couldn\'t send command block info", exception); } finally { packetbuffer.release(); } this.mc.displayGuiScreen((GuiScreen)null); } } }
private static void sendPacket(int keyInt){ PacketBuffer pb = new PacketBuffer(Unpooled.buffer()); try { pb.writeInt(keyInt); pb.writeBoolean(true); pb.writeInt(Minecraft.getMinecraft().thePlayer.getDisplayName().getBytes().length); pb.writeBytes(Minecraft.getMinecraft().thePlayer.getDisplayName().getBytes()); } catch (Exception ex) { ex.printStackTrace(); } C17PacketCustomPayload packet = new C17PacketCustomPayload("AvatarKey", pb); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(packet); }