diff --git a/gradle.properties b/gradle.properties index 24a6c147..197b1d1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.configuration-cache=false # Fabric Properties # check https://fabricmc.net/develop/ - minecraft_version=25w44a + minecraft_version=25w45a loader_version=0.17.3 jsr305_version=3.0.2 fabric_version=0.134.0+1.21.9 diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index a2d55ebd..8df84e0d 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -14,7 +14,7 @@ import net.fabricmc.loader.api.SemanticVersion; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerInterface; import net.minecraft.server.dedicated.DedicatedServer; @@ -938,7 +938,7 @@ public class CarpetSettings @Override public String validate(CommandSourceStack source, CarpetRule currentRule, String newValue, String string) { if (source == null) return newValue; // closing or sync - Optional ignoredBlock = source.registryAccess().lookupOrThrow(Registries.BLOCK).getOptional(ResourceLocation.tryParse(newValue)); + Optional ignoredBlock = source.registryAccess().lookupOrThrow(Registries.BLOCK).getOptional(Identifier.tryParse(newValue)); if (!ignoredBlock.isPresent()) { Messenger.m(source, "r Unknown block '" + newValue + "'."); return null; diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index 2d9c8174..26966ae5 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -43,7 +43,7 @@ public class PerimeterInfoCommand executes( (c) -> perimeterDiagnose( c.getSource(), BlockPosArgument.getSpawnablePos(c, "center position"), - getSummonableEntityType(c, "mob").key().location().toString() + getSummonableEntityType(c, "mob").key().identifier().toString() )))); dispatcher.register(command); } diff --git a/src/main/java/carpet/helpers/HopperCounter.java b/src/main/java/carpet/helpers/HopperCounter.java index 3fc8ca68..2cd4a987 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -14,7 +14,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.DyeColor; @@ -370,7 +370,7 @@ public class HopperCounter Block block = null; final Registry itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM); final Registry blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK); - ResourceLocation id = itemRegistry.getKey(item); + Identifier id = itemRegistry.getKey(item); if (item instanceof BlockItem blockItem) { block = blockItem.getBlock(); @@ -411,7 +411,7 @@ public class HopperCounter return WHITE; } - ResourceLocation id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); + Identifier id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); if (id == null) { return null; diff --git a/src/main/java/carpet/logging/Logger.java b/src/main/java/carpet/logging/Logger.java index 86cf5c91..e0476c83 100644 --- a/src/main/java/carpet/logging/Logger.java +++ b/src/main/java/carpet/logging/Logger.java @@ -9,7 +9,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.function.Supplier; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java index 6ed8489f..fa19c497 100644 --- a/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ChunkMap_scarpetChunkCreationMixin.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; import carpet.fakes.SimpleEntityLookupInterface; import carpet.fakes.ServerWorldInterface; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.server.MinecraftServer; import net.minecraft.server.TickTask; diff --git a/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java b/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java index d92513c9..2bf5418d 100644 --- a/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java +++ b/src/main/java/carpet/mixins/MinecraftServer_scarpetMixin.java @@ -2,7 +2,7 @@ package carpet.mixins; import carpet.fakes.MinecraftServerInterface; import carpet.script.CarpetScriptServer; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java index 06aaa474..2f0d6f04 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImplMixin.java @@ -5,7 +5,7 @@ import carpet.network.ServerNetworkHandler; import net.minecraft.network.protocol.PacketUtils; import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; import net.minecraft.network.protocol.game.ServerGamePacketListener; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java index a85d6108..b29d46c0 100644 --- a/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerGamePacketListenerImpl_scarpetEventsMixin.java @@ -72,7 +72,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin @Inject(method = "handlePlayerAction", cancellable = true, at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerPlayer;drop(Z)Z", // dropSelectedItem + target = "Lnet/minecraft/server/level/ServerPlayer;drop(Z)V", // dropSelectedItem ordinal = 0, shift = At.Shift.BEFORE )) @@ -96,7 +96,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin @Inject(method = "handlePlayerAction", cancellable = true, at = @At( value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerPlayer;drop(Z)Z", // dropSelectedItem + target = "Lnet/minecraft/server/level/ServerPlayer;drop(Z)V", // dropSelectedItem ordinal = 1, shift = At.Shift.BEFORE )) @@ -261,7 +261,7 @@ public class ServerGamePacketListenerImpl_scarpetEventsMixin if (displayInfo == null) { return; } - if(PLAYER_CHOOSES_RECIPE.onRecipeSelected(player, displayInfo.parent().id().location(), packet.useMaxItems())) ci.cancel(); + if(PLAYER_CHOOSES_RECIPE.onRecipeSelected(player, displayInfo.parent().id().identifier(), packet.useMaxItems())) ci.cancel(); } } diff --git a/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java b/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java index ed3beb6d..5587c438 100644 --- a/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java +++ b/src/main/java/carpet/mixins/ServerPlayerGameMode_scarpetEventsMixin.java @@ -54,7 +54,7 @@ public class ServerPlayerGameMode_scarpetEventsMixin implements ServerPlayerInte @Inject(method = "useItemOn", at = @At( value = "INVOKE", - target = "Lnet/minecraft/advancements/critereon/ItemUsedOnLocationTrigger;trigger(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V", + target = "Lnet/minecraft/advancements/criterion/ItemUsedOnLocationTrigger;trigger(Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V", shift = At.Shift.BEFORE )) private void onBlockActivated(ServerPlayer serverPlayerEntity, Level world, ItemStack stack, InteractionHand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) diff --git a/src/main/java/carpet/mixins/StructureBlockEntity_limitsMixin.java b/src/main/java/carpet/mixins/StructureBlockEntity_limitsMixin.java index cf47efba..fff86f89 100644 --- a/src/main/java/carpet/mixins/StructureBlockEntity_limitsMixin.java +++ b/src/main/java/carpet/mixins/StructureBlockEntity_limitsMixin.java @@ -32,7 +32,7 @@ public abstract class StructureBlockEntity_limitsMixin } @ModifyArg( - method = "saveStructure(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Vec3i;ZLjava/lang/String;ZLjava/util/List;)Z", + method = "saveStructure(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/resources/Identifier;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Vec3i;ZLjava/lang/String;ZLjava/util/List;)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate;fillFromWorld(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Vec3i;ZLjava/util/List;)V" diff --git a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java index 61aa4008..ea0eaa22 100644 --- a/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java +++ b/src/main/java/carpet/mixins/ThreadedLevelLightEngine_scarpetChunkCreationMixin.java @@ -2,7 +2,7 @@ package carpet.mixins; import java.util.concurrent.CompletableFuture; import java.util.function.IntSupplier; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.server.level.ChunkMap; diff --git a/src/main/java/carpet/network/CarpetClient.java b/src/main/java/carpet/network/CarpetClient.java index a2e83ee2..69aef15c 100644 --- a/src/main/java/carpet/network/CarpetClient.java +++ b/src/main/java/carpet/network/CarpetClient.java @@ -11,7 +11,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public class CarpetClient { @@ -45,7 +45,7 @@ public class CarpetClient private static LocalPlayer clientPlayer = null; private static boolean isServerCarpet = false; public static String serverCarpetVersion; - public static final ResourceLocation CARPET_CHANNEL = ResourceLocation.fromNamespaceAndPath("carpet", "hello"); + public static final Identifier CARPET_CHANNEL = Identifier.fromNamespaceAndPath("carpet", "hello"); public static void gameJoined(LocalPlayer player) { diff --git a/src/main/java/carpet/script/CarpetEventServer.java b/src/main/java/carpet/script/CarpetEventServer.java index f627f1fa..e97a46b1 100644 --- a/src/main/java/carpet/script/CarpetEventServer.java +++ b/src/main/java/carpet/script/CarpetEventServer.java @@ -45,7 +45,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -828,7 +828,7 @@ public class CarpetEventServer public static final Event PLAYER_CHOOSES_RECIPE = new Event("player_chooses_recipe", 3, false) { @Override - public boolean onRecipeSelected(ServerPlayer player, ResourceLocation recipe, boolean fullStack) + public boolean onRecipeSelected(ServerPlayer player, Identifier recipe, boolean fullStack) { return handler.call(() -> Arrays.asList( @@ -936,8 +936,8 @@ public class CarpetEventServer // eligibility already checked in mixin Value fromValue = ListValue.fromTriple(from.x, from.y, from.z); Value toValue = (to == null) ? Value.NULL : ListValue.fromTriple(to.x, to.y, to.z); - Value fromDimStr = NBTSerializableValue.nameFromRegistryId(fromDim.location()); - Value toDimStr = NBTSerializableValue.nameFromRegistryId(dimTo.location()); + Value fromDimStr = NBTSerializableValue.nameFromRegistryId(fromDim.identifier()); + Value toDimStr = NBTSerializableValue.nameFromRegistryId(dimTo.identifier()); handler.call(() -> Arrays.asList(new EntityValue(player), fromValue, fromDimStr, toValue, toDimStr), player::createCommandSourceStack); } @@ -981,12 +981,12 @@ public class CarpetEventServer public static final Event STATISTICS = new Event("statistic", 4, false) { - private ResourceLocation getStatId(Stat stat) + private Identifier getStatId(Stat stat) { return stat.getType().getRegistry().getKey(stat.getValue()); } - private final Set skippedStats = Set.of( + private final Set skippedStats = Set.of( Stats.TIME_SINCE_DEATH, Stats.TIME_SINCE_REST, Stats.PLAY_TIME, @@ -996,7 +996,7 @@ public class CarpetEventServer @Override public void onPlayerStatistic(ServerPlayer player, Stat stat, int amount) { - ResourceLocation id = getStatId(stat); + Identifier id = getStatId(stat); if (skippedStats.contains(id)) { return; @@ -1296,7 +1296,7 @@ public class CarpetEventServer return false; } - public boolean onRecipeSelected(ServerPlayer player, ResourceLocation recipe, boolean fullStack) + public boolean onRecipeSelected(ServerPlayer player, Identifier recipe, boolean fullStack) { return false; } diff --git a/src/main/java/carpet/script/annotation/OutputConverter.java b/src/main/java/carpet/script/annotation/OutputConverter.java index 1562957b..b0219d21 100644 --- a/src/main/java/carpet/script/annotation/OutputConverter.java +++ b/src/main/java/carpet/script/annotation/OutputConverter.java @@ -10,7 +10,7 @@ import net.minecraft.core.GlobalPos; import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; @@ -54,7 +54,7 @@ public final class OutputConverter register(BlockPos.class, (v, r) -> ValueConversions.of(v)); register(Vec3.class, (v, r) -> ValueConversions.of(v)); register(ItemStack.class, (v, r) -> ValueConversions.of(v, r)); - register(ResourceLocation.class, (v, r) -> ValueConversions.of(v)); + register(Identifier.class, (v, r) -> ValueConversions.of(v)); register(GlobalPos.class, (v, r) -> ValueConversions.of(v)); } diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java index 4a58c153..b1541734 100644 --- a/src/main/java/carpet/script/api/Auxiliary.java +++ b/src/main/java/carpet/script/api/Auxiliary.java @@ -53,7 +53,7 @@ import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetTitlesAnimationPacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -132,10 +132,10 @@ public class Auxiliary CarpetContext cc = (CarpetContext) c; if (lv.isEmpty()) { - return ListValue.wrap(cc.registry(Registries.SOUND_EVENT).listElements().map(soundEventReference -> ValueConversions.of(soundEventReference.key().location()))); + return ListValue.wrap(cc.registry(Registries.SOUND_EVENT).listElements().map(soundEventReference -> ValueConversions.of(soundEventReference.key().identifier()))); } String rawString = lv.get(0).getString(); - ResourceLocation soundName = InputValidator.identifierOf(rawString); + Identifier soundName = InputValidator.identifierOf(rawString); Vector3Argument locator = Vector3Argument.findIn(lv, 1); Holder soundHolder = Holder.direct(SoundEvent.createVariableRangeEvent(soundName)); @@ -177,7 +177,7 @@ public class Auxiliary CarpetContext cc = (CarpetContext) c; if (lv.isEmpty()) { - return ListValue.wrap(cc.registry(Registries.PARTICLE_TYPE).listElements().map(particleTypeReference -> ValueConversions.of(particleTypeReference.key().location()))); + return ListValue.wrap(cc.registry(Registries.PARTICLE_TYPE).listElements().map(particleTypeReference -> ValueConversions.of(particleTypeReference.key().identifier()))); } MinecraftServer ms = cc.server(); ServerLevel world = cc.level(); @@ -1064,8 +1064,8 @@ public class Auxiliary { return Value.NULL; } - ResourceLocation category; - ResourceLocation statName; + Identifier category; + Identifier statName; category = InputValidator.identifierOf(lv.get(1).getString()); statName = InputValidator.identifierOf(lv.get(2).getString()); StatType type = cc.registry(Registries.STAT_TYPE).getValue(category); @@ -1387,7 +1387,7 @@ public class Auxiliary } @Nullable - private static Stat getStat(StatType type, ResourceLocation id) + private static Stat getStat(StatType type, Identifier id) { T key = type.getRegistry().getValue(id); if (key == null || !type.contains(key)) diff --git a/src/main/java/carpet/script/api/Entities.java b/src/main/java/carpet/script/api/Entities.java index 9c478d4b..afa28c93 100644 --- a/src/main/java/carpet/script/api/Entities.java +++ b/src/main/java/carpet/script/api/Entities.java @@ -28,7 +28,7 @@ import java.util.function.Predicate; import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; @@ -107,10 +107,10 @@ public class Entities throw new InternalExpressionException("'spawn' function takes mob name, and position to spawn"); } String entityString = lv.get(0).getString(); - ResourceLocation entityId; + Identifier entityId; try { - entityId = ResourceLocation.read(new StringReader(entityString)); + entityId = Identifier.read(new StringReader(entityString)); EntityType type = cc.registry(Registries.ENTITY_TYPE).getOptional(entityId).orElse(null); if (type == null || !type.canSummon()) { diff --git a/src/main/java/carpet/script/api/Inventories.java b/src/main/java/carpet/script/api/Inventories.java index e7b45930..35b1b26d 100644 --- a/src/main/java/carpet/script/api/Inventories.java +++ b/src/main/java/carpet/script/api/Inventories.java @@ -33,7 +33,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.TagKey; import net.minecraft.util.context.ContextMap; @@ -72,7 +72,7 @@ public class Inventories Registry items = cc.registry(Registries.ITEM); if (lv.isEmpty()) { - return ListValue.wrap(items.listElements().map(itemReference -> ValueConversions.of(itemReference.key().location()))); + return ListValue.wrap(items.listElements().map(itemReference -> ValueConversions.of(itemReference.key().identifier()))); } String tag = lv.get(0).getString(); Optional> itemTag = items.get(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag))); @@ -196,7 +196,7 @@ public class Inventories expression.addContextFunction("crafting_remaining_item", 1, (c, t, v) -> { String itemStr = v.get(0).getString(); - ResourceLocation id = InputValidator.identifierOf(itemStr); + Identifier id = InputValidator.identifierOf(itemStr); CarpetContext cc = (CarpetContext) c; Registry registry = cc.registry(Registries.ITEM); Item item = registry.getOptional(id).orElseThrow(() -> new ThrowStatement(itemStr, Throwables.UNKNOWN_ITEM)); diff --git a/src/main/java/carpet/script/api/Scoreboards.java b/src/main/java/carpet/script/api/Scoreboards.java index f903eb0a..61248e5b 100644 --- a/src/main/java/carpet/script/api/Scoreboards.java +++ b/src/main/java/carpet/script/api/Scoreboards.java @@ -21,7 +21,7 @@ import java.util.List; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.ServerScoreboard; import net.minecraft.server.bossevents.CustomBossEvent; import net.minecraft.server.bossevents.CustomBossEvents; @@ -547,11 +547,11 @@ public class Scoreboards if (lv.isEmpty()) { - return ListValue.wrap(bossBarManager.getEvents().stream().map(CustomBossEvent::getTextId).map(ResourceLocation::toString).map(StringValue::of)); + return ListValue.wrap(bossBarManager.getEvents().stream().map(CustomBossEvent::getTextId).map(Identifier::toString).map(StringValue::of)); } String id = lv.get(0).getString(); - ResourceLocation identifier = InputValidator.identifierOf(id); + Identifier identifier = InputValidator.identifierOf(id); if (lv.size() == 1) { diff --git a/src/main/java/carpet/script/api/WorldAccess.java b/src/main/java/carpet/script/api/WorldAccess.java index 9e45dfad..b651aafa 100644 --- a/src/main/java/carpet/script/api/WorldAccess.java +++ b/src/main/java/carpet/script/api/WorldAccess.java @@ -30,7 +30,7 @@ import carpet.script.value.ValueConversions; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.LongSet; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Holder; @@ -87,7 +87,7 @@ import java.util.stream.Stream; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.game.ClientboundExplodePacket; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionResult; @@ -397,7 +397,7 @@ public class WorldAccess return Value.TRUE; } String poiTypeString = poi.getString().toLowerCase(Locale.ROOT); - ResourceLocation resource = InputValidator.identifierOf(poiTypeString); + Identifier resource = InputValidator.identifierOf(poiTypeString); Registry poiReg = cc.registry(Registries.POINT_OF_INTEREST_TYPE); PoiType type = poiReg.getOptional(resource) .orElseThrow(() -> new ThrowStatement(poiTypeString, Throwables.UNKNOWN_POI)); @@ -1228,9 +1228,9 @@ public class WorldAccess Registry blocks = cc.registry(Registries.BLOCK); if (lv.isEmpty()) { - return ListValue.wrap(blocks.listElements().map(blockReference -> ValueConversions.of(blockReference.key().location()))); + return ListValue.wrap(blocks.listElements().map(blockReference -> ValueConversions.of(blockReference.key().identifier()))); } - ResourceLocation tag = InputValidator.identifierOf(lv.get(0).getString()); + Identifier tag = InputValidator.identifierOf(lv.get(0).getString()); Optional> tagset = blocks.get(TagKey.create(Registries.BLOCK, tag)); return tagset.isEmpty() ? Value.NULL : ListValue.wrap(tagset.get().stream().map(b -> ValueConversions.of(blocks.getKey(b.value())))); }); @@ -1259,7 +1259,7 @@ public class WorldAccess ServerLevel world = cc.level(); if (lv.isEmpty()) { - return ListValue.wrap(cc.registry(Registries.BIOME).listElements().map(biomeReference -> ValueConversions.of(biomeReference.key().location()))); + return ListValue.wrap(cc.registry(Registries.BIOME).listElements().map(biomeReference -> ValueConversions.of(biomeReference.key().identifier()))); } Biome biome; @@ -1296,7 +1296,7 @@ public class WorldAccess Climate.quantizeCoord(numberGetOrThrow(weirdness)) ); biome = mnbs.getNoiseBiome(point).value(); - ResourceLocation biomeId = cc.registry(Registries.BIOME).getKey(biome); + Identifier biomeId = cc.registry(Registries.BIOME).getKey(biome); return NBTSerializableValue.nameFromRegistryId(biomeId); } @@ -1317,7 +1317,7 @@ public class WorldAccess // in locatebiome if (locator.offset == lv.size()) { - ResourceLocation biomeId = cc.registry(Registries.BIOME).getKey(biome); + Identifier biomeId = cc.registry(Registries.BIOME).getKey(biome); return NBTSerializableValue.nameFromRegistryId(biomeId); } String biomeFeature = lv.get(locator.offset).getString(); @@ -1433,7 +1433,7 @@ public class WorldAccess if (!requested.isNull()) { String reqString = requested.getString(); - ResourceLocation id = InputValidator.identifierOf(reqString); + Identifier id = InputValidator.identifierOf(reqString); Structure requestedStructure = reg.getValue(id); if (requestedStructure != null) { diff --git a/src/main/java/carpet/script/command/CommandArgument.java b/src/main/java/carpet/script/command/CommandArgument.java index 4f7da43e..cb5fcc41 100644 --- a/src/main/java/carpet/script/command/CommandArgument.java +++ b/src/main/java/carpet/script/command/CommandArgument.java @@ -55,7 +55,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import net.minecraft.ChatFormatting; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.SharedSuggestionProvider; @@ -73,7 +73,7 @@ import net.minecraft.commands.arguments.ObjectiveCriteriaArgument; import net.minecraft.commands.arguments.ParticleArgument; import net.minecraft.commands.arguments.RangeArgument; import net.minecraft.commands.arguments.ResourceArgument; -import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.commands.arguments.IdentifierArgument; import net.minecraft.commands.arguments.ResourceOrTagArgument; import net.minecraft.commands.arguments.ScoreHolderArgument; import net.minecraft.commands.arguments.ScoreboardSlotArgument; @@ -98,7 +98,7 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.BossBarCommands; import net.minecraft.server.commands.LootCommand; @@ -210,8 +210,8 @@ public abstract class CommandArgument new VanillaUnconfigurableArgument("loottable", Registries.LOOT_TABLE), new VanillaUnconfigurableArgument("attribute", Registries.ATTRIBUTE), - new VanillaUnconfigurableArgument("boss", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), BossBarCommands.SUGGEST_BOSS_BAR + new VanillaUnconfigurableArgument("boss", IdentifierArgument::id, + (c, p) -> ValueConversions.of(IdentifierArgument.getId(c, p)), BossBarCommands.SUGGEST_BOSS_BAR ), new VanillaUnconfigurableArgument("biome", c -> ResourceOrTagArgument.resourceOrTag(c, Registries.BIOME), @@ -229,11 +229,11 @@ public abstract class CommandArgument return Value.NULL; }, (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().registryAccess().lookupOrThrow(Registries.BIOME).keySet(), builder) ), - new VanillaUnconfigurableArgument("sound", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), SuggestionProviders.cast(SuggestionProviders.AVAILABLE_SOUNDS) + new VanillaUnconfigurableArgument("sound", IdentifierArgument::id, + (c, p) -> ValueConversions.of(IdentifierArgument.getId(c, p)), SuggestionProviders.cast(SuggestionProviders.AVAILABLE_SOUNDS) ), - new VanillaUnconfigurableArgument("storekey", ResourceLocationArgument::id, - (c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getCommandStorage().keys(), builder) + new VanillaUnconfigurableArgument("storekey", IdentifierArgument::id, + (c, p) -> ValueConversions.of(IdentifierArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getCommandStorage().keys(), builder) ), // default @@ -841,7 +841,7 @@ public abstract class CommandArgument private static class CustomIdentifierArgument extends CommandArgument { - Set validOptions = Collections.emptySet(); + Set validOptions = Collections.emptySet(); protected CustomIdentifierArgument() { @@ -851,13 +851,13 @@ public abstract class CommandArgument @Override protected ArgumentType getArgumentType(CarpetScriptHost host) { - return ResourceLocationArgument.id(); + return IdentifierArgument.id(); } @Override protected Value getValueFromContext(CommandContext context, String param) throws CommandSyntaxException { - ResourceLocation choseValue = ResourceLocationArgument.getId(context, param); + Identifier choseValue = IdentifierArgument.getId(context, param); if (!validOptions.isEmpty() && !validOptions.contains(choseValue)) { throw new SimpleCommandExceptionType(Component.literal("Incorrect value for " + param + ": " + choseValue + " for custom type " + suffix)).create(); @@ -882,7 +882,7 @@ public abstract class CommandArgument { throw error("Custom sting type requires options passed as a list" + " for custom type " + suffix); } - validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> ResourceLocation.parse(v.getString())).collect(Collectors.toSet()); + validOptions = ((ListValue) optionsValue).getItems().stream().map(v -> Identifier.parse(v.getString())).collect(Collectors.toSet()); } } } diff --git a/src/main/java/carpet/script/utils/EntityTools.java b/src/main/java/carpet/script/utils/EntityTools.java index 0b7e1cb6..b3a4b2ce 100644 --- a/src/main/java/carpet/script/utils/EntityTools.java +++ b/src/main/java/carpet/script/utils/EntityTools.java @@ -27,6 +27,6 @@ public class EntityTools float u = e.getYRot() * 0.017453292F; // yaw e.setDeltaMovement(e.getDeltaMovement().add((-Mth.sin(g) * 0.2F), 0.0D, (Mth.cos(u) * 0.2F))); } - e.hasImpulse = true; + e.needsSync = true; } } diff --git a/src/main/java/carpet/script/utils/Experimental.java b/src/main/java/carpet/script/utils/Experimental.java index 79d42834..141b2f35 100644 --- a/src/main/java/carpet/script/utils/Experimental.java +++ b/src/main/java/carpet/script/utils/Experimental.java @@ -9,7 +9,7 @@ import carpet.script.value.ValueConversions; import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.DynamicOps; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.commands.Commands; import net.minecraft.core.Holder; import net.minecraft.core.Registry; diff --git a/src/main/java/carpet/script/utils/FeatureGenerator.java b/src/main/java/carpet/script/utils/FeatureGenerator.java index 79a5e766..f81e0274 100644 --- a/src/main/java/carpet/script/utils/FeatureGenerator.java +++ b/src/main/java/carpet/script/utils/FeatureGenerator.java @@ -23,7 +23,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.Pools; import net.minecraft.data.worldgen.ProcessorLists; import net.minecraft.data.worldgen.placement.PlacementUtils; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BiomeTags; @@ -75,7 +75,7 @@ public class FeatureGenerator { return custom.apply(world).plop(world, pos); } - ResourceLocation id = ResourceLocation.parse(featureName); + Identifier id = Identifier.parse(featureName); Structure structure = world.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(id); if (structure != null) { @@ -129,7 +129,7 @@ public class FeatureGenerator @Nullable public static Structure resolveConfiguredStructure(String name, ServerLevel world, BlockPos pos) { - ResourceLocation id = ResourceLocation.parse(name); + Identifier id = Identifier.parse(name); Structure configuredStructureFeature = world.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(id); if (configuredStructureFeature != null) { diff --git a/src/main/java/carpet/script/utils/InputValidator.java b/src/main/java/carpet/script/utils/InputValidator.java index f33edc36..afee7ecd 100644 --- a/src/main/java/carpet/script/utils/InputValidator.java +++ b/src/main/java/carpet/script/utils/InputValidator.java @@ -4,8 +4,8 @@ import carpet.script.exception.InternalExpressionException; import java.util.Locale; -import net.minecraft.ResourceLocationException; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.IdentifierException; +import net.minecraft.resources.Identifier; public class InputValidator { @@ -19,13 +19,13 @@ public class InputValidator return simplified; } - public static ResourceLocation identifierOf(String string) + public static Identifier identifierOf(String string) { try { - return ResourceLocation.parse(string); + return Identifier.parse(string); } - catch (ResourceLocationException iie) + catch (IdentifierException iie) { throw new InternalExpressionException("Incorrect identifier format '" + string + "': " + iie.getMessage()); } diff --git a/src/main/java/carpet/script/utils/RecipeHelper.java b/src/main/java/carpet/script/utils/RecipeHelper.java index 94c484d0..5536f755 100644 --- a/src/main/java/carpet/script/utils/RecipeHelper.java +++ b/src/main/java/carpet/script/utils/RecipeHelper.java @@ -2,7 +2,7 @@ package carpet.script.utils; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.context.ContextMap; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeManager; @@ -16,7 +16,7 @@ import java.util.List; public class RecipeHelper { - public static List> getRecipesForOutput(RecipeManager recipeManager, RecipeType type, ResourceLocation id, Level level) + public static List> getRecipesForOutput(RecipeManager recipeManager, RecipeType type, Identifier id, Level level) { List> results = new ArrayList<>(); @@ -28,7 +28,7 @@ public class RecipeHelper for (RecipeDisplay recipeDisplay : r.value().display()) { recipeDisplay.result().resolveForStacks(context).forEach(stack -> { - if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::location).orElseThrow(IllegalStateException::new).equals(id)) + if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::identifier).orElseThrow(IllegalStateException::new).equals(id)) { results.add(r.value()); } @@ -39,7 +39,7 @@ public class RecipeHelper return results; } - public static List> getRecipesForOutput(RecipeManager recipeManager, ResourceLocation id, Level level) + public static List> getRecipesForOutput(RecipeManager recipeManager, Identifier id, Level level) { List> results = new ArrayList<>(); @@ -48,7 +48,7 @@ public class RecipeHelper for (RecipeDisplay recipeDisplay : r.value().display()) { recipeDisplay.result().resolveForStacks(context).forEach(stack -> { - if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::location).orElseThrow(IllegalStateException::new).equals(id)) + if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::identifier).orElseThrow(IllegalStateException::new).equals(id)) { results.add(r.value()); } diff --git a/src/main/java/carpet/script/utils/ShapeDispatcher.java b/src/main/java/carpet/script/utils/ShapeDispatcher.java index 9c69224e..d8136e68 100644 --- a/src/main/java/carpet/script/utils/ShapeDispatcher.java +++ b/src/main/java/carpet/script/utils/ShapeDispatcher.java @@ -43,7 +43,7 @@ import net.minecraft.nbt.NumericTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -119,7 +119,7 @@ public class ShapeDispatcher } params = ShapeDispatcher.parseParams(paramList); } - params.putIfAbsent("dim", new StringValue(world.dimension().location().toString())); + params.putIfAbsent("dim", new StringValue(world.dimension().identifier().toString())); params.putIfAbsent("duration", duration); if (params.containsKey("player")) @@ -395,7 +395,7 @@ public class ShapeDispatcher key = 0; followEntity = -1; - shapeDimension = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(options.get("dim").getString())); + shapeDimension = ResourceKey.create(Registries.DIMENSION, Identifier.parse(options.get("dim").getString())); if (options.containsKey("follow")) { followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt(); diff --git a/src/main/java/carpet/script/utils/ShapesRenderer.java b/src/main/java/carpet/script/utils/ShapesRenderer.java index 8f913d7f..1c2257f8 100644 --- a/src/main/java/carpet/script/utils/ShapesRenderer.java +++ b/src/main/java/carpet/script/utils/ShapesRenderer.java @@ -430,7 +430,7 @@ public class ShapesRenderer float blue = (color & 0xFF) / 255.0F; RenderType type; if (blockState.getBlock() instanceof LeavesBlock && !Minecraft.getInstance().options.cutoutLeaves().get()) { - type = RenderTypes.solid(); + type = RenderTypes.solidMovingBlock(); } else { type = ItemBlockRenderTypes.getRenderType(blockState); } diff --git a/src/main/java/carpet/script/utils/SystemInfo.java b/src/main/java/carpet/script/utils/SystemInfo.java index 1c9ab887..a49f44d5 100644 --- a/src/main/java/carpet/script/utils/SystemInfo.java +++ b/src/main/java/carpet/script/utils/SystemInfo.java @@ -60,7 +60,7 @@ public class SystemInfo String tlf = serverPath.getName(nodeCount - 2).toString(); return StringValue.of(tlf); }); - put("world_dimensions", c -> ListValue.wrap(c.server().levelKeys().stream().map(k -> ValueConversions.of(k.location())))); + put("world_dimensions", c -> ListValue.wrap(c.server().levelKeys().stream().map(k -> ValueConversions.of(k.identifier())))); put("world_spawn_point", c -> ValueConversions.of(c.server().overworld().getLevelData().getRespawnData().pos())); put("world_bottom", c -> new NumericValue(c.level().getMinY())); diff --git a/src/main/java/carpet/script/utils/WorldTools.java b/src/main/java/carpet/script/utils/WorldTools.java index 5851b821..c2274ec3 100644 --- a/src/main/java/carpet/script/utils/WorldTools.java +++ b/src/main/java/carpet/script/utils/WorldTools.java @@ -4,14 +4,14 @@ package carpet.script.utils; import carpet.script.external.Vanilla; //import net.fabricmc.api.EnvType; //import net.fabricmc.api.Environment; -import net.minecraft.Util; +import net.minecraft.util.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.MappedRegistry; import net.minecraft.core.Registry; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -93,7 +93,7 @@ public class WorldTools /* public static boolean createWorld(MinecraftServer server, String worldKey, Long seed) { - ResourceLocation worldId = new ResourceLocation(worldKey); + Identifier worldId = new Identifier(worldKey); ServerLevel overWorld = server.overworld(); Set> worldKeys = server.levelKeys(); diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index f63526eb..6c7e1e4c 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -32,7 +32,7 @@ import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket; import net.minecraft.network.protocol.game.ClientboundSetHeldSlotPacket; import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -385,7 +385,7 @@ public class EntityValue extends Value return (illagers.contains(type) || arthropods.contains(type) || undeads.contains(type) || aquatique.contains(type)) && e.isAlive(); }, allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); - for (ResourceLocation typeId : BuiltInRegistries.ENTITY_TYPE.keySet()) + for (Identifier typeId : BuiltInRegistries.ENTITY_TYPE.keySet()) { EntityType type = BuiltInRegistries.ENTITY_TYPE.getValue(typeId); String mobType = ValueConversions.simplify(typeId); @@ -500,7 +500,7 @@ public class EntityValue extends Value put("immune_to_frost", (e, a) -> BooleanValue.of(!e.canFreeze())); put("invulnerable", (e, a) -> BooleanValue.of(e instanceof Player player ? player.getAbilities().invulnerable : e.isInvulnerable())); - put("dimension", (e, a) -> nameFromRegistryId(e.level().dimension().location())); // getDimId + put("dimension", (e, a) -> nameFromRegistryId(e.level().dimension().identifier())); // getDimId put("height", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).height())); put("width", (e, a) -> new NumericValue(e.getDimensions(Pose.STANDING).width())); put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight())); @@ -853,7 +853,7 @@ public class EntityValue extends Value AttributeMap container = el.getAttributes(); return MapValue.wrap(attributes.listElements().filter(container::hasAttribute).collect(Collectors.toMap(aa -> ValueConversions.of(aa.key()), aa -> NumericValue.of(container.getValue(aa))))); } - ResourceLocation id = InputValidator.identifierOf(a.getString()); + Identifier id = InputValidator.identifierOf(a.getString()); Holder attrib = attributes.get(id).orElseThrow( () -> new InternalExpressionException("Unknown attribute: " + a.getString()) ); diff --git a/src/main/java/carpet/script/value/NBTSerializableValue.java b/src/main/java/carpet/script/value/NBTSerializableValue.java index ecb9e7d9..ab9df0b3 100644 --- a/src/main/java/carpet/script/value/NBTSerializableValue.java +++ b/src/main/java/carpet/script/value/NBTSerializableValue.java @@ -37,7 +37,7 @@ import net.minecraft.nbt.NumericTag; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; import net.minecraft.nbt.TagParser; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; @@ -113,13 +113,13 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa return value; } - public static Value nameFromRegistryId(@Nullable ResourceLocation id) + public static Value nameFromRegistryId(@Nullable Identifier id) { return StringValue.of(nameFromResource(id)); } @Nullable - public static String nameFromResource(@Nullable ResourceLocation id) + public static String nameFromResource(@Nullable Identifier id) { return id == null ? null : id.getNamespace().equals("minecraft") ? id.getPath() : id.toString(); } diff --git a/src/main/java/carpet/script/value/ValueConversions.java b/src/main/java/carpet/script/value/ValueConversions.java index 14780cb4..9777cea4 100644 --- a/src/main/java/carpet/script/value/ValueConversions.java +++ b/src/main/java/carpet/script/value/ValueConversions.java @@ -7,7 +7,7 @@ import carpet.script.external.Vanilla; import carpet.script.utils.Colors; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.minecraft.advancements.critereon.MinMaxBounds; +import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.core.BlockPos; import net.minecraft.core.GlobalPos; import net.minecraft.core.HolderSet; @@ -20,7 +20,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ColumnPos; import net.minecraft.server.level.ServerLevel; @@ -81,7 +81,7 @@ public class ValueConversions public static Value of(ServerLevel world) { - return of(world.dimension().location()); + return of(world.dimension().identifier()); } public static Value of(MapColor color) @@ -166,11 +166,11 @@ public class ValueConversions case "overworld", "over_world" -> server.getLevel(Level.OVERWORLD); default -> { ResourceKey dim = null; - ResourceLocation id = ResourceLocation.parse(dimString); + Identifier id = Identifier.parse(dimString); // not using RegistryKey.of since that one creates on check for (ResourceKey world : (server.levelKeys())) { - if (id.equals(world.location())) + if (id.equals(world.identifier())) { dim = world; break; @@ -188,7 +188,7 @@ public class ValueConversions public static Value of(ResourceKey dim) { - return of(dim.location()); + return of(dim.identifier()); } public static Value of(TagKey tagKey) @@ -201,7 +201,7 @@ public class ValueConversions return of(tagKey.key().location()); } - public static Value of(@Nullable ResourceLocation id) + public static Value of(@Nullable Identifier id) { if (id == null) // should be Value.NULL { @@ -210,7 +210,7 @@ public class ValueConversions return new StringValue(simplify(id)); } - public static String simplify(ResourceLocation id) + public static String simplify(Identifier id) { if (id == null) // should be Value.NULL { @@ -554,7 +554,7 @@ public class ValueConversions { return NumericValue.of(number); } - if (o instanceof final ResourceLocation resourceLocation) + if (o instanceof final Identifier resourceLocation) { return of(resourceLocation); } diff --git a/src/main/java/carpet/utils/CarpetProfiler.java b/src/main/java/carpet/utils/CarpetProfiler.java index 9bcf3595..1bc694bb 100644 --- a/src/main/java/carpet/utils/CarpetProfiler.java +++ b/src/main/java/carpet/utils/CarpetProfiler.java @@ -7,7 +7,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -140,7 +140,7 @@ public class CarpetProfiler Level world = tok.world; String current_section = (world == null) ? (String) tok.section : - String.format("%s.%s%s", world.dimension().location(), tok.section, world.isClientSide() ? " (Client)" : ""); + String.format("%s.%s%s", world.dimension().identifier(), tok.section, world.isClientSide() ? " (Client)" : ""); SECTION_STATS.addTo(current_section, end_time - tok.start); } } @@ -234,7 +234,7 @@ public class CarpetProfiler for (ResourceKey dim : server.levelKeys()) { - ResourceLocation dimensionId = dim.location(); + Identifier dimensionId = dim.identifier(); boolean hasSomethin = false; for (String section : SECTIONS.keySet()) { @@ -275,7 +275,7 @@ public class CarpetProfiler private static String sectionName(Pair section) { - ResourceLocation id; + Identifier id; final RegistryAccess regs = section.getKey().registryAccess(); if (section.getValue() instanceof EntityType) { @@ -290,7 +290,7 @@ public class CarpetProfiler { name += " (client)"; } - ResourceLocation dimkey = section.getKey().dimension().location(); + Identifier dimkey = section.getKey().dimension().identifier(); String dim = "minecraft".equals(dimkey.getNamespace())?dimkey.getPath():dimkey.toString(); return name+" in "+dim; } diff --git a/src/main/java/carpet/utils/SpawnOverrides.java b/src/main/java/carpet/utils/SpawnOverrides.java index d4c05f40..024d6c14 100644 --- a/src/main/java/carpet/utils/SpawnOverrides.java +++ b/src/main/java/carpet/utils/SpawnOverrides.java @@ -6,7 +6,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.random.WeightedList; import net.minecraft.world.entity.EntityType; @@ -54,7 +54,7 @@ public class SpawnOverrides { public static WeightedList test(StructureManager structureFeatureManager, LongSet foo, MobCategory cat, Structure confExisting, BlockPos where) { - ResourceLocation resource = structureFeatureManager.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(confExisting); + Identifier resource = structureFeatureManager.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(confExisting); ResourceKey key = ResourceKey.create(Registries.STRUCTURE, resource); final Pair spawnData = carpetOverrides.get(Pair.of(cat, key)); if (spawnData == null || !spawnData.getKey().getAsBoolean()) return null; diff --git a/src/main/java/carpet/utils/SpawnReporter.java b/src/main/java/carpet/utils/SpawnReporter.java index 3c086e4f..bbcdb166 100644 --- a/src/main/java/carpet/utils/SpawnReporter.java +++ b/src/main/java/carpet/utils/SpawnReporter.java @@ -98,7 +98,7 @@ public class SpawnReporter public static List printMobcapsForDimension(ServerLevel world, boolean multiline) { ResourceKey dim = world.dimension(); - String name = dim.location().getPath(); + String name = dim.identifier().getPath(); List lst = new ArrayList<>(); if (multiline) lst.add(Messenger.s(String.format("Mobcaps for %s:",name))); @@ -314,7 +314,7 @@ public class SpawnReporter private static String getWorldCode(ResourceKey world) { if (world == Level.OVERWORLD) return ""; - return "("+Character.toUpperCase(world.location().getPath().charAt("THE_".length()))+")"; + return "("+Character.toUpperCase(world.identifier().getPath().charAt("THE_".length()))+")"; } public static List makeTrackingReport(Level worldIn)