Résolu Recuper la variable lorsque le joueur spawn pour la tout première fois.
-
at portuar.otherWorld.client.MainClass.preInit(MainClass.java:45)
Tu as quoi dans cette classe à la ligne 45 ? -
je l’ai écris relit mon post
-
Ah oui, j’avais pas vu. Et comme ça :
network.registerMessage(PacketAlteration.Handler.class, PacketAlteration.class, 0, Side.CLIENT);
package portuar.otherWorld.client.alteration; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class PacketAlteration implements IMessage { long maxMoney; long Money; public PacketAlteration(long maxMoney, long money) { this.maxMoney = maxMoney; this.Money = money; } @Override public void fromBytes(ByteBuf buf) { this.maxMoney = buf.readLong(); this.Money = buf.readLong(); } @Override public void toBytes(ByteBuf buf) { buf.writeLong(maxMoney); buf.writeLong(Money); } public static class Handler implements IMessageHandler <packetalteration, imessage="">{ @Override public IMessage onMessage(PacketAlteration message, MessageContext ctx) { ExtendedEntityPropAlteration props = ExtendedEntityPropAlteration.get(FMLClientHandler.instance().getClientPlayerEntity()); props.maxMoney = message.maxMoney; props.money = message.Money; return null; } } } ```</packetalteration,>
-
Ca crash encore
[12:56:00] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [12:56:00] [main/INFO] [FML]: Forge Mod Loader version 7.2.129.1047 for Minecraft 1.7.2 loading [12:56:00] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_51, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7 [12:56:00] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [12:56:00] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [12:56:00] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [12:56:00] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [12:56:01] [main/ERROR] [FML]: The minecraft jar file:/D:/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1047/forgeSrc-1.7.2-10.12.0.1047.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again! [12:56:01] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem! [12:56:01] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/D:/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1047/forgeSrc-1.7.2-10.12.0.1047.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it [12:56:01] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [12:56:01] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [12:56:01] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [12:56:01] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [12:56:02] [main/INFO]: Setting user: Player671 [12:56:02] [Client thread/INFO]: LWJGL Version: 2.9.0 [12:56:03] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [12:56:03] [Client thread/INFO] [FML]: MinecraftForge v10.12.0.1047 Initialized [12:56:03] [Client thread/INFO] [FML]: Replaced 141 ore recipies [12:56:03] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [12:56:03] [Client thread/INFO] [FML]: Searching D:\ModMinecraft\Cubic beyond\eclipse\mods for mods [12:56:04] [Client thread/ERROR] [FML]: FML has detected a mod that is using a package name based on 'net.minecraft.src' : net.minecraft.src.FMLRenderAccessLibrary. This is generally a severe programming error. There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into a new package. Go on. DO IT NOW! [12:56:05] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [12:56:05] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:OtherWorld [12:56:05] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [12:56:05] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [12:56:05] [Client thread/ERROR] [FML]: mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{7.2.129.1047} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized Forge{10.12.0.1047} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized otherworld{0.0.1} [OtherWorld] (bin) Unloaded->Constructed->Errored [12:56:05] [Client thread/ERROR] [FML]: The following problems were captured during this phase [12:56:05] [Client thread/ERROR] [FML]: Caught exception from otherworld java.lang.IllegalStateException: cannot determine the type of the type parameter 'REQ': class cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper at io.netty.util.internal.TypeParameterMatcher.fail(TypeParameterMatcher.java:171) ~[TypeParameterMatcher.class:?] at io.netty.util.internal.TypeParameterMatcher.find0(TypeParameterMatcher.java:165) ~[TypeParameterMatcher.class:?] at io.netty.util.internal.TypeParameterMatcher.find(TypeParameterMatcher.java:93) ~[TypeParameterMatcher.class:?] at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:60) ~[SimpleChannelInboundHandler.class:?] at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:50) ~[SimpleChannelInboundHandler.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.<init>(SimpleChannelHandlerWrapper.java:17) ~[SimpleChannelHandlerWrapper.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.getHandlerWrapper(SimpleNetworkWrapper.java:85) ~[SimpleNetworkWrapper.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.addClientHandlerAfter(SimpleNetworkWrapper.java:79) ~[SimpleNetworkWrapper.class:?] at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:67) ~[SimpleNetworkWrapper.class:?] at portuar.otherWorld.client.MainClass.preInit(MainClass.java:45) ~[MainClass.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at cpw.mods.fml.common.Loader.loadMods(Loader.java:495) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:564) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:934) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_51] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_51] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] –-- Minecraft Crash Report ---- // I'm sorry, Dave. Time: 17/06/14 12:56 Description: Initializing game java.lang.IllegalStateException: cannot determine the type of the type parameter 'REQ': class cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper at io.netty.util.internal.TypeParameterMatcher.fail(TypeParameterMatcher.java:171) at io.netty.util.internal.TypeParameterMatcher.find0(TypeParameterMatcher.java:165) at io.netty.util.internal.TypeParameterMatcher.find(TypeParameterMatcher.java:93) at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:60) at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:50) at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.<init>(SimpleChannelHandlerWrapper.java:17) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.getHandlerWrapper(SimpleNetworkWrapper.java:85) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.addClientHandlerAfter(SimpleNetworkWrapper.java:79) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:67) at portuar.otherWorld.client.MainClass.preInit(MainClass.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:495) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201) at net.minecraft.client.Minecraft.startGame(Minecraft.java:564) at net.minecraft.client.Minecraft.run(Minecraft.java:934) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at io.netty.util.internal.TypeParameterMatcher.fail(TypeParameterMatcher.java:171) at io.netty.util.internal.TypeParameterMatcher.find0(TypeParameterMatcher.java:165) at io.netty.util.internal.TypeParameterMatcher.find(TypeParameterMatcher.java:93) at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:60) at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:50) at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.<init>(SimpleChannelHandlerWrapper.java:17) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.getHandlerWrapper(SimpleNetworkWrapper.java:85) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.addClientHandlerAfter(SimpleNetworkWrapper.java:79) at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:67) at portuar.otherWorld.client.MainClass.preInit(MainClass.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) at com.google.common.eventbus.EventBus.post(EventBus.java:267) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:495) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201) at net.minecraft.client.Minecraft.startGame(Minecraft.java:564) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:934) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 867230656 bytes (827 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.01-pre FML v7.2.129.1047 Minecraft Forge 10.12.0.1047 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{7.2.129.1047} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized Forge{10.12.0.1047} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1047.jar) Unloaded->Constructed->Pre-initialized otherworld{0.0.1} [OtherWorld] (bin) Unloaded->Constructed->Errored Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: GeForce GTX 560 Ti/PCI/SSE2 GL version 4.1.0, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: null Anisotropic Filtering: Off (1) #@!@# Game crashed! Crash report saved to: #@!@# D:\ModMinecraft\Cubic beyond\eclipse\.\crash-reports\crash-2014-06-17_12.56.05-client.txt ```</init></init></init></init></init></init></init></init></init>
-
Je Up car je suis vraiment bloquer à cause de sa… je ne comprend vraiment pas pourquoi le jeu crash je pense que c’est au niveau de packet mais je n’arrive pas à réglé le problème
-
Je ne sais pas nom plus J’ai jamais vu ce type d’erreur, je ne vois pas d’où ça peut venir. Au pire as-tu vraiment besoin des paquets ?
Si tu fais juste l’action en serveur, le paquet ne sert à rien. Et sinon tu peux toujours passer par les DataWatcher -
Ouai j’en ai vraiment besoin c’est sa le problème.
-
Dans ce cas passe au DataWatcher.
-
et comment je connais pas non plus. Après j’ai trouvé ceci https://github.com/coolAlias/Forge_Tutorials/blob/master/IExtendedEntityPropertiesTutorial.java mais c’est en 1.6.4 et des choses sont inexistantes en 1.7
-
EntityPlayer.getDataWatcher() fonctionne très bien en 1.7, on l’utilise dans nanotech hunger game
-
Il y a un tutoriel ? et esque c’est assez simple, c’est à dire qu’on peut créer des fonction comme AddXp() etc?
-
Simple a utiliser, et non il n’y a pas de tuto. Tiens un exemple :
package fr.mcnanotech.nhg.common; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; public class CustomPlayerProperties implements IExtendedEntityProperties { private EntityPlayer player; private int kitId; public static final int KIT_WATCHER = 30; public static final String NAME = "ngh_prop"; public CustomPlayerProperties(EntityPlayer player) { this.player = player; this.player.getDataWatcher().addObject(KIT_WATCHER, this.kitId); } @Override public void saveNBTData(NBTTagCompound compound) { compound.setInteger("PlayerKit", this.player.getDataWatcher().getWatchableObjectInt(KIT_WATCHER)); } @Override public void loadNBTData(NBTTagCompound compound) { this.player.getDataWatcher().updateObject(KIT_WATCHER, compound.getInteger("PlayerKit")); } @Override public void init(Entity entity, World world) { } public static CustomPlayerProperties get(EntityPlayer player) { return (CustomPlayerProperties)player.getExtendedProperties(NAME); } public int getKitIndex() { return this.player.getDataWatcher().getWatchableObjectInt(KIT_WATCHER); } public void setKit(int kitId) { this.player.getDataWatcher().updateObject(KIT_WATCHER, kitId); } }
-
et quand le perso meurt il ne restart pas ?
Bon j’ai testé et donc j’ai voulut l’utilisé dans un item en faisant props.KIT_WATCHER++; juste pour teste mais il me dise d’enlever final dans : public static final int KIT_WATCHER = 30; mais si je le fait quand je me suicide le jeu crash
-
Pour monter de un, setMachin(getMachin + 1)
Les setter et getter son la pour ça.
KIT_WATCHER n’est pas à modifier, c’est l’id du WATCHER, il faut modifier la valeur du watcher. -
ok j’ai testé mais quand je meurt sa reset…
-
Alors la je ne sais pas
Faudrait demander sur le forum anglais de forge. -
JAI ENFIN REUSSI YESSSSSS !
-
Tu peux donner la solution pour les autres membres qui auraient le même problème?
-
ouai :
package portuar.otherWorld.client.alteration; import java.util.*; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageCodec; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.INetHandler; import net.minecraft.network.NetHandlerPlayServer; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.FMLEmbeddedChannel; import cpw.mods.fml.common.network.FMLOutboundHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** * Packet pipeline class. Directs all registered packet data to be handled by the packets themselves. * @author sirgingalot * some code from: cpw */ @ChannelHandler.Sharable public class PacketHandler extends MessageToMessageCodec <fmlproxypacket, abstractpacket="">{ private EnumMap <side, fmlembeddedchannel="">channels; private LinkedList<class<? extends="" abstractpacket="">> packets = new LinkedList<class<? extends="" abstractpacket="">>(); private boolean isPostInitialised = false; /** * Register your packet with the pipeline. Discriminators are automatically set. * * @param clazz the class to register * * @return whether registration was successful. Failure may occur if 256 packets have been registered or if the registry already contains this packet */ public boolean registerPacket(Class clazz) { if (this.packets.size() > 256) { return false; } if (this.packets.contains(clazz)) { return false; } if (this.isPostInitialised) { return false; } this.packets.add(clazz); return true; } @Override protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List <object>out) throws Exception { ByteBuf buffer = Unpooled.buffer(); Class clazz = msg.getClass(); if (!this.packets.contains(msg.getClass())) { throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName()); } byte discriminator = (byte) this.packets.indexOf(clazz); buffer.writeByte(discriminator); msg.encodeInto(ctx, buffer); FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get()); out.add(proxyPacket); } @Override protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List <object>out) throws Exception { ByteBuf payload = msg.payload(); byte discriminator = payload.readByte(); Class clazz = this.packets.get(discriminator); if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: " + discriminator); } AbstractPacket pkt = clazz.newInstance(); pkt.decodeInto(ctx, payload.slice()); EntityPlayer player; switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: player = this.getClientPlayer(); pkt.handleClientSide(player); break; case SERVER: INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); player = ((NetHandlerPlayServer) netHandler).playerEntity; pkt.handleServerSide(player); break; default: } out.add(pkt); } public void initialise() { this.channels = NetworkRegistry.INSTANCE.newChannel("TUT", this); } public void postInitialise() { if (this.isPostInitialised) { return; } this.isPostInitialised = true; Collections.sort(this.packets, new Comparator<class<? extends="" abstractpacket="">>() { @Override public int compare(Class clazz1, Class clazz2) { int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName()); if (com == 0) { com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName()); } return com; } }); } @SideOnly(Side.CLIENT) private EntityPlayer getClientPlayer() { return Minecraft.getMinecraft().thePlayer; } /** * Send this message to everyone. * * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send */ public void sendToAll(AbstractPacket message) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to the specified player. * * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param player The player to send it to */ public void sendTo(AbstractPacket message, EntityPlayerMP player) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to everyone within a certain range of a point. * * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param point The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send */ public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to everyone within the supplied dimension. * * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send * @param dimensionId The dimension id to target */ public void sendToDimension(AbstractPacket message, int dimensionId) { this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); this.channels.get(Side.SERVER).writeAndFlush(message); } /** * Send this message to the server. * * Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper * * @param message The message to send */ public void sendToServer(AbstractPacket message) { this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); this.channels.get(Side.CLIENT).writeAndFlush(message); } }
package portuar.otherWorld.client.alteration; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import cpw.mods.fml.common.network.ByteBufUtils; public class PacketAlteration extends AbstractPacket { private NBTTagCompound data; public PacketAlteration() {} public PacketAlteration(EntityPlayer player) { data = new NBTTagCompound(); ExtendedEntityPropAlteration.get(player).saveNBTData(data); } @Override public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { ByteBufUtils.writeTag(buffer, data); } @Override public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { data = ByteBufUtils.readTag(buffer); } @Override public void handleClientSide(EntityPlayer player) { ExtendedEntityPropAlteration.get(player).loadNBTData(data); } @Override public void handleServerSide(EntityPlayer player) { } }
Dans la MainClass :
@EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new EventAlteration()); packetHandler.initialise(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { packetHandler.postInitialise(); }
package portuar.otherWorld.client.alteration; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import portuar.otherWorld.proxy.CommonProxy; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventAlteration { @SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer && ExtendedEntityPropAlteration.get((EntityPlayer) event.entity) == null) ExtendedEntityPropAlteration.register((EntityPlayer) event.entity); if (event.entity instanceof EntityPlayer && event.entity.getExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME) == null) event.entity.registerExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME, new ExtendedEntityPropAlteration((EntityPlayer) event.entity)); } public static void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME, new ExtendedEntityPropAlteration(player)); } @SubscribeEvent public void onLivingDeathEvent(LivingDeathEvent event) { if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) { NBTTagCompound playerData = new NBTTagCompound(); ((ExtendedEntityPropAlteration)(event.entity.getExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME))).saveNBTData(playerData); CommonProxy.storeEntityData(((EntityPlayer) event.entity).getCommandSenderName(), playerData); ExtendedEntityPropAlteration.saveProxyData((EntityPlayer) event.entity); } } // we already have this event, but we need to modify it some @SubscribeEvent public void onEntityJoinWorld(EntityJoinWorldEvent event) { if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) { NBTTagCompound playerData = CommonProxy.getEntityData(((EntityPlayer) event.entity).getCommandSenderName()); if (playerData != null) { ((ExtendedEntityPropAlteration)(event.entity.getExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME))).loadNBTData(playerData); } ((ExtendedEntityPropAlteration)(event.entity.getExtendedProperties(ExtendedEntityPropAlteration.EXT_PROP_NAME))).sync(); } } }
puis l’extendproperties que vous prenez dans le tuto de ce forum.</class<?></object></object></class<?></class<?></side,></fmlproxypacket,>