Résolu Clés Flansmod
-
Salut j’aimerais rajouté un système de clés au mod Flansmod,
Voici le code intéréssant de la classe EntityDriveable :
@Override public void writeSpawnData(ByteBuf data) { ByteBufUtils.writeUTF8String(data, driveableType); NBTTagCompound tag = new NBTTagCompound(); driveableData.writeToNBT(tag); ByteBufUtils.writeTag(data, tag); data.writeFloat(axes.getYaw()); data.writeFloat(axes.getPitch()); data.writeFloat(axes.getRoll()); // Write damage for(EnumDriveablePart ep : EnumDriveablePart.values()) { DriveablePart part = getDriveableData().parts.get(ep); data.writeShort((short)part.health); data.writeBoolean(part.onFire); } } public String nom = ""; @Override public void readSpawnData(ByteBuf data) { try { // TODO: Lecture spawn driveableType = ByteBufUtils.readUTF8String(data); driveableData = new DriveableData(ByteBufUtils.readTag(data)); initType(getDriveableType(), true); axes.setAngles(data.readFloat(), data.readFloat(), data.readFloat()); prevRotationYaw = axes.getYaw(); prevRotationPitch = axes.getPitch(); prevRotationRoll = axes.getRoll(); // Read damage for(EnumDriveablePart ep : EnumDriveablePart.values()) { DriveablePart part = getDriveableData().parts.get(ep); part.health = data.readShort(); part.onFire = data.readBoolean(); } } catch(Exception e) { FlansMod.log("Failed to retreive plane type from server."); super.setDead(); e.printStackTrace(); } camera = new EntityCamera(worldObj, this); worldObj.spawnEntityInWorld(camera); }
Seulement j’aimerais rajouter donc le paramètre joueur sauf que je ne sais pas trop comment marche ByteBuf et de plus il n’y a pas de ByteBufUtils.“writeString” donc bon en espérant un peu d’aide
-
writeUTF8String = writeString …
Pour le joueur le mieux c’est de mettre l’uuid -
Je pensais que je parlais du data excuses-moi, sinon je ne peux pas faire du copier coller et adapter ceci :
driveableType = ByteBufUtils.readUTF8String(data);
qui me plairait, du stylenom = ByteBufUtils.readUTF8String(data);
Seulement on peut pas ajouter un paramètre aureadUTF8String(data)
… comment faire ? -
Pourquoi tu veux ajouter un paramètre ?
-
Bas par exemple dans ce code :
@Override protected void writeEntityToNBT(NBTTagCompound tag) { driveableData.writeToNBT(tag); tag.setString("Type", driveableType); tag.setFloat("RotationYaw", axes.getYaw()); tag.setFloat("RotationPitch", axes.getPitch()); tag.setFloat("RotationRoll", axes.getRoll()); }
On peut définir “Type”, “RotationYaw” etc et appliquer à chacun son contenu seulement pour ByteBuf, il n’y a pas cette possibilité donc on ne peut qu’avoir un contenu indistingable d’un autre par fonction.
-
Dans ByteBuf tout est une question d’ordre.
-
Ce code est très difficile à manier, je travaulle dessus depuis plusieurs jours, je n’en peux plus, soit tu veux bien qu’on se voit sur TeamSpeak et TeamViewer pour que tu m’aides un peu soit j’abandonne et c’est pas grave. Merci quand même.
-
Je ne vois pas où est le problème x) ?
Il y a quoi de si compliqué ? -
C’est que le code est éxécuté pour chaque véhicule le Write et le Spawn alors que le véhicule est déjà spawn quand je déco reco et des problèmes pour faire spawn le véhicule enfin bon un bordel, si tu pourrais venir sur le TS MFF, ce serai cool je suis connecté
-
Du coup je passe pour un packet pour faire spawn un véhicule déjà,
package fr.altiscraft.benjaminloison.packets; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import com.flansmod.common.FlansMod; import com.flansmod.common.driveables.DriveableData; import com.flansmod.common.driveables.EntityVehicle; import com.flansmod.common.driveables.EnumDriveablePart; import com.flansmod.common.driveables.VehicleType; import com.flansmod.common.parts.PartType; import com.flansmod.common.types.EnumType; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.registry.GameRegistry; import io.netty.buffer.ByteBuf; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class PacketVehicule implements IMessage { static EntityClientPlayerMP player; static WorldClient monde; public PacketVehicule(EntityClientPlayerMP thePlayer, WorldClient world) { player = thePlayer; monde = world; } @Override public void fromBytes(ByteBuf buf) {} @Override public void toBytes(ByteBuf buf) {} private static NBTTagCompound getTagCompound(ItemStack stack, World world) { if(stack.stackTagCompound == null) { if(!world.isRemote) stack.stackTagCompound = getOldTagCompound(stack, world); if(stack.stackTagCompound == null) { stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("Type", VehicleType.getVehicle("QuadBC").shortName); stack.stackTagCompound.setString("Engine", PartType.defaultEngines.get(EnumType.vehicle).shortName); } } return stack.stackTagCompound; } private static NBTTagCompound getOldTagCompound(ItemStack stack, World world) { try { File file1 = world.getSaveHandler().getMapFileFromName("vehicle_" + stack.getItemDamage()); FileInputStream fileinputstream = new FileInputStream(file1); NBTTagCompound tags = CompressedStreamTools.readCompressed(fileinputstream).getCompoundTag("data"); for(EnumDriveablePart part : EnumDriveablePart.values()) { tags.setInteger(part.getShortName() + "_Health", VehicleType.getVehicle("QuadBC").health.get(part) == null ? 0 : VehicleType.getVehicle("QuadBC").health.get(part).health); tags.setBoolean(part.getShortName() + "_Fire", false); } fileinputstream.close(); return tags; } catch(IOException e) { FlansMod.log("Failed to read old vehicle file"); e.printStackTrace(); return null; } } public static DriveableData getData(ItemStack itemstack, World world) { return new DriveableData(getTagCompound(itemstack, world)); } public static class Handler implements IMessageHandler <packetvehicule, imessage=""> { @Override public IMessage onMessage(PacketVehicule message, MessageContext ctx) { int PosX = 0; int PosY = 0; int PosZ = 0; int DirectionVeh = 0; monde.spawnEntityInWorld(new EntityVehicle(monde, (double) PosX + 0.5F, (double) PosY + 2.5F, (double) PosZ + 0.5F, player, VehicleType.getVehicle("QuadBC"), getData(GameRegistry.findItemStack("flansmod", "QuadBC", 1), monde))); return null; } } }
Ligne dans le Gui pour le spawn,
ModAltisCraft.network.sendToServer(new PacketVehicule(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().theWorld));
Le log (qui fait planter le solo) :
[21:19:51] [Server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more [21:19:51] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more [21:19:51] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more [21:19:51] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more [21:19:51] [Server thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more [21:19:51] [Server thread/ERROR] [FML]: There was a critical exception handling a packet on channel altiscraft io.netty.handler.codec.DecoderException: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule 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.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.InstantiationException: fr.altiscraft.benjaminloison.packets.PacketVehicule at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_60] 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:?] … 13 more Caused by: java.lang.NoSuchMethodException: fr.altiscraft.benjaminloison.packets.PacketVehicule.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_60] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_60] 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:?] … 13 more
Voilà je comprends pas trop d’où vient le problème dans le Packet…
-
Sérieusement u_U ?
static EntityClientPlayerMP player;
static WorldClient monde;public PacketVehicule(EntityClientPlayerMP thePlayer, WorldClient world) {
player = thePlayer;
monde = world;
}
-> poubelle.et ici :
monde.spawnEntityInWorld(new EntityVehicle(monde, (double) PosX + 0.5F, (double) PosY + 2.5F, (double) PosZ + 0.5F, player, VehicleType.getVehicle(“QuadBC”), getData(GameRegistry.findItemStack(“flansmod”, “QuadBC”, 1), monde)));
monde -> ctx.getServerHandler().playerEntity.worldObj -
Nice merci beaucoup excuses je commence dans les packets et juste maintantn j’ai ça :
package fr.altiscraft.benjaminloison.packets; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import com.flansmod.common.FlansMod; import com.flansmod.common.driveables.DriveableData; import com.flansmod.common.driveables.EntityVehicle; import com.flansmod.common.driveables.EnumDriveablePart; import com.flansmod.common.driveables.VehicleType; import com.flansmod.common.parts.PartType; import com.flansmod.common.types.EnumType; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.common.registry.GameRegistry; import io.netty.buffer.ByteBuf; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class PacketVehicule implements IMessage { @Override public void fromBytes(ByteBuf buf) {} @Override public void toBytes(ByteBuf buf) {} private static NBTTagCompound getTagCompound(ItemStack stack, World world) { if(stack.stackTagCompound == null) { if(!world.isRemote) stack.stackTagCompound = getOldTagCompound(stack, world); if(stack.stackTagCompound == null) { stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("Type", VehicleType.getVehicle("QuadBC").shortName); stack.stackTagCompound.setString("Engine", PartType.defaultEngines.get(EnumType.vehicle).shortName); } } return stack.stackTagCompound; } private static NBTTagCompound getOldTagCompound(ItemStack stack, World world) { try { File file1 = world.getSaveHandler().getMapFileFromName("vehicle_" + stack.getItemDamage()); FileInputStream fileinputstream = new FileInputStream(file1); NBTTagCompound tags = CompressedStreamTools.readCompressed(fileinputstream).getCompoundTag("data"); for(EnumDriveablePart part : EnumDriveablePart.values()) { tags.setInteger(part.getShortName() + "_Health", VehicleType.getVehicle("QuadBC").health.get(part) == null ? 0 : VehicleType.getVehicle("QuadBC").health.get(part).health); tags.setBoolean(part.getShortName() + "_Fire", false); } fileinputstream.close(); return tags; } catch(IOException e) { FlansMod.log("Failed to read old vehicle file"); e.printStackTrace(); return null; } } public static DriveableData getData(ItemStack itemstack, World world) { return new DriveableData(getTagCompound(itemstack, world)); } public static class Handler implements IMessageHandler <packetvehicule, imessage=""> { @Override public IMessage onMessage(PacketVehicule message, MessageContext ctx) { World monde; EntityPlayer player; monde = ctx.getServerHandler().playerEntity.worldObj; player = ctx.getServerHandler().playerEntity; int PosX = 0; int PosY = 0; int PosZ = 0; int DirectionVeh = 0; monde.spawnEntityInWorld(new EntityVehicle(monde, (double) PosX + 0.5F, (double) PosY + 2.5F, (double) PosZ + 0.5F, player, VehicleType.getVehicle("QuadBC"), getData(GameRegistry.findItemStack("flansmod", "QuadBC", 1), monde))); return null; } } }
Mais j’ai ça dans les logs et aucun quad :
[17:20:15] [Server thread/INFO] [STDOUT]: [com.flansmod.common.FlansMod:log:546]: [AltisCraft.fr] Failed to read old vehicle file [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: java.io.FileNotFoundException: .\saves\Nouveau monde–\data\vehicle_0.dat (Le fichier spécifié est introuvable) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at java.io.FileInputStream.open0(Native Method) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at java.io.FileInputStream.open(FileInputStream.java:195) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at java.io.FileInputStream.<init>(FileInputStream.java:138) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at fr.altiscraft.benjaminloison.packets.PacketVehicule.getOldTagCompound(PacketVehicule.java:54) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at fr.altiscraft.benjaminloison.packets.PacketVehicule.getTagCompound(PacketVehicule.java:41) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at fr.altiscraft.benjaminloison.packets.PacketVehicule.getData(PacketVehicule.java:72) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at fr.altiscraft.benjaminloison.packets.PacketVehicule$Handler.onMessage(PacketVehicule.java:87) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at fr.altiscraft.benjaminloison.packets.PacketVehicule$Handler.onMessage(PacketVehicule.java:1) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:37) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:17) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)</init></packetvehicule,>
-
[17:20:15] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStreamTirer la languerintln:748]: java.io.FileNotFoundException: .\saves\Nouveau monde–\data\vehicle_0.dat (Le fichier spécifié est introuvable)
Visiblement il ne trouve pas ce fichier. C’est la fonction pour avoir les données du véhicule qui cause problème. -
C’est cette méthode qui déconne :
private static NBTTagCompound getOldTagCompound(ItemStack stack, World world) { try { File file1 = world.getSaveHandler().getMapFileFromName("vehicle_" + stack.getItemDamage()); FileInputStream fileinputstream = new FileInputStream(file1); NBTTagCompound tags = CompressedStreamTools.readCompressed(fileinputstream).getCompoundTag("data"); for(EnumDriveablePart part : EnumDriveablePart.values()) { tags.setInteger(part.getShortName() + "_Health", VehicleType.getVehicle("QuadBC").health.get(part) == null ? 0 : VehicleType.getVehicle("QuadBC").health.get(part).health); tags.setBoolean(part.getShortName() + "_Fire", false); } fileinputstream.close(); return tags; } catch(IOException e) { FlansMod.log("Failed to read old vehicle file"); e.printStackTrace(); return null; } }
Seulement j’ai souvent cette erreur dans les logs de mon serveur habituellement et ça ne change rien donc bon ça me parait étrange que rien ne spawn…
Je suis comme d’habitude sur TeamSpeak prêt à lancer mon Chrome Desktop ^^ si tu es dispo
-
Vire complètement la fonction sinon. Vu qu’il y a Old dans le nom c’est surement pour avoir une rétro-compatibilité avec les vieilles maps.
-
J’ai résolu ça, du coup j’arrive par le Gui à faire spawn les véhicules, maintenant il faut faire le système de clés, String[] sur chaque EntityVehicle mais j’ai fais un code de base mais bon ça marche pas très bien :S, si tu pourrais venir sur TS, pour ce truc complexe
-
Bizarre, j’arrive à faire un code pour que ça définisse bien le propriétaire et permettre alors à ce joueur de monter mais le code s’applique à tout les véhicules pour une raison inconnue…
-
Je ne sais pas plus que toi. Peut-être que flan’s mod a plusieurs types de véhicule (dans plusieurs classes).
-
Projet fini.