本文整理汇总了Java中net.minecraft.item.ItemFood类的典型用法代码示例。如果您正苦于以下问题:Java ItemFood类的具体用法?Java ItemFood怎么用?Java ItemFood使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemFood类属于net.minecraft.item包,在下文中一共展示了ItemFood类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isItemValid
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public boolean isItemValid(ItemStack stack) {
if(!stack.isEmpty())
{
boolean flag = false;
int[] ids = OreDictionary.getOreIDs(stack);
for(int id: ids)
if(OreDictionary.getOreName(id).contains("food")){
flag = true;
break;
}
if(stack.getItem() instanceof ItemFood || flag)
{
if(!FurnaceRecipes.instance().getSmeltingResult(stack).isEmpty())
{
return true;
}
}
}
return false;
}
示例2: matches
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
// Make sure the first item is a Simic Slaw
ItemStack stack0 = inv.getStackInSlot(0);
if (stack0.getItem() != ModItems.simic_slaw) {
return false;
}
// Make sure the slaw isn't full
if (stack0.hasTagCompound()) {
byte foodAdditions = stack0.getTagCompound().getByte("additions");
if (foodAdditions > 5) {
return false;
}
}
// Make sure we're putting food into the slaw
ItemStack stack1 = inv.getStackInSlot(1);
if (!(stack1.getItem() instanceof ItemFood)) {
return false;
}
return true;
}
示例3: postInit
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
Items.blaze_rod.setFull3D();
Blocks.trapped_chest.setCreativeTab(CreativeTabs.tabRedstone);
if (enableUpdatedFoodValues) {
setFinalField(ItemFood.class, Items.carrot, 3, "healAmount", "field_77853_b");
setFinalField(ItemFood.class, Items.baked_potato, 5, "healAmount", "field_77853_b");
}
if (enableUpdatedHarvestLevels) {
Blocks.packed_ice.setHarvestLevel("pickaxe", 0);
Blocks.ladder.setHarvestLevel("axe", 0);
Blocks.melon_block.setHarvestLevel("axe", 0);
}
}
示例4: instanceOf
import net.minecraft.item.ItemFood; //导入依赖的package包/类
public boolean instanceOf(IItemType type) {
if (type.equals(IItemType.ItemFishingRod)) {
return item instanceof ItemFishingRod;
} else if (type.equals(IItemType.ItemPotion)) {
return item instanceof ItemPotion;
} else if (type.equals(IItemType.ItemFood)) {
return item instanceof ItemFood;
} else if (type.equals(IItemType.ItemSword)) {
return item instanceof ItemSword;
} else if (type.equals(IItemType.ItemTool)) {
return item instanceof ItemTool;
} else if (type.equals(IItemType.ItemNameTag)) {
return item instanceof ItemNameTag;
} else if (type.equals(IItemType.ItemBlock)) {
return item instanceof ItemBlock;
} else if (type.equals(IItemType.ItemHoe)) {
return item instanceof ItemHoe;
}
return false;
}
示例5: canAdvance
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
for (EntityItem item : items) {
if (!item.isDead && item.getEntityItem() != null) {
if (item.getEntityItem().getItem() instanceof ItemFood)
{
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.CLOUD, pos.getX(), pos.getY(), pos.getZ(), 6));
item.getEntityItem().stackSize--;
if (item.getEntityItem().stackSize <= 0)
item.setDead();
return true;
}
}
}
return false;
}
示例6: eatFood
import net.minecraft.item.ItemFood; //导入依赖的package包/类
private void eatFood() {
for(int slot = 44; slot >= 9; slot--) {
ItemStack stack = Wrapper.getPlayer().inventoryContainer.getSlot(slot).getStack();
if(stack != null) {
if(slot >= 36 && slot <= 44) {
if(stack.getItem() instanceof ItemFood
&& !(stack.getItem() instanceof ItemAppleGold)) {
Wrapper.getPlayer().inventory.currentItem = slot - 36;
Wrapper.getMinecraft().gameSettings.keyBindUseItem.pressed = true;
return;
}
} else if(stack.getItem() instanceof ItemFood
&& !(stack.getItem() instanceof ItemAppleGold)) {
int itemSlot = slot;
int currentSlot = Wrapper.getPlayer().inventory.currentItem + 36;
Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
Wrapper.getMinecraft().playerController.windowClick(0, currentSlot, 0, ClickType.PICKUP, Wrapper.getPlayer());
Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
return;
}
}
}
}
示例7: tweakVanilla
import net.minecraft.item.ItemFood; //导入依赖的package包/类
public static void tweakVanilla()
{
((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20);
((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25);
((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here
((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25);
((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30);
if(BBConfig.makeStuffStackable)
{
// Let's face it, the vanilla stack sizes for these suck.
Items.MINECART.setMaxStackSize(16);
// Strangely enough the oak one doesn't change name.
Items.OAK_DOOR.setMaxStackSize(16);
Items.SPRUCE_DOOR.setMaxStackSize(16);
Items.BIRCH_DOOR.setMaxStackSize(16);
Items.ACACIA_DOOR.setMaxStackSize(16);
Items.DARK_OAK_DOOR.setMaxStackSize(16);
Items.IRON_DOOR.setMaxStackSize(16);
}
if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart");
}
示例8: loadLiqueurs
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Load
public void loadLiqueurs() {
ForgeRegistries.ITEMS.getKeys().stream().filter(s -> s.getResourcePath().contains("liqueur")).map(ForgeRegistries.ITEMS::getValue).forEach(liqueur -> {
for (LiqueurType liqueurType : LiqueurTypes.values()) {
if (liqueurType == LiqueurTypes.NORMAL)
continue;
ItemLiqueur typedLiqueur = new ItemLiqueur(MathHelper.floor(liqueurType.getHealModifier() * ((ItemFood) liqueur).getHealAmount(new ItemStack(liqueur))));
typedLiqueur.setLiqueurType(liqueurType);
typedLiqueur.setRegistryName(liqueur.getRegistryName().getResourceDomain(), liqueurType.getUnlocalizedName() + "_" + liqueur.getRegistryName().getResourcePath());
typedLiqueur.setUnlocalizedName(liqueur.getUnlocalizedName());
ForgeRegistries.ITEMS.register(typedLiqueur);
OreDictionary.registerOre("listAll" + StringUtils.capitalize(liqueurType.getUnlocalizedName()) + "liqueur", typedLiqueur);
OreDictionary.registerOre("listAllliqueur", typedLiqueur);
OreDictionary.registerOre("listAllfoods", typedLiqueur);
cachedLiqueurs.add(typedLiqueur);
}
});
}
示例9: OnFinish
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@SubscribeEvent
public void OnFinish(LivingEntityUseItemEvent.Finish e) //Why not PlayerUseItemEvent.Finish... FORGE 1.9
{
if (e.getEntity() instanceof EntityPlayer && e.getItem() != null && e.getItem().getItem() instanceof ItemFood) {
ItemFood food = (ItemFood) e.getItem().getItem();
World world = e.getEntity().getEntityWorld();
if (!world.isRemote) {
String unlocName = food.getUnlocalizedName().substring(5).toLowerCase();
if (unlocName.startsWith("raw") || unlocName.endsWith("raw") || unlocName.equals("fish")) {
if (world.rand.nextFloat() > 0.3F)
((EntityPlayer) e.getEntity()).addPotionEffect(new PotionEffect(MobEffects.hunger, 600, 0));
}
}
}
}
示例10: getRecipe
import net.minecraft.item.ItemFood; //导入依赖的package包/类
public static BasicMachineRecipe getRecipe(ItemStack input){
if (ItemStackTools.isNullStack(input)) {
return null;
}
for(ItemStack stack : recipeMap.keySet()){
if(ItemUtil.stackMatchUseOre(input, stack)){
return recipeMap.get(stack);
}
}
if(ItemStackTools.isValid(FurnaceRecipes.instance().getSmeltingResult(input))){
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input).copy();
int i = 1600;
if ((output.getItem() instanceof ItemFood)) {
i /= 2;
}
if ((input.getItem() instanceof ItemFood)) {
i /= 2;
}
if ((ItemUtil.isDust(output)) && (ItemUtil.isIngot(output))) {
i = 1000;
}
return new BasicMachineRecipe(input, output, i);
}
return null;
}
示例11: updateTask
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public void updateTask() {
--eatCooldown;
if(eatingFood != ItemStack.EMPTY) {
if (foodEatTime > 0) {
if (--foodEatTime % 4 == 0) {
PacketHandler.getChannel().sendToAllAround(
new WolfEatMessage(entity.getEntityId(), eatingFood),
new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60));
this.entity.playSound(SoundEvents.ENTITY_GENERIC_EAT,
0.5F,
(this.entity.getRNG().nextFloat() - this.entity.getRNG().nextFloat()) * 0.2F + 1);
}
} else if (!hasHealedSinceLastReset) {
hasHealedSinceLastReset = true;
PacketHandler.getChannel().sendToAllAround(
new WolfHealMessage(entity.getEntityId()),
new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60));
this.entity.heal((float) ((ItemFood) eatingFood.getItem()).getHealAmount(eatingFood));
this.eatingFood.shrink(1);
}
}
}
示例12: updateTask
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public void updateTask() {
if (!meat.isDead & Math.pow(living.posX - meat.posX, 2) + Math.pow(living.posZ - meat.posZ, 2) < 32 * 32 &&
meat.getPosition().distanceSq(living.getPosition()) < 2 && apply(meat)) {
ItemStack food = meat.getItem();
food.setCount(food.getCount() - 1);
if (food.getCount() < 1)
meat.setDead();
living.heal(((ItemFood) food.getItem()).getHealAmount(food));
living.getEntityData().setInteger(NBT_KEY_LAST_MEAL, living.ticksExisted);
List<Double6IntArrayPackage> d6iaps = new LinkedList<Double6IntArrayPackage>();
for (int i = 0; i < 7; i++)
d6iaps.add(new Double6IntArrayPackage(
living.posX + (living.rand.nextFloat() * living.width * 2.0F) - living.width,
living.posY + 0.5D + living.rand.nextFloat() * living.height,
living.posZ + (living.rand.nextFloat() * living.width * 2.0F) - living.width,
living.rand.nextGaussian() * 0.02D, living.rand.nextGaussian() * 0.02D, living.rand.nextGaussian() * 0.02D));
AlchemyNetworkHandler.spawnParticle(EnumParticleTypes.HEART,
AABBHelper.getAABBFromEntity(living, AlchemyNetworkHandler.getParticleRange()), living.world, d6iaps);
}
}
示例13: getFoodValue
import net.minecraft.item.ItemFood; //导入依赖的package包/类
int getFoodValue(ItemStack is) {
if (is == null) {
return 0;
}
Item it = is.getItem();
int heal = 0;
double sat = 0;
FoodInfo fi = lookup(is);
if (fi != null) {
heal = fi.heal;
sat = fi.sat;
} else if (it instanceof ItemFood) {
ItemFood nom = (ItemFood) it;
heal = nom.getHealAmount(is);
sat = nom.getSaturationModifier(is);
}
if (heal < sat) {
double swapah = heal;
heal = (int) sat;
sat = swapah;
}
heal += Math.min(0, heal*2*sat);
int r = (int)(heal*(heal/4F));
return Math.max(heal, r);
}
示例14: onUpdate
import net.minecraft.item.ItemFood; //导入依赖的package包/类
@Override
public void onUpdate() {
if (!AutoEatMod.this.isActive() || Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode ||
Minecraft.getMinecraft().thePlayer.getFoodStats().getFoodLevel() >= 20) {
stop();
return;
}
ItemStack item = Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(bestSlot);
if (item == null || !(item.getItem() instanceof ItemFood)) {
stop();
return;
}
Minecraft.getMinecraft().thePlayer.inventory.currentItem = bestSlot;
Minecraft.getMinecraft().playerController
.sendUseItem(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().theWorld, item);
Minecraft.getMinecraft().gameSettings.keyBindUseItem.pressed = true;
}
示例15: addNutrition
import net.minecraft.item.ItemFood; //导入依赖的package包/类
public static void addNutrition(FoodStats fs, ItemStack is)
{
IFoodStatsTFC stats = (IFoodStatsTFC)fs;
TFCFood food = FoodRegistry.getInstance().getFood(is.getItem(), is.getItemDamage());
if(food != null && is.getItem() instanceof ItemFood)
{
ItemFood item = (ItemFood)is.getItem();
Iterator iter = food.foodGroup.iterator();
while(iter.hasNext())
{
FoodGroupPair pair = (FoodGroupPair) iter.next();
float amount = pair.amount;
if(pair.foodGroup != EnumFoodGroup.None)
{
amount = Math.min(stats.getNutritionMap().get(pair.foodGroup) + (item.getHealAmount(is) * (pair.amount / 100f)*0.25f), 20);
stats.getNutritionMap().put(pair.foodGroup, amount);
}
}
}
}