use of net.minecraft.item.ItemFood in project minecolonies by Minecolonies.
the class EntityAIGoHome method handleSaturation.
/**
* Handle the saturation of the citizen.
*
* @param pos the position.
*/
private void handleSaturation(@NotNull final BlockPos pos) {
if (citizen.isWorkerAtSiteWithMove(pos, 2) && citizen.getColony() != null && citizen.getCitizenData() != null && citizen.getCitizenData().getSaturation() < EntityCitizen.HIGH_SATURATION) {
final double currentSaturation = citizen.getCitizenData().getSaturation();
boolean tookFood = false;
final AbstractBuilding home = citizen.getColony().getBuilding(pos);
if (home instanceof BuildingHome && currentSaturation < EntityCitizen.FULL_SATURATION) {
final int slot = InventoryUtils.findFirstSlotInProviderNotEmptyWith(home.getTileEntity(), itemStack -> itemStack.getItem() instanceof ItemFood);
if (slot != -1) {
final ItemStack stack = home.getTileEntity().getStackInSlot(slot);
if (!InventoryUtils.isItemStackEmpty(stack)) {
final int slotToSet = InventoryUtils.getFirstOpenSlotFromItemHandler(new InvWrapper(citizen.getInventoryCitizen()));
if (slotToSet == -1) {
InventoryUtils.forceItemStackToItemHandler(new InvWrapper(citizen.getInventoryCitizen()), new ItemStack(stack.getItem(), 1), stack1 -> citizen.getWorkBuilding() == null || !citizen.getWorkBuilding().neededForWorker(stack1));
} else {
citizen.getInventoryCitizen().setInventorySlotContents(slotToSet, new ItemStack(stack.getItem(), 1));
}
tookFood = true;
stack.setCount(stack.getCount() - 1);
}
((BuildingHome) home).setFoodNeeded(false);
}
}
if (!tookFood) {
requestFoodIfRequired(currentSaturation, home);
}
}
}
use of net.minecraft.item.ItemFood in project minecolonies by Minecolonies.
the class EntityCitizen method tryToEat.
/**
* Lets the citizen tryToEat to replentish saturation.
*/
public void tryToEat() {
final int slot = InventoryUtils.findFirstSlotInProviderWith(this, itemStack -> !InventoryUtils.isItemStackEmpty(itemStack) && itemStack.getItem() instanceof ItemFood);
if (slot == -1) {
return;
}
final ItemStack stack = inventory.getStackInSlot(slot);
if (!InventoryUtils.isItemStackEmpty(stack) && stack.getItem() instanceof ItemFood && citizenData != null) {
final int heal = ((ItemFood) stack.getItem()).getHealAmount(stack);
citizenData.increaseSaturation(heal);
inventory.decrStackSize(slot, 1);
citizenData.markDirty();
}
}
use of net.minecraft.item.ItemFood in project BetterWithAddons by DaedalusGame.
the class ModItems method load.
public static void load(FMLPreInitializationEvent event) {
ironSpade = (ItemSpade) registerItem("iron_spade", new ItemSpade(Item.ToolMaterial.IRON));
ironMatchPick = (ItemMatchPick) registerItem("iron_matchpick", new ItemMatchPick(Item.ToolMaterial.IRON));
ironMachete = (ItemMachete) registerItem("iron_machete", new ItemMachete(Item.ToolMaterial.IRON));
ironKukri = (ItemKukri) registerItem("iron_kukri", new ItemKukri(Item.ToolMaterial.IRON, 8.0f, -3.1f));
ironCarpenterSaw = (ItemCarpenterSaw) registerItem("iron_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.IRON, 8.0f, -3.1f));
ironMasonPick = (ItemMasonPick) registerItem("iron_masonpick", new ItemMasonPick(Item.ToolMaterial.IRON));
goldSpade = (ItemSpade) registerItem("gold_spade", new ItemSpade(Item.ToolMaterial.GOLD));
goldMatchPick = (ItemMatchPick) registerItem("gold_matchpick", new ItemMatchPick(Item.ToolMaterial.GOLD));
goldMachete = (ItemMachete) registerItem("gold_machete", new ItemMachete(Item.ToolMaterial.GOLD));
goldKukri = (ItemKukri) registerItem("gold_kukri", new ItemKukri(Item.ToolMaterial.GOLD, 6.0f, -3.0f));
goldCarpenterSaw = (ItemCarpenterSaw) registerItem("gold_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.GOLD, 6.0f, -3.0f));
goldMasonPick = (ItemMasonPick) registerItem("gold_masonpick", new ItemMasonPick(Item.ToolMaterial.GOLD));
diamondSpade = (ItemSpade) registerItem("diamond_spade", new ItemSpade(Item.ToolMaterial.DIAMOND));
diamondMatchPick = (ItemMatchPick) registerItem("diamond_matchpick", new ItemMatchPick(Item.ToolMaterial.DIAMOND));
diamondMachete = (ItemMachete) registerItem("diamond_machete", new ItemMachete(Item.ToolMaterial.DIAMOND));
diamondKukri = (ItemKukri) registerItem("diamond_kukri", new ItemKukri(Item.ToolMaterial.DIAMOND, 8.0f, -3.0f));
diamondCarpenterSaw = (ItemCarpenterSaw) registerItem("diamond_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.DIAMOND, 8.0f, -3.0f));
diamondMasonPick = (ItemMasonPick) registerItem("diamond_masonpick", new ItemMasonPick(Item.ToolMaterial.DIAMOND));
steelSpade = (ItemSpade) registerItem("steel_spade", new ItemSpade(BWMItems.SOULFORGED_STEEL) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
steelMatchPick = (ItemMatchPick) registerItem("steel_matchpick", new ItemMatchPick(BWMItems.SOULFORGED_STEEL) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
steelMachete = (ItemMachete) registerItem("steel_machete", new ItemMachete(BWMItems.SOULFORGED_STEEL) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
steelKukri = (ItemKukri) registerItem("steel_kukri", new ItemKukri(BWMItems.SOULFORGED_STEEL, 8.0F, -3.0F) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
steelCarpenterSaw = (ItemCarpenterSaw) registerItem("steel_carpentersaw", new ItemCarpenterSaw(BWMItems.SOULFORGED_STEEL, 8.0F, -3.0F) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
steelMasonPick = (ItemMasonPick) registerItem("steel_masonpick", new ItemMasonPick(BWMItems.SOULFORGED_STEEL) {
@Override
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
}
});
material = (ItemMaterial) registerItem("material", new ItemMaterial(new String[] { "arrowhead", "midori", "midori_popped", "thornrose", "stone_brick", "bone_ingot", "ender_cream" }));
worldShard = (ItemWorldScale) registerItem("worldshard", new ItemWorldScale());
greatbow = (ItemGreatbow) registerItem("greatbow", new ItemGreatbow());
greatarrow = (ItemGreatarrow) registerItem("greatarrow", new ItemGreatarrow());
greatarrowLightning = (ItemGreatarrow) registerItem("greatarrow_lightning", new ItemGreatarrowLightning());
greatarrowDestruction = (ItemGreatarrow) registerItem("greatarrow_destruction", new ItemGreatarrowDestruction());
monument = (ItemMonument) registerItem("monument", new ItemMonument());
// Food
bakedMushroom = (ItemFood) registerItem("food_mushroom_baked", new ItemFood(3, 0.2F, false));
bakedAmanita = (ItemFood) registerItem("food_amanita_baked", new ItemFood(3, 0.2F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 100, 0), 1.0F));
cookedBeetroot = (ItemFood) registerItem("food_beetroot_cooked", new ItemFood(4, 0.5F, false));
bakedBeetroot = (ItemFood) registerItem("food_beetroot_baked", new ItemFood(5, 0.4F, false));
cookedCarrot = (ItemFood) registerItem("food_carrot_cooked", new ItemFood(3, 0.6F, false));
bakedCarrot = (ItemFood) registerItem("food_carrot_baked", new ItemFood(4, 0.5F, false));
cookedPotato = (ItemFood) registerItem("food_potato_cooked", new ItemFood(4, 0.7F, false));
cookedEgg = (ItemFood) registerItem("food_egg_cooked", new ItemFood(4, 0.3F, false));
meatballs = (ItemFood) registerItem("food_meatballs", new ItemFood(3, 0.6F, true));
groundMeat = (ItemFood) registerItem("food_ground_meat", new ItemFood(1, 0.1F, true));
pieMushroom = (ItemFood) registerItem("food_pie_mushroom", new ItemFood(8, 0.3F, false));
pieAmanita = (ItemFood) registerItem("food_pie_amanita", new ItemFood(8, 0.3F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 100, 0), 1.0F));
pieMeat = (ItemFood) registerItem("food_pie_meat", new ItemFood(9, 0.5F, true));
pieMelon = (ItemFood) registerItem("food_pie_melon", new ItemFood(8, 0.4F, false));
cookedClownfish = (ItemFood) registerItem("food_clownfish_cooked", new ItemFood(6, 0.5F, false));
cookedPuffer = (ItemFood) registerItem("food_pufferfish_baked", new ItemFood(6, 0.6F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 500, 1), 0.1F));
preparedPuffer = (ItemFood) registerItem("food_pufferfish_prepared", new ItemFood(2, 0.1F, false));
preparedCookedPuffer = (ItemFood) registerItem("food_pufferfish_cooked", new ItemFood(4, 0.5F, false));
fuguSac = (ItemFood) registerItem("food_fugu_sac", new ItemFood(2, 0.1F, false).setPotionEffect(new PotionEffect(MobEffects.WITHER, 2000, 1), 1.0F));
sashimi = (ItemFood) registerItem("food_sashimi", new ItemFood(2, 0.1F, false));
mulberry = (ItemFood) registerItem("food_mulberry", new ItemFood(1, 0.2F, false));
rice = (ItemFood) registerItem("food_cooked_rice", new ItemFood(2, 0.3F, false));
riceBowl = (ItemFood) registerItem("food_bowl_rice", new ItemFood(9, 0.6F, false).setMaxStackSize(1));
laxative = registerItem("laxative", new Item());
soulSandPile = registerItem("soulsand_pile", new Item());
rottenFood = (ItemFood) registerItem("rotten_food", new ItemFood(1, 0.1f, false).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 2000, 1), 1.0F));
wool = (ItemColored) registerItem("wool", new ItemColored());
/*bowls = (ItemMaterial) registerItem("bowl", new ItemMaterial(
new String[]{"salt"}
));*/
salts = (ItemMaterial) registerItem("salt", new ItemMaterial(new String[] { "crystal" }));
artifactFrame = (ItemArtifactFrame) registerItem("artifact_frame", new ItemArtifactFrame());
brokenArtifact = (ItemToolShard) registerItem("tool_shard", new ItemToolShard().setMaxStackSize(1));
stainedBrick = (ItemStainedBrick) registerItem("brick_stained", new ItemStainedBrick());
shinai = (ItemShinai) registerItem("shinai", new ItemShinai());
katana = (ItemKatana) registerItem("katana", new ItemKatana());
wakizashi = (ItemWakizashi) registerItem("wakizashi", new ItemWakizashi());
tanto = (ItemTanto) registerItem("tanto", new ItemTanto());
yumi = (ItemYumi) registerItem("yumi", new ItemYumi());
ya = (ItemYa) registerItem("ya", new ItemYa());
ancestryBottle = (ItemAncestryBottle) registerItem("ancestry_bottle", new ItemAncestryBottle());
materialJapan = (ItemMaterial) registerItem("japanmat", new ItemMaterial(new String[] { "rice", "soaked_rice", "rice_stalk", "rice_hay", "rice_ash", "rush", "soaked_bamboo", "bamboo_slats", "soaked_mulberry", "mulberry_paste", "mulberry_sheet", "washi", "iron_scales", "lamellar", "paper_lamellar", "tsuka", "half_katana_blade", "ya_head", "yumi_top", "yumi_bottom", "tamahagane", "tamahagane_heated", "tamahagane_folded", "tamahagane_reheated", "tamahagane_finished", "tamahagane_wrapped", "hocho_tetsu", "hocho_tetsu_heated", "hocho_tetsu_fold_1", "hocho_tetsu_fold_2", "hocho_tetsu_finished", "helmet_undecorated", "chest_undecorated", "legs_undecorated", "boots_undecorated", "bark_sakura", "bark_mulberry" }));
samuraiHelm = (ItemSamuraiArmor) registerItem("helmet_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.HEAD));
samuraiChestplate = (ItemSamuraiArmor) registerItem("chest_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.CHEST));
samuraiLeggings = (ItemSamuraiArmor) registerItem("legs_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.LEGS));
samuraiBoots = (ItemSamuraiArmor) registerItem("boots_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.FEET));
materialBag = (ItemMaterial) registerItem("bag", new ItemMaterial(new String[] { "seed", "seed_hemp", "seed_melon", "seed_pumpkin", "seed_beets", "cocoa", "redstone", "glowstone", "sugar", "gunpowder", "flour", "sulfur", "nitre", "sawdust", "sawdust_soul", "potash", "hellfire", "kibble" }));
materialCrate = (ItemMaterial) registerItem("crate", new ItemMaterial(new String[] { "pork", "pork_raw", "chicken", "chicken_raw", "steak", "steak_raw", "mutton", "mutton_raw", "rabbit", "rabbit_raw", "egg", "slime", "enderpearl", "cactus", "inksac" }));
materialCongealed = (ItemMaterial) registerItem("congealed", new ItemMaterial(new String[] { "bone", "flesh", "eye", "amanita", "mushroom", "wart" }));
materialBolt = (ItemMaterial) registerItem("bolt", new ItemMaterial(new String[] { "fabric", "vine", "paper", "leather", "scoured_leather", "tanned_leather", "string" }));
materialBundle = (ItemMaterial) registerItem("bundle", new ItemMaterial(new String[] { "feather", "arrows", "blazerods", "oak", "birch", "spruce", "jungle", "acacia", "darkoak" }));
materialDeco = (ItemMaterial) registerItem("decomat", new ItemMaterial(new String[] { "hemp_oil", "wood_bleach", "wood_stain", "glass_chunk" }));
materialTweak = (ItemMaterial) registerItem("tweakmat", new ItemMaterial(new String[] { "ash", "ink_and_quill" }));
materialWheat = (ItemMaterial) registerItem("wheatmat", new ItemMaterial(new String[] { "hay" }));
explosion = registerItem("explosion", new Item() {
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
return;
}
});
}
use of net.minecraft.item.ItemFood in project Almura by AlmuraDev.
the class FoodLevelChangeApply method apply0.
@Override
public void apply0(final EntityPlayer entity, final ItemApplyContext context) {
final ItemStack usedStack = context.item();
if (usedStack.getItem() instanceof ItemFood) {
final ItemFood food = (ItemFood) usedStack.getItem();
final int currentFoodLevel = entity.getFoodStats().foodLevel;
entity.getFoodStats().foodLevel = Math.min(currentFoodLevel + food.getHealAmount(usedStack), 20);
}
}
Aggregations