Skip to content

Conversation

@Argmaster
Copy link
Collaborator

@Argmaster Argmaster commented Mar 24, 2025

This pull request add basic parser for block patterns similar to WE patterns.

Example patterns:

  • cubyz:stone,cubyz:oak_planks - randomly select between stone (weight 1) and planks (weight 1)
  • 10%cubyz:stone,90%cubyz:oak_planks - randomly select between stone (weight 10) and planks (weight 90)

Extracted from #1236
Related to: #1214

@Argmaster Argmaster mentioned this pull request Mar 24, 2025
@Argmaster Argmaster marked this pull request as ready for review March 24, 2025 04:01
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No idea where this file should be placed, so its here for now, I am open for suggestions.

This should probably be renamed to Pattern.zig if it is to remain as file-struct.

const NeverFailingAllocator = main.heap.NeverFailingAllocator;

blocks: AliasTable(Entry),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

First I have implemented it as a struct within a file, but it was only thing here, so I figured it doesn't make sense to have a single struct within a file of the same name.

@Argmaster
Copy link
Collaborator Author

Ok, so only problem is that this file is not included in build anywhere, so I can literally write whatever and there is no way to check if it compiles.

@IntegratedQuantum
Copy link
Member

You mean like switching to f64 and breaking the alias table?

@Argmaster
Copy link
Collaborator Author

Argmaster commented Mar 24, 2025

Like anything, making const something that shouldn't be const, any typos, missed variable renames etc.

Anyway, I will just fix whatever comes up in #1236

@IntegratedQuantum
Copy link
Member

Please rebase this on #1249
Then, if you add an import to it, you will be able to check if it compiles with zig build test

@Argmaster
Copy link
Collaborator Author

Where should I add the import?

@IntegratedQuantum
Copy link
Member

Just locally I guess, you don't really need to add it to the PR.

@Argmaster
Copy link
Collaborator Author

Seems like it compiles.

@IntegratedQuantum
Copy link
Member

Did you add it as a public import?

@Argmaster
Copy link
Collaborator Author

Yes, in src/server/command/worldedit/blueprint.zig: pub const pattern = @import("Pattern.zig");

@IntegratedQuantum
Copy link
Member

There must be a private import in the chain. Try importing it directly in main.zig

@Argmaster
Copy link
Collaborator Author

Cool, now its fixed.

Copy link
Member

@IntegratedQuantum IntegratedQuantum left a comment

Choose a reason for hiding this comment

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

just a small detail in the comment

@IntegratedQuantum IntegratedQuantum merged commit d9dc3f1 into PixelGuys:master Mar 28, 2025
1 check passed
@Argmaster Argmaster mentioned this pull request May 9, 2025
IntegratedQuantum added a commit that referenced this pull request May 20, 2025
## Description

This pull request adds `/replace` command. The main difference from
`/set` with `/mask global` is that mask specified for `/replace` is
inlined, local and positive, i.e. only blocks matching the mask
specified as part of `/replace` command will be affected. `/replace`
ignores global masks.

```
/replace <old> <new>
```

`<old>` - expression following mask syntax (#1284), blocks which match
will be affected
`<new>` - expression following pattern syntax (#1237) used to fill
blocks matched by `<old>`

## Examples

`/replace cubyz:air cubyz:void`
`/replace $leaf|cubyz:air cubyz:stone,cubyz:grass`

## Links

Related to: #1214 
Depends on: #1337 
Depends on: #1284

---------

Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com>
Argmaster added a commit to Argmaster/Cubyz that referenced this pull request May 21, 2025
## Description

This pull request adds `/replace` command. The main difference from
`/set` with `/mask global` is that mask specified for `/replace` is
inlined, local and positive, i.e. only blocks matching the mask
specified as part of `/replace` command will be affected. `/replace`
ignores global masks.

```
/replace <old> <new>
```

`<old>` - expression following mask syntax (PixelGuys#1284), blocks which match
will be affected
`<new>` - expression following pattern syntax (PixelGuys#1237) used to fill
blocks matched by `<old>`

## Examples

`/replace cubyz:air cubyz:void`
`/replace $leaf|cubyz:air cubyz:stone,cubyz:grass`

## Links

Related to: PixelGuys#1214 
Depends on: PixelGuys#1337 
Depends on: PixelGuys#1284

---------

Co-authored-by: IntegratedQuantum <43880493+IntegratedQuantum@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants