Résolu Envoyez un text en action bar
-
Bonjour à tous
Depuis quelques jours, je regarde pour ajouter la possibilité d’envoyer des texts dans l’action bar
Bien sur, cette possibilité a été ajouté en 1.8.
J’aimerai savoir par quel moyen on pourrait le rendre fonctionnel en 1.7.10J’ai commencé à faire une commande en partant du système dans ItemStack.class
@Override public void processCommand(ICommandSender sender, String[] args) { if(args.length < 2){ throw new WrongUsageException(this.getCommandUsage(sender)); } else { World world = MinecraftServer.getServer().worldServers[0]; EntityPlayer player = world.getPlayerEntityByName(args[0]); if(player == null){ throw new WrongUsageException(this.getCommandUsage(sender)); } else { StringBuilder sb = new StringBuilder(); for(int i=1; i <args.length; i++){<br="">sb.append(args*); sb.append(" "); } String msg = sb.toString(); ChatComponentText chatcomponenttext = new ChatComponentText(msg); IChatComponent ichatcomponent = (new ChatComponentText("[")).appendSibling(chatcomponenttext).appendText("]"); ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, chatcomponenttext)); player.addChatComponentMessage(ichatcomponent); } } }
Et ça envoie juste un message dans le tchat
Merci à tous pour votre potentielle aide, et bonne journée
Rremis</args.length;> -
Comment ça mettre un texte dans l’action bar ? Mettre un texte à l’endroit où le nom d’un disque qui se joue est marqué ? Si oui c’est simplement GuiIngame.setRecordPlayingMessage(texte) ou GuiIngame.func_110326_a(texte, couleuraleatoire).
-
@‘AymericRed’:
Comment ça mettre un texte dans l’action bar ? Mettre un texte à l’endroit où le nom d’un disque qui se joue est marqué ? Si oui c’est simplement GuiIngame.setRecordPlayingMessage(texte) ou GuiIngame.func_110326_a(texte, couleuraleatoire).
Merci de ton aide, mais j’aimerais savoir, c’est possible de get le minecraft du joueur ?
Car avec ceci, c’est la personne qui exécute la commande qui voit ça tandis que j’aimerais envoyer le message à un joueur précis.
-
Salut,
Il suffit de créer une variable EntityPlayerMP à partir du username renseigné dans la commande.
Dans le packet qui ira du serveur->client spécifié, tu peux dans la fonction onMessage du handler, faire un Minecraft.getMinecraft().ingameGUI.setRecordPlayingMessage. -
@‘Plaigon’:
Salut,
Il suffit de créer une variable EntityPlayerMP à partir du username renseigné dans la commande.
Dans le packet qui ira du serveur->client spécifié, tu peux dans la fonction onMessage du handler, faire un Minecraft.getMinecraft().ingameGUI.setRecordPlayingMessage.Bonjour, et merci de ton aide, j’ai fais ceci :
:::@Override public void processCommand(ICommandSender sender, String[] args) { if(args.length < 2){ throw new WrongUsageException(this.getCommandUsage(sender)); } else { World world = MinecraftServer.getServer().worldServers[0]; EntityPlayer player = world.getPlayerEntityByName(args[0]); if(player == null){ throw new WrongUsageException(this.getCommandUsage(sender)); } else { StringBuilder sb = new StringBuilder(); for(int i=1; i <args.length; i++){<br="">sb.append(args*); sb.append(" "); } String msg = sb.toString(); InstantRP.network.sendTo(new PacketActionBarMessage(msg), (EntityPlayerMP) player); } } }
:::
:::
@EventHandler public void PreLoad(FMLPreInitializationEvent event){ proxy.registerRenderInfo(); network = NetworkRegistry.INSTANCE.newSimpleChannel(References.MOD_ID); network.registerMessage(PacketGuiLois.Handler.class, PacketGuiLois.class, 0, Side.CLIENT); network.registerMessage(PacketGuiEditLois.Handler.class, PacketGuiEditLois.class, 1, Side.CLIENT); network.registerMessage(PacketActionBarMessage.Handler.class, PacketActionBarMessage.class, 2, Side.CLIENT); MCreativeTab.initializeTabs(); BlockList.mainRegistry(); ItemsList.mainRegistry(); }
:::
:::
public class PacketActionBarMessage implements IMessage { static String msg; public PacketActionBarMessage(String message){ this.msg = message; } @Override public void fromBytes(ByteBuf buf) { } @Override public void toBytes(ByteBuf buf) { } public static class Handler implements IMessageHandler<packetactionbarmessage, imessage="">{ @SideOnly(Side.CLIENT) public IMessage onMessage(PacketActionBarMessage message, MessageContext ctx) { Minecraft.getMinecraft().ingameGUI.func_110326_a(msg, false); return null; } } }
:::
Et quand je fais la commande, j’ai un gros crash du jeu :::
[12:37:33] [Client thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more Caused by: java.lang.NoSuchMethodException: fr.rremis.instantrp.packets.PacketActionBarMessage.<init>() at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_65] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more [12:37:33] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more Caused by: java.lang.NoSuchMethodException: fr.rremis.instantrp.packets.PacketActionBarMessage.<init>() at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_65] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more [12:37:33] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more Caused by: java.lang.NoSuchMethodException: fr.rremis.instantrp.packets.PacketActionBarMessage.<init>() at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_65] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more [12:37:33] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more Caused by: java.lang.NoSuchMethodException: fr.rremis.instantrp.packets.PacketActionBarMessage.<init>() at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_65] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more [12:37:33] [Client thread/ERROR] [FML]: There was a critical exception handling a packet on channel instantrp io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:99) ~[MessageToMessageDecoder.class:?] at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?] at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?] at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.InstantiationException: fr.rremis.instantrp.packets.PacketActionBarMessage at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more Caused by: java.lang.NoSuchMethodException: fr.rremis.instantrp.packets.PacketActionBarMessage.<init>() at java.lang.Class.getConstructor0(Unknown Source) ~[?:1.8.0_65] at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_65] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:75) ~[FMLIndexedMessageToMessageCodec.class:?] at cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec.decode(FMLIndexedMessageToMessageCodec.java:17) ~[FMLIndexedMessageToMessageCodec.class:?] at io.netty.handler.codec.MessageToMessageCodec$2.decode(MessageToMessageCodec.java:81) ~[MessageToMessageCodec$2.class:?] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) ~[MessageToMessageDecoder.class:?] … 20 more
:::
J’ai clairement fais une bêtise me connaissant en voulant ajouter le string du message.</init></init></init></init></init></packetactionbarmessage,></args.length;>
-
Ton packet doit obligatoirement avoir un constructeur vide, sans paramètre.
-
@‘Plaigon’:
Ton packet doit obligatoirement avoir un constructeur vide, sans paramètre.
Ok, et je peux faire comment pour récupérer le string msg ?
-
Eh bien tu laisses ton constructeur avec le String, mais à côté d’un sans paramètre.
En gros ta classe packet peut avoir plusieurs constructeurs (mais obligatoirement un vide, sans paramètres). -
@‘Plaigon’:
Eh bien tu laisses ton constructeur avec le String, mais à côté d’un sans paramètre.
En gros ta classe packet peut avoir plusieurs constructeurs (mais obligatoirement un vide, sans paramètres).Ok, j’ai essayé, et ça marche.
Mais en serveur, quand j’execute la commande, rien ne se passe
Vous auriez une solution ? -
Il faut debug ton code.
-
Pas besoin de debug là, le problème est simple : tes fonctions from et toBytes sont vides.
-
@‘Plaigon’:
Il faut debug ton code.
Apres avoir rajouter quelques messages de debug, cela vient clairement du packet.
En effet, il ne s’exécute pas ici : (car le print ne s’affiche pas).
C’est à cause du side, non ? J’ai essayé en remplacant le side server (ici et dans la classe principale) et ça ne marche pas non plus.public static class Handler implements IMessageHandler<packetactionbarmessage, imessage="">{ @SideOnly(Side.CLIENT) public IMessage onMessage(PacketActionBarMessage message, MessageContext ctx) { System.out.println("Packet reçu"); Minecraft.getMinecraft().ingameGUI.func_110326_a(msg, false); return null; } }
J’avais pas vu ton message, AymericRed, c’est à dire ? Je devrais mettre quoi dedans</packetactionbarmessage,>
-
@Override public void fromBytes(ByteBuf buf) { this.msg = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, msg); }
-
@‘Plaigon’:
@Override public void fromBytes(ByteBuf buf) { this.msg = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, msg); }
Ah, merci, tout marche bien