Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for stored enchantments of enchanted books #2866

Open
dkbay opened this issue Mar 19, 2020 · 6 comments
Open

Support for stored enchantments of enchanted books #2866

dkbay opened this issue Mar 19, 2020 · 6 comments
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. PR available Issues which have a yet-to-be merged PR resolving it priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).

Comments

@dkbay
Copy link

dkbay commented Mar 19, 2020

Description

Normally minecraft enchantsments in 1.15 are stored like so.

{id: "minecraft:enchanted_book", Count: 1b, tag: {StoredEnchantments: [{lvl: 1s, id: "minecraft:mending"}]}

But when I use Skript to give me a mending book using the following script

give player enchanted book of mending

It gives me a book that looks like this and there for doesn't work as a mending book...

{id: "minecraft:enchanted_book", Count: 1b, tag: {Enchantments: [{lvl: 1s, id: "minecraft:mending"}]}

Steps to Reproduce

Run the following script and try to use the book in an anvil you can also compare it to a normal mending book (They have different name colors too...)

command /mending:
	description: Get a mending book
	
	trigger:
		give player enchanted book of mending

Expected Behavior

Enchantments should be stored as "StoredEnchantments" instead of "Enchantments"

Errors / Screenshots

Vanilla mending book:
image

Skript mending book:
image

Server Information

  • Server version/platform: Paper 143 (1.15.2)
  • Skript version: 2.4.1
@Laukage
Copy link

Laukage commented Mar 19, 2020

i can confirm this.

@ShaneBeee
Copy link
Contributor

This isn't a bug, this is just the fact that Skript doesn't have an expression for stored enchantments on books.

Ill mark this as a feature request. Hopefully we can get an expression for this in the future.

@ShaneBeee ShaneBeee added enhancement Feature request, an issue about something that could be improved, or a PR improving something. priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements). labels Mar 19, 2020
@Anarchick
Copy link

Anarchick commented Mar 22, 2020

if it can help you:

function AddStoredEnchants(item: item, enchantments: enchantment types, force: boolean) :: item:
    set {_meta} to {_item}.getItemMeta()
    loop {_enchantments::*}:
        set {_ench} to loop-value
        set {_type} to {_ench}.getType()
        set {_level} to {_ench}.getLevel()
        {_meta}.addStoredEnchant({_type}, {_level} and {_force})
    {_item}.setItemMeta({_meta})
    return {_item}

function GetStoredEnchants(item: item) :: enchantment types:
    set {_meta} to {_item}.getItemMeta()
    set {_ench} to {_meta}.getStoredEnchants()
    set {_keys::*} to ...{_ench}.keySet()
    set {_values::*} to ...{_ench}.values()
    loop {_keys::*}:
        set {_enchantmentType} to "%loop-value% %{_values::%loop-index%}%" parsed as enchantment type
        add {_enchantmentType} to {_return::*}
    return {_return::*}

function RemoveStoredEnchants(item: item, enchantments: enchantments) :: item:
    set {_meta} to {_item}.getItemMeta()
    loop {_enchantments::*}:
        set {_enchantment} to loop-value
        {_meta}.removeStoredEnchant({_enchantment})
    {_item}.setItemMeta({_meta})
    return {_item}```

@ShaneBeee
Copy link
Contributor

I forgot to add, until this is added directly to Skript, you can use what Anarchick showed above (which requires Skript-mirror), or I have also added it to SkBee https://skripthub.net/docs/?id=4071

@ShaneBeee ShaneBeee changed the title Enchantments are stored in books incorrectly Add expression for stored enchantments of enchanted books Oct 2, 2020
@TPGamesNL TPGamesNL changed the title Add expression for stored enchantments of enchanted books Support for stored enchantments of enchanted books Oct 14, 2021
@TPGamesNL
Copy link
Member

Same goes for CondIsEnchanted, and probably more stuff

@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Oct 16, 2021
@xartuu
Copy link

xartuu commented Apr 4, 2024

Skript 2.8.2 same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something. PR available Issues which have a yet-to-be merged PR resolving it priority: lowest "Nice to have" updates that are not required (tiny low impact bug fixes or QoL enhancements).
Projects
None yet
Development

No branches or pull requests

6 participants