mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
eir's token
This commit is contained in:
parent
b4990a6664
commit
438a1b0c24
8 changed files with 126 additions and 1 deletions
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "naturesaura:item/break_prevention"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ElytraItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.Style;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ItemBreakPrevention extends ItemImpl {
|
||||||
|
public ItemBreakPrevention() {
|
||||||
|
super("break_prevention");
|
||||||
|
MinecraftForge.EVENT_BUS.register(new Events());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Events {
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onAnvilUpdate(AnvilUpdateEvent event) {
|
||||||
|
ItemStack stack = event.getLeft();
|
||||||
|
if (stack.getToolTypes().isEmpty() || !stack.isDamageable())
|
||||||
|
return;
|
||||||
|
ItemStack second = event.getRight();
|
||||||
|
if (second.getItem() != ModItems.BREAK_PREVENTION)
|
||||||
|
return;
|
||||||
|
ItemStack output = stack.copy();
|
||||||
|
output.getOrCreateTag().putBoolean(NaturesAura.MOD_ID + ":break_prevention", true);
|
||||||
|
event.setOutput(output);
|
||||||
|
event.setMaterialCost(1);
|
||||||
|
event.setCost(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onBreakSpeed(PlayerEvent.BreakSpeed event) {
|
||||||
|
PlayerEntity player = event.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
return;
|
||||||
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
|
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))
|
||||||
|
return;
|
||||||
|
if (ElytraItem.isUsable(stack))
|
||||||
|
return;
|
||||||
|
event.setNewSpeed(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onTooltip(ItemTooltipEvent event) {
|
||||||
|
ItemStack stack = event.getItemStack();
|
||||||
|
if (!stack.hasTag() || !stack.getTag().getBoolean(NaturesAura.MOD_ID + ":break_prevention"))
|
||||||
|
return;
|
||||||
|
List<ITextComponent> tooltip = event.getToolTip();
|
||||||
|
tooltip.add(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".break_prevention").setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||||
|
if (ElytraItem.isUsable(stack))
|
||||||
|
return;
|
||||||
|
if (tooltip.size() < 1)
|
||||||
|
return;
|
||||||
|
tooltip.get(0).appendSibling(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".broken").setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,4 +60,5 @@ public final class ModItems {
|
||||||
public static Item SKY_SHOES;
|
public static Item SKY_SHOES;
|
||||||
public static Item FORTRESS_FINDER;
|
public static Item FORTRESS_FINDER;
|
||||||
public static Item END_CITY_FINDER;
|
public static Item END_CITY_FINDER;
|
||||||
|
public static Item BREAK_PREVENTION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,8 @@ public final class ModRegistry {
|
||||||
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlotType.LEGS),
|
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlotType.LEGS),
|
||||||
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlotType.FEET),
|
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlotType.FEET),
|
||||||
new ItemStructureFinder("fortress_finder", "Fortress", 0xba2800),
|
new ItemStructureFinder("fortress_finder", "Fortress", 0xba2800),
|
||||||
new ItemStructureFinder("end_city_finder", "EndCity", 0xca5cd6)
|
new ItemStructureFinder("end_city_finder", "EndCity", 0xca5cd6),
|
||||||
|
new ItemBreakPrevention()
|
||||||
);
|
);
|
||||||
Helper.populateObjectHolders(ModItems.class, event.getRegistry());
|
Helper.populateObjectHolders(ModItems.class, event.getRegistry());
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@
|
||||||
"item.naturesaura.light_staff": "Staff of Baldur",
|
"item.naturesaura.light_staff": "Staff of Baldur",
|
||||||
"item.naturesaura.fortress_finder": "Eye of the Blaze",
|
"item.naturesaura.fortress_finder": "Eye of the Blaze",
|
||||||
"item.naturesaura.end_city_finder": "Eye of the Shulker",
|
"item.naturesaura.end_city_finder": "Eye of the Shulker",
|
||||||
|
"item.naturesaura.break_prevention": "Eir's Token",
|
||||||
"container.naturesaura:tree_ritual.name": "Ritual of the Forest",
|
"container.naturesaura:tree_ritual.name": "Ritual of the Forest",
|
||||||
"container.naturesaura:altar.name": "Natural Altar Infusion",
|
"container.naturesaura:altar.name": "Natural Altar Infusion",
|
||||||
"container.naturesaura:offering.name": "Offering to the Gods",
|
"container.naturesaura:offering.name": "Offering to the Gods",
|
||||||
|
@ -150,6 +151,8 @@
|
||||||
"info.naturesaura.range_visualizer.end": "You lose focus of the magnification...",
|
"info.naturesaura.range_visualizer.end": "You lose focus of the magnification...",
|
||||||
"info.naturesaura.range_visualizer.end_all": "You lose focus of all magnifications...",
|
"info.naturesaura.range_visualizer.end_all": "You lose focus of all magnifications...",
|
||||||
"info.naturesaura.remaining": "%s remaining",
|
"info.naturesaura.remaining": "%s remaining",
|
||||||
|
"info.naturesaura.break_prevention": "Eir's Token applied",
|
||||||
|
"info.naturesaura.broken": " (Broken)",
|
||||||
"advancement.naturesaura.root": "Nature's Aura",
|
"advancement.naturesaura.root": "Nature's Aura",
|
||||||
"advancement.naturesaura.root.desc": "Becoming a magical botanist",
|
"advancement.naturesaura.root.desc": "Becoming a magical botanist",
|
||||||
"advancement.naturesaura.get_book": "Pages of Discovery",
|
"advancement.naturesaura.get_book": "Pages of Discovery",
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 376 B |
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "Eir's Token",
|
||||||
|
"icon": "naturesaura:break_prevention",
|
||||||
|
"category": "items",
|
||||||
|
"advancement": "naturesaura:sky_ingot",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "There are few things more unpleasant than one's favorite $(thing)tool$() breaking when it is needed most, removing the ability to even repair it and rendering all enchanting efforts useless. To mitigate this problem, $(item)Eir's Token$() can be applied to any tool using an $(thing)anvil$(). Any tools that have this token applied will, instead of breaking when their durability reaches zero, simply $(thing)stop functioning$() instead."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "naturesaura:tree_ritual",
|
||||||
|
"text": "Creating the $(item)Eir's Token$() using the $(l:practices/tree_ritual)Ritual of the Forest$()",
|
||||||
|
"recipe": "naturesaura:break_prevention"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"type": "naturesaura:tree_ritual",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "minecraft:diamond"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "naturesaura:tainted_gold"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "naturesaura:sky_ingot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "naturesaura:token_fear"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sapling": {
|
||||||
|
"item": "minecraft:oak_sapling"
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"item": "naturesaura:break_prevention"
|
||||||
|
},
|
||||||
|
"time": 200
|
||||||
|
}
|
Loading…
Reference in a new issue