Résolu [+/- Résolu]Faire lancer une boule de feu par une entité
-
Rebonjour
J’ai essayer de créer une entité capable de jeter des boules de feu toute les 3 secondes mais je n’arrive pas a trouver le code pour lancer la boule de feu j’ai cherché dans la classe du ghast mais sans grand résultat.
Voila ma class de base sans grand chose a l’intérieur je peut poster ma class avec mes tentatives de codes si vous la voulez pour m’aiderMerci d’avance
Thegamer9112
package fr.minecraftforgefrance.mogame.common; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class EntityVlad extends EntityMob { private short timerEntity; private int explosionStrength = 1; private Entity targetedEntity; private static final String __OBFID = "CL_00001689"; public EntityVlad(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } protected void updateEntityActionState() { timerEntity++; if ( timerEntity == 160) { timerEntity = 0; } } }
-
ctrl + f en recherche tu met fireball et tu trouve ceci:
if (this.attackCounter == 20) { this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0); EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); entitylargefireball.field_92057_e = this.explosionStrength; double d8 = 4.0D; Vec3 vec3 = this.getLook(1.0F); entitylargefireball.posX = this.posX + vec3.xCoord * d8; entitylargefireball.posY = this.posY + (double)(this.height / 2.0F) + 0.5D; entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; this.worldObj.spawnEntityInWorld(entitylargefireball); this.attackCounter = -40; }
par exemple
ensuite fait attention j’ai vu une déclaration en rapport avec les fireball en commentaire
-
J’avais déjà vu ça donc voila le code que j’ai essayer mais cela fais crasher le jeu
package fr.minecraftforgefrance.mogame.common; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class EntityVlad extends EntityMob { private short timerEntity; private int explosionStrength = 1; private Entity targetedEntity; private static final String __OBFID = "CL_00001689"; public EntityVlad(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } protected void updateEntityActionState() { timerEntity++; if ( timerEntity == 160) { timerEntity = 0; this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); double d5 = this.targetedEntity.posX - this.posX; double d6 = this.targetedEntity.boundingBox.minY + (double)(this.targetedEntity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); double d7 = this.targetedEntity.posZ - this.posZ; this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0); EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); entitylargefireball.field_92057_e = this.explosionStrength; double d8 = 4.0D; Vec3 vec3 = this.getLook(1.0F); entitylargefireball.posX = this.posX + vec3.xCoord * d8; entitylargefireball.posY = this.posY + (double)(this.height / 2.0F) + 0.5D; entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; this.worldObj.spawnEntityInWorld(entitylargefireball); } } }
Voila aussi le crash-report si ça peut vous aidez.
–-- Minecraft Crash Report ---- // Ouch. That hurt :( Time: 23/10/14 21:30 Description: Ticking entity java.lang.NullPointerException: Ticking entity at fr.minecraftforgefrance.mogame.common.EntityVlad.updateEntityActionState(EntityVlad.java:41) at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:1987) at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:431) at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:39) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1814) at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250) at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2271) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) at net.minecraft.world.World.updateEntity(World.java:2231) at net.minecraft.world.World.updateEntities(World.java:2081) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at fr.minecraftforgefrance.mogame.common.EntityVlad.updateEntityActionState(EntityVlad.java:41) at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:1987) at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:431) at net.minecraft.entity.monster.EntityMob.onLivingUpdate(EntityMob.java:39) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1814) at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:250) at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:47) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2271) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) at net.minecraft.world.World.updateEntity(World.java:2231) -- Entity being ticked -- Details: Entity Type: vlad (fr.minecraftforgefrance.mogame.common.EntityVlad) Entity ID: 140 Entity Name: entity.vlad.name Entity's Exact location: -84,35, 89,00, 264,56 Entity's Block location: World: (-85,89,264), Chunk: (at 11,5,8 in -6,16; contains blocks -96,0,256 to -81,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0,00, -0,08, 0,00 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2081) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) -- Affected level -- Details: Level name: Test All players: 1 total; [EntityPlayerMP['Player432'/368, l='Test', x=-67,92, y=79,00, z=261,96]] Chunk stats: ServerChunkCache: 739 Drop: 0 Level seed: 1092869606416780975 Level generator: ID 00 - default, ver 1\. Features enabled: true Level generator options: Level spawn location: World: (-60,64,228), Chunk: (at 4,4,4 in -4,14; contains blocks -64,0,224 to -49,255,239), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 2764 game time, 2764 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 101220 (now: false), thunder time: 174972 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) – System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 848298528 bytes (809 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.05 FML v7.10.25.1206 Minecraft Forge 10.13.0.1206 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{7.10.25.1206} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1206.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.13.0.1206} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1206.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available mogame{1.0.0} [Mo'game] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player432'/368, l='Test', x=-67,92, y=79,00, z=261,96]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
J’attend avec espoir une réponse de votre part.
-
targetedEntity est pas défini donc t’as un NPE ^^’
-
Très bien mais cependant je ne vois pas comment la définir car j’ai bien mis
private Entity targetedEntity; this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D);
donc je ne vois vraiment pas où il faut définir targetedEntity…
-
Tout d’abord, je pense que la NPE est lancée parce qu’il n’y a pas de joueur aux environs.
Essaie comme cela, ça devrait marcher:
package com.flareheat.mineventure.entity.boss; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class EntityVlad extends EntityMob { private short timerEntity; private int explosionStrength = 1; public EntityVlad(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } @Override public void attackEntity(Entity entity, float value) { if (this.timerEntity == 0) { double xPos = entity.posX - posX; double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F)); double zPos = entity.posZ - posZ; float sqrt = MathHelper.sqrt_float(value) * 0.5F; worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0); EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt)); fireball.posY = posY + (height / 2.0F) + 0.5D; fireball.field_92057_e = explosionStrength; worldObj.spawnEntityInWorld(fireball); } } protected void updateEntityActionState() { timerEntity++; if (timerEntity == 160) { timerEntity = 0; } } }
-
… implements IRangedAttackMob //plutôt simple non ?
Je dis ça, je dis rien
(Je te laisse mijoter un peu) -
toss, ça ne marcheras pas, car il semble que TheGamer9112 ne veux pas utiliser les AI (selon son code), or la méthode attackEntityWithRangedAttack(…) est appelée dans la classe EntityAIArrowAttack, il faudrait donc activer l’AI pour l’utiliser. De plus pour cela il faudrait faire une nouvelle classe d’AI pour les boules de feu, tu compliques vraiment les choses
-
AlphaSwittleTeam avec ton code le jeu ne crash pas mais les EntityVlad ne lance pas de boules de feus
Il faut peut être leur mettre une ai pour qu’il attaque le joueur car la il ne se dirige même pas vers moi -
D’accord, une seconde je corrige
Edit: après tests, il s’avère que le mob lance bien des boules de feu, il suffisait d’attendre
Je remets le code au cas où:
import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityVlad extends EntityMob { private short timerEntity; private int explosionStrength = 1; public EntityVlad(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } @Override public void attackEntity(Entity entity, float value) { if (this.timerEntity == 0) { double xPos = entity.posX - posX; double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F)); double zPos = entity.posZ - posZ; float sqrt = MathHelper.sqrt_float(value) * 0.5F; worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0); EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt)); fireball.posY = posY + (height / 2.0F) + 0.5D; fireball.field_92057_e = explosionStrength; worldObj.spawnEntityInWorld(fireball); } } protected void updateEntityActionState() { super.updateEntityActionState(); timerEntity++; if (timerEntity == 50) { timerEntity = 0; } } }
-
je vais manger je te dis si ça fonctionne des que je reviens.
-
Et moi entre temps je dois sortir, je verrais le sujet quand je reviendrais, sur ce bonne chance
-
Ok ça fonctionne perfect merci beaucoup de ton aide et j’ai une dernière question si jamais j’utilise cet entity:
package mrplaigon.psccraft.minesagasmod.common; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityGiantZombie; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityBalleGun extends EntityThrowable { public EntityBalleGun(World par1World) { super(par1World); } public EntityBalleGun(World par1World, EntityLivingBase par2EntityLivingBase) { super(par1World, par2EntityLivingBase); } public EntityBalleGun(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } @Override protected void onImpact(MovingObjectPosition par1MovingObjectPosition) { if (par1MovingObjectPosition.entityHit != null) { byte degat = 100; //par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), degat); /**if (!this.worldObj.isRemote) { worldObj.newExplosion(null, par1MovingObjectPosition.entityHit.posX, par1MovingObjectPosition.entityHit.posY, par1MovingObjectPosition.entityHit.posZ, 2.0F, false, true); }*/ //par1MovingObjectPosition.entityHit.setFire(10);//l'argument int de la méthode est la durée en seconde /**EntityLivingBase entitylivingbase = (EntityLivingBase) par1MovingObjectPosition.entityHit; entitylivingbase.addPotionEffect(new PotionEffect(Potion.poison.id, 6 * 20, 10));//2eme argument en int c'est la durée , 3ème argument c'est la puissance de l'effet*/ /** worldObj.addWeatherEffect(new EntityLightningBolt(Minecraft.getMinecraft().theWorld, par1MovingObjectPosition.entityHit.posX, par1MovingObjectPosition.entityHit.posY, par1MovingObjectPosition.entityHit.posZ)); par1MovingObjectPosition.entityHit.setDead();*/ /**EntityGiantZombie entityGiantZombie = new EntityGiantZombie (worldObj); entityGiantZombie.setLocationAndAngles(this.lastTickPosX, this.lastTickPosY, this.lastTickPosZ, this.rotationYaw, this.rotationPitch); worldObj.spawnEntityInWorld(entityGiantZombie);*/ /** A REVOIR SIU TU PEUX worldObj.setThunderStrength(10.5F);*/ } for (int i = 0; i < 1; ++i) { //this.worldObj.spawnParticle("largesmoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); /**if (!this.worldObj.isRemote) { worldObj.newExplosion(null, par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY, par1MovingObjectPosition.blockZ, 3.5F, false, true); }*/ /**this.worldObj(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY + 1, par1MovingObjectPosition.blockZ, Blocks.fire); this.worldObj.setBlock(par1MovingObjectPosition.blockX, par1MovingObjectPosition.blockY + 1, par1MovingObjectPosition.blockZ + 1, Blocks.fire);*/ } if (!this.worldObj.isRemote) { this.setDead(); } } }
a la place de l’entityfireball ça peut fonctionner a ton avis??
-
Ok merci ça fonctionne très bien!!
ais je voulais mettre un peu plus de code dans cette entity donc j’ai essayé de faire qu’elle voit le joueur de moins loin voila le code que j’ai fait:package fr.minecraftforgefrance.mogame.common; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityVlad extends EntityMob { private short timerEntity; private int explosionStrength = 1; private Entity currentTarget; public EntityVlad(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } @Override public void attackEntity(Entity entity, float value) { if (this.timerEntity == 0) { double xPos = entity.posX - posX; double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F)); double zPos = entity.posZ - posZ; float sqrt = MathHelper.sqrt_float(value) * 0.5F; worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0); EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt)); fireball.posY = posY + (height / 2.0F) + 0.5D; fireball.field_92057_e = explosionStrength; worldObj.spawnEntityInWorld(fireball); } } protected void updateEntityActionState() { super.updateEntityActionState(); timerEntity++; if (timerEntity == 50) { timerEntity = 0; float f = 1.0F; if (this.rand.nextFloat() < 0.02F) { EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, (double)f); if (entityplayer != null) { this.currentTarget = entityplayer; this.numTicksToChaseTarget = 10 + this.rand.nextInt(20); } else { this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F; } } if (this.currentTarget != null) { this.faceEntity(this.currentTarget, 10.0F, (float)this.getVerticalFaceSpeed()); if (this.numTicksToChaseTarget– <= 0 || this.currentTarget.isDead || this.currentTarget.getDistanceSqToEntity(this) > (double)(f * f)) { this.currentTarget = null; } } else { if (this.rand.nextFloat() < 0.05F) { this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F; } this.rotationYaw += this.randomYawVelocity; this.rotationPitch = this.defaultPitch; } } } }
Mais le Problème c’est que j’ai l’impression que ça fonctionne pas
Encore une fois c’est surement du a mon manque de connaissance en modding. -
Je vais tester et te dire
Edit:
package com.flareheat.mineventure.entity.boss; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityVlad extends EntityMob implements IBossDisplayData { private short timerEntity; private final int explosionStrength; private final double distance; public EntityVlad(World world) { super(world); timerEntity = 0; explosionStrength = 1; distance = 8D; } @Override public void applyEntityAttributes() { super.applyEntityAttributes(); getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D); getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } @Override public void attackEntity(Entity entity, float value) { if (timerEntity == 0) { final double xPos = entity.posX - posX; final double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F)); final double zPos = entity.posZ - posZ; final float sqrt = MathHelper.sqrt_float(value) * 0.5F; worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0); final EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt)); fireball.posY = posY + (height / 2.0F) + 0.5D; fireball.field_92057_e = explosionStrength; worldObj.spawnEntityInWorld(fireball); } } @Override protected void updateEntityActionState() { super.updateEntityActionState(); timerEntity++; if (timerEntity == 50) { timerEntity = 0; } } @Override public Entity findPlayerToAttack() { final EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, distance); if (entityplayer != null) { return entityplayer; } else { return null; } } @Override public boolean attackEntityFrom(DamageSource damagesource, float f) { return super.attackEntityFrom(damagesource, f); } @Override protected boolean canDespawn() { return false; } @Override protected void updateArmSwingProgress() { super.updateArmSwingProgress(); } }
-
Ok je viens de tester ça fonctionne très bien mais le problème c’est que une fois qu’il nous a vu il ne nous lâche plus…
Et je sais pas comment faire qu’il nous lâche plus tôt. -
je dis sa comme sa mais de base dans minecraft aucun mob te lache sauf si tu sors de son champ de vision donc a priori t’a juste a tracer et il te lachera
sinon faut réduire son champ de vision ( je ne sais pas comment sa marche par contre ) -
Essaye ça:
package com.flareheat.mineventure.entity.boss; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityLargeFireball; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityVlad extends EntityMob implements IBossDisplayData { private short timerEntity; private final int explosionStrength; private final double distance; public EntityVlad(World world) { super(world); timerEntity = 0; explosionStrength = 1; distance = 8D; } @Override public void applyEntityAttributes() { super.applyEntityAttributes(); getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D); getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D); getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0?D); getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D); } @Override public void attackEntity(Entity entity, float value) { if (timerEntity == 0) { final double xPos = entity.posX - posX; final double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F)); final double zPos = entity.posZ - posZ; final float sqrt = MathHelper.sqrt_float(value) * 0.5F; worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0); final EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt)); fireball.posY = posY + (height / 2.0F) + 0.5D; fireball.field_92057_e = explosionStrength; worldObj.spawnEntityInWorld(fireball); } } @Override protected void updateEntityActionState() { super.updateEntityActionState(); timerEntity++; if (timerEntity == 50) { timerEntity = 0; } } @Override public Entity findPlayerToAttack() { final EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, distance); if (entityplayer != null && canEntityBeSeen(entityplayer)) { return entityplayer; } else { setTarget(null); return null; } } }
-
Ok mais dsl je viens de comprendre mon erreur en fait ce que je voulais dire c’est qu’elle arrête de lancer des boules de feus mais il suffit de rajouter && canEntityBeSeen(entityplayer) dans la condition du timer.
-
donc ton problème est résolu ?