Résolu Nouveau modèle pour le player
-
Bonjour,
Donc j’ai créer un nouveau modèle pour le joueur et on m’a dit d’utiliser “ObfuscationReflectionHelper.setPrivateValue” dans le RenderPlayerEvent.Pre . Du coup pour tester j’ai essayer de remplacer le model du joueur par celui du cochon, ça n’a pas fonctionner, j’ai essayer avec un autre model que j’avais ajouter, pareil.
Voici comme j’utilise l’event :
@SubscribeEvent public void onRenderPlayerEventPre(RenderPlayerEvent.Pre event) { ObfuscationReflectionHelper.setPrivateValue(net.minecraft.client.renderer.entity.RendererLivingEntity.class, event.renderer, new ModelPig(), new String[] { "mainModel", "field_77045_g" }); }
Le crash log:
–-- Minecraft Crash Report ---- // Ooh. Shiny. Time: 06/03/16 15:51 Description: Rendering entity in world java.lang.ClassCastException: net.minecraft.client.model.ModelPig cannot be cast to net.minecraft.client.model.ModelPlayer at net.minecraft.client.renderer.entity.RenderPlayer.getPlayerModel(RenderPlayer.java:55) at net.minecraft.client.renderer.entity.RenderPlayer.func_177137_d(RenderPlayer.java:78) at net.minecraft.client.renderer.entity.RenderPlayer.func_180596_a(RenderPlayer.java:70) at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:275) at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:377) at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:334) at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:301) at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:657) at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1350) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1088) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1114) at net.minecraft.client.Minecraft.run(Minecraft.java:376) at net.minecraft.client.main.Main.main(Main.java:117) 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:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraft.client.renderer.entity.RenderPlayer.getPlayerModel(RenderPlayer.java:55) at net.minecraft.client.renderer.entity.RenderPlayer.func_177137_d(RenderPlayer.java:78) at net.minecraft.client.renderer.entity.RenderPlayer.func_180596_a(RenderPlayer.java:70) at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:275) -- Entity being rendered -- Details: Entity Type: null (net.minecraft.client.entity.EntityPlayerSP) Entity ID: 216 Entity Name: Player578 Entity's Exact location: -250,72, 63,00, 894,08 Entity's Block location: -251,00,63,00,894,00 - World: (-251,63,894), Chunk: (at 5,3,14 in -16,55; contains blocks -256,0,880 to -241,255,895), Region: (-1,1; contains chunks -32,32 to -1,63, blocks -512,0,512 to -1,255,1023) Entity's Momentum: 0,00, -0,08, 0,00 Entity's Rider: ~~ERROR~~ NullPointerException: null Entity's Vehicle: ~~ERROR~~ NullPointerException: null -- Renderer details -- Details: Assigned renderer: net.minecraft.client.renderer.entity.RenderPlayer@c0c9d4a Location: 0,00,0,00,0,00 - World: (0,0,0), Chunk: (at 0,0,0 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Rotation: 84.44902 Delta: 0.36179066 Stacktrace: at net.minecraft.client.renderer.entity.RenderManager.doRenderEntity(RenderManager.java:377) at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:334) at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:301) at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:657) at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1350) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player578'/216, l='MpServer', x=-250,72, y=63,00, z=894,08]] Chunk stats: MultiplayerChunkCache: 575, 575 Level seed: 0 Level generator: ID 00 - default, ver 1\. Features enabled: false Level generator options: Level spawn location: -294,00,64,00,962,00 - World: (-294,64,962), Chunk: (at 10,4,2 in -19,60; contains blocks -304,0,960 to -289,255,975), Region: (-1,1; contains chunks -32,32 to -1,63, blocks -512,0,512 to -1,255,1023) Level time: 32656 game time, 32656 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: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 100 total; [EntitySkeleton['Skeleton'/35, l='MpServer', x=-328,84, y=39,00, z=873,47], EntityEnderman['Enderman'/36, l='MpServer', x=-328,00, y=40,00, z=872,38], EntitySkeleton['Skeleton'/37, l='MpServer', x=-327,47, y=40,00, z=871,41], EntityCreeper['Creeper'/40, l='MpServer', x=-322,09, y=51,00, z=918,66], EntityBat['Bat'/41, l='MpServer', x=-320,06, y=17,66, z=928,03], EntitySkeleton['Skeleton'/43, l='MpServer', x=-328,31, y=28,00, z=953,44], EntitySquid['Squid'/53, l='MpServer', x=-308,25, y=55,03, z=860,44], EntitySquid['Squid'/54, l='MpServer', x=-309,06, y=52,69, z=856,84], EntitySquid['Squid'/55, l='MpServer', x=-302,91, y=52,78, z=851,53], EntitySquid['Squid'/56, l='MpServer', x=-307,72, y=54,91, z=858,03], EntitySkeleton['Skeleton'/57, l='MpServer', x=-312,84, y=32,00, z=915,53], EntityCreeper['Creeper'/58, l='MpServer', x=-308,97, y=47,00, z=915,56], EntitySkeleton['Skeleton'/59, l='MpServer', x=-304,53, y=42,00, z=925,16], EntitySkeleton['Skeleton'/60, l='MpServer', x=-312,50, y=44,00, z=920,50], EntitySkeleton['Skeleton'/61, l='MpServer', x=-309,09, y=49,00, z=912,53], EntityCreeper['Creeper'/62, l='MpServer', x=-316,50, y=49,00, z=925,66], EntityCreeper['Creeper'/63, l='MpServer', x=-318,03, y=50,00, z=927,41], EntityBat['Bat'/64, l='MpServer', x=-321,34, y=22,06, z=952,41], EntityZombie['Zombie'/65, l='MpServer', x=-316,84, y=39,00, z=942,56], EntitySkeleton['Skeleton'/66, l='MpServer', x=-316,78, y=39,00, z=939,88], EntitySkeleton['Skeleton'/67, l='MpServer', x=-311,09, y=46,02, z=946,22], EntitySquid['Squid'/68, l='MpServer', x=-286,50, y=61,38, z=853,16], EntitySquid['Squid'/69, l='MpServer', x=-294,34, y=54,97, z=861,84], EntitySquid['Squid'/70, l='MpServer', x=-288,91, y=57,66, z=864,91], EntityZombie['Zombie'/71, l='MpServer', x=-295,50, y=20,00, z=915,13], EntityZombie['Zombie'/72, l='MpServer', x=-289,66, y=17,00, z=918,34], EntityCreeper['Creeper'/73, l='MpServer', x=-292,03, y=17,00, z=918,59], EntityCreeper['Creeper'/74, l='MpServer', x=-294,72, y=41,00, z=919,81], EntityBat['Bat'/75, l='MpServer', x=-301,53, y=16,02, z=941,88], EntitySquid['Squid'/77, l='MpServer', x=-286,66, y=60,59, z=851,94], EntitySquid['Squid'/78, l='MpServer', x=-288,25, y=60,94, z=844,06], EntitySquid['Squid'/79, l='MpServer', x=-280,25, y=57,38, z=862,53], EntitySquid['Squid'/80, l='MpServer', x=-285,63, y=56,81, z=857,75], EntitySquid['Squid'/81, l='MpServer', x=-281,72, y=61,47, z=849,66], EntityEnderman['Enderman'/82, l='MpServer', x=-278,69, y=23,00, z=879,41], EntitySquid['Squid'/83, l='MpServer', x=-287,97, y=55,00, z=871,03], EntitySquid['Squid'/84, l='MpServer', x=-278,53, y=57,79, z=896,50], EntitySquid['Squid'/85, l='MpServer', x=-279,73, y=55,07, z=888,49], EntitySquid['Squid'/86, l='MpServer', x=-287,34, y=56,38, z=888,19], EntitySquid['Squid'/87, l='MpServer', x=-280,95, y=57,73, z=887,56], EntityCreeper['Creeper'/88, l='MpServer', x=-284,50, y=17,00, z=921,50], EntityCreeper['Creeper'/89, l='MpServer', x=-280,50, y=17,00, z=926,50], EntitySkeleton['Skeleton'/90, l='MpServer', x=-285,50, y=17,00, z=923,50], EntityBat['Bat'/96, l='MpServer', x=-260,44, y=40,10, z=895,25], EntityCreeper['Creeper'/97, l='MpServer', x=-260,50, y=18,00, z=901,50], EntitySquid['Squid'/107, l='MpServer', x=-242,00, y=59,59, z=842,28], EntitySquid['Squid'/108, l='MpServer', x=-245,81, y=59,28, z=838,59], EntitySquid['Squid'/109, l='MpServer', x=-241,16, y=53,19, z=854,16], EntitySquid['Squid'/110, l='MpServer', x=-244,16, y=56,00, z=862,53], EntitySquid['Squid'/111, l='MpServer', x=-253,03, y=54,19, z=855,13], EntitySquid['Squid'/112, l='MpServer', x=-249,50, y=55,94, z=861,53], EntityBat['Bat'/113, l='MpServer', x=-253,00, y=19,02, z=867,75], EntitySpider['Spider'/114, l='MpServer', x=-247,31, y=33,91, z=891,28], EntityCreeper['Creeper'/115, l='MpServer', x=-254,19, y=34,00, z=943,50], EntitySheep['Sheep'/116, l='MpServer', x=-240,06, y=65,00, z=941,91], EntitySheep['Sheep'/117, l='MpServer', x=-246,53, y=69,00, z=964,19], EntitySheep['Sheep'/118, l='MpServer', x=-242,50, y=76,00, z=968,50], EntitySquid['Squid'/131, l='MpServer', x=-243,63, y=61,38, z=844,22], EntitySquid['Squid'/132, l='MpServer', x=-239,53, y=57,75, z=843,28], EntityCreeper['Creeper'/133, l='MpServer', x=-224,50, y=51,00, z=925,50], EntityCreeper['Creeper'/134, l='MpServer', x=-224,53, y=51,00, z=920,66], EntityZombie['Zombie'/135, l='MpServer', x=-224,50, y=51,00, z=924,50], EntitySheep['Sheep'/136, l='MpServer', x=-228,53, y=64,00, z=943,09], EntitySheep['Sheep'/137, l='MpServer', x=-231,69, y=66,00, z=952,81], EntitySheep['Sheep'/138, l='MpServer', x=-234,03, y=65,00, z=948,00], EntitySheep['Sheep'/139, l='MpServer', x=-229,63, y=64,00, z=943,72], EntitySheep['Sheep'/140, l='MpServer', x=-228,88, y=67,00, z=964,91], EntitySkeleton['Skeleton'/152, l='MpServer', x=-208,53, y=12,22, z=887,28], EntityBat['Bat'/153, l='MpServer', x=-211,41, y=29,10, z=921,44], EntitySkeleton['Skeleton'/154, l='MpServer', x=-207,94, y=52,00, z=926,59], EntityZombie['Zombie'/155, l='MpServer', x=-222,50, y=51,00, z=924,50], EntityEnderman['Enderman'/156, l='MpServer', x=-217,16, y=52,00, z=917,44], EntitySpider['Spider'/157, l='MpServer', x=-221,50, y=51,00, z=922,50], EntityZombie['Zombie'/158, l='MpServer', x=-219,06, y=40,00, z=967,47], EntityCreeper['Creeper'/159, l='MpServer', x=-220,59, y=32,00, z=965,66], EntityZombie['Zombie'/160, l='MpServer', x=-212,50, y=33,00, z=966,50], EntityBat['Bat'/161, l='MpServer', x=-213,25, y=41,94, z=964,44], EntityCreeper['Creeper'/162, l='MpServer', x=-223,75, y=32,00, z=966,69], EntityCreeper['Creeper'/163, l='MpServer', x=-211,44, y=33,00, z=968,34], EntityBat['Bat'/170, l='MpServer', x=-205,50, y=15,10, z=866,25], EntityCreeper['Creeper'/171, l='MpServer', x=-204,31, y=12,00, z=889,13], EntityCreeper['Creeper'/172, l='MpServer', x=-203,41, y=12,00, z=890,00], EntitySkeleton['Skeleton'/173, l='MpServer', x=-206,22, y=12,00, z=888,75], EntityCreeper['Creeper'/174, l='MpServer', x=-204,63, y=44,00, z=908,97], EntityCreeper['Creeper'/175, l='MpServer', x=-197,41, y=25,00, z=924,06], EntitySkeleton['Skeleton'/176, l='MpServer', x=-200,94, y=35,00, z=928,53], EntityCreeper['Creeper'/177, l='MpServer', x=-207,81, y=49,19, z=941,06], EntitySquid['Squid'/178, l='MpServer', x=-190,78, y=47,03, z=955,44], EntitySquid['Squid'/179, l='MpServer', x=-197,53, y=46,00, z=954,50], EntityCreeper['Creeper'/180, l='MpServer', x=-206,50, y=31,00, z=962,50], EntityBat['Bat'/181, l='MpServer', x=-185,63, y=25,88, z=902,75], EntityBat['Bat'/182, l='MpServer', x=-181,25, y=24,09, z=908,75], EntityCreeper['Creeper'/187, l='MpServer', x=-187,50, y=22,00, z=927,50], EntitySquid['Squid'/188, l='MpServer', x=-189,00, y=55,13, z=939,66], EntitySquid['Squid'/190, l='MpServer', x=-191,13, y=54,25, z=930,22], EntitySquid['Squid'/192, l='MpServer', x=-186,66, y=45,56, z=953,34], EntitySquid['Squid'/193, l='MpServer', x=-189,31, y=48,00, z=946,97], EntitySkeleton['Skeleton'/200, l='MpServer', x=-174,25, y=22,00, z=941,72], EntityZombie['Zombie'/201, l='MpServer', x=-174,81, y=19,00, z=939,66], EntityPlayerSP['Player578'/216, l='MpServer', x=-250,72, y=63,00, z=894,08]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2614) at net.minecraft.client.Minecraft.run(Minecraft.java:398) at net.minecraft.client.main.Main.main(Main.java:117) 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:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) – System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.8.0_25, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 650566504 bytes (620 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 61, allocated: 13, tallocated: 95 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1446 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{11.14.3.1446} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available tm{Palexor_Alpha_0.1.04} [Mod Drakaelia] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Loaded coremods (and transformers): GL info: ' Vendor: 'Intel' Version: '4.2.0 - Build 10.18.10.3355' Renderer: 'Intel(R) HD Graphics 4400' Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: Intel(R) HD Graphics 4400 GL version 4.2.0 - Build 10.18.10.3355, Intel GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No 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)
Mais ce que je ne comprend pas, c’est que ce code marche en 1.7.10 ,au niveau du mapping j’ai regardé et le field de ma version est le même. Ce bug serait causé par le fait qu’il faut en 1.8 que le modèle de remplacement pour le joueur soit un modèle qui utilise le ModelBiped ?
-
Non il y a un endroit où mc appelle une fonction qui n’appartient que au ModelPlayer, donc il faut que ton modèle soit extends ModelPlayer.
-
Lors de tes essaies, RenderPlayerAPI est-il installé ? Peut-être qu’il patche certaines classes de MC dans le but de forcer ce cast qui cause ton exception. Essaie sans cet API, y’a pas de raisons apparentes pour qu’entre la 1.7x et la 1.8, le code ne marche plus.
Sinon si tu n’en viens pas à bout, essaie d’extends ton modèle par ModelPlayer et de virer les shapes du ModelPlayer qui ne t’intéressent pas.
Si finalement après tout ceci, tu n’y arrives pas, je te propose la solution C, d’utiliser RenderPlayerAPI qui est plutôt facile d’utilisation, surtout qu’il y a un tuto sur le post officiel et que des mods open source s’en servant pour remplacer le modèle du joueur existe. Peut-être qu’une (très)ancienne version du Aether mod s’en servait. A toi de rechercher -
@‘AymericRed’:
Non il y a un endroit où mc appelle une fonction qui n’appartient que au ModelPlayer, donc il faut que ton modèle soit extends ModelPlayer.
Effectivement ça ne crash plus et le modèle s’affiche, merci.
@‘Plaigon’:
Lors de tes essaies, RenderPlayerAPI est-il installé ? Peut-être qu’il patche certaines classes de MC dans le but de forcer ce cast qui cause ton exception. Essaie sans cet API, y’a pas de raisons apparentes pour qu’entre la 1.7x et la 1.8, le code ne marche plus.
Sinon si tu n’en viens pas à bout, essaie d’extends ton modèle par ModelPlayer et de virer les shapes du ModelPlayer qui ne t’intéressent pas.
Si finalement après tout ceci, tu n’y arrives pas, je te propose la solution C, d’utiliser RenderPlayerAPI qui est plutôt facile d’utilisation, surtout qu’il y a un tuto sur le post officiel et que des mods open source s’en servant pour remplacer le modèle du joueur existe. Peut-être qu’une (très)ancienne version du Aether mod s’en servait. A toi de rechercherMerci pour l’aide apportée et oui maintenant plus qu’à enlever ce que je n’aime pas.
Je passe en résolu.