OnItemRightClick sur une entity.
-
crash: at com.AltisMine.mod.AT.func_111207_a(AT.java:32)
ligne 32:
stack.getTagCompound().setInteger(“level”, prop.getAlcool());EDIT:
C’est je crois que j’ai trouvé . -
Rapport de crash complet ?
-
–-- Minecraft Crash Report ---- // I let you down. Sorry :( Time: 24/12/15 00:06 Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.AltisMine.mod.AT.func_111207_a(AT.java:32) at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:324) at net.minecraft.entity.player.EntityPlayer.func_70998_m(EntityPlayer.java:1135) at net.minecraft.client.multiplayer.PlayerControllerMP.func_78768_b(PlayerControllerMP.java:413) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1431) at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1953) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:973) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:898) at net.minecraft.client.main.Main.main(SourceFile:148) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) 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 com.AltisMine.mod.AT.func_111207_a(AT.java:32) at net.minecraft.item.ItemStack.func_111282_a(ItemStack.java:324) at net.minecraft.entity.player.EntityPlayer.func_70998_m(EntityPlayer.java:1135) at net.minecraft.client.multiplayer.PlayerControllerMP.func_78768_b(PlayerControllerMP.java:413) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1431) -- Affected level -- Details: Level name: MpServer All players: 3 total; [MCH_ViewEntityDummy['McHeliDummyEntity'/14, l='MpServer', x=677,50, y=66,62, z=153,50], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=696,27, y=73,62, z=1097,51], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72]] Chunk stats: MultiplayerChunkCache: 71, 71 Level seed: 0 Level generator: ID 02 - largeBiomes, ver 0\. Features enabled: false Level generator options: Level spawn location: World: (677,64,153), Chunk: (at 5,4,9 in 42,9; contains blocks 672,0,144 to 687,255,159), Region: (1,0; contains chunks 32,0 to 63,31, blocks 512,0,0 to 1023,255,511) Level time: 275531588 game time, 102350000 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Forced entities: 8 total; [EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=718,63, y=73,00, z=1186,53], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=699,27, y=72,71, z=1130,01], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=696,27, y=73,62, z=1097,51], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=697,50, y=72,00, z=1098,72], EntityClientPlayerMP['floriangabet'/56, l='MpServer', x=746,45, y=72,62, z=1136,70], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=745,06, y=71,00, z=1134,88], EntityOtherPlayerMP['Mr_KIKI_72'/140, l='MpServer', x=739,08, y=73,12, z=1086,82]] Retry entities: 0 total; [] Server brand: cauldron,craftbukkit,mcpc,fml,forge Server type: Non-integrated multiplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:373) at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2444) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:927) at net.minecraft.client.main.Main.main(SourceFile:148) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) – System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_25, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 626870992 bytes (597 MB) / 1430659072 bytes (1364 MB) up to 2134114304 bytes (2035 MB) JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 103 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 Optifine OptiFine_1.7.10_HD_B7 23 mods loaded, 23 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJA FML{7.10.99.99} [Forge Mod Loader] (forge-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJA Forge{10.13.4.1448} [Minecraft Forge] (forge-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJA amm{1.0} [§aAltisMineMod] (AltisMineModV1.0(1.7.10).jar) UCHIJA BiblioCraft{1.9.0} [BiblioCraft] (BiblioCraft[v1.9.0][MC1.7.10].jar) UCHIJA AlcoholMod{1.5-Beta} [Alcohol Mod] (booze.jar) UCHIJA CarpentersBlocks{3.2.5} [Carpenter's Blocks] (Carpenters-Blocks-Mod-1.7.10.zip) UCHIJA chisel{1.5.7} [Chisel] (Chisel-1.7.10-1.5.7.jar) UCHIJA customnpcs{1.7.10c} [CustomNpcs] (CustomNPCs_1.7.10c.jar) UCHIJA PTRModelLib{1.0.0} [PTRModelLib] (Decocraft-2.1.1_1.7.10.jar) UCHIJA props{2.1.1} [Decocraft] (Decocraft-2.1.1_1.7.10.jar) UCHIJA Dynmap{2.2-143} [Dynmap] (Dynmap-2.2-forge-1.7.10.jar) UCHIJA flansmod{4.10.0} [Flan's Mod] (Flans Mod.jar) UCHIJA flenixcities{0.9.0} [FlenixCities] (FlenixCitiesCore_[1.7.10]-0.9.0.jar) UCHIJA mcheli{0.10.7} [MC Helicopter] (mcheli) UCHIJA Monoblocks{1.9.11} [§1M§2o§3n§4o§5b§6l§7o§8c§9k§as] (Monoblocks-1.9.11.jar) UCHIJA MonoblocksMultipart{1.9.11} [MonoblocksMultipart] (Monoblocks-1.9.11.jar) UCHIJA cfm{3.3.5} [§6MrCrayfish's Furniture Mod] (MrCrayfishs-Furniture-Mod-1.7.10.jar) UCHIJA MumbleLink{4.1.1-2b3035b} [MumbleLink for Forge] (MumbleLink-1.7.10-4.1.1-2b3035b.jar) UCHIJA ExtendedPASupport{1.0.0-2b3035b} [ExtendedPASupport for MumbleLink] (MumbleLink-1.7.10-4.1.1-2b3035b.jar) UCHIJA pseudoeraser{0.1} [Pseudo' Eraser] (Pseudo' Eraser v0.1 - 1.7.10.jar) UCHIJA RopesPlus{1.6.3} [Ropes+] (Ropes-Plus-Mod-1.7.10.jar) UCHIJA thirstmod{1.8.8} [Thirst Mod] (thirstmod-1.8.8.jar) Launched Version: 1.7.10-Forge10.13.4.1448-1.7.10 LWJGL: 2.9.1 OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 355.82, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Anisotropic filtering is supported and maximum anisotropy is 16. Shaders are available because OpenGL 2.1 is supported. 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: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)Au fait j’ai pas trouvé pour le crash.
-
Tu as enregistré ton ExtendedEntityPropAlcool ?
-
J’ai rien régister c’est ou que je dois le register ?
EDIT: J’ai mis ça dans la class principale :
FMLCommonHandler.instance().bus().register(new ExtendedEntityPropAlcool(null)); MinecraftForge.EVENT_BUS.register(new ExtendedEntityPropAlcool(null)); -
Euh …. Fait plus ça s’il te plaît
Je crois qu’il voulait parler de l’event EntityEvent.EntityConstructing
**EDIT : ** ou pas xD
-
…
C’est pas du tout comme ça qu’il faut l’enregistrer. Il faut passer par l’event EntityEvent.EntityConstructing. -
Peut-etre mieux non?
@SubscribeEvent public void onEntityConstructing(EntityConstructing event) { if (event.entity instanceof EntityPlayer && ExtendedEntityPropAlcool.get((EntityPlayer) event.entity) == null) ExtendedEntityPropAlcool.register((EntityPlayer) event.entity); } -
Oui. Tu as bien mit cette ligne dans une classe que tu as enregistré avec MinecraftForge.EVENT_BUS.register(new NomDeLaClasse()); ?
-
Alors oui mais je les mis dans ExtendedEntityPropAlcool c’est pas grave ?
car j’ai une érreur sur le: [font=Ubuntu, sans-serif```java
MinecraftForge.EVENT_BUS.register(new ExtendedEntityPropAlcool());[font=Ubuntu, sans-serifil me demande de vire le EntityPlayer de cette ligne (cette ligne est dans le ExtendedEntityPropAlcool):] [font=Ubuntu, sans-serif```java public ExtendedEntityPropAlcool*(***EntityPlayer player***)* {] [font=Ubuntu, sans-serif} ```] -
Fait une autre classe nommé EntityEvent, ça sera mieux.
-
Ouaip merci j’essaye ça je vous dis.
-
Crash réglé mais quand un joueur boit et que j’interagi avec le clic droit sa m’indique 0 et quand on inverse c’est pareil 0 aussi.
-
Tu as bien changé le code dans les autres items ?
-
J’ai j’ai changer la class At qui permet de prendre le niveau d’alcool par contre j’ai pas touché a la class LIIT qui est la class pour les boissons d’alcool est donc normalement ajouté le niveau d’alcool .
package com.AltisMine.mod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class LIIT extends ItemFood { AT alcohol = new AT(); public LIIT (int itemID, int i, boolean b) { super(itemID, i, b); } public EnumAction getItemUseAction(ItemStack itemstack) { return EnumAction.drink; } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (player.canEat(true)) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); } return stack; } public int getMaxItemUseDuration(ItemStack stack) { return 32; } public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { –stack.stackSize; ExtendedEntityPropAlcool.alcoolvl = Math.abs(ExtendedEntityPropAlcool.alcoolvl +1); player.getFoodStats().addStats(1, 2); // nombre de demi-gigots + saturation world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); player.addPotionEffect(new PotionEffect(Potion.confusion.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.hunger.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.weakness.id, 315,0)); return stack; } @Override public boolean hasEffect(ItemStack par1ItemStack){ return true; } } -
ExtendedEntityPropAlcool prop = ExtendedEntityPropAlcool.get(player); prop.setAlcool(prop.getAlcool() + 1); -
Et la variable alcoolvl de la classe ExtendedEntityPropAlcool ne doit pas être static. Sinon ton ExtendedEntityPropAlcool n’a plus aucun intérêt (les instances ça fait partie de la base Java vivement que le tutoriel soit publié).
-
**Hors-Sujet : ** Oui mais est-ce-que ceux qui ne prenez même pas la peine d’apprendre le Java sur OpenClassroom prendront la peine de regarder des tutoriels de Java sur MFF ? C’est la question que je me pose …
Vu que c’est du hors-sujet tu peux supprimer le message, je soulevais juste la question -
Une fois que le tutoriel sera disponible je ne vais plus m’embêter. Si quelqu’un demande de l’aide dans support pour les moddeurs et que je remarque que le minimum nécessaire pour coder en Java n’est pas acquis ça sera lock + lien vers le tutoriel.
À la base la description de la section c’est ça :Il s’agit de la section de support pour ceux qui créent des mods avec Forge. L’aide au modding va ici, cependant, gardez à l’esprit que ce n’est pas une école de programmation Java. Vous êtes censé avoir au moins certaines base de Java avant de poster ici.
-
J’ai fais comme vous avez dis mais j’ai un problème encore :
Detected ongoing potential memory leak. 4000 packets have leaked. Top offenders
[22:36:38] [Client thread/ERROR] [FML]: amm: : 4000
[22:36:38] [Client thread/ERROR] [FML]: Detected ongoing potential memory leak. 4100 packets have leaked. Top offenders
fuite de mémoire …
Class item:public class LIIT extends ItemFood { AT alcohol = new AT(); public LIIT (int itemID, int i, boolean b) { super(itemID, i, b); } public EnumAction getItemUseAction(ItemStack itemstack) { return EnumAction.drink; } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (player.canEat(true)) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); } return stack; } public int getMaxItemUseDuration(ItemStack stack) { return 32; } public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) { –stack.stackSize; ExtendedEntityPropAlcool prop = ExtendedEntityPropAlcool.get(player); prop.setAlcool(prop.getAlcool() + 1); player.getFoodStats().addStats(1, 2); // nombre de demi-gigots + saturation world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); player.addPotionEffect(new PotionEffect(Potion.confusion.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.hunger.id, 315,0)); player.addPotionEffect(new PotionEffect(Potion.weakness.id, 315,0)); return stack; } @Override public boolean hasEffect(ItemStack par1ItemStack){ return true; } }class ExtendedEntity:
public class ExtendedEntityPropAlcool implements IExtendedEntityProperties { public final static String EXT_PROP_NAME = "ExtPropAlcool"; private int alcool = 0; private final EntityPlayer player; public ExtendedEntityPropAlcool(EntityPlayer player) { this.player = player; } @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); properties.setInteger("alcool", this.alcool); compound.setTag(EXT_PROP_NAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.alcool = properties.getInteger("alcool"); } @Override public void init(Entity entity, World world) { // TODO Auto-generated method stub } public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedEntityPropAlcool.EXT_PROP_NAME, new ExtendedEntityPropAlcool(player)); } public static final ExtendedEntityPropAlcool get(EntityPlayer player) { return (ExtendedEntityPropAlcool) player.getExtendedProperties(EXT_PROP_NAME); } public final void sync() { PacketAlcool packetAlcool = new PacketAlcool(this.alcool); AltisMineMod.network.sendToServer(packetAlcool); if (!player.worldObj.isRemote) { EntityPlayerMP playerClient = (EntityPlayerMP) this.player; AltisMineMod.network.sendTo(packetAlcool, playerClient); } } private static String getSaveKey(EntityPlayer player) { return player.getDisplayName() + ":" + EXT_PROP_NAME; } public static void saveProxyData(EntityPlayer player) { ExtendedEntityPropAlcool playerData = ExtendedEntityPropAlcool.get(player); NBTTagCompound savedData = new NBTTagCompound(); playerData.saveNBTData(savedData); CommonProxy.storeEntityData(getSaveKey(player), savedData); } public static void loadProxyData(EntityPlayer player) { ExtendedEntityPropAlcool playerData = ExtendedEntityPropAlcool.get(player); NBTTagCompound savedData = CommonProxy .getEntityData(getSaveKey(player)); if (savedData != null) { playerData.loadNBTData(savedData); } playerData.sync(); } public void setAlcool(int taux) { this.alcool = taux; this.sync(); } public int getAlcool() { this.alcool = 0; if (alcool != 0) alcool = Math.abs(alcool / 2); else if (alcool == 0) { alcool = Math.abs(alcool); } return this.alcool; } }