Skip to content

Commit b65a07a

Browse files
committed
initial port to 1.21.11
1 parent 51dbf33 commit b65a07a

File tree

75 files changed

+351
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+351
-356
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
// see https://fabricmc.net/develop/ for new versions
3-
id 'fabric-loom' version '1.11-SNAPSHOT' apply false
3+
id 'fabric-loom' version '1.13-SNAPSHOT' apply false
44
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
5-
id 'net.neoforged.moddev' version '2.0.115' apply false
5+
id 'net.neoforged.moddev' version '2.0.123' apply false
66
}
77

88

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ some great advantages for the future:
389389

390390
## Fixed
391391

392-
* Fix ResourceLocation/Identifier entries in `covered_block_entities` not correctly considered in some versions (1.20+).
392+
* Fix Identifier/Identifier entries in `covered_block_entities` not correctly considered in some versions (1.20+).
393393
* Tags included in the list `covered_block_entity_tags` inside the config `yawp-flags.toml` are now considered for the `break-blocks` and `place-blocks` flag
394394
* Fix RegionMarker not working properly
395395
* Fix NPE when checking for player related flags which caused (beside others) issues with Minecolonies

common/src/main/java/de/z0rdak/yawp/api/Flag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package de.z0rdak.yawp.api;
22

33
import de.z0rdak.yawp.core.flag.FlagMetaInfo;
4-
import net.minecraft.resources.ResourceLocation;
4+
import net.minecraft.resources.Identifier;
55

6-
public record Flag(ResourceLocation id, FlagMetaInfo flagInfo) {
6+
public record Flag(Identifier id, FlagMetaInfo flagInfo) {
77

88
public String name() {
99
return id.toString();

common/src/main/java/de/z0rdak/yawp/api/FlagRegister.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import de.z0rdak.yawp.constants.Constants;
44
import de.z0rdak.yawp.core.flag.*;
5-
import net.minecraft.ResourceLocationException;
6-
import net.minecraft.resources.ResourceLocation;
5+
import net.minecraft.IdentifierException;
6+
import net.minecraft.resources.Identifier;
77
import org.jetbrains.annotations.NotNull;
88
import org.jetbrains.annotations.Nullable;
99

@@ -15,21 +15,21 @@ public class FlagRegister {
1515
private FlagRegister() {
1616
}
1717

18-
private static final Map<ResourceLocation, Flag> flagRegister = new HashMap<>();
18+
private static final Map<Identifier, Flag> flagRegister = new HashMap<>();
1919

20-
private static ResourceLocation flagId(final String flagName) {
21-
return ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, flagName);
20+
private static Identifier flagId(final String flagName) {
21+
return Identifier.fromNamespaceAndPath(Constants.MOD_ID, flagName);
2222
}
2323

2424
/**
2525
* Checks if the given flag ID matches the specified Flag.
2626
*
2727
* @param flagId The string representation of the flag ID.
2828
* @param flag The flag to compare against.
29-
* @return True if the flag ID matches the flag's ResourceLocation, false otherwise.
29+
* @return True if the flag ID matches the flag's Identifier, false otherwise.
3030
*/
3131
public static boolean isSame(String flagId, Flag flag) {
32-
ResourceLocation left = ResourceLocation.parse(flagId);
32+
Identifier left = Identifier.parse(flagId);
3333
return left.equals(flag.id());
3434
}
3535

@@ -38,20 +38,20 @@ public static boolean isSame(String flagId, Flag flag) {
3838
*
3939
* @param left The first flag.
4040
* @param right The second flag.
41-
* @return True if both flags have the same ResourceLocation, false otherwise.
41+
* @return True if both flags have the same Identifier, false otherwise.
4242
*/
4343
public static boolean isSame(Flag left, Flag right) {
4444
return isSame(left.id(), right);
4545
}
4646

4747
/**
48-
* Checks if the given ResourceLocation matches the specified Flag.
48+
* Checks if the given Identifier matches the specified Flag.
4949
*
50-
* @param flagId The ResourceLocation of the flag.
50+
* @param flagId The Identifier of the flag.
5151
* @param flag The flag to compare against.
52-
* @return True if the ResourceLocation matches the flag's ResourceLocation, false otherwise.
52+
* @return True if the Identifier matches the flag's Identifier, false otherwise.
5353
*/
54-
public static boolean isSame(ResourceLocation flagId, Flag flag) {
54+
public static boolean isSame(Identifier flagId, Flag flag) {
5555
return flagId.equals(flag.id());
5656
}
5757

@@ -71,14 +71,14 @@ private static boolean registerFlag(Flag flag) {
7171
}
7272

7373
/**
74-
* Registers a flag in the internal flag registry using a {@link ResourceLocation} and {@link FlagMetaInfo}.
74+
* Registers a flag in the internal flag registry using a {@link Identifier} and {@link FlagMetaInfo}.
7575
* If a flag with the same resource location already exists, registration is skipped.
7676
*
7777
* @param flagRl The unique resource location of the flag.
7878
* @param flagMetaInfo The metadata associated with the flag.
7979
* @return {@code true} if the flag was successfully registered, {@code false} if it was already registered.
8080
*/
81-
public static boolean registerFlag(@NotNull ResourceLocation flagRl, @NotNull FlagMetaInfo flagMetaInfo) {
81+
public static boolean registerFlag(@NotNull Identifier flagRl, @NotNull FlagMetaInfo flagMetaInfo) {
8282
if (flagRl.getNamespace().equalsIgnoreCase(Constants.MOD_ID)) {
8383
throw new IllegalArgumentException("You are not permitted to register flags with the YAWP namespace!");
8484
}
@@ -95,7 +95,7 @@ public static boolean registerFlag(@NotNull ResourceLocation flagRl, @NotNull Fl
9595
* @return {@code true} if the flag was successfully registered, {@code false} if it was already registered.
9696
*/
9797
public static boolean registerFlag(@NotNull String modId, @NotNull String flagId, @NotNull FlagMetaInfo flagMetaInfo) {
98-
var rl = ResourceLocation.fromNamespaceAndPath(modId, flagId);
98+
var rl = Identifier.fromNamespaceAndPath(modId, flagId);
9999
return registerFlag(rl, flagMetaInfo);
100100
}
101101

@@ -112,12 +112,12 @@ public static Set<Flag> getFlagsByFrequency(FlagFrequency frequency) {
112112
}
113113

114114
/**
115-
* Checks if a flag is registered based on its ResourceLocation.
115+
* Checks if a flag is registered based on its Identifier.
116116
*
117-
* @param rl The ResourceLocation of the flag.
117+
* @param rl The Identifier of the flag.
118118
* @return True if the flag is registered, false otherwise.
119119
*/
120-
public static boolean isFlagRegistered(ResourceLocation rl) {
120+
public static boolean isFlagRegistered(Identifier rl) {
121121
return flagRegister.containsKey(rl);
122122
}
123123

@@ -129,9 +129,9 @@ public static boolean isFlagRegistered(ResourceLocation rl) {
129129
*/
130130
public static boolean isRegistered(String flagIdentifier) {
131131
try {
132-
ResourceLocation rl = ResourceLocation.parse(flagIdentifier);
132+
Identifier rl = Identifier.parse(flagIdentifier);
133133
return isFlagRegistered(rl);
134-
} catch (ResourceLocationException rle) {
134+
} catch (IdentifierException rle) {
135135
return false;
136136
}
137137
}
@@ -145,29 +145,29 @@ public static boolean isRegistered(String flagIdentifier) {
145145
*/
146146
public static Flag byId(String flagIdentifier) throws IllegalArgumentException {
147147
if (isRegistered(flagIdentifier)) {
148-
return flagRegister.get(ResourceLocation.parse(flagIdentifier));
148+
return flagRegister.get(Identifier.parse(flagIdentifier));
149149
}
150150
throw new IllegalArgumentException("Invalid region flag identifier supplied");
151151
}
152152

153153
/**
154154
* Retrieves an Optional containing the Flag if it exists.
155155
*
156-
* @param rl The ResourceLocation of the flag.
156+
* @param rl The Identifier of the flag.
157157
* @return An Optional containing the flag if registered, otherwise empty.
158158
*/
159-
public static Optional<Flag> getFlagOptional(ResourceLocation rl) {
159+
public static Optional<Flag> getFlagOptional(Identifier rl) {
160160
return isFlagRegistered(rl) ? Optional.of(flagRegister.get(rl)) : Optional.empty();
161161
}
162162

163163
/**
164-
* Retrieves a Flag by its ResourceLocation, or null if not found.
164+
* Retrieves a Flag by its Identifier, or null if not found.
165165
*
166-
* @param rl The ResourceLocation of the flag.
166+
* @param rl The Identifier of the flag.
167167
* @return The corresponding Flag if registered, otherwise null.
168168
*/
169169
@Nullable
170-
public static Flag getFlag(ResourceLocation rl) {
170+
public static Flag getFlag(Identifier rl) {
171171
return isFlagRegistered(rl) ? flagRegister.get(rl) : null;
172172
}
173173

@@ -178,7 +178,7 @@ public static Flag getFlag(ResourceLocation rl) {
178178
*/
179179
public static List<String> getFlagNames() {
180180
return flagRegister.keySet().stream()
181-
.map(ResourceLocation::toString)
181+
.map(Identifier::toString)
182182
.collect(Collectors.toList());
183183
}
184184

common/src/main/java/de/z0rdak/yawp/api/FlagTagRegister.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package de.z0rdak.yawp.api;
22

33
import de.z0rdak.yawp.core.flag.FlagTag;
4-
import net.minecraft.resources.ResourceLocation;
4+
import net.minecraft.resources.Identifier;
55

66
import java.util.*;
77
import java.util.concurrent.ConcurrentHashMap;
88

99
public final class FlagTagRegister {
1010

11-
private static final Map<ResourceLocation, FlagTag> REGISTRY = new ConcurrentHashMap<>();
11+
private static final Map<Identifier, FlagTag> REGISTRY = new ConcurrentHashMap<>();
1212

1313
/**
1414
* Flags that evaluate per-player context or directly
@@ -17,7 +17,7 @@ public final class FlagTagRegister {
1717
* {@code USE_ITEM}, etc. </p>
1818
*/
1919
public static final FlagTag PLAYER = register(new FlagTag(
20-
ResourceLocation.fromNamespaceAndPath("yawp", "player"),
20+
Identifier.fromNamespaceAndPath("yawp", "player"),
2121
"Flags that evaluate per-player context or directly affect player actions. Examples: BREAK_BLOCKS, PLACE_BLOCKS, USE_ITEM, etc."
2222
));
2323

@@ -30,7 +30,7 @@ public final class FlagTagRegister {
3030
* Usually combined with {@link #PLAYER}.
3131
*/
3232
public static final FlagTag BENEFICIAL = register(new FlagTag(
33-
ResourceLocation.fromNamespaceAndPath("yawp", "beneficial"),
33+
Identifier.fromNamespaceAndPath("yawp", "beneficial"),
3434
"Flags granting advantages or permissions to players. Denying these feels wrong from a player perspective. Usually combined with PLAYER. Examples: INVINCIBLE, KEEP_INV, KEEP_XP."
3535
));
3636

@@ -41,7 +41,7 @@ public final class FlagTagRegister {
4141
* Always implies {@link #PLAYER}.
4242
*/
4343
public static final FlagTag PLAYER_PREVENTION = register(new FlagTag(
44-
ResourceLocation.fromNamespaceAndPath("yawp", "prevention"),
44+
Identifier.fromNamespaceAndPath("yawp", "prevention"),
4545
"Flags that actively block or prevent a player’s attempted action. Always implies PLAYER. Examples: BREAK_BLOCKS, PLACE_BLOCKS, USE_ITEM."
4646
));
4747

@@ -51,7 +51,7 @@ public final class FlagTagRegister {
5151
* {@code BLOCK_BREAK}, etc.</p>
5252
*/
5353
public static final FlagTag BLOCK = register(new FlagTag(
54-
ResourceLocation.fromNamespaceAndPath("yawp", "block"),
54+
Identifier.fromNamespaceAndPath("yawp", "block"),
5555
"Flags concerning block-based events or world state. Examples: FIRE_SPREAD, TNT_EXPLODE, BLOCK_BREAK."
5656
));
5757

@@ -62,7 +62,7 @@ public final class FlagTagRegister {
6262
* Often combined with {@link #PLAYER}.
6363
*/
6464
public static final FlagTag ITEM = register(new FlagTag(
65-
ResourceLocation.fromNamespaceAndPath("yawp", "item"),
65+
Identifier.fromNamespaceAndPath("yawp", "item"),
6666
"Flags tied to item actions or mechanics. Examples: USE_ITEM, DROP_ITEM, PICKUP_ITEM. Often combined with PLAYER."
6767
));
6868

@@ -71,7 +71,7 @@ public final class FlagTagRegister {
7171
* <p>Examples: {@code INTERACT_ENTITY}.</p>
7272
*/
7373
public static final FlagTag ENTITY = register(new FlagTag(
74-
ResourceLocation.fromNamespaceAndPath("yawp", "entity"),
74+
Identifier.fromNamespaceAndPath("yawp", "entity"),
7575
"Flags involving entities as targets or sources. Examples: INTERACT_ENTITY."
7676
));
7777

@@ -82,7 +82,7 @@ public final class FlagTagRegister {
8282
* {@code FLUID_FLOW}, {@code ICE_MELT}.</p>
8383
*/
8484
public static final FlagTag ENVIRONMENT = register(new FlagTag(
85-
ResourceLocation.fromNamespaceAndPath("yawp", "environment"),
85+
Identifier.fromNamespaceAndPath("yawp", "environment"),
8686
"Flags controlling world-level effects or non-entity mechanics. Examples: FIRE_TICK, LEAF_DECAY, FLUID_FLOW, ICE_MELT."
8787
));
8888

@@ -92,7 +92,7 @@ public final class FlagTagRegister {
9292
* <p>Examples: {@code MOVE}, {@code FIRE_TICK}, {@code FLUID_FLOW}.</p>
9393
*/
9494
public static final FlagTag HIGH_FREQUENCY = register(new FlagTag(
95-
ResourceLocation.fromNamespaceAndPath("yawp", "high-frequency"),
95+
Identifier.fromNamespaceAndPath("yawp", "high-frequency"),
9696
"Flags checked repeatedly per n-ticks, usually for movement or environment updates. Examples: MOVE, FIRE_TICK, FLUID_FLOW."
9797
));
9898

@@ -102,7 +102,7 @@ public final class FlagTagRegister {
102102
* <p>Examples: {@code BLOCK_EXPLODE}, {@code griefing}, etc.</p>
103103
*/
104104
public static final FlagTag PROTECTION = register(new FlagTag(
105-
ResourceLocation.fromNamespaceAndPath("yawp", "protection"),
105+
Identifier.fromNamespaceAndPath("yawp", "protection"),
106106
"Flags defining preventive or defensive behavior rather than granting permissions. Examples: BLOCK_EXPLODE, griefing."
107107
));
108108

@@ -112,8 +112,8 @@ public static FlagTag register(FlagTag tag) {
112112
return tag;
113113
}
114114

115-
/** Retrieves a FlagTag by its ResourceLocation. */
116-
public static FlagTag from(ResourceLocation rl) throws IllegalArgumentException {
115+
/** Retrieves a FlagTag by its Identifier. */
116+
public static FlagTag from(Identifier rl) throws IllegalArgumentException {
117117
FlagTag tag = REGISTRY.get(rl);
118118
if (tag == null) throw new IllegalArgumentException("Invalid flag tag: " + rl);
119119
return tag;

common/src/main/java/de/z0rdak/yawp/api/commands/Commands.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
import de.z0rdak.yawp.core.flag.RegionFlag;
88
import de.z0rdak.yawp.core.group.GroupType;
99
import de.z0rdak.yawp.core.region.IMarkableRegion;
10-
import de.z0rdak.yawp.core.region.IMarkableRegion;
1110
import de.z0rdak.yawp.core.region.IProtectedRegion;
1211
import net.minecraft.core.BlockPos;
13-
import net.minecraft.resources.ResourceKey;
14-
import net.minecraft.resources.ResourceLocation;
15-
import net.minecraft.world.level.Level;
16-
import net.minecraft.resources.ResourceLocation;
12+
import net.minecraft.resources.Identifier;
1713

1814
import static de.z0rdak.yawp.api.commands.CommandConstants.*;
1915
import static de.z0rdak.yawp.util.ChatComponentBuilder.commandBlockPosStr;
@@ -35,10 +31,10 @@ public static String buildRegionBaseCmd(IProtectedRegion region) {
3531
return buildCommandStr(GLOBAL.toString());
3632
}
3733
case DIMENSION: {
38-
return buildCommandStr(DIM.toString(), region.getDim().location().toString());
34+
return buildCommandStr(DIM.toString(), region.getDim().identifier().toString());
3935
}
4036
case LOCAL: {
41-
return buildCommandStr(LOCAL.toString(), region.getDim().location().toString(), region.getName());
37+
return buildCommandStr(LOCAL.toString(), region.getDim().identifier().toString(), region.getName());
4238
}
4339
default:
4440
throw new IllegalArgumentException("Unexpected value: " + region.getRegionType());
@@ -51,10 +47,10 @@ public static String buildFlagBaseCmd(IProtectedRegion region, String flag) {
5147
return buildCommandStr(FLAG.toString(), GLOBAL.toString(), flag);
5248
}
5349
case DIMENSION: {
54-
return buildCommandStr(FLAG.toString(), DIM.toString(), region.getDim().location().toString(), flag);
50+
return buildCommandStr(FLAG.toString(), DIM.toString(), region.getDim().identifier().toString(), flag);
5551
}
5652
case LOCAL: {
57-
return buildCommandStr(FLAG.toString(), LOCAL.toString(), region.getDim().location().toString(), region.getName(), flag);
53+
return buildCommandStr(FLAG.toString(), LOCAL.toString(), region.getDim().identifier().toString(), region.getName(), flag);
5854
}
5955
default:
6056
throw new IllegalArgumentException("Unexpected value: " + region.getRegionType());
@@ -155,7 +151,7 @@ public static String buildSetDisplayBlockCommand(IMarkableRegion region) {
155151
return buildDisplaySubCommand(region, subCmd);
156152
}
157153

158-
public static String buildSetDisplayBlockCommand(IMarkableRegion region, ResourceLocation block) {
154+
public static String buildSetDisplayBlockCommand(IMarkableRegion region, Identifier block) {
159155
String subCmd = buildSubCmdStr(BLOCK.toString(), block.toString());
160156
return buildDisplaySubCommand(region, subCmd);
161157
}
@@ -185,7 +181,7 @@ public static String buildVisualizationShowCommand(IMarkableRegion region, Displ
185181
return buildShowSubCommand(region, subCmd);
186182
}
187183

188-
public static String buildAdvancedVisualizationShowCommand(IMarkableRegion region, DisplayType displayType, ResourceLocation block, boolean glow, int lightLevel) {
184+
public static String buildAdvancedVisualizationShowCommand(IMarkableRegion region, DisplayType displayType, Identifier block, boolean glow, int lightLevel) {
189185
String subCmd = buildSubCmdStr(LOCAL.toString(), displayType.name, block.toString(), String.valueOf(glow), String.valueOf(lightLevel));
190186
return buildShowSubCommand(region, subCmd);
191187
}
@@ -347,7 +343,7 @@ public static String buildRemoveTeleportAnchorCommand(IMarkableRegion region, St
347343
return buildRemoveCommand(region, subCmd);
348344
}
349345

350-
public static String buildListLocalRegionCommand(ResourceLocation levelRl) {
346+
public static String buildListLocalRegionCommand(Identifier levelRl) {
351347
return buildCommandStr(DIM.toString(), levelRl.toString(), LIST.toString(), LOCAL.toString());
352348
}
353349

common/src/main/java/de/z0rdak/yawp/api/core/IRegionManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import de.z0rdak.yawp.core.region.IProtectedRegion;
55
import de.z0rdak.yawp.data.region.LevelRegionData;
66
import net.minecraft.resources.ResourceKey;
7-
import net.minecraft.resources.ResourceLocation;
7+
import net.minecraft.resources.Identifier;
88
import net.minecraft.world.level.Level;
99

1010
import java.util.Optional;
@@ -61,7 +61,7 @@ public interface IRegionManager {
6161

6262
/**
6363
* Create the corresponding ResourceKey for the provided resource key string (e.g. 'minecraft:overworld')
64-
* Basically a wrapper around `ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(dimKey));`
64+
* Basically a wrapper around `ResourceKey.create(Registries.DIMENSION, Identifier.parse(dimKey));`
6565
* @param dimKey resource key of the level/dimension
6666
* @return the corresponding ResourceKey for the level/dimension
6767
*/
@@ -87,7 +87,7 @@ public interface IRegionManager {
8787
* Returns a set of resource keys for all created Dimensional Regions
8888
* @return a set of resource keys corresponding to registered DimensionalRegions
8989
*/
90-
Set<ResourceLocation> getLevels();
90+
Set<Identifier> getLevels();
9191

9292
/**
9393
* Resets the DimensionalRegion as well as all LocalRegions of the corresponding level.

0 commit comments

Comments
 (0)