Problème Render projectile dispenser
-
@‘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 
-
Oui, pleins d’erreurs x)
J’ai tout corrigé par contre toujours pas de rendu, surement car il n’y a pas de texture.Et pas de boucle/triple/quadruple posts … J’ai tout fusionné. Utilises l’option éditer à l’avenir.
On a même gagné une page après fusion tellement tu avais fait de double/triple posts … -
Je relance le sujet parce que maintenant après tout ce temps j’ai créé un ModelRocket sauf que quand je lance le jeu aucun rendu ni quoique ce soit sors du dispenser à l’activation de celui-ci :
Behaviordefault :
package fr.freshblock.freshrocket.common; import fr.freshblock.freshrocket.entity.projectile.EntityFreshRocket; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public final class BehaviorDefault extends BehaviorDefaultDispenseItem { @Override protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { //Obtenir le monde World world = source.getWorld(); //instancier l'entité Entity entityfreshrocket = new EntityFreshRocket(world); //spawn de l'entité dans le monde world.spawnEntityInWorld(entityfreshrocket); //Enlever 1 au stack –stack.stackSize; return stack; } }EntityFreshRocket :
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(); } } }RenderFreshRocket :
package fr.freshblock.freshrocket.proxy; import java.util.HashMap; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import fr.freshblock.freshrocket.common.ModFreshrocket; import fr.freshblock.freshrocket.entity.projectile.EntityFreshRocket; import fr.freshblock.freshrocket.proxy.ModelRocket; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityPotion; import net.minecraft.item.ItemPotion; import net.minecraft.potion.PotionHelper; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; public class RenderFreshRocket extends Render { private static final ResourceLocation Textures = new ResourceLocation("freshrocket:textures/items/ModelRocket.png"); //Texture protected ModelBase modelProjectile = new ModelRocket(); //Model public RenderFreshRocket(ModelRocket modelRocket) { } 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 = ModFreshrocket.freshRocket.getIconFromDamage(0); 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(); } } @Override protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return TextureMap.locationItemsTexture; } private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_) { float f = p_77026_2_.getMinU(); float f1 = p_77026_2_.getMaxU(); float f2 = p_77026_2_.getMinV(); float f3 = p_77026_2_.getMaxV(); float f4 = 1.0F; float f5 = 0.5F; float f6 = 0.25F; GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); p_77026_1_.startDrawingQuads(); p_77026_1_.setNormal(0.0F, 1.0F, 0.0F); p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); p_77026_1_.draw(); } public void doRenderRocket(EntityFreshRocket var1, double var2, double var4, double var6, float var8, float var9) { GL11.glPushMatrix(); ModelRocket.render(var1,0,0,0,0,0.0625f); GL11.glPopMatrix(); } }ClientProxy :
package fr.freshblock.freshrocket.proxy; import cpw.mods.fml.client.registry.RenderingRegistry; import fr.freshblock.freshrocket.entity.projectile.EntityFreshRocket; import net.minecraft.client.Minecraft; import fr.freshblock.freshrocket.proxy.RenderFreshRocket; import fr.freshblock.freshrocket.proxy.ModelRocket; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityFreshRocket.class, new RenderFreshRocket(new ModelRocket())); } }ModelRocket :
// Date: 26/12/2015 14:12:20 // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package fr.freshblock.freshrocket.proxy; import fr.freshblock.freshrocket.entity.projectile.EntityFreshRocket; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelRocket extends ModelBase { //fields public ModelRenderer PartOfRocketFront1; public ModelRenderer PartOfRocketFront2; public ModelRenderer PartOfRocketFront3; public ModelRenderer PartOfRocketFront6; public ModelRenderer PartOfRocketFront7; public ModelRenderer PartOfRocketFront8; public ModelRenderer PartOfRocketFront4; public ModelRenderer PartOfRocketFront5; public ModelRenderer RocketBody; public ModelRenderer PartOfRocketBottom1; public ModelRenderer PartOfRocketBottom2; public ModelRenderer PartOfRocketBottom3; public ModelRenderer PartOfRocketBottom4; public ModelRenderer PartOfRocketBottom5; public ModelRenderer PartOfRocketBottom6; public ModelRenderer PartOfRocketFront9; public ModelRenderer PartOfRocketFront10; public ModelRenderer PartOfRocketFront11; public ModelRenderer PartOfRocketFront12; public ModelRenderer PartOfRocketFront13; public ModelRocket() { textureWidth = 64; textureHeight = 64; PartOfRocketFront1 = new ModelRenderer(this, 0, 0); PartOfRocketFront1.mirror = true; PartOfRocketFront1.addBox(0F, 0F, 0F, 3, 1, 1); PartOfRocketFront1.setRotationPoint(-2F, 15F, -7F); PartOfRocketFront1.setTextureSize(64, 32); setRotation(PartOfRocketFront1, 0F, 0F, 0F); PartOfRocketFront2 = new ModelRenderer(this, 0, 0); PartOfRocketFront2.mirror = true; PartOfRocketFront2.addBox(0F, 0F, 0F, 3, 1, 2); PartOfRocketFront2.setRotationPoint(-2F, 14F, -6F); PartOfRocketFront2.setTextureSize(64, 32); setRotation(PartOfRocketFront2, 0F, 0F, 0F); PartOfRocketFront3 = new ModelRenderer(this, 0, 0); PartOfRocketFront3.mirror = true; PartOfRocketFront3.addBox(0F, 0F, 0F, 3, 1, 2); PartOfRocketFront3.setRotationPoint(-2F, 16F, -6F); PartOfRocketFront3.setTextureSize(64, 32); setRotation(PartOfRocketFront3, 0F, 0F, 0F); PartOfRocketFront6 = new ModelRenderer(this, 0, 0); PartOfRocketFront6.mirror = true; PartOfRocketFront6.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketFront6.setRotationPoint(-1F, 15F, -8F); PartOfRocketFront6.setTextureSize(64, 64); setRotation(PartOfRocketFront6, 0F, 0F, 0F); PartOfRocketFront7 = new ModelRenderer(this, 0, 0); PartOfRocketFront7.mirror = true; PartOfRocketFront7.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketFront7.setRotationPoint(-1F, 14F, -7F); PartOfRocketFront7.setTextureSize(64, 64); setRotation(PartOfRocketFront7, 0F, 0F, 0F); PartOfRocketFront8 = new ModelRenderer(this, 0, 0); PartOfRocketFront8.mirror = true; PartOfRocketFront8.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketFront8.setRotationPoint(-1F, 16F, -7F); PartOfRocketFront8.setTextureSize(64, 64); setRotation(PartOfRocketFront8, 0F, 0F, 0F); PartOfRocketFront4 = new ModelRenderer(this, 0, 0); PartOfRocketFront4.mirror = true; PartOfRocketFront4.addBox(0F, 0F, 0F, 1, 1, 2); PartOfRocketFront4.setRotationPoint(1F, 15F, -5F); PartOfRocketFront4.setTextureSize(64, 64); setRotation(PartOfRocketFront4, 0F, 0F, 0F); PartOfRocketFront5 = new ModelRenderer(this, 0, 0); PartOfRocketFront5.mirror = true; PartOfRocketFront5.addBox(0F, 0F, 0F, 1, 1, 2); PartOfRocketFront5.setRotationPoint(-3F, 15F, -5F); PartOfRocketFront5.setTextureSize(64, 64); setRotation(PartOfRocketFront5, 0F, 0F, 0F); RocketBody = new ModelRenderer(this, 28, 0); RocketBody.mirror = true; RocketBody.addBox(0F, 0F, 0F, 1, 1, 7); RocketBody.setRotationPoint(-1F, 15F, -5F); RocketBody.setTextureSize(64, 64); setRotation(RocketBody, 0F, 0F, 0F); PartOfRocketBottom1 = new ModelRenderer(this, 0, 0); PartOfRocketBottom1.mirror = true; PartOfRocketBottom1.addBox(0F, 0F, 0F, 2, 3, 1); PartOfRocketBottom1.setRotationPoint(-1.5F, 14F, 2F); PartOfRocketBottom1.setTextureSize(64, 64); setRotation(PartOfRocketBottom1, 0F, 0F, 0F); PartOfRocketBottom2 = new ModelRenderer(this, 0, 0); PartOfRocketBottom2.mirror = true; PartOfRocketBottom2.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketBottom2.setRotationPoint(0F, 15F, 3F); PartOfRocketBottom2.setTextureSize(64, 64); setRotation(PartOfRocketBottom2, 0F, 0F, 0F); PartOfRocketBottom3 = new ModelRenderer(this, 0, 0); PartOfRocketBottom3.mirror = true; PartOfRocketBottom3.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketBottom3.setRotationPoint(-2F, 15F, 3F); PartOfRocketBottom3.setTextureSize(64, 64); setRotation(PartOfRocketBottom3, 0F, 0F, 0F); PartOfRocketBottom4 = new ModelRenderer(this, 0, 0); PartOfRocketBottom4.mirror = true; PartOfRocketBottom4.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketBottom4.setRotationPoint(-1F, 15F, 4F); PartOfRocketBottom4.setTextureSize(64, 64); setRotation(PartOfRocketBottom4, 0F, 0F, 0F); PartOfRocketBottom5 = new ModelRenderer(this, 0, 0); PartOfRocketBottom5.mirror = true; PartOfRocketBottom5.addBox(0F, 0F, -1F, 1, 1, 1); PartOfRocketBottom5.setRotationPoint(-1F, 14F, 4F); PartOfRocketBottom5.setTextureSize(64, 64); setRotation(PartOfRocketBottom5, 0F, 0F, 0F); PartOfRocketBottom6 = new ModelRenderer(this, 0, 0); PartOfRocketBottom6.mirror = true; PartOfRocketBottom6.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketBottom6.setRotationPoint(-0.9333333F, 16F, 3F); PartOfRocketBottom6.setTextureSize(64, 64); setRotation(PartOfRocketBottom6, 0F, 0F, 0F); PartOfRocketFront9 = new ModelRenderer(this, 0, 0); PartOfRocketFront9.mirror = true; PartOfRocketFront9.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketFront9.setRotationPoint(-0.4666667F, 15F, -4F); PartOfRocketFront9.setTextureSize(64, 64); setRotation(PartOfRocketFront9, 0F, 0F, 0F); PartOfRocketFront10 = new ModelRenderer(this, 0, 0); PartOfRocketFront10.mirror = true; PartOfRocketFront10.addBox(0F, 0F, 0F, 1, 1, 1); PartOfRocketFront10.setRotationPoint(-1.5F, 15F, -4F); PartOfRocketFront10.setTextureSize(64, 64); setRotation(PartOfRocketFront10, 0F, 0F, 0F); PartOfRocketFront11 = new ModelRenderer(this, 0, 0); PartOfRocketFront11.mirror = true; PartOfRocketFront11.addBox(0F, 0F, 0F, 1, 1, 2); PartOfRocketFront11.setRotationPoint(-1F, 13F, -5F); PartOfRocketFront11.setTextureSize(64, 64); setRotation(PartOfRocketFront11, 0F, 0F, 0F); PartOfRocketFront12 = new ModelRenderer(this, 0, 0); PartOfRocketFront12.mirror = true; PartOfRocketFront12.addBox(0F, 0F, 0F, 1, 1, 2); PartOfRocketFront12.setRotationPoint(-1F, 17F, -5F); PartOfRocketFront12.setTextureSize(64, 64); setRotation(PartOfRocketFront12, 0F, 0F, 0F); PartOfRocketFront13 = new ModelRenderer(this, 0, 0); PartOfRocketFront13.mirror = true; PartOfRocketFront13.addBox(0F, 0F, 0F, 3, 1, 1); PartOfRocketFront13.setRotationPoint(-2F, 15F, -6F); PartOfRocketFront13.setTextureSize(64, 64); setRotation(PartOfRocketFront13, 0F, 0F, 0F); } public void renderAll() { PartOfRocketFront1.render(0.0625F); PartOfRocketFront2.render(0.0625F); PartOfRocketFront3.render(0.0625F); PartOfRocketFront6.render(0.0625F); PartOfRocketFront7.render(0.0625F); PartOfRocketFront8.render(0.0625F); PartOfRocketFront4.render(0.0625F); PartOfRocketFront5.render(0.0625F); RocketBody.render(0.0625F); PartOfRocketBottom1.render(0.0625F); PartOfRocketBottom2.render(0.0625F); PartOfRocketBottom3.render(0.0625F); PartOfRocketBottom4.render(0.0625F); PartOfRocketBottom5.render(0.0625F); PartOfRocketBottom6.render(0.0625F); PartOfRocketFront9.render(0.0625F); PartOfRocketFront10.render(0.0625F); PartOfRocketFront11.render(0.0625F); PartOfRocketFront12.render(0.0625F); PartOfRocketFront13.render(0.0625F); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity ent) { super.setRotationAngles(0, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, ent); } public static void render(EntityFreshRocket var1, int i, int j, int k, int l, float f) { } } ``` Merci à tous ceux qui m'ont aidé jusque là ----------------------------------------- UP maintenant l'entité spawn devant le dispenser, va à une vitesse correcte, elle fait l'impact d'une boule de neige et il y a toujours un problème de rendu -
j’ai supprimé le message