MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    addPotionEffect > Failed to handle packet

    Planifier Épinglé Verrouillé Déplacé Résolu 1.12.x
    1.12.2
    3 Messages 2 Publieurs 203 Vues 2 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • KporalK Hors-ligne
      Kporal
      dernière édition par

      Bien le bonjour, bon le souci est déjà dans le titre, pour faire court j’ajoute des effets de potion sur mon armure de cette manière :

      package com.kporal.mcplus.items;
      
      import com.kporal.mcplus.Main;
      
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.EntityPlayerMP;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.init.MobEffects;
      import net.minecraft.inventory.EntityEquipmentSlot;
      import net.minecraft.item.ItemArmor;
      import net.minecraft.item.ItemStack;
      import net.minecraft.potion.Potion;
      import net.minecraft.potion.PotionEffect;
      import net.minecraft.world.World;
      
      public class DragoonArmor extends ItemArmor {
      
      	public DragoonArmor( ArmorMaterial material, EntityEquipmentSlot slot, String name ) {
      		super( material, 0, slot );
      		this.setRegistryName( name );
      		this.setTranslationKey( name );
      		this.setCreativeTab( Main.mcptab );
      	}
      	
      	@Override
      	public void onArmorTick( World w, EntityPlayer p, ItemStack i ) {
      		
      		if( p instanceof EntityPlayerMP ) { // Test mais crash quand même
      			p = ( EntityPlayerMP ) p;
      		}
      		
      		InventoryPlayer inv = p.inventory;
      			
      		if( inv.armorItemInSlot( 0 ).getItem() == Main.cursedBoots ) {
      			potionEffect( p, MobEffects.FIRE_RESISTANCE, 5, 1, false, false );
      		}
      		if( inv.armorItemInSlot( 1 ).getItem() == Main.cursedLegs ) {
      			potionEffect( p, MobEffects.SPEED, 5, 0, false, false );
      		}
      		if( inv.armorItemInSlot( 2 ).getItem() == Main.cursedChest ) {
      			potionEffect( p, MobEffects.REGENERATION, 5, 0, false, false );
      		}
      		if( inv.armorItemInSlot( 3 ).getItem() == Main.cursedHelmet ) {
      			potionEffect( p, MobEffects.NIGHT_VISION, 5, 2, false, false );
      		}
      	}
      	
      	private int secondToTicks( int s ) {
      		return s * 20;
      	}
      	
      	private void potionEffect( EntityPlayer player, Potion e, int t, int p, boolean ambiant, boolean particle ) {
      		if( player.getActivePotionEffect( e ) == null ) {
      			player.addPotionEffect( new PotionEffect( e, secondToTicks( t ), p, ambiant, particle ));
      		}
      	}
      }
      

      Ce qui fonctionne sans problème, en local évidement, par contre une fois le mod placer sur mon serveur dev et mon mc officiel et que j’équipe mon armure j’obtiens cette erreur ( et je en comprend pas trop pourquoi ) :

      [10:52:43] [Server thread/WARN] [net.minecraft.network.NetworkSystem]: Failed to handle packet for /192.168.1.1:51949
      net.minecraft.util.ReportedException: Ticking player
      	at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:459) ~[oq.class:?]
      	at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:173) ~[pa.class:?]
      	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:209) ~[NetworkDispatcher$1.class:?]
      	at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285) ~[gw.class:?]
      	at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180) [oz.class:?]
      	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790) [MinecraftServer.class:?]
      	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
      	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
      	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
      	at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
      Caused by: java.lang.NoSuchMethodError: net.minecraft.entity.player.InventoryPlayer.func_70440_f(I)Lnet/minecraft/item/ItemStack;
      	at com.kporal.mcplus.items.DragoonArmor.onArmorTick(DragoonArmor.java:35) ~[DragoonArmor.class:?]
      	at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:371) ~[aec.class:?]
      	at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:511) ~[aed.class:?]
      	at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2172) ~[vp.class:?]
      	at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:234) ~[aed.class:?]
      	at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:382) ~[oq.class:?]
      	... 9 more
      

      Des idées ?

      Check out my mod : https://www.curseforge.com/minecraft/mc-mods/eygo

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002R Hors-ligne
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
        dernière édition par

        Bonjour,

        La fonction armorItemInSlot(index) ne serait pas client side only ? Si oui, il faut utiliser une autre fonction.

        1 réponse Dernière réponse Répondre Citer 0
        • KporalK Hors-ligne
          Kporal
          dernière édition par

          Problème résolu, grossière erreur de ma pars d’autant plus que … hum je cherche à récupérer inutilement un slot précis alors que la fonction donne par défaut … et oui l’item en question ( le recule est censé être bien mais parfois on se sent juste con 😄 )

          package com.kporal.mcplus.items;
          
          import com.kporal.mcplus.Main;
          
          import net.minecraft.creativetab.CreativeTabs;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.entity.player.EntityPlayerMP;
          import net.minecraft.entity.player.InventoryPlayer;
          import net.minecraft.init.MobEffects;
          import net.minecraft.inventory.EntityEquipmentSlot;
          import net.minecraft.item.ItemArmor;
          import net.minecraft.item.ItemStack;
          import net.minecraft.potion.Potion;
          import net.minecraft.potion.PotionEffect;
          import net.minecraft.world.World;
          
          public class DragoonArmor extends ItemArmor {
          
          	public DragoonArmor( ArmorMaterial material, EntityEquipmentSlot slot, String name ) {
          		super( material, 0, slot );
          		this.setRegistryName( name );
          		this.setTranslationKey( name );
          		this.setCreativeTab( Main.mcptab );
          	}
          	
          	@Override
          	public void onArmorTick( World w, EntityPlayer p, ItemStack i ) {
          		if( i.getItem() == Main.cursedBoots ) {
          			potionEffect( p, MobEffects.FIRE_RESISTANCE, 5, 1, false, false );
          		}
          		if( i.getItem() == Main.cursedLegs ) {
          			potionEffect( p, MobEffects.SPEED, 5, 0, false, false );
          		}
          		if( i.getItem() == Main.cursedChest ) {
          			potionEffect( p, MobEffects.REGENERATION, 5, 0, false, false );
          		}
          		if( i.getItem() == Main.cursedHelmet ) {
          			potionEffect( p, MobEffects.NIGHT_VISION, 5, 2, false, false );
          		}
          	}
          	
          	private int secondToTicks( int s ) {
          		return s * 20;
          	}
          	
          	private void potionEffect( EntityPlayer player, Potion e, int t, int p, boolean ambiant, boolean particle ) {
          		if( player.getActivePotionEffect( e ) == null ) {
          			player.addPotionEffect( new PotionEffect( e, secondToTicks( t ), p, ambiant, particle ));
          		}
          	}
          }
          

          Problème résolu et sa fonctionne. Merci de ton aide !

          Check out my mod : https://www.curseforge.com/minecraft/mc-mods/eygo

          1 réponse Dernière réponse Répondre Citer 0
          • 1 / 1
          • Premier message
            Dernier message
          Design by Woryk
          ContactMentions Légales

          MINECRAFT FORGE FRANCE © 2024

          Powered by NodeBB