public IPacket getIPacket() { if (packet instanceof CPacketPlayer) { return new ICPacketPlayer(packet); } else if (packet instanceof CPacketPlayer.PositionRotation) { return new ICPacketPositionRotation(packet); } else if (packet instanceof CPacketPlayer.Rotation) { return new ICPacketRotation(packet); } else if (packet instanceof CPacketPlayer.Position) { return new ICPacketPosition(packet); } else if (packet instanceof CPacketCloseWindow) { return new ICPacketCloseWindow(packet); } return new IPacket(packet); }
/** * Processes the client closing windows (container) */ public void processCloseWindow(CPacketCloseWindow packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld()); this.playerEntity.closeContainer(); }
/** * set current crafting inventory back to the 2x2 square */ public void closeScreen() { this.connection.sendPacket(new CPacketCloseWindow(this.openContainer.windowId)); this.closeScreenAndDropStack(); }
@DelayedRegistration(RegistrationPhase.PRE_INIT) @Override public void registerDefaults() { // Handshake register("handshake", "Handshake", PacketSide.SERVERBOUND, PacketPhase.HANDSHAKE, C00Handshake.class); // Entity clientbound("destroy_entities", "Destroy Entities", SPacketDestroyEntities.class, PacketControlFactory::createDestroyEntities); clientbound("entity_metadata", "Entity Metadata", SPacketEntityMetadata.class, PacketControlFactory::createEntityMetadata); clientbound("entity_velocity", "Entity Velocity", SPacketEntityVelocity.class); clientbound("spawn_experience_orb", "Spawn Experience Orb", SPacketSpawnExperienceOrb.class); clientbound("spawn_global_entity", "Spawn Global Entity", SPacketSpawnGlobalEntity.class); clientbound("spawn_mob", "Spawn Mob", SPacketSpawnMob.class); clientbound("spawn_object", "Spawn Object", SPacketSpawnObject.class, PacketControlFactory::createSpawnObject); clientbound("spawn_painting", "Spawn Painting", SPacketSpawnPainting.class); // Inventory clientbound("close_window", "Close Window", SPacketCloseWindow.class, PacketControlFactory::createCloseWindow); clientbound("confirm_transaction", "Confirm Transaction", SPacketConfirmTransaction.class, PacketControlFactory::createConfirmTransaction); clientbound("open_window", "Open Window", SPacketOpenWindow.class, PacketControlFactory::createOpenWindow); clientbound("set_slot", "Set Slot", SPacketSetSlot.class, PacketControlFactory::createSetSlot); clientbound("window_items", "Window Items", SPacketWindowItems.class, PacketControlFactory::createWindowItems); // Player clientbound("player_abilities", "Player Abilities", SPacketPlayerAbilities.class, PacketControlFactory::createPlayerAbilities); clientbound("spawn_player", "Spawn Player", SPacketSpawnPlayer.class); clientbound("use_bed", "Use Bed", SPacketUseBed.class, PacketControlFactory::createUseBed); clientbound("vehicle_position", "Vehicle Position", SPacketMoveVehicle.class); // World clientbound("custom_sound", "Custom Sound", SPacketCustomSound.class, PacketControlFactory::createCustomSound); clientbound("game_sound", "Game Sound", SPacketSoundEffect.class, PacketControlFactory::createGameSound); clientbound("open_sign_editor", "Open Sign Editor", SPacketSignEditorOpen.class, PacketControlFactory::createOpenSignEditor); clientbound("world_time", "World Time", SPacketTimeUpdate.class, PacketControlFactory::createWorldTime); // Client serverbound("click_window", "Click Window", CPacketClickWindow.class); serverbound("move_vehicle", "Move Vehicle", CPacketVehicleMove.class); serverbound("update_sign", "Update Sign", CPacketUpdateSign.class); serverbound("window_close", "Window Close", CPacketCloseWindow.class); }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == -2) { this.mc.player.connection.sendPacket(new CPacketCloseWindow(this.mc.player.openContainer.windowId)); this.mc.displayGuiScreen((GuiScreen)null); } else if (button.id == -1) { String s = "MC|Beacon"; PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.tileBeacon.getField(1)); packetbuffer.writeInt(this.tileBeacon.getField(2)); this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|Beacon", packetbuffer)); this.mc.player.connection.sendPacket(new CPacketCloseWindow(this.mc.player.openContainer.windowId)); this.mc.displayGuiScreen((GuiScreen)null); } else if (button instanceof GuiBeacon.PowerButton) { GuiBeacon.PowerButton guibeacon$powerbutton = (GuiBeacon.PowerButton)button; if (guibeacon$powerbutton.isSelected()) { return; } int i = Potion.getIdFromPotion(guibeacon$powerbutton.effect); if (guibeacon$powerbutton.tier < 3) { this.tileBeacon.setField(1, i); } else { this.tileBeacon.setField(2, i); } this.buttonList.clear(); this.initGui(); this.updateScreen(); } }
/** * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) */ protected void actionPerformed(GuiButton button) throws IOException { if (button.id == -2) { this.mc.thePlayer.connection.sendPacket(new CPacketCloseWindow(this.mc.thePlayer.openContainer.windowId)); this.mc.displayGuiScreen((GuiScreen)null); } else if (button.id == -1) { String s = "MC|Beacon"; PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeInt(this.tileBeacon.getField(1)); packetbuffer.writeInt(this.tileBeacon.getField(2)); this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|Beacon", packetbuffer)); this.mc.thePlayer.connection.sendPacket(new CPacketCloseWindow(this.mc.thePlayer.openContainer.windowId)); this.mc.displayGuiScreen((GuiScreen)null); } else if (button instanceof GuiBeacon.PowerButton) { GuiBeacon.PowerButton guibeacon$powerbutton = (GuiBeacon.PowerButton)button; if (guibeacon$powerbutton.isSelected()) { return; } int i = Potion.getIdFromPotion(guibeacon$powerbutton.effect); if (guibeacon$powerbutton.tier < 3) { this.tileBeacon.setField(1, i); } else { this.tileBeacon.setField(2, i); } this.buttonList.clear(); this.initGui(); this.updateScreen(); } }
@Override public void processCloseWindow(CPacketCloseWindow p_147356_1_) { }
@Override public void processCloseWindow(@Nonnull CPacketCloseWindow p_147356_1_) { }
@Override public void processCloseWindow(CPacketCloseWindow packetIn) { }
/** * Processes the client closing windows (container) */ void processCloseWindow(CPacketCloseWindow packetIn);