Help : L'oxygene
-
Oui ^^
Par contre je sais pas trop comment m’y prendre pour la suffocation
quelqu’un peut m’aider ? -
Mince

Je viens de penser au fait qu’il faut créer un nouveau type de dommages sinon la suffocation normal c’est dans un mur…
Je regarde ce que je peux faireEDIT : Le DamageSource est en protected

protected DamageSource(String par1Str)EDIT2 : Bon je crois que le code c’est bon, j’ai du recopier toute la class DamageSource car 99% des méthodes sont en protected ou en private
-
Pas de problème ^^
Fais une classe qui extends de DamageSource
-
Nope la class voit pas les .setMachinTruc, je sais pas pourquoi
-
Pour détecter si un bloc d’oxygène peut vivre, tu peux faire cette condition :
Toucher le bloc générateur d’oxygène / un autre bloc d’oxygène.
Ne pas être en contact avec trop de blocs d’air ( Pour faire en sorte que l’oxygène meurts sur la surface de la lune en se dissipant )
-
Bon je crois que c’est bon pour les damage source (il faut que je fasse un tuto dessus!)
EDIT :
Code à mettre dans la class (pense à remplacer NomDeLaClass par… le nom de la class :dodgy:) :import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityFireball; import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSource; import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.StatCollector; import net.minecraft.world.Explosion; /** This whole code is a high-modified copy of DamageSource. * Original code is from Minecraft * @author utybo * */ public class NomDeLaClass extends DamageSource { public static DamageSource moonSuffocation = (new NomDeLaClass("moonSuffocation")).setDamageBypassesArmor().setDamageAllowedInCreativeMode(); public NomDeLaClass(String par1Str) { super(par1Str); this.damageType = par1Str; } protected NomDeLaClass setDamageBypassesArmor() { this.isUnblockable = true; this.hungerDamage = 0.0F; return this; } private boolean isUnblockable; private boolean isDamageAllowedInCreativeMode; private float hungerDamage = 0.3F; /** This kind of damage is based on fire or not. */ private boolean fireDamage; /** This kind of damage is based on a projectile or not. */ private boolean projectile; /** * Whether this damage source will have its damage amount scaled based on the current difficulty. */ private boolean difficultyScaled; private boolean magicDamage; private boolean explosion; public String damageType; public static DamageSource causeMobDamage(EntityLivingBase par0EntityLivingBase) { return new EntityDamageSource("mob", par0EntityLivingBase); } /** * returns an EntityDamageSource of type player */ public static DamageSource causePlayerDamage(EntityPlayer par0EntityPlayer) { return new EntityDamageSource("player", par0EntityPlayer); } /** * returns EntityDamageSourceIndirect of an arrow */ public static DamageSource causeArrowDamage(EntityArrow par0EntityArrow, Entity par1Entity) { return (new EntityDamageSourceIndirect("arrow", par0EntityArrow, par1Entity)).setProjectile(); } public static DamageSource causeThrownDamage(Entity par0Entity, Entity par1Entity) { return (new EntityDamageSourceIndirect("thrown", par0Entity, par1Entity)).setProjectile(); } /** * Returns the EntityDamageSource of the Thorns enchantment */ public static DamageSource causeThornsDamage(Entity par0Entity) { return (new EntityDamageSource("thorns", par0Entity)).setMagicDamage(); } public static DamageSource setExplosionSource(Explosion par0Explosion) { return par0Explosion != null && par0Explosion.getExplosivePlacedBy() != null ? (new EntityDamageSource("explosion.player", par0Explosion.getExplosivePlacedBy())).setDifficultyScaled().setExplosion() : (new NomDeLaClass("explosion")).setDifficultyScaled().setExplosion(); } /** * Returns true if the damage is projectile based. */ public boolean isProjectile() { return this.projectile; } /** * Define the damage type as projectile based. */ public NomDeLaClass setProjectile() { this.projectile = true; return this; } public boolean isExplosion() { return this.explosion; } public NomDeLaClass setExplosion() { this.explosion = true; return this; } public boolean isUnblockable() { return this.isUnblockable; } /** * How much satiate(food) is consumed by this DamageSource */ public float getHungerDamage() { return this.hungerDamage; } public boolean canHarmInCreative() { return this.isDamageAllowedInCreativeMode; } public Entity getSourceOfDamage() { return this.getEntity(); } public Entity getEntity() { return null; } protected NomDeLaClass setDamageAllowedInCreativeMode() { this.isDamageAllowedInCreativeMode = true; return this; } /** * Define the damage type as fire based. */ protected NomDeLaClass setFireDamage() { this.fireDamage = true; return this; } /** * Returns the message to be displayed on player death. */ public ChatMessageComponent getDeathMessage(EntityLivingBase par1EntityLivingBase) { EntityLivingBase entitylivingbase1 = par1EntityLivingBase.func_94060_bK(); String s = "death.attack." + this.damageType; String s1 = s + ".player"; return entitylivingbase1 != null && StatCollector.func_94522_b(s1) ? ChatMessageComponent.createFromTranslationWithSubstitutions(s1, new Object[] {par1EntityLivingBase.getTranslatedEntityName(), entitylivingbase1.getTranslatedEntityName()}): ChatMessageComponent.createFromTranslationWithSubstitutions(s, new Object[] {par1EntityLivingBase.getTranslatedEntityName()}); } /** * Returns true if the damage is fire based. */ public boolean isFireDamage() { return this.fireDamage; } /** * Return the name of damage type. */ public String getDamageType() { return this.damageType; } /** * Set whether this damage source will have its damage amount scaled based on the current difficulty. */ public NomDeLaClass setDifficultyScaled() { this.difficultyScaled = true; return this; } /** * Return whether this damage source will have its damage amount scaled based on the current difficulty. */ public boolean isDifficultyScaled() { return this.difficultyScaled; } /** * Returns true if the damage is magic based. */ public boolean isMagicDamage() { return this.magicDamage; } /** * Define the damage type as magic based. */ public NomDeLaClass setMagicDamage() { this.magicDamage = true; return this; } }Code à mettre après les conditions et la méthode d’activation :
par3EntityPlayer.attackEntityFrom(NomDeLaClass.moonSuffocation, demi-coeurs);(Demi-coeurs est un float)
A mettre dans le fichier .lang :
death.attack.moonSuffocation=%1$s suffocated because of a lack of oxygen -
Merci beaucoup
mais il y a un truc que je comprends pas
par3EntityPlayer.attackEntityFrom(NomDeLaClass.moonSuffocation, demi-coeurs);je met sa ou je vois pas ou il faut le mettre
-
Après les codes “Si on est dans la dimension X et que je ne suis pas en contact avec un bloc d’oxygène”.
Si tu veux que cela tue en un coup, mets le nombre de demi-coeurs à 20 sinon il faut faire un boucle et je ne sais pas comment faire… -
Ou au pire autant utiliser la reflection java… xD
-
Moi et la reflexion java ça fait 2…
-
Euhhh du coup je fais quoi ? ^^
je suis un peu perdu dans le vide intersideral du code java xD