-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25a57d0
commit 8ae6417
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/harkenscythe/models/item/soul_cookie.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "harkenscythe:items/soul_cookie" | ||
} | ||
} |
Binary file added
BIN
+264 Bytes
src/main/resources/assets/harkenscythe/textures/items/soul_cookie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.