This commit is contained in:
gnembon committed 2025-11-04 18:04:16 +01:00
1 parent 2ddfdddb89
commit 0a146e1d4e
36 files changed
+115 -115

No files matched your search

+2 -2
View File
@@ -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<String> currentRule, String newValue, String string) {
if (source == null) return newValue; // closing or sync
Optional<Block> ignoredBlock = source.registryAccess().lookupOrThrow(Registries.BLOCK).getOptional(ResourceLocation.tryParse(newValue));
Optional<Block> ignoredBlock = source.registryAccess().lookupOrThrow(Registries.BLOCK).getOptional(Identifier.tryParse(newValue));
if (!ignoredBlock.isPresent()) {
Messenger.m(source, "r Unknown block '" + newValue + "'.");
return null;
@@ -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);
}
@@ -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<Item> itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM);
final Registry<Block> 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;
+1 -1
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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();
}
}
@@ -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<InteractionResult> cir)
@@ -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"
@@ -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;
@@ -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)
{
@@ -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 <T> ResourceLocation getStatId(Stat<T> stat)
private <T> Identifier getStatId(Stat<T> stat)
{
return stat.getType().getRegistry().getKey(stat.getValue());
}
private final Set<ResourceLocation> skippedStats = Set.of(
private final Set<Identifier> 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;
}
@@ -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<T>
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));
}
@@ -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<SoundEvent> 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 <T> Stat<T> getStat(StatType<T> type, ResourceLocation id)
private static <T> Stat<T> getStat(StatType<T> type, Identifier id)
{
T key = type.getRegistry().getValue(id);
if (key == null || !type.contains(key))
@@ -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<? extends Entity> type = cc.registry(Registries.ENTITY_TYPE).getOptional(entityId).orElse(null);
if (type == null || !type.canSummon())
{
@@ -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<Item> 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<HolderSet.Named<Item>> 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<Item> registry = cc.registry(Registries.ITEM);
Item item = registry.getOptional(id).orElseThrow(() -> new ThrowStatement(itemStr, Throwables.UNKNOWN_ITEM));
@@ -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)
{
@@ -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<PoiType> 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<Block> 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<HolderSet.Named<Block>> 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)
{
@@ -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<ResourceLocation> validOptions = Collections.emptySet();
Set<Identifier> 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<CommandSourceStack> 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());
}
}
}
@@ -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;
}
}
@@ -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;
@@ -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)
{
@@ -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());
}
@@ -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<Recipe<?>> getRecipesForOutput(RecipeManager recipeManager, RecipeType<?> type, ResourceLocation id, Level level)
public static List<Recipe<?>> getRecipesForOutput(RecipeManager recipeManager, RecipeType<?> type, Identifier id, Level level)
{
List<Recipe<?>> 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<Recipe<?>> getRecipesForOutput(RecipeManager recipeManager, ResourceLocation id, Level level)
public static List<Recipe<?>> getRecipesForOutput(RecipeManager recipeManager, Identifier id, Level level)
{
List<Recipe<?>> 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());
}
@@ -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();
@@ -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);
}
@@ -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()));
@@ -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<ResourceKey<Level>> worldKeys = server.levelKeys();
@@ -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<Attribute> attrib = attributes.get(id).orElseThrow(
() -> new InternalExpressionException("Unknown attribute: " + a.getString())
);
@@ -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();
}
@@ -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<Level> dim = null;
ResourceLocation id = ResourceLocation.parse(dimString);
Identifier id = Identifier.parse(dimString);
// not using RegistryKey.of since that one creates on check
for (ResourceKey<Level> 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);
}
@@ -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<Level> 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<Level,Object> 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;
}
@@ -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<MobSpawnSettings.SpawnerData> 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<Structure> key = ResourceKey.create(Registries.STRUCTURE, resource);
final Pair<BooleanSupplier, StructureSpawnOverride> spawnData = carpetOverrides.get(Pair.of(cat, key));
if (spawnData == null || !spawnData.getKey().getAsBoolean()) return null;
@@ -98,7 +98,7 @@ public class SpawnReporter
public static List<Component> printMobcapsForDimension(ServerLevel world, boolean multiline)
{
ResourceKey<Level> dim = world.dimension();
String name = dim.location().getPath();
String name = dim.identifier().getPath();
List<Component> 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<Level> 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<Component> makeTrackingReport(Level worldIn)