-
Notifications
You must be signed in to change notification settings - Fork 32
Access Modifiers
Access modifiers can limit the use of certain resources in a set of specific files. They should be put as annotations in IMP-Doc comments.
All of these access modifiers will only be used by DHP for providing completions and diagnostics. If your project is large enough and you don't want your completion list to be filled with hundreds of items, you can use this feature. These modifiers will not affect any of the in-game behavior. You can actually use "private" resources anywhere.
Restrict the visibility of this resource to certain files that match the namespaced ID pattern.
within <id: namespaced ID pattern>
within * <id: namespaced ID pattern>
within <type: file type> <id: namespaced ID pattern>
You can see a full list of file types in this page. Only the specified type of files that match the namespaced ID pattern can access to the resource.
Specifying *
or not specifying file type at all results in allowing any types of files that match the pattern to
access the resource.
A namespaced ID pattern is really similar to a namespaced ID. The difference is that you can use certain wildcards in it:
-
?
: Represents an arbitrary character that matches[a-z0-9_\-\.]
. -
*
: Represents 1 or more characters that matches[a-z0-9_\-\.]
. -
**
: Represents any amount (including 0) of any characters (including:
and/
).
Some examples of the namespaced ID pattern:
-
spgoding:foo
: Matchesspgoding:foo
. -
spgoding:ba?
: Matchesspgoding:bar
andspgoding:baz
, but notspgoding:foo
. -
spgoding:*/qux
: Matchesspgoding:foo/qux
andspgoding:bar/qux
, but notspgoding:abc
norspgoding:qux
. -
spgoding:**/foo
: Matchesspgoding:foo
,spgoding:bar/foo
, andspgoding:bar/qux/foo
. -
spgoding:**
: Matches any files that is under thespgoding
namespace. -
**
: Matches everything.
#> spgoding:foo
# This function can be accessed from any files under the `example` namespace.
# @within example:**
#> spgoding:foo
# This function can be accessed from any files under the `example` namespace.
# @within * example:**
#> spgoding:foo
# This function can only be accessed from functions under the `example` namespace.
# @within function example:**
#> spgoding:foo
# This function can be accessed from both functions and function tags under the `example` namespace.
# @within
# function example:**
# tag/function example:**
Restrict the visibility of this resource to the current file.
@private
#>
# This objective can be accessed from the current file.
# @private
scoreboard objectives add foo dummy
#>
# The effect of @private can actually be implemented with @within:
# @within <The ID of the current function file>
Restrict the visibility of this resource to the same namespace as the current file and the default
namespace (minecraft
).
@internal
#> spgoding:foo
# This function can be accessed from any files under the `spgoding` namespace and the `minecraft` namespace.
# @internal
#> spgoding:foo
# The effect of @internal can actually be implemented with @within:
# @within
# spgoding:**
# minecraft:**
No restrictions to the visibility of this resource.
@public
@api
#> spgoding:foo
# This function can be accessed from everywhere.
# @public
#> spgoding:foo
# The effect of @public can actually be implemented with @within:
# @within **
You can change the default visibility for resources in the config. See datapack.env.defaultVisibility
for more information.
You can enable several strict check configs to show diagnostics for undefined resources. See Lint Rules for more information.