Problème Render projectile dispenser
-
Ligne 177 tu l’enlève et t’en met une tout à la fin
-
@‘BrokenSwing’:
Ligne 177 tu l’enlève et t’en met une tout à la fin
Je viens de le faire ça ne change strictement rien toujours le même problème___@‘robin4002’:
Sans des color qui n’ont rien à faire là ça serait mieux.
Vérifies bien que toutes les accolades que tu ouvres sont bien fermées.Ok je viens de vérifier c’est juste l’accolade qui ne devait pas être là sauf que maintenant ```java
private static final HashMap field_77925_n; -
Il est final, donc il faut que tu l’initialise
-
@‘BrokenSwing’:
Il est final, donc il faut que tu l’initialise
Je l’ai supprimé parce qu’il ne servait strictement à rien dans le code sauf que ça crash encore parce que je n’ai pas défini le constructeur renderFreshRocket___@‘BrokenSwing’:
Il est final, donc il faut que tu l’initialise
Je viens de définir le constructeur sauf qu’il crash pour la même raison ```java
public RenderFreshRocket(Item FreshRocket, int i)
{
{
this.field_94151_a = FreshRocket;
this.shadowOpaque = i;
}
}public RenderFreshRocket(Item FreshRocket)
{
this(FreshRocket, 0);
} -
Ça serait bien de renommer tes variables parce que entre field_94151_a et field_94451_a bah c’est pas facile de s’y retrouver
Tu parle de la HashMap et ensuite tu parle de ton constructeur, je suis perdu
-
@‘BrokenSwing’:
Ça serait bien de renommer tes variables parce que entre field_94151_a et field_94451_a bah c’est pas facile de s’y retrouver
Tu parle de la HashMap et ensuite tu parle de ton constructeur, je suis perdu
Ok je suis dsl c’est pas clair en effet mais si tu veux je suis aller voir dans le crash report et le problème ne vient pas cette classe en faite le problème vient de la déclaration du rendu (RegisterRender….)___dernière question que dois-je mettre dans l’enregistrement à la place de ModelBiped pour un projectile ?
-
Je viens de voir en effet
Dans ta classe RenderFreshRocket tu as un constructeur avec un RenderManager, un ModelFreshRocket, et un float.
Et puis dans ton ClientProxy tu appelle le constructeur comme ça :
new RenderFreshRocket(new ModelRocket())Là il n’y a que le model, faut rajouter le reste pour qu’ils correspondent
-
Ok maintenant que j’ai changer le register render, le model maintenant retour au RenderFreshRocket c’est le IconFromDamage qui déconne ```java
public void doRender(Entity EntityFreshRocket, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
IIcon iicon = this.field_94151_a.getIconFromDamage((int) this.shadowOpaque);if (iicon != null)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glScalef(0.5F, 0.5F, 0.5F);
this.bindEntityTexture(EntityFreshRocket);
Tessellator tessellator = Tessellator.instance;if (iicon == ItemPotion.func_94589_d(“explosion”))
{
int i = PotionHelper.func_77915_a(((EntityPotion)EntityFreshRocket).getPotionDamage(), false);
float f2 = (float)(i >> 16 & 255) / 255.0F;
float f3 = (float)(i >> 8 & 255) / 255.0F;
float f4 = (float)(i & 255) / 255.0F;
GL11.glColor3f(f2, f3, f4);
GL11.glPushMatrix();
this.func_77026_a(tessellator, ItemPotion.func_94589_d(“overlay”));
GL11.glPopMatrix();
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}this.func_77026_a(tessellator, iicon);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
___et quand je regarde le crash report toujours le registerrender undefinedjava
RenderingRegistry.registerEntityRenderingHandler(EntityFreshRocket.class, new RenderFreshRocket(new ModelRocket(), 0.5F)); -
Bah il manque toujours le RenderManager dans ton constructeur, et ensuite comme je te l’ai déjà dit “field_94151_a” c’est pas vraiment explicite
-
@‘BrokenSwing’:
Bah il manque toujours le RenderManager dans ton constructeur, et ensuite comme je te l’ai déjà dit “field_94151_a” c’est pas vraiment explicite
je ne sais vraiment p___je ne sais vraiment pas quoi mettre dans le constructeur si quelqu’un avait un tut ça serait sympa :p___UP!
Le problème ne vient plus de là mais de cette ligne :java FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());___```java
[10:54:46] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
// Sorry
Time: 22/12/15 10:54
Description: Initializing gamejava.lang.NullPointerException: Initializing game
at cpw.mods.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:171)
at cpw.mods.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:150)
at fr.freshblock.freshrocket.common.ModFreshrocket.init(ModFreshrocket.java:55)
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:532)
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 cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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 cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
at net.minecraft.client.Minecraft.run(Minecraft.java:942)
at net.minecraft.client.main.Main.main(Main.java:164)
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) -
java.lang.NullPointerException
Tu essaie d’enregistrer un entité null at fr.freshblock.freshrocket.common.ModFreshrocket.init(ModFreshrocket.java:55)
-
L’init de la classe principale :
@EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); GameRegistry.addRecipe(new ItemStack (freshRocket), new Object []{"BSB","BTB","BRB",'B', Blocks.gold_block, 'S', Items.slime_ball, 'T', Blocks.tnt, 'R', Items.blaze_rod}); BlockDispenser.dispenseBehaviorRegistry.putObject(freshRocket, new BehaviorDefault()); EntityRegistry.registerModEntity(EntityFreshRocket.class,"EntityFreshRocket", 420, this.instance, 40, 1, true); EntityRegistry.registerGlobalEntityID(EntityFreshRocket.class,"EntityfreshRocket", EntityRegistry.findGlobalUniqueEntityId()); } -
Essai d’inverser les deux lignes avec EntityRegistry (la 7 et la

-
toujours le même problème

-
Envoie ta classe principale et ta classe de l’entité
-
classe principale :
package fr.freshblock.freshrocket.common; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import fr.freshblock.freshrocket.entity.projectile.EntityFreshRocket; import fr.freshblock.freshrocket.proxy.CommonProxy; import fr.freshblock.freshrocket.proxy.ModelRocket; import fr.freshblock.freshrocket.proxy.RenderFreshRocket; import net.minecraft.block.BlockDispenser; import net.minecraft.client.model.ModelBase; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @Mod(modid = "freshRocket", name = "ModFreshrocket", version = "1.0.0") public class ModFreshrocket { public static final String MODID = "freshRocket"; @Instance("MODID") public static ModFreshrocket instance; @SidedProxy(clientSide = "fr.freshblock.freshrocket.proxy.ClientProxy", serverSide = "fr.freshblock.freshrocket.proxy.CommonProxy") public static CommonProxy proxy; public static Item freshRocket; @EventHandler public void preInit(FMLPreInitializationEvent event) { freshRocket = new FreshRocket().setUnlocalizedName("freshRocket").setTextureName(MODID + ":fresh_rocket").setCreativeTab(CreativeTabs.tabCombat); GameRegistry.registerItem(freshRocket,"FreshRocket"); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); GameRegistry.addRecipe(new ItemStack (freshRocket), new Object []{"BSB","BTB","BRB",'B', Blocks.gold_block, 'S', Items.slime_ball, 'T', Blocks.tnt, 'R', Items.blaze_rod}); BlockDispenser.dispenseBehaviorRegistry.putObject(freshRocket, new BehaviorDefault()); EntityRegistry.registerGlobalEntityID(EntityFreshRocket.class,"EntityfreshRocket", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityFreshRocket.class,"EntityFreshRocket", 420, this.instance, 40, 1, true); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }classe de l’entité :
package fr.freshblock.freshrocket.entity.projectile; import cpw.mods.fml.common.registry.EntityRegistry; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.IProgressUpdate; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; public class EntityFreshRocket extends Entity implements IProjectile { private int xTile = -1; //Position X du projectile private int yTile = -1; //Position Y du projectile private int zTile = -1; //Postion Z du projectile private Block inTile; private int inData; private boolean inGround; //Dans un bloc ou pas public int arrowShake; public Entity shootingEntity; // Le joueur qui a tiré le projectile private int ticksInGround; //Je pense que c'est clair private int ticksInAir; //Je pense que c'est clair également private double damage = 6.0D; //Dégats du projectile private int knockbackStrength; //Puissance du knockback private Explosion explosion; public int canBePickedUp; @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound compound) { } @Override protected void writeEntityToNBT(NBTTagCompound compound) { } @Override public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) { this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); this.setPosition(p_70186_3_, p_70186_5_, p_70186_7_); this.yOffset = 0.0F; } public EntityFreshRocket(World worldIn) { super(worldIn); this.renderDistanceWeight = 10.0D; //Si je comprend bien, la distance du render de la flèche this.setSize(0.5F, 0.5F); //taille du projectile } public EntityFreshRocket(World worldIn, double x, double y, double z) { super(worldIn); this.renderDistanceWeight = 10.0D; //Pareil qu'au dessus this.setSize(0.5F, 0.5F); //Pareil qu'au dessus this.setPosition(x, y, z); //La position du projectile } public EntityFreshRocket(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { super(worldIn); this.renderDistanceWeight = 10.0D; //Toujours pareil this.shootingEntity = shooter; //Qui a tiré le projectile if (shooter instanceof EntityPlayer) { this.canBePickedUp = 0; //Si le tireur peut ramasser le projectile } //Plein de méthode chelous… this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D; double d0 = p_i1755_3_.posX - shooter.posX; double d1 = p_i1755_3_.getBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY; double d2 = p_i1755_3_.posZ - shooter.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); double d4 = d0 / d3; double d5 = d2 / d3; this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3); float f4 = (float)(d3 * 0.20000000298023224D); this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_); } } public EntityFreshRocket(World worldIn, EntityLivingBase shooter, float p_i1756_3_) //Quasiment la mème qu'au dessus { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.setSize(0.5F, 0.5F); this.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); } protected void onImpact(MovingObjectPosition EntityFreshRocket) { if (EntityFreshRocket.entityHit != null) { byte b0 = 0; if (EntityFreshRocket.entityHit instanceof EntityBlaze) { b0 = 3; } EntityFreshRocket.entityHit.attackEntityFrom(DamageSource.setExplosionSource(explosion), distanceWalkedModified); } for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } if (!this.worldObj.isRemote) { this.setDead(); } } } -
Essai de mettre le même nom non localisé, c’est à dire
EntityRegistry.registerGlobalEntityID(EntityFreshRocket.class,"EntityFreshRocket", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityFreshRocket.class,"EntityFreshRocket", 420, this.instance, 40, 1, true); -
toujours le problème
-
Il ne faut pas utiliser registerGlobalEntityID normalement.
Tu peux m’envoyer un zip de ton dossier src ? Je vais voir ce que je peux faire de mon côté. -
ok pièce jointe
t’as trouvé des trucs robin ?
@‘TheWolf’:
t’as trouvé des trucs robin ?
je fais des tests mais en vain j’ai l’impression de courir dans le vide
Est-ce que l’enregistrement d’une entité ce fait bien pendant l’initialisation du jeu ?
merci Robin
et dsl pour les posts Joyeux noël 