Résolu Problème Rendu EntityThrowable
-
Bonjour, dans le mod que je suis en train de programmer, j’ai créer un item comme la boule de neige. (L’item “ChestProjector” lance des “EntityChestProjectile”).
Les effets de l’item fonctionnent bien mais impossible d’avoir voir le rendu de l’item comme lorsque l’on lance une boule de neige. (Lorsque j’utilise mon “ChestProjector” on ne le vois pas se lancer mais les effets fonctionnent). Voici les codes qui peuvent être utile:
**ItemRenderRegister:** public final class ItemRenderRegister { public static void registerItemRenderer() { reg(ModItems.chestProjector); } public static String modid = Main.MODID; public static void reg(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(item, 0, new ModelResourceLocation(modid + ":" + item.getUnlocalizedName().substring(5), "inventory")); } }
**EntityRenderRegister:** public class EntityRenderRegister { public static void registerEntityRenderer() { RenderingRegistry.registerEntityRenderingHandler(EntityChestProjectile.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), ModItems.chestProjector, Minecraft.getMinecraft().getRenderItem())); } public static void reg(Item item) { ItemRenderRegister.reg(item); } }
Merci d’avance pour votre aide !
PS: Je suis encore un débutant dans le modding forge/minecraft donc désolée si le problème était évident.
PPS: Je n’ai pas de problème avec le rendu d’un mob que j’ai créer. -
Salut,
As-tu enregistré ton entité EntityChestProjectile ? -
Oui, dans mon “ModEntity” et le rendu via le ClientProxy.
public class ModEntity { public static Entity EntityChestProjectile; public static void createEntities() { registerEntity(EntityChestProjectile.class, "ChestProjectile", 0, 0); } public static void registerEntity(Class entityClass, String string, int bg, int fg) { EntityRegistry.registerGlobalEntityID(entityClass, string, EntityRegistry.findGlobalUniqueEntityId(), bg, fg); } }
-
Ta fonction createEntities est bien appelé dans ta classe principale ?
De plus tu devrais utiliser registerModEntity et non registerGlobalEntityID -
Oui elle est appelé, lorsque je modifie en “registerModEntity” ça crash, je vais voir si je ne peux pas régler ce problème en attendant voici les logs du crash :
[16:03:18] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [16:03:18] [Client thread/ERROR] [FML]: mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized pirateslife{0.1} [Pirate's Life Mod] (bin) Unloaded->Constructed->Errored Baubles{1.1.1.0} [Baubles] (Baubles-1.8-1.1.1.0-deobf.jar) Unloaded->Constructed->Pre-initialized [16:03:18] [Client thread/ERROR] [FML]: The following problems were captured during this phase [16:03:18] [Client thread/ERROR] [FML]: Caught exception from pirateslife java.lang.NullPointerException at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:163) ~[forgeSrc-1.8-11.14.1.1334.jar:?] at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:149) ~[forgeSrc-1.8-11.14.1.1334.jar:?] at fr.slimgma.pirateslife.common.entity.ModEntity.registerEntity(ModEntity.java:23) ~[bin/:?] at fr.slimgma.pirateslife.common.entity.ModEntity.createEntities(ModEntity.java:16) ~[bin/:?] at fr.slimgma.pirateslife.Main.preInit(Main.java:35) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) ~[forgeSrc-1.8-11.14.1.1334.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.8-11.14.1.1334.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.8-11.14.1.1334.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:446) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] [16:03:18] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: –-- Minecraft Crash Report ---- // Would you like a cupcake? Time: 24/07/15 16:03 Description: Initializing game java.lang.NullPointerException: Initializing game at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:163) at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:149) at fr.slimgma.pirateslife.common.entity.ModEntity.registerEntity(ModEntity.java:23) at fr.slimgma.pirateslife.common.entity.ModEntity.createEntities(ModEntity.java:16) at fr.slimgma.pirateslife.Main.preInit(Main.java:35) 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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:446) at net.minecraft.client.Minecraft.run(Minecraft.java:356) 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.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:163) at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:149) at fr.slimgma.pirateslife.common.entity.ModEntity.registerEntity(ModEntity.java:23) at fr.slimgma.pirateslife.common.entity.ModEntity.createEntities(ModEntity.java:16) at fr.slimgma.pirateslife.Main.preInit(Main.java:35) 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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:446) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:356) 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_45, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 836984336 bytes (798 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.10 FML v8.0.37.1334 Minecraft Forge 11.14.1.1334 5 mods loaded, 5 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{8.0.37.1334} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized Forge{11.14.1.1334} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1334.jar) Unloaded->Constructed->Pre-initialized pirateslife{0.1} [Pirate's Life Mod] (bin) Unloaded->Constructed->Errored Baubles{1.1.1.0} [Baubles] (Baubles-1.8-1.1.1.0-deobf.jar) Unloaded->Constructed->Pre-initialized Loaded coremods (and transformers): Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: Intel(R) HD Graphics GL version 4.0.0 - Build 10.18.10.3366, 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) [16:03:19] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: #@!@# Game crashed! Crash report saved to: #@!@# D:\Users\Llulu\Downloads\Modding\1.8\forge-src\eclipse\.\crash-reports\crash-2015-07-24_16.03.18-client.txt Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
-
java.lang.NullPointerException
at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:163) ~[forgeSrc-1.8-11.14.1.1334.jar:?]
Il y a un NPE, envoie ton code. -
public class ModEntity { public static Entity EntityChestProjectile; public static void createEntities() { registerEntity(EntityChestProjectile.class, "ChestProjectile", 0, 0); } public static void registerEntity(Class entityClass, String string, int bg, int fg) { EntityRegistry.registerModEntity(entityClass, string, fg, fg, fg, fg, false); } }
-
Comment ta fonction est-elle appelée ?
-
Tu utilises les mauvais arguments. Les bons arguments sont :
https://github.com/MinecraftForge/MinecraftForge/blob/master/fml/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java#L141-L150 -
En changeant les arguments j’ai ça par défaut:
public class ModEntity { public static Entity EntityChestProjectile; public static void createEntities() { registerModEntity(EntityChestProjectile.class, null, 0, EntityChestProjectile, 0, 0, false); } public static void registerModEntity(Class entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) { EntityRegistry.registerModEntity(entityClass, entityName, updateFrequency, mod, updateFrequency, updateFrequency, sendsVelocityUpdates); } }
Et en modifiant j’ai ça:
public class ModEntity { public static Entity EntityChestProjectile; public static void createEntities() { registerModEntity(EntityChestProjectile.class, "EntityChestProjectile", 0, EntityChestProjectile, 0, 0, false); } public static void registerModEntity(Class entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) { EntityRegistry.registerModEntity(entityClass, entityName, updateFrequency, mod, updateFrequency, updateFrequency, sendsVelocityUpdates); } }
Dans les deux cas toujours un crash. Et ma fonction est “createEntities”.
-
Object mod -> tu es sensé mettre l’instance du mod ici. Et pour trackingRange et updateFrequency ce n’est pas une bonne idée de mettre 0.
-
C’est bon tout marche correctement, le rendu aussi, merci beaucoup, je met la balise résolu !
PS: Pour tous ceux qui veulent des explications plus détaillé pour chaque paramètre du registerModEntity et du globalEntity allez sur ce lien : http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/1437990-mod-entity-problem-updated-with-forge?page=8 (C’est en anglais et en version 1.4.7 mais les explications des paramètres sont toujours valide je pense. (voir le post de [size=smalllockNload147)]
-
C’est étrange ça.
Sur NHG on a :EntityRegistry.registerModEntity(EntitySlimeBall.class, "SlimeBall", 225, instance, 120, 2, true);
package fr.mcnanotech.nhg.common.entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import fr.mcnanotech.nhg.common.CustomPlayerProperties; import fr.mcnanotech.nhg.common.kit.Kit; public class EntitySlimeBall extends EntityThrowable { public EntitySlimeBall(World par1World) { super(par1World); } public EntitySlimeBall(World par1World, EntityLivingBase par2EntityLivingBase) { super(par1World, par2EntityLivingBase); } public EntitySlimeBall(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } @Override protected void onImpact(MovingObjectPosition movingObject) { if(movingObject.entityHit != null && !movingObject.entityHit.worldObj.isRemote) { movingObject.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); if(movingObject.entityHit instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase)movingObject.entityHit; if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; CustomPlayerProperties prop = CustomPlayerProperties.get(player); Kit kit = Kit.getKit(prop.getKitIndex()); if(kit != null && kit == Kit.slime) { player.heal((player.worldObj.rand.nextFloat() / 2)); } else { player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200)); } } else { entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200)); } } } for(int i = 0; i < 8; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.SLIME, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if(!this.worldObj.isRemote) { this.setDead(); } } }
RenderingRegistry.registerEntityRenderingHandler(EntitySlimeBall.class, new RenderItemThrowable(Items.slime_ball, Minecraft.getMinecraft()));
package fr.mcnanotech.nhg.client.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderItemThrowable extends Render { private Item item; private int metadata; private final RenderItem itemRenderer; public RenderItemThrowable(RenderManager rendermgr, Item item, int metadata, RenderItem renderItem) { super(rendermgr); this.item = item; this.metadata = metadata; this.itemRenderer = renderItem; } public RenderItemThrowable(Item item, Minecraft mc) { this(mc.getRenderManager(), item, 0, mc.getRenderItem()); } @Override public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, (float)z); GlStateManager.enableRescaleNormal(); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); this.bindTexture(TextureMap.locationBlocksTexture); this.itemRenderer.renderItemModel(new ItemStack(this.item, 1, this.metadata)); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, yaw, partialTicks); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationBlocksTexture; } }
Et cela fonctionne très bien. (d’ailleurs il me semble que RenderItemThrowable n’est même pas nécessaire, on peut directement utilisé le rendu de la boule de neige).
-
@‘robin4002’:
C’est étrange ça.
Sur NHG on a :EntityRegistry.registerModEntity(EntitySlimeBall.class, "SlimeBall", 225, instance, 120, 2, true);
package fr.mcnanotech.nhg.common.entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import fr.mcnanotech.nhg.common.CustomPlayerProperties; import fr.mcnanotech.nhg.common.kit.Kit; public class EntitySlimeBall extends EntityThrowable { public EntitySlimeBall(World par1World) { super(par1World); } public EntitySlimeBall(World par1World, EntityLivingBase par2EntityLivingBase) { super(par1World, par2EntityLivingBase); } public EntitySlimeBall(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } @Override protected void onImpact(MovingObjectPosition movingObject) { if(movingObject.entityHit != null && !movingObject.entityHit.worldObj.isRemote) { movingObject.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); if(movingObject.entityHit instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase)movingObject.entityHit; if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; CustomPlayerProperties prop = CustomPlayerProperties.get(player); Kit kit = Kit.getKit(prop.getKitIndex()); if(kit != null && kit == Kit.slime) { player.heal((player.worldObj.rand.nextFloat() / 2)); } else { player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200)); } } else { entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 200)); } } } for(int i = 0; i < 8; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.SLIME, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if(!this.worldObj.isRemote) { this.setDead(); } } }
RenderingRegistry.registerEntityRenderingHandler(EntitySlimeBall.class, new RenderItemThrowable(Items.slime_ball, Minecraft.getMinecraft()));
package fr.mcnanotech.nhg.client.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderItemThrowable extends Render { private Item item; private int metadata; private final RenderItem itemRenderer; public RenderItemThrowable(RenderManager rendermgr, Item item, int metadata, RenderItem renderItem) { super(rendermgr); this.item = item; this.metadata = metadata; this.itemRenderer = renderItem; } public RenderItemThrowable(Item item, Minecraft mc) { this(mc.getRenderManager(), item, 0, mc.getRenderItem()); } @Override public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) { GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, (float)z); GlStateManager.enableRescaleNormal(); GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); this.bindTexture(TextureMap.locationBlocksTexture); this.itemRenderer.renderItemModel(new ItemStack(this.item, 1, this.metadata)); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, yaw, partialTicks); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationBlocksTexture; } }
Et cela fonctionne très bien. (d’ailleurs il me semble que RenderItemThrowable n’est même pas nécessaire, on peut directement utilisé le rendu de la boule de neige).
J’ai édit mon post sans voir ton message désolée, tout marche il fallait juste que je mette sur true (c’était encore sur false). Merci encore
PS: Oui on peut directement utilisé le rendu de la boule de neige je confirme (c’est ce que j’ai fais).