Предмет

Версия Minecraft
1.7.10
199
1
17
Всем привет! Ребят, решил я сделать мод на лекарства и столкнулся с такой проблемой, я пытаюсь вызвать некоторые эффекты при съедании и они не вызываются, вот код: 
Код:
package excraft.bookkiller.items;

import excraft.bookkiller.ExCraftTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class Adrenaline extends ItemFood {
 
   public Adrenaline() {
      super(0, 0.0F, false);
      this.setUnlocalizedName("adrenaline");
      this.setTextureName("excraft:adrenaline");
      this.setMaxStackSize(4);
      this.setCreativeTab(ExCraftTabs.tabExCraft);
   }

   protected void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
         player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 600));
         player.addPotionEffect(new PotionEffect(Potion.jump.id, 400));
         player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200));
   }

   public ItemStack ItemStack (ItemStack itemStack, World p_77659_2_, EntityPlayer player) {
      return itemStack;
   }
}
 
Решение
BookKiller написал(а):
Всем привет! Ребят, решил я сделать мод на лекарства и столкнулся с такой проблемой, я пытаюсь вызвать некоторые эффекты при съедании и они не вызываются, вот код: 
Код:
package excraft.bookkiller.items;

import excraft.bookkiller.ExCraftTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class Adrenaline extends ItemFood {
 
   public Adrenaline() {
      super(0, 0.0F, false);
      this.setUnlocalizedName("adrenaline");
      this.setTextureName("excraft:adrenaline");
      this.setMaxStackSize(4);
    ...
1,200
37
237
BookKiller написал(а):
Всем привет! Ребят, решил я сделать мод на лекарства и столкнулся с такой проблемой, я пытаюсь вызвать некоторые эффекты при съедании и они не вызываются, вот код: 
Код:
package excraft.bookkiller.items;

import excraft.bookkiller.ExCraftTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class Adrenaline extends ItemFood {
 
   public Adrenaline() {
      super(0, 0.0F, false);
      this.setUnlocalizedName("adrenaline");
      this.setTextureName("excraft:adrenaline");
      this.setMaxStackSize(4);
      this.setCreativeTab(ExCraftTabs.tabExCraft);
   }

   protected void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
         player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 600));
         player.addPotionEffect(new PotionEffect(Potion.jump.id, 400));
         player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200));
   }

   public ItemStack ItemStack (ItemStack itemStack, World p_77659_2_, EntityPlayer player) {
      return itemStack;
   }
}

Убери все методы, кроме конструктора, добавь следующий метод и подставь свои эффекты, тогда будет анимация 'поедания':

Код:
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
 if (!world.isRemote) {
 //твои эффекты
 }
 super.onFoodEaten(stack, world, player);
}
 
199
1
17
MJaroslav написал(а):
BookKiller написал(а):
Всем привет! Ребят, решил я сделать мод на лекарства и столкнулся с такой проблемой, я пытаюсь вызвать некоторые эффекты при съедании и они не вызываются, вот код: 
Код:
package excraft.bookkiller.items;

import excraft.bookkiller.ExCraftTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class Adrenaline extends ItemFood {
 
   public Adrenaline() {
      super(0, 0.0F, false);
      this.setUnlocalizedName("adrenaline");
      this.setTextureName("excraft:adrenaline");
      this.setMaxStackSize(4);
      this.setCreativeTab(ExCraftTabs.tabExCraft);
   }

   protected void onArmorTick(ItemStack stack, World world, EntityPlayer player) {
         player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 600));
         player.addPotionEffect(new PotionEffect(Potion.jump.id, 400));
         player.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200));
   }

   public ItemStack ItemStack (ItemStack itemStack, World p_77659_2_, EntityPlayer player) {
      return itemStack;
   }
}

Убери все методы, кроме конструктора, добавь следующий метод и подставь свои эффекты, тогда будет анимация 'поедания':

Код:
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
 if (!world.isRemote) {
 //твои эффекты
 }
 super.onFoodEaten(stack, world, player);
}
Спасибо огромное!
 
Сверху