Skip to content

Implement blocks filter & refactor regions#1076

Merged
Electroid merged 2 commits into
devfrom
blocks-filter
Oct 10, 2022
Merged

Implement blocks filter & refactor regions#1076
Electroid merged 2 commits into
devfrom
blocks-filter

Conversation

@Pablete1234

@Pablete1234 Pablete1234 commented Oct 10, 2022

Copy link
Copy Markdown
Member

Implements a new filter type, blocks.
They allows for complex structures where you let players freely edit the air blocks (or other blocks) but prevent then from breaking the original blocks. PGM will on match load check all blocks that match the filter, and reuse them later to allow/deny queries against the filter.

<union id="woolroom-regions">
  <cuboid min="-50,0,-110" max="-20,20,-100"/>
  <cuboid min="-50,0,100" max="-20,20,110"/>
</union>

<deny id="deny-woolroom-blocks">
  <blocks region="woolroom-regions">
    <not>
      <any>
        <material>air</material>
        <material>web</material>
      </any>
    </not>
  </blocks>
</deny>

<apply block="deny-woolroom-blocks" region="woolroom-regions"/>

In this example, the blocks within the woolroom region that aren't air or cobwebs, are made part of the blocks filter. They will be denied from breaking/replacing those blocks in any way.

The region is required, the filter may be specified as a filter attribute or a child filter (as shown in the example). Filter is not required and will default to a not-air filter.

Keep in mind there can be performance considerations, with the new filter, avoid making unnecessarily big regions, when possible make smaller regions and join them in an union as pgm will handle them better.

The PR has been tested and works as intended.

@Pablete1234 Pablete1234 added the feature New feature or request label Oct 10, 2022
Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>

@Electroid Electroid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice refactor, looks good!

@Electroid Electroid merged commit 576db6b into dev Oct 10, 2022
@Electroid Electroid deleted the blocks-filter branch October 10, 2022 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Development

Successfully merging this pull request may close these issues.

2 participants