Skip to content

Commit

Permalink
Add cookie of souls
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Jun 9, 2024
1 parent 25a57d0 commit 8ae6417
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class HSItemTooltipEvent
private static final ResourceLocation SOUL_ALTAR = new ResourceLocation(HarkenScythe.MOD_ID, "soul_altar");
private static final ResourceLocation BLUNT_HARKEN_BLADE = new ResourceLocation(HarkenScythe.MOD_ID, "blunt_harken_blade");
private static final ResourceLocation HARKEN_ATHAME = new ResourceLocation(HarkenScythe.MOD_ID, "harken_athame");
private static final ResourceLocation SOUL_COOKIE = new ResourceLocation(HarkenScythe.MOD_ID, "soul_cookie");

@SubscribeEvent
public static void onItemTooltip(ItemTooltipEvent event)
Expand All @@ -36,5 +37,9 @@ else if (ForgeRegistries.ITEMS.getKey(item).equals(BLUNT_HARKEN_BLADE))
{
event.getToolTip().add(1, I18n.format("tooltip.harkenscythe.blunt_blade"));
}
else if (ForgeRegistries.ITEMS.getKey(item).equals(SOUL_COOKIE))
{
event.getToolTip().add(1, I18n.format("tooltip.harkenscythe.soul_cookie"));
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/mod/emt/harkenscythe/init/HSItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mod.emt.harkenscythe.items.HSEssenceVessel;
import mod.emt.harkenscythe.items.HSEssenceVesselBlood;
import mod.emt.harkenscythe.items.HSEssenceVesselSoul;
import mod.emt.harkenscythe.items.HSFood;
import mod.emt.harkenscythe.items.HSItem;
import mod.emt.harkenscythe.items.HSNecronomicon;
import mod.emt.harkenscythe.items.tools.HSAxe;
Expand Down Expand Up @@ -142,6 +143,9 @@ public class HSItems
public static HSArmor livingmetal_leggings;
@GameRegistry.ObjectHolder("livingmetal_boots")
public static HSArmor livingmetal_boots;

@GameRegistry.ObjectHolder("soul_cookie")
public static HSFood soul_cookie;

@GameRegistry.ObjectHolder("blunt_harken_blade")
public static HSItem blunt_harken_blade;
Expand Down Expand Up @@ -211,6 +215,7 @@ public static void onRegisterItemsEvent(@Nonnull final RegistryEvent.Register<It
HSRegistry.setup(new HSArmor(ARMOR_LIVINGMETAL, 4, EntityEquipmentSlot.CHEST, EnumRarity.UNCOMMON), "livingmetal_chestplate").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSArmor(ARMOR_LIVINGMETAL, 4, EntityEquipmentSlot.LEGS, EnumRarity.UNCOMMON), "livingmetal_leggings").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSArmor(ARMOR_LIVINGMETAL, 4, EntityEquipmentSlot.FEET, EnumRarity.UNCOMMON), "livingmetal_boots").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSFood(3, 0.2F, false, 16, true, EnumRarity.UNCOMMON), "soul_cookie").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSItem(EnumRarity.COMMON), "blunt_harken_blade").setCreativeTab(HarkenScythe.TAB),
HSRegistry.setup(new HSSword(ToolMaterial.IRON, EnumRarity.COMMON), "harken_athame").setCreativeTab(HarkenScythe.TAB)
);
Expand Down
76 changes: 76 additions & 0 deletions src/main/java/mod/emt/harkenscythe/items/HSFood.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package mod.emt.harkenscythe.items;

import mod.emt.harkenscythe.init.HSItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

public class HSFood extends ItemFood
{
public int itemUseDuration;
public boolean alwaysEdible;
private final EnumRarity rarity;

public HSFood(int amount, float saturation, boolean isWolfFood, boolean alwaysEdible, EnumRarity rarity)
{
super(amount, saturation, isWolfFood);
this.alwaysEdible = alwaysEdible;
this.rarity = rarity;
}

public HSFood(int amount, float saturation, boolean isWolfFood, int eatingSpeed, boolean alwaysEdible, EnumRarity rarity)
{
super(amount, saturation, isWolfFood);
this.alwaysEdible = alwaysEdible;
this.itemUseDuration = eatingSpeed; // 32 by default
this.rarity = rarity;
}

@Override
public int getMaxItemUseDuration(ItemStack stack) {
if (itemUseDuration == 0) {
return 32;
}

return itemUseDuration;
}

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);

if (player.canEat(this.alwaysEdible))
{
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
else
{
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemstack);
}
}

@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
if (this == HSItems.soul_cookie)
{
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 4 * 20, 0));
}

super.onFoodEaten(stack, world, player);
}

@Override
public EnumRarity getRarity(ItemStack stack)
{
return rarity;
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/harkenscythe/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ item.harkenscythe.livingmetal_scythe.name=Livingmetal Scythe
item.harkenscythe.livingmetal_shovel.name=Livingmetal Shovel
item.harkenscythe.livingmetal_sword.name=Livingmetal Sword
item.harkenscythe.shadow_book.name=Book of Shadows
item.harkenscythe.soul_cookie.name=Cookie of Souls
item.harkenscythe.soul_essence.name=Ghostly Essence
item.harkenscythe.stone_glaive.name=Stone Glaive
item.harkenscythe.stone_scythe.name=Stone Scythe
Expand All @@ -66,3 +67,4 @@ message.harkenscythe.hs_reap=%s was reaped
tooltip.harkenscythe.altar=Requires a Harken Athame for rituals
tooltip.harkenscythe.athame=An Iron Sword could develop magical abilities if it comes into contact with blood or souls...
tooltip.harkenscythe.blunt_blade=It could develop magical abilities if it comes into contact with blood or souls...
tooltip.harkenscythe.soul_cookie=Gives Regeneration (0:04) when eaten
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "harkenscythe:items/soul_cookie"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8ae6417

Please sign in to comment.