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

Implement resize transformed region #1421

Merged
merged 2 commits into from
Nov 3, 2024
Merged

Implement resize transformed region #1421

merged 2 commits into from
Nov 3, 2024

Conversation

Pablete1234
Copy link
Member

Resized regions

Resized regions take in another region and resize it by a certain amount. I think the best way to visualize this is with an example:

    <action id="fill-regions" expose="true" scope="match">
      <fill material="glass">
        <resize min="5,6,5" max="5,4,5" region="monument-region"/>
      </fill>
      <fill material="stained_glass:1">
        <resize min="1,1,1" max="1,1,1"  relative="true" region="monument-region"/>
      </fill>
      <fill material="obsidian">
        <region id="monument-region"/>
      </fill>
    </action>

This will fill an area 5 blocks sideways, 6 down and 4 up with glass, then will fill a region that expands by 100% of the original size to each direction with orange glass, and finally places back the obsidian.
Result is as follows:
image

Attributes

  • min How much to expand in the -x, -y and -z directions
  • max How much to expand in the +x, +y and +z directions
  • relative If the min&max should be relative to the original size of the region (proportion) or absolute (number of blocks)
    • false (default): min & max are a number of blocks to expand in each direction
    • true: min & max represent a multiplier of the original size, eg: 2 = means 200% in each direction
    • Example: to expand a region by 50% you would relative="true" min="0.5,0.5,0.5" max="0.5,0.5,0.5"
  • region Can be an attribute, or be a direct child.

Relative resize

Expand the region by a factor of 100% in each direction (notice: relative="true"), so because the original is 2 tall, and 1 wide, it expands 2 up/down, and 1 to each side.

<resize min="1,1,1" max="1,1,1"  relative="true" region="monument-region"/> <!-- Filled with orange glass -->

image

Absolute resize

Expand the region by an absolute 5 blocks sideways, 6 down, 4 up:

<resize min="5,6,5" max="5,4,5" region="monument-region"/> <!-- Filled with regular glass -->

image

Caution with unions

BE AWARE: Multiple children will act as a union. You probably do not want to use this region type with unions, as it will likely not create the effect you desire!!

What happens with a union:

    <action id="fill-regions" expose="true" scope="match">
      <fill material="glass">
        <resize min="5,6,5" max="5,4,5" region="monument-region"/>
      </fill>
      <fill material="stained_glass:1">
        <resize min="1,1,1" max="1,1,1"  relative="true" region="monument-region"/>
      </fill>
      <fill material="obsidian">
        <region id="monument-region"/>
      </fill>
    </action>
    <action id="fill-regions-union" expose="true" scope="match">
      <fill material="glass">
        <resize min="5,6,5" max="5,4,5">
          <region id="monument-region1"/>
          <region id="monument-region2"/>
          <region id="monument-region3"/>
        </resize>
      </fill>
      <fill material="stained_glass:1">
        <resize min="1,1,1" max="1,1,1"  relative="true">
          <region id="monument-region1"/>
          <region id="monument-region2"/>
          <region id="monument-region3"/>
        </resize>
      </fill>
    </action>

Relative result:
The union is like 34 blocks across, so the relative resize by an extra factor of 100% in each direction, it triples the size and the result of the resize is a region 102 blocks wide (orange glass).
image

Absolute result:
The absolute region ends up looking pretty broken, because it's "only" enlarging by 5 blocks a region that is over 30 blocks across, meaning its a very small % increase, and barely creates extra area.
So the region did in fact grow by 4 blocks up and 5 sideways, and the area of the monument (the two blocks) enlarge to this 2x4 glass column:
image

Other changes/fixes

The PR includes a couple minor fixes too:

  • You can now use item matchers that ignore all meta except name/enchants, before pgm wouldn't allow it.
  • Enchant item action calls setItem so that the update is instantly sent to the client instead of waiting a few ticks for the next inventory sync

Signed-off-by: Pablo Herrera <[email protected]>
@Pablete1234 Pablete1234 merged commit 2e4165e into dev Nov 3, 2024
2 checks passed
@Pablete1234 Pablete1234 deleted the resize-region branch November 3, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants