diff options
| author | Maximusbarcz <maxim.baranek@gmail.com> | 2022-12-23 22:31:38 +0100 |
|---|---|---|
| committer | Maximusbarcz <maxim.baranek@gmail.com> | 2022-12-23 22:31:38 +0100 |
| commit | f7ca47ba8132addd94928aa8615448c47a6b3d7b (patch) | |
| tree | a46151060500ffba77630e64817a4bfb842268e0 /src/main/java/dev/mayaqq/ygasi/items | |
| parent | e5bc4dae41d2d3e04440a4fe02793d4084427437 (diff) | |
| download | ygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.tar.gz ygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.tar.bz2 ygasi-f7ca47ba8132addd94928aa8615448c47a6b3d7b.zip | |
Enormous amounts of trolling :tomfoolery:, not only that I fixed basically everything and switched the entire system to advancements, it now also has a cool custom book that you can open and stuff! Only issue I'm currently facing is that you get a skill point when you get the advancement for opening the gui and clicking stuff... right not that big of an issue but when I add 2 billion advancements its gonna hurt a bit. Love, Mayaqq
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/items')
| -rw-r--r-- | src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java b/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java new file mode 100644 index 0000000..ce4143f --- /dev/null +++ b/src/main/java/dev/mayaqq/ygasi/items/SkillBookItem.java @@ -0,0 +1,52 @@ +package dev.mayaqq.ygasi.items; + +import dev.mayaqq.ygasi.gui.BranchGui; +import eu.pb4.polymer.api.item.PolymerItemUtils; +import eu.pb4.polymer.api.item.SimplePolymerItem; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.Hand; + +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class SkillBookItem extends SimplePolymerItem { + + public SkillBookItem(Settings settings, Item polymerItem) { + super(settings, polymerItem); + } + + @Override + public ItemStack getPolymerItemStack(ItemStack itemStack, ServerPlayerEntity player) { + ItemStack out = PolymerItemUtils.createItemStack(itemStack, player); + out.addEnchantment(Enchantments.LURE, 0); + out.setCustomName(Text.translatable("item.ygasi.skill_book").formatted(Formatting.GOLD).formatted(Formatting.BOLD)); + return out; + } + + @Override + public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) { + ServerPlayerEntity player = (ServerPlayerEntity) playerEntity; + BranchGui.gui(player); + return TypedActionResult.success(playerEntity.getStackInHand(hand)); + } + + @Override + public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) { + return 1; + } + + @Override + public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) { + tooltip.add(Text.translatable("item.ygasi.skill_book.tooltip").formatted(Formatting.GRAY)); + } +}
\ No newline at end of file |
