Créer des effets de potions
-
C est cette ligne
- if (event.entityLiving.isPotionActive(BOTIEffect.superPowersFlash))
-
Ah ok merci! J’etais bloqué et tu me rend extrêmement service

-
Déjà tu devais lire le tutoriel sur les event car le code que tu as mit ne risque pas du tout de fonctionner …
Et 24h entre chaque message, merci de respecter le règlement. -
J’ai mis le code, suivis le tuto sur les events mais je ne sais pas par quoi remplacer
:::
[size=xx-smallBOTIEffect][size=xx-small.][size=xx-smallsuperPowersFlash]
:::J’ai remplacer BOTIEffect par SomniferePotionEffect, mais pour le superPowersFlash je ne sais pas quoi mettre car sinon ca fais une erreur…
Et la j’ai pas besoin d’attendre 24h pour répondre non ? Car tu as mis un message toi non?
-
Oui, 24h entre deux posts de la même personne, dans l’autre cas il suffit d’éditer le message …
C’est presque la même règle sur tous les forums, ça évite le spam.Logiquement tu mets ClassOuSeTrouveLaDeclarationDeLaPotion.nomDuField
ça c’est la base en Java, il faut l’apprendre (il y a un bon tutoriel sur OpenClassRoom) sinon tu n’arrivera à rien. -
Je vais suivre ce tuto des que je peux
Mais OpenClassRoom c’est le site du zero non ? -
Oui. Ils ont changés de nom depuis un bon moment.
-
Alors j’ai suivis vos conseils à la lettre mais ca n’a aucun effet (j’ai bien l’effet mais lui n’en a aucun, je sais ma phrase est bizzard… un effet sans effet)
Mes codes:
:::package com.harrypotter.sosoh.common; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventHandler { @SubscribeEvent public void LivingEvent(LivingEvent event){ if(event.entityLiving instanceof EntityPlayer) { if (event.entityLiving.isPotionActive(SomniferePotionEffect.somniferePotionEffect)){ if (event.entityLiving.getActivePotionEffect(SomniferePotionEffect.somniferePotionEffect).getDuration() == 0){ event.entityLiving.removePotionEffect(SomniferePotionEffect.somniferePotionEffect.id); return; } if (event.entityLiving.worldObj.isRemote){ if(event.entityLiving.onGround){ event.entityLiving.motionX *= 5.0F; event.entityLiving.motionZ *= 5.0F; } } } } } }package com.harrypotter.sosoh.common; import java.awt.Color; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Type; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.potion.Potion; public class SomniferePotionEffect extends Potion{ public static SomniferePotionEffect somniferePotionEffect; public static int SomniferePotionEffectID; protected SomniferePotionEffect(int id, boolean isBadEffectOrNot, int color, String name) { super(id, isBadEffectOrNot, color); this.setPotionName("potion." + name); } @Override public SomniferePotionEffect setIconIndex(int x, int y) { super.setIconIndex(x, y); return this; } public static void loadEffects() { somniferePotionEffect = new SomniferePotionEffect(SomniferePotionEffectID, true, Color.LIGHT_GRAY.getRGB(), "somniferePotionEffect").setIconIndex(4, 1); } public static void register() { SomniferePotionEffect.potionTypes[somniferePotionEffect.getId()] = somniferePotionEffect; } }package com.harrypotter.sosoh.common; import com.harrypotter.sosoh.common.blocks.BlockChaudron; import com.harrypotter.sosoh.common.blocks.TileEntityChaudron; import com.harrypotter.sosoh.common.creativetabs.CreativeTabsHPB; import com.harrypotter.sosoh.common.creativetabs.CreativeTabsHPF; import com.harrypotter.sosoh.common.creativetabs.CreativeTabsHPP; import com.harrypotter.sosoh.common.items.ItemBaguette1; import com.harrypotter.sosoh.common.items.ItemBaguette2; import com.harrypotter.sosoh.common.items.ItemBaguette3; import com.harrypotter.sosoh.common.items.ItemBiere; import com.harrypotter.sosoh.common.items.ItemChocogrenouille; import com.harrypotter.sosoh.common.items.ItemChope; import com.harrypotter.sosoh.common.items.ItemDragees; import com.harrypotter.sosoh.common.items.ItemJusCitrouille; import com.harrypotter.sosoh.common.items.ItemPaquetDragees; import com.harrypotter.sosoh.common.items.ItemRhumGroseille; import com.harrypotter.sosoh.common.items.ItemSucacide; import com.harrypotter.sosoh.common.items.ItemTabletteChocolat; import com.harrypotter.sosoh.common.items.ItemVerreVide; import com.harrypotter.sosoh.common.items.ItemVinOrtie; import com.harrypotter.sosoh.common.items.ItemVinSureau; import com.harrypotter.sosoh.proxy.CommonProxy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.potion.Potion; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; 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.GameRegistry; @Mod(modid = "modharrypotter", name = "Mod Harry Potter", version = "1.0.0") public class ModHarryPotter{ //Nourritures public static Item itemChocogrenouille, itemPaquetDragees, itemDragees, itemSucacide, itemTabletteChocolat, itemVerreVide, itemVinOrtie, itemVinSureau, itemChope, itemBiere, itemRhumGroseille, itemJusCitrouille; //Baguettes public static Item itemBaguette1, itemBaguette2, itemBaguette3; //Plantes //Potions public static Block blockChaudron; public static Item itemPotionTueLoup; //Creative Tabs public static CreativeTabs creativetabsHPF, creativetabsHPB, creativetabsHPP; // public static final String MODID = "modharrypotter"; @Instance("modharrypotter") public static ModHarryPotter instance; @SidedProxy(clientSide = "com.harrypotter.sosoh.proxy.ClientProxy", serverSide = "com.harrypotter.sosoh.proxy.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { //Creative Tabs creativetabsHPF = new CreativeTabsHPF("creative_tabs_hpf"); creativetabsHPB = new CreativeTabsHPB("creative_tabs_hpb"); creativetabsHPP = new CreativeTabsHPP("creative_tabs_hpp"); //Nourriture itemChocogrenouille = new ItemChocogrenouille(6,0.5F,false).setUnlocalizedName("chocogrenouille"); GameRegistry.registerItem(itemChocogrenouille, "item_chocogrenouille", ModHarryPotter.MODID); itemDragees = new ItemDragees(1,0.4F,false).setUnlocalizedName("dragees"); GameRegistry.registerItem(itemDragees, "item_dragees", ModHarryPotter.MODID); itemPaquetDragees = new ItemPaquetDragees().setUnlocalizedName("paquetdragees"); GameRegistry.registerItem(itemPaquetDragees, "item_paquet_dragees", ModHarryPotter.MODID); itemSucacide = new ItemSucacide(3, 0.5F, false).setUnlocalizedName("sucacide"); GameRegistry.registerItem(itemSucacide, "item_sucacide", ModHarryPotter.MODID); itemTabletteChocolat = new ItemTabletteChocolat(4,1.0F,false).setUnlocalizedName("tablettechocolat"); GameRegistry.registerItem(itemTabletteChocolat, "item_tablettechocolat", ModHarryPotter.MODID); itemVerreVide = new ItemVerreVide().setUnlocalizedName("verrevide"); GameRegistry.registerItem(itemVerreVide, "item_verrevide", ModHarryPotter.MODID); itemVinOrtie = new ItemVinOrtie(4, 0.6F, false).setUnlocalizedName("vinortie"); GameRegistry.registerItem(itemVinOrtie, "item_vinortie", ModHarryPotter.MODID); itemVinSureau = new ItemVinSureau(4, 0.8F, false).setUnlocalizedName("vinsureau"); GameRegistry.registerItem(itemVinSureau, "item_vinsureau", ModHarryPotter.MODID); itemBiere = new ItemBiere(6, 0.7F, false).setUnlocalizedName("biere"); GameRegistry.registerItem(itemBiere, "item_biere", ModHarryPotter.MODID); itemChope = new ItemChope().setUnlocalizedName("chope"); GameRegistry.registerItem(itemChope, "item_chope", ModHarryPotter.MODID); itemRhumGroseille = new ItemRhumGroseille(6, 0.7F, false).setUnlocalizedName("rhumgroseille"); GameRegistry.registerItem(itemRhumGroseille, "item_rhumgroseille", ModHarryPotter.MODID); itemJusCitrouille = new ItemJusCitrouille(3, 1.0F, false).setUnlocalizedName("juscitrouille"); GameRegistry.registerItem(itemJusCitrouille, "item_juscitrouille", ModHarryPotter.MODID); //Baguettes itemBaguette1 = new ItemBaguette1().setUnlocalizedName("baguette1"); GameRegistry.registerItem(itemBaguette1, "item_baguette_1", ModHarryPotter.MODID); itemBaguette2 = new ItemBaguette2().setUnlocalizedName("baguette2"); GameRegistry.registerItem(itemBaguette2, "item_baguette_2", ModHarryPotter.MODID); itemBaguette3 = new ItemBaguette3().setUnlocalizedName("baguette3"); GameRegistry.registerItem(itemBaguette3, "item_baguette_3", ModHarryPotter.MODID); //Plantes //Potions blockChaudron = new BlockChaudron(Material.iron).setBlockName("chaudron"); GameRegistry.registerBlock(blockChaudron, "block_chaudron"); GameRegistry.registerTileEntity(TileEntityChaudron.class, "ModHarryPotter.MODID:BlockChaudron"); SomniferePotionEffect.SomniferePotionEffectID = 30; } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRender(); //Potions SomniferePotionEffect.loadEffects(); SomniferePotionEffect.register(); MinecraftForge.EVENT_BUS.register(new com.harrypotter.sosoh.common.EventHandler()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }:::
-
Remplace la condition
if (event.entityLiving.worldObj.isRemote){
par l’inverse :
if (!event.entityLiving.worldObj.isRemote){Voir enlève-la totalement si ce n’est toujours pas bon.
-
Je fais ca dessuite et j’edit mon post pour te dire si ça a marcher !

Edit:Si je remplace ça ne marche pas. Et quand je mets rien ca marche merci !
-
Il est fortement pas recommandé d’appeler deux classes avec le même nom EventHandler existe deja change le nkm de la classe et vois si le problème persiste
Envoyé depuis mon Android edition by sfr STARADDICT avec Tapatalk
-
Et au niveau des amplifier car de 1 on ne le voit pas dans l’inventaire. Et de 2 si j’essaie de faire une condition pour get l’amplifier de ma potion je récolte un magnifique NPE
Merci d’avance -
Salut est-il possible de faire un effet de potion que quand tu tombe tu flotte comme l’entity poule

-
Dans LivingUpdateEvent tu check si le block en dessous du joueur est de l’air et si l’effet de potion est actif, alors tu modifies son motionY ou sa vélocité.
-
@‘Plaigon’:
Dans LivingUpdateEvent tu check si le block en dessous du joueur est de l’air et si l’effet de potion est actif, alors tu modifies son motionY ou sa vélocité.
Merci

-
Ce message a été supprimé ! -
bonjour, je sais j arrive un peut tard mais serait il possible de faire un effet de potion qui fait que tu ne prend pas de dégât de chute ?
EDIT:oui mais je ne sais pas comment annuler les dégats de chute
-
@Heaven Ca existe déjà, c’est la potion Slow Falling.
Sinon, tu crée ton effet de potion et dans l’évent
LivingFallEventTu annule les dégâts de chutes si la potion est active.
-
oui mais je ne sais malheureusement pas comment désactiver les dégats de chute voici mon code :
public class EventHandler { @SubscribeEvent public void LivingEvent(LivingEvent event){ if(event.entityLiving instanceof EntityPlayer) { if (event.entityLiving.isPotionActive(CustomPotion.FeatherFoaling)){ if (event.entityLiving.getActivePotionEffect(CustomPotion.FeatherFoaling).getDuration() == 0){ event.entityLiving.removePotionEffect(CustomPotion.FeatherFoaling.id); return; } if(event.entityLiving.onGround){ event.entityLiving.motionX *= 5.0F; event.entityLiving.motionZ *= 5.0F; } } } } } -
Bonjour,
Avecevent.setCancel(true);(ça fait partie des méthodes de base des event …).