8000 Add infinite attribute to blocks by CoWinkKeyDinkInc · Pull Request #931 · PGMDev/PGM · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add infinite attribute to blocks #931

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

Merged
merged 9 commits into from
Nov 13, 2021

Conversation

CoWinkKeyDinkInc
Copy link
Contributor

Fixes #781 as suggested by @RuedigerLP

Example

<kit id="the-kit" force="true">
        <item slot="0">bow</item>
        <item slot="2" amount="64">arrow</item>
        <!-- gives infinite blocks --> 
        <item slot="8" material="bedrock" infinite="true"/>
        <helmet locked="true">chainmail helmet</helmet>
        <boots locked="true">chainmail boots</boots>
        <effect duration="900" amplifier="3">jump_boost</effect>
    </kit>

This PR gives affected blocks Infinite ∞ in the lore, which is unable to be created or edited in survival, to safely hold the trait. The infinity character on it's own does not look so well in game so I prefixed it with infinite to make it more clear. I tried expanding this to potions but it did not seem to work out well.

2021-10-23_19 03 59

Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
@Pablete1234
Copy link
Member

In the current state, this is extremely hacky.

In the xml syntax, adapt pgm so that amount="oo" can be used instead of adding a new infinite attribute. It is very common pgm syntax to use "oo" for infinity (eg: region coordinates)

Secondly, giving 1 item is a bad idea for several reasons. For one the user may not notice it's infinite or they have multiple, and may think they have just one. For this purpose either a stack with 64 or 127 (abusing mc a bit) may be a better. Another problem with single item is that client-server desyncs will be frequent, you click twice, clent-side you wasted your block, and you don't see it come back until after your 2nd click, where the block latee pops-up as a server-side place instead of a client-side one. Players fast-bridging will want to kill you.

Giving more than one item should also make it easier as you can just change the amount of items in the stack back to 64 (or 127, or -1, whatever works best).
It also comes with challenges, as the stack can be split in half and you may not want them to be sharing half of the infinite block. You should monitor inventory events and make sure the stack always stays as a whole.

Lastly, do not ever use lore string as a check, we're better than that. Look at how metadata for grenades or itemmods is done, pgm has some nice utils for it, it saves as an internal nbt metadata flag

Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
@CoWinkKeyDinkInc
Copy link
Contributor Author

The PR now does everything smarter like you were saying. Players will see the infinite block as holding -1 items in it, when the block is placed they are given -1 blocks, which resets it back to -1. The other advantage of using -1 blocks is that it cannot be split, stacked, or dragged, so listeners aren't needed to deal with those events.

<kits>
    <kit id="the-kit" force="true">
        <item slot="0">bow</item>
        <item slot="2" amount="64">arrow</item>
        <item slot="8" material="bedrock" amount="oo"/>
    </kit>
</kits>

Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
@@ -422,7 +429,12 @@ public ItemStack parseItem(Element el, Material type, short damage) throws Inval
throw new InvalidXMLException("Invalid item/block", el);
}

if (amount == -1 && !itemStack.getType().isBlock()) {
throw new InvalidXMLException("infinity can only be applied to a block material", el);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we support infinite snowballs or enderpearls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested them at the time, I'll see if works.

Signed-off-by: Patrick <cowinkkeydinkinc@gmail.com>
@Pablete1234 Pablete1234 added the ready PR is ready to merge label Nov 12, 2021
@Electroid Electroid merged commit bd0f173 into PGMDev:dev Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PR is ready to merge
Development

Successfully merging this pull request may close these issues.

Infinite Stacks
3 participants
0