RenderItem
-
Les entitées doivent être dans la méthode init, alors que tu l’as mis dans preInit
-
@Asonyx ah ok
-
@Asonyx re, désolé de te redéranger ,mais, je voudrais que l’entité n’explose que si elle atterrit sur un bloc. Comment faire ?
Mercipublic EntityDyna(World worldIn) { super(worldIn); } public EntityDyna(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } public EntityDyna(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public static void registerFixesSnowball(DataFixer fixer) { EntityThrowable.registerFixesThrowable(fixer, "Snowball"); } /** * Handler for {@link World#setEntityState} */ @SideOnly(Side.CLIENT) public void handleStatusUpdate(byte id) { if (id == 3) { for (int i = 0; i < 8; ++i) { this.world.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } } } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityBlaze) { i = 3; } result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i); world.createExplosion(this, this.posX, this.posY, this.posZ, 4.0F, true); this.setDead(); } if (!this.world.isRemote) { this.world.setEntityState(this, (byte)3); this.setDead(); } } -
Normalement, dans onImpact, tu peut utiliser une fonction qui s’appelle je crois isOnGround() qui retourne un boolean (je ne suis pas sûr)
Ou une fontion de result -
@Asonyx yas inGround et onGround mais aucun ne va.
-
Sinon tu vérifie si l’entité touchée est null
-
@Asonyx Comment ca ?
-
Tu fais :
if (result.entityHit == null) { //Le code quand la dynamite touche le sol } -
@Asonyx a dit dans RenderItem :
if (result.entityHit == null) { //Le code quand la dynamite touche le sol }
toujours pas…
if (result.entityHit.equals(null)) { world.createExplosion(this, this.posX, this.posY, this.posZ, 1.5F, true); this.setDead(); } -
Et ça :
if (result.entityHit != null) { } else { //Le code }