45a great reg split

This commit is contained in:
gnembon committed 2022-11-10 20:51:10 +01:00
1 parent 48c804fcaa
commit cda6994cae
28 files changed
+164 -153

No files matched your search

+2 -2
View File
@@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html # or better: https://modmuss50.me/fabric.html
minecraft_version=22w44a minecraft_version=22w45a
loader_version=0.14.10 loader_version=0.14.10
fabric_version=0.65.2+1.19.3 fabric_version=0.66.1+1.19.3
# Mod Properties # Mod Properties
mod_version = 1.4.87 mod_version = 1.4.87
+2 -2
View File
@@ -12,7 +12,7 @@ import carpet.utils.Messenger;
import carpet.utils.SpawnChunks; import carpet.utils.SpawnChunks;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerInterface; import net.minecraft.server.ServerInterface;
@@ -1005,7 +1005,7 @@ public class CarpetSettings
@Override @Override
public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) { public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
Optional<Block> ignoredBlock = Registry.BLOCK.getOptional(ResourceLocation.tryParse(newValue)); Optional<Block> ignoredBlock = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.tryParse(newValue));
if (!ignoredBlock.isPresent()) { if (!ignoredBlock.isPresent()) {
Messenger.m(source, "r Unknown block '" + newValue + "'."); Messenger.m(source, "r Unknown block '" + newValue + "'.");
return null; return null;
@@ -8,7 +8,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries;
import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.argument;
import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.Commands.literal;
@@ -22,7 +22,7 @@ public class MobAICommand
{ {
LiteralArgumentBuilder<CommandSourceStack> command = literal("track"). LiteralArgumentBuilder<CommandSourceStack> command = literal("track").
requires((player) -> CommandHelper.canUseCommand(player, CarpetSettings.commandTrackAI)). requires((player) -> CommandHelper.canUseCommand(player, CarpetSettings.commandTrackAI)).
then(argument("entity type", resource(commandBuildContext, Registry.ENTITY_TYPE_REGISTRY)). then(argument("entity type", resource(commandBuildContext, Registries.ENTITY_TYPE)).
suggests( (c, b) -> suggest(MobAI.availbleTypes(), b)). suggests( (c, b) -> suggest(MobAI.availbleTypes(), b)).
then(literal("clear").executes( (c) -> then(literal("clear").executes( (c) ->
@@ -11,7 +11,7 @@ import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.coordinates.BlockPosArgument; import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
import net.minecraft.commands.synchronization.SuggestionProviders; import net.minecraft.commands.synchronization.SuggestionProviders;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@@ -37,7 +37,7 @@ public class PerimeterInfoCommand
c.getSource(), c.getSource(),
BlockPosArgument.getSpawnablePos(c, "center position"), BlockPosArgument.getSpawnablePos(c, "center position"),
null)). null)).
then(argument("mob", resource(commandBuildContext, Registry.ENTITY_TYPE_REGISTRY)). then(argument("mob", resource(commandBuildContext, Registries.ENTITY_TYPE)).
suggests(SuggestionProviders.SUMMONABLE_ENTITIES). suggests(SuggestionProviders.SUMMONABLE_ENTITIES).
executes( (c) -> perimeterDiagnose( executes( (c) -> perimeterDiagnose(
c.getSource(), c.getSource(),
@@ -20,6 +20,8 @@ import net.minecraft.core.HolderSet;
import net.minecraft.core.QuartPos; import net.minecraft.core.QuartPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.Pools; import net.minecraft.data.worldgen.Pools;
import net.minecraft.data.worldgen.ProcessorLists; import net.minecraft.data.worldgen.ProcessorLists;
import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.data.worldgen.placement.PlacementUtils;
@@ -71,13 +73,13 @@ public class FeatureGenerator
return custom.apply(world).plop(world, pos); return custom.apply(world).plop(world, pos);
} }
ResourceLocation id = new ResourceLocation(featureName); ResourceLocation id = new ResourceLocation(featureName);
Structure structure = world.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).get(id); Structure structure = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id);
if (structure != null) if (structure != null)
{ {
return plopAnywhere( structure, world, pos, world.getChunkSource().getGenerator(), false); return plopAnywhere( structure, world, pos, world.getChunkSource().getGenerator(), false);
} }
ConfiguredFeature<?, ?> configuredFeature = world.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY).get(id); ConfiguredFeature<?, ?> configuredFeature = world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(id);
if (configuredFeature != null) if (configuredFeature != null)
{ {
CarpetSettings.skipGenerationChecks.set(true); CarpetSettings.skipGenerationChecks.set(true);
@@ -90,14 +92,14 @@ public class FeatureGenerator
CarpetSettings.skipGenerationChecks.set(false); CarpetSettings.skipGenerationChecks.set(false);
} }
} }
Optional<StructureType<?>> structureType = Registry.STRUCTURE_TYPES.getOptional(id); Optional<StructureType<?>> structureType = BuiltInRegistries.STRUCTURE_TYPE.getOptional(id);
if (structureType.isPresent()) if (structureType.isPresent())
{ {
Structure configuredStandard = getDefaultFeature(structureType.get(), world, pos); Structure configuredStandard = getDefaultFeature(structureType.get(), world, pos);
if (configuredStandard != null) if (configuredStandard != null)
return plopAnywhere(configuredStandard, world, pos, world.getChunkSource().getGenerator(), false); return plopAnywhere(configuredStandard, world, pos, world.getChunkSource().getGenerator(), false);
} }
Feature<?> feature = Registry.FEATURE.get(id); Feature<?> feature = BuiltInRegistries.FEATURE.get(id);
if (feature != null) if (feature != null)
{ {
ConfiguredFeature<?,?> configuredStandard = getDefaultFeature(feature, world, pos, true); ConfiguredFeature<?,?> configuredStandard = getDefaultFeature(feature, world, pos, true);
@@ -120,9 +122,9 @@ public class FeatureGenerator
public static Structure resolveConfiguredStructure(String name, ServerLevel world, BlockPos pos) public static Structure resolveConfiguredStructure(String name, ServerLevel world, BlockPos pos)
{ {
ResourceLocation id = new ResourceLocation(name); ResourceLocation id = new ResourceLocation(name);
Structure configuredStructureFeature = world.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).get(id); Structure configuredStructureFeature = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id);
if (configuredStructureFeature != null) return configuredStructureFeature; if (configuredStructureFeature != null) return configuredStructureFeature;
StructureType<?> structureFeature = Registry.STRUCTURE_TYPES.get(id); StructureType<?> structureFeature = BuiltInRegistries.STRUCTURE_TYPE.get(id);
if (structureFeature == null) return null; if (structureFeature == null) return null;
return getDefaultFeature(structureFeature, world, pos); return getDefaultFeature(structureFeature, world, pos);
} }
@@ -178,7 +180,7 @@ public class FeatureGenerator
// TODO allow old types, like vaillage, or bastion // TODO allow old types, like vaillage, or bastion
Holder<Biome> existingBiome = world.getBiome(pos); Holder<Biome> existingBiome = world.getBiome(pos);
Structure result = null; Structure result = null;
for (Structure confstr : world.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).entrySet().stream(). for (Structure confstr : world.registryAccess().registryOrThrow(Registries.STRUCTURE).entrySet().stream().
filter(cS -> cS.getValue().type() == structure).map(Map.Entry::getValue).toList()) filter(cS -> cS.getValue().type() == structure).map(Map.Entry::getValue).toList())
{ {
result = confstr; result = confstr;
@@ -197,7 +199,7 @@ public class FeatureGenerator
return provider.value().feature().value(); return provider.value().feature().value();
} }
if (!tryHard) return null; if (!tryHard) return null;
return world.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY).entrySet().stream(). return world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).entrySet().stream().
filter(cS -> cS.getValue().feature() == feature). filter(cS -> cS.getValue().feature() == feature).
findFirst().map(Map.Entry::getValue).orElse(null); findFirst().map(Map.Entry::getValue).orElse(null);
} }
@@ -258,16 +260,16 @@ public class FeatureGenerator
put("bastion_remnant_units", l -> { put("bastion_remnant_units", l -> {
RegistryAccess regs = l.registryAccess(); RegistryAccess regs = l.registryAccess();
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY); final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registries.PROCESSOR_LIST);
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION); final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY); final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registries.TEMPLATE_POOL);
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY); final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
return spawnCustomStructure( return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings( new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT), l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
Map.of(), Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES, GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE TerrainAdjustment.NONE
@@ -288,15 +290,15 @@ public class FeatureGenerator
put("bastion_remnant_hoglin_stable", l -> { put("bastion_remnant_hoglin_stable", l -> {
RegistryAccess regs = l.registryAccess(); RegistryAccess regs = l.registryAccess();
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY); final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registries.PROCESSOR_LIST);
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION); final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY); final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registries.TEMPLATE_POOL);
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY); final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
return spawnCustomStructure( return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings( new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT), l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
Map.of(), Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES, GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE TerrainAdjustment.NONE
@@ -317,15 +319,15 @@ public class FeatureGenerator
put("bastion_remnant_treasure", l -> { put("bastion_remnant_treasure", l -> {
RegistryAccess regs = l.registryAccess(); RegistryAccess regs = l.registryAccess();
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY); final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registries.PROCESSOR_LIST);
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION); final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY); final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registries.TEMPLATE_POOL);
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY); final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
return spawnCustomStructure( return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings( new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT), l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
Map.of(), Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES, GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE TerrainAdjustment.NONE
@@ -346,15 +348,15 @@ public class FeatureGenerator
put("bastion_remnant_bridge", l -> { put("bastion_remnant_bridge", l -> {
RegistryAccess regs = l.registryAccess(); RegistryAccess regs = l.registryAccess();
final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registry.PROCESSOR_LIST_REGISTRY); final HolderGetter<StructureProcessorList> processorLists = regs.lookupOrThrow(Registries.PROCESSOR_LIST);
final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION); final Holder<StructureProcessorList> bastionGenericDegradation = processorLists.getOrThrow(ProcessorLists.BASTION_GENERIC_DEGRADATION);
final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registry.TEMPLATE_POOL_REGISTRY); final HolderGetter<StructureTemplatePool> pools = regs.lookupOrThrow(Registries.TEMPLATE_POOL);
final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY); final Holder<StructureTemplatePool> empty = pools.getOrThrow(Pools.EMPTY);
return spawnCustomStructure( return spawnCustomStructure(
new JigsawStructure(new Structure.StructureSettings( new JigsawStructure(new Structure.StructureSettings(
l.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT), l.registryAccess().registryOrThrow(Registries.BIOME).getOrCreateTag(BiomeTags.HAS_BASTION_REMNANT),
Map.of(), Map.of(),
GenerationStep.Decoration.SURFACE_STRUCTURES, GenerationStep.Decoration.SURFACE_STRUCTURES,
TerrainAdjustment.NONE TerrainAdjustment.NONE
@@ -396,7 +398,7 @@ public class FeatureGenerator
if (!wireOnly) if (!wireOnly)
{ {
Registry<Structure> registry3 = world.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); Registry<Structure> registry3 = world.registryAccess().registryOrThrow(Registries.STRUCTURE);
world.setCurrentlyGenerating(() -> { world.setCurrentlyGenerating(() -> {
Objects.requireNonNull(structure); Objects.requireNonNull(structure);
return registry3.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString); return registry3.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString);
@@ -8,7 +8,7 @@ import carpet.utils.Messenger;
import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongMap;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
@@ -336,14 +336,14 @@ public class HopperCounter
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMaterialColor().col)); if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMaterialColor().col));
if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getDyeColor().getMaterialColor().col)); if (item instanceof DyeItem) return TextColor.fromRgb(appropriateColor(((DyeItem) item).getDyeColor().getMaterialColor().col));
Block block = null; Block block = null;
ResourceLocation id = Registry.ITEM.getKey(item); ResourceLocation id = BuiltInRegistries.ITEM.getKey(item);
if (item instanceof BlockItem) if (item instanceof BlockItem)
{ {
block = ((BlockItem) item).getBlock(); block = ((BlockItem) item).getBlock();
} }
else if (Registry.BLOCK.getOptional(id).isPresent()) else if (BuiltInRegistries.BLOCK.getOptional(id).isPresent())
{ {
block = Registry.BLOCK.get(id); block = BuiltInRegistries.BLOCK.get(id);
} }
if (block != null) if (block != null)
{ {
@@ -363,8 +363,8 @@ public class HopperCounter
TextColor direct = fromItem(item); TextColor direct = fromItem(item);
if (direct != null) return direct; if (direct != null) return direct;
if (CarpetServer.minecraft_server == null) return WHITE; if (CarpetServer.minecraft_server == null) return WHITE;
ResourceLocation id = Registry.ITEM.getKey(item); ResourceLocation id = BuiltInRegistries.ITEM.getKey(item);
for (RecipeType<?> type: Registry.RECIPE_TYPE) for (RecipeType<?> type: BuiltInRegistries.RECIPE_TYPE)
{ {
for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id)) for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id))
{ {
@@ -5,9 +5,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.commands.arguments.ParticleArgument; import net.minecraft.commands.arguments.ParticleArgument;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
@@ -20,7 +19,7 @@ public class ParticleDisplay
{ {
try try
{ {
return ParticleArgument.readParticle(new StringReader(name), level.holderLookup(Registry.PARTICLE_TYPE_REGISTRY)); return ParticleArgument.readParticle(new StringReader(name), level.holderLookup(Registries.PARTICLE_TYPE));
} }
catch (CommandSyntaxException e) catch (CommandSyntaxException e)
{ {
@@ -6,7 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@@ -76,7 +76,7 @@ public class ExplosionLogHelper
messages.add(c((k.pos.equals(pos))?"r - TNT":"w - ", messages.add(c((k.pos.equals(pos))?"r - TNT":"w - ",
Messenger.dblt((k.pos.equals(pos))?"r":"y", k.pos.x, k.pos.y, k.pos.z), "w dV", Messenger.dblt((k.pos.equals(pos))?"r":"y", k.pos.x, k.pos.y, k.pos.z), "w dV",
Messenger.dblt("d", k.accel.x, k.accel.y, k.accel.z), Messenger.dblt("d", k.accel.x, k.accel.y, k.accel.z),
"w "+Registry.ENTITY_TYPE.getKey(k.type).getPath(), (v>1)?"l ("+v+")":"" "w "+ BuiltInRegistries.ENTITY_TYPE.getKey(k.type).getPath(), (v>1)?"l ("+v+")":""
)); ));
}); });
} }
@@ -2,13 +2,13 @@ package carpet.mixins;
import carpet.fakes.ChunkHolderInterface; import carpet.fakes.ChunkHolderInterface;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import net.minecraft.core.registries.Registries;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.atomic.AtomicReferenceArray;
import net.minecraft.core.Registry;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.thread.BlockableEventLoop; import net.minecraft.util.thread.BlockableEventLoop;
@@ -30,7 +30,7 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold
{ {
int i = ChunkStatus.EMPTY.getIndex(); int i = ChunkStatus.EMPTY.getIndex();
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completableFuture2 = CompletableFuture.supplyAsync( CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completableFuture2 = CompletableFuture.supplyAsync(
() -> Either.left(new ProtoChunk(chpos, UpgradeData.EMPTY, world, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..? () -> Either.left(new ProtoChunk(chpos, UpgradeData.EMPTY, world, world.registryAccess().registryOrThrow(Registries.BIOME), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..?
executor executor
); );
updateChunkToSave(completableFuture2, "unfull"); // possible debug data updateChunkToSave(completableFuture2, "unfull"); // possible debug data
@@ -4,7 +4,7 @@ import carpet.CarpetSettings;
import carpet.fakes.CoralFeatureInterface; import carpet.fakes.CoralFeatureInterface;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
@@ -58,7 +58,7 @@ public abstract class CoralFanBlock_renewableCoralMixin implements BonemealableB
MaterialColor color = blockUnder.getMapColor(worldIn, pos); MaterialColor color = blockUnder.getMapColor(worldIn, pos);
BlockState proper_block = blockUnder; BlockState proper_block = blockUnder;
Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet()); Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
for (Block block: coralBlockSet) for (Block block: coralBlockSet)
{ {
proper_block = block.defaultBlockState(); proper_block = block.defaultBlockState();
@@ -3,7 +3,7 @@ package carpet.mixins;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import carpet.fakes.CoralFeatureInterface; import carpet.fakes.CoralFeatureInterface;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -60,7 +60,7 @@ public abstract class CoralPlantBlock_renewableCoralMixin implements Bonemealabl
MaterialColor color = blockUnder.getMapColor(worldIn, pos); MaterialColor color = blockUnder.getMapColor(worldIn, pos);
BlockState proper_block = blockUnder; BlockState proper_block = blockUnder;
Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet()); Set<Block> coralBlockSet = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow().stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
for (Block block: coralBlockSet) for (Block block: coralBlockSet)
{ {
proper_block = block.defaultBlockState(); proper_block = block.defaultBlockState();
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.fakes.RecipeManagerInterface; import carpet.fakes.RecipeManagerInterface;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.core.registries.BuiltInRegistries;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@@ -9,7 +10,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.item.crafting.RecipeManager;
@@ -29,6 +29,6 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
if (typeRecipes == null) return Collections.emptyList(); if (typeRecipes == null) return Collections.emptyList();
if (typeRecipes.containsKey(output)) return Collections.singletonList(typeRecipes.get(output)); if (typeRecipes.containsKey(output)) return Collections.singletonList(typeRecipes.get(output));
return Lists.newArrayList(typeRecipes.values().stream().filter( return Lists.newArrayList(typeRecipes.values().stream().filter(
r -> Registry.ITEM.getKey(r.getResultItem().getItem()).equals(output)).collect(Collectors.toList())); r -> BuiltInRegistries.ITEM.getKey(r.getResultItem().getItem()).equals(output)).collect(Collectors.toList()));
} }
} }
@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -941,7 +941,7 @@ public class CarpetEventServer
if (skippedStats.contains(id)) return; if (skippedStats.contains(id)) return;
handler.call( () -> Arrays.asList( handler.call( () -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
StringValue.of(NBTSerializableValue.nameFromRegistryId(Registry.STAT_TYPE.getKey(stat.getType()))), StringValue.of(NBTSerializableValue.nameFromRegistryId(BuiltInRegistries.STAT_TYPE.getKey(stat.getType()))),
StringValue.of(NBTSerializableValue.nameFromRegistryId(id)), StringValue.of(NBTSerializableValue.nameFromRegistryId(id)),
new NumericValue(amount) new NumericValue(amount)
), player::createCommandSourceStack); ), player::createCommandSourceStack);
@@ -1036,11 +1036,11 @@ public class CarpetEventServer
@Deprecated @Deprecated
public static String getEntityLoadEventName(EntityType<? extends Entity> et) public static String getEntityLoadEventName(EntityType<? extends Entity> et)
{ {
return "entity_loaded_" + ValueConversions.of(Registry.ENTITY_TYPE.getKey(et)).getString(); return "entity_loaded_" + ValueConversions.of(BuiltInRegistries.ENTITY_TYPE.getKey(et)).getString();
} }
@Deprecated @Deprecated
public static final Map<EntityType<? extends Entity>, Event> ENTITY_LOAD = Registry.ENTITY_TYPE public static final Map<EntityType<? extends Entity>, Event> ENTITY_LOAD = BuiltInRegistries.ENTITY_TYPE
.stream() .stream()
.map(et -> Map.entry(et, new Event(getEntityLoadEventName(et), 1, true, false) .map(et -> Map.entry(et, new Event(getEntityLoadEventName(et), 1, true, false)
{ {
@@ -1056,10 +1056,10 @@ public class CarpetEventServer
public static String getEntityHandlerEventName(EntityType<? extends Entity> et) public static String getEntityHandlerEventName(EntityType<? extends Entity> et)
{ {
return "entity_handler_" + ValueConversions.of(Registry.ENTITY_TYPE.getKey(et)).getString(); return "entity_handler_" + ValueConversions.of(BuiltInRegistries.ENTITY_TYPE.getKey(et)).getString();
} }
public static final Map<EntityType<? extends Entity>, Event> ENTITY_HANDLER = Registry.ENTITY_TYPE public static final Map<EntityType<? extends Entity>, Event> ENTITY_HANDLER = BuiltInRegistries.ENTITY_TYPE
.stream() .stream()
.map(et -> Map.entry(et, new Event(getEntityHandlerEventName(et), 2, true, false) { .map(et -> Map.entry(et, new Event(getEntityHandlerEventName(et), 2, true, false) {
@Override @Override
+10 -9
View File
@@ -42,10 +42,11 @@ import com.mojang.bridge.game.PackType;
import net.minecraft.SharedConstants; import net.minecraft.SharedConstants;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.Rotations; import net.minecraft.core.Rotations;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
@@ -136,12 +137,12 @@ public class Auxiliary {
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
if (lv.size() == 0) if (lv.size() == 0)
{ {
return ListValue.wrap(Registry.SOUND_EVENT.keySet().stream().map(ValueConversions::of)); return ListValue.wrap(BuiltInRegistries.SOUND_EVENT.keySet().stream().map(ValueConversions::of));
} }
String rawString = lv.get(0).getString(); String rawString = lv.get(0).getString();
ResourceLocation soundName = InputValidator.identifierOf(rawString); ResourceLocation soundName = InputValidator.identifierOf(rawString);
Vector3Argument locator = Vector3Argument.findIn(lv, 1); Vector3Argument locator = Vector3Argument.findIn(lv, 1);
if (Registry.SOUND_EVENT.get(soundName) == null) if (BuiltInRegistries.SOUND_EVENT.get(soundName) == null)
throw new ThrowStatement(rawString, Throwables.UNKNOWN_SOUND); throw new ThrowStatement(rawString, Throwables.UNKNOWN_SOUND);
float volume = 1.0F; float volume = 1.0F;
float pitch = 1.0F; float pitch = 1.0F;
@@ -175,7 +176,7 @@ public class Auxiliary {
expression.addContextFunction("particle", -1, (c, t, lv) -> expression.addContextFunction("particle", -1, (c, t, lv) ->
{ {
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
if (lv.size() == 0) return ListValue.wrap(Registry.PARTICLE_TYPE.keySet().stream().map(ValueConversions::of)); if (lv.size() == 0) return ListValue.wrap(BuiltInRegistries.PARTICLE_TYPE.keySet().stream().map(ValueConversions::of));
MinecraftServer ms = cc.s.getServer(); MinecraftServer ms = cc.s.getServer();
ServerLevel world = cc.s.getLevel(); ServerLevel world = cc.s.getLevel();
Vector3Argument locator = Vector3Argument.findIn(lv, 1); Vector3Argument locator = Vector3Argument.findIn(lv, 1);
@@ -755,16 +756,16 @@ public class Auxiliary {
ListValue.wrap(FeatureGenerator.featureMap.keySet().stream().sorted().map(StringValue::of).collect(Collectors.toList())) ListValue.wrap(FeatureGenerator.featureMap.keySet().stream().sorted().map(StringValue::of).collect(Collectors.toList()))
); );
plopData.put(StringValue.of("features"), plopData.put(StringValue.of("features"),
ListValue.wrap(Registry.FEATURE.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ListValue.wrap(BuiltInRegistries.FEATURE.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
); );
plopData.put(StringValue.of("configured_features"), plopData.put(StringValue.of("configured_features"),
ListValue.wrap(registryManager.registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ListValue.wrap(registryManager.registryOrThrow(Registries.CONFIGURED_FEATURE).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
); );
plopData.put(StringValue.of("structure_types"), plopData.put(StringValue.of("structure_types"),
ListValue.wrap(Registry.STRUCTURE_TYPES.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ListValue.wrap(BuiltInRegistries.STRUCTURE_TYPE.keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
); );
plopData.put(StringValue.of("structures"), plopData.put(StringValue.of("structures"),
ListValue.wrap(registryManager.registryOrThrow(Registry.STRUCTURE_REGISTRY).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList())) ListValue.wrap(registryManager.registryOrThrow(Registries.STRUCTURE).keySet().stream().sorted().map(ValueConversions::of).collect(Collectors.toList()))
); );
return MapValue.wrap(plopData); return MapValue.wrap(plopData);
} }
@@ -960,7 +961,7 @@ public class Auxiliary {
ResourceLocation statName; ResourceLocation statName;
category = InputValidator.identifierOf(lv.get(1).getString()); category = InputValidator.identifierOf(lv.get(1).getString());
statName = InputValidator.identifierOf(lv.get(2).getString()); statName = InputValidator.identifierOf(lv.get(2).getString());
StatType<?> type = Registry.STAT_TYPE.get(category); StatType<?> type = BuiltInRegistries.STAT_TYPE.get(category);
if (type == null) return Value.NULL; if (type == null) return Value.NULL;
Stat<?> stat = getStat(type, statName); Stat<?> stat = getStat(type, statName);
if (stat == null) return Value.NULL; if (stat == null) return Value.NULL;
@@ -25,7 +25,7 @@ import java.util.UUID;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -101,7 +101,7 @@ public class Entities {
try try
{ {
entityId = ResourceLocation.read(new StringReader(entityString)); entityId = ResourceLocation.read(new StringReader(entityString));
EntityType<? extends Entity> type = Registry.ENTITY_TYPE.getOptional(entityId).orElse(null); EntityType<? extends Entity> type = BuiltInRegistries.ENTITY_TYPE.getOptional(entityId).orElse(null);
if (type == null || !type.canSummon()) if (type == null || !type.canSummon())
return Value.NULL; return Value.NULL;
} }
@@ -30,6 +30,8 @@ import java.util.stream.Collectors;
import net.minecraft.commands.arguments.item.ItemInput; import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.core.HolderSet; import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
@@ -65,11 +67,11 @@ public class Inventories {
expression.addContextFunction("item_list", -1, (c, t, lv) -> expression.addContextFunction("item_list", -1, (c, t, lv) ->
{ {
if (lv.size() == 0) if (lv.size() == 0)
return ListValue.wrap(Registry.ITEM.keySet().stream().map(ValueConversions::of).collect(Collectors.toList())); return ListValue.wrap(BuiltInRegistries.ITEM.keySet().stream().map(ValueConversions::of).collect(Collectors.toList()));
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
Registry<Item> items = cc.s.getServer().registryAccess().registryOrThrow(Registry.ITEM_REGISTRY); Registry<Item> items = cc.s.getServer().registryAccess().registryOrThrow(Registries.ITEM);
String tag = lv.get(0).getString(); String tag = lv.get(0).getString();
Optional<HolderSet.Named<Item>> itemTag = items.getTag(TagKey.create(Registry.ITEM_REGISTRY, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Item>> itemTag = items.getTag(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag)));
if (itemTag.isEmpty()) return Value.NULL; if (itemTag.isEmpty()) return Value.NULL;
return ListValue.wrap(itemTag.get().stream().map(b -> ValueConversions.of(items.getKey(b.value()))).collect(Collectors.toList())); return ListValue.wrap(itemTag.get().stream().map(b -> ValueConversions.of(items.getKey(b.value()))).collect(Collectors.toList()));
/* /*
@@ -85,7 +87,7 @@ public class Inventories {
{ {
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
Registry<Item> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registry.ITEM_REGISTRY); Registry<Item> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registries.ITEM);
if (lv.size() == 0) if (lv.size() == 0)
return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of).collect(Collectors.toList())); return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of).collect(Collectors.toList()));
Item item = NBTSerializableValue.parseItem(lv.get(0).getString(), cc.s.registryAccess()).getItem(); Item item = NBTSerializableValue.parseItem(lv.get(0).getString(), cc.s.registryAccess()).getItem();
@@ -94,7 +96,7 @@ public class Inventories {
return ListValue.wrap( blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == item))).map(e -> ValueConversions.of(e.getFirst())).collect(Collectors.toList())); return ListValue.wrap( blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == item))).map(e -> ValueConversions.of(e.getFirst())).collect(Collectors.toList()));
} }
String tag = lv.get(1).getString(); String tag = lv.get(1).getString();
Optional<HolderSet.Named<Item>> tagSet = blocks.getTag(TagKey.create(Registry.ITEM_REGISTRY, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Item>> tagSet = blocks.getTag(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag)));
if (tagSet.isEmpty()) return Value.NULL; if (tagSet.isEmpty()) return Value.NULL;
//return BooleanValue.of(tagSet.get().contains(item.builtInRegistryHolder())); //return BooleanValue.of(tagSet.get().contains(item.builtInRegistryHolder()));
@@ -123,7 +125,7 @@ public class Inventories {
if (lv.size() > 1) if (lv.size() > 1)
{ {
String recipeType = lv.get(1).getString(); String recipeType = lv.get(1).getString();
type = Registry.RECIPE_TYPE.get(InputValidator.identifierOf(recipeType)); type = BuiltInRegistries.RECIPE_TYPE.get(InputValidator.identifierOf(recipeType));
} }
List<Recipe<?>> recipes; List<Recipe<?>> recipes;
recipes = ((RecipeManagerInterface) cc.s.getServer().getRecipeManager()).getAllMatching(type, InputValidator.identifierOf(recipeName)); recipes = ((RecipeManagerInterface) cc.s.getServer().getRecipeManager()).getAllMatching(type, InputValidator.identifierOf(recipeName));
@@ -197,9 +199,9 @@ public class Inventories {
String itemStr = v.getString(); String itemStr = v.getString();
Item item; Item item;
ResourceLocation id = InputValidator.identifierOf(itemStr); ResourceLocation id = InputValidator.identifierOf(itemStr);
item = Registry.ITEM.getOptional(id).orElseThrow(() -> new ThrowStatement(itemStr, Throwables.UNKNOWN_ITEM)); item = BuiltInRegistries.ITEM.getOptional(id).orElseThrow(() -> new ThrowStatement(itemStr, Throwables.UNKNOWN_ITEM));
if (!item.hasCraftingRemainingItem()) return Value.NULL; if (!item.hasCraftingRemainingItem()) return Value.NULL;
return new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.ITEM.getKey(item.getCraftingRemainingItem()))); return new StringValue(NBTSerializableValue.nameFromRegistryId(BuiltInRegistries.ITEM.getKey(item.getCraftingRemainingItem())));
}); });
expression.addContextFunction("inventory_size", -1, (c, t, lv) -> expression.addContextFunction("inventory_size", -1, (c, t, lv) ->
@@ -44,6 +44,8 @@ import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet; import net.minecraft.core.HolderSet;
import net.minecraft.core.QuartPos; import net.minecraft.core.QuartPos;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.chunk.PalettedContainer;
@@ -295,7 +297,7 @@ public class WorldAccess {
if (poi == null) if (poi == null)
return Value.NULL; return Value.NULL;
return ListValue.of( return ListValue.of(
ValueConversions.of(Registry.POINT_OF_INTEREST_TYPE.getKey(poi.getPoiType().value())), ValueConversions.of(BuiltInRegistries.POINT_OF_INTEREST_TYPE.getKey(poi.getPoiType().value())),
new NumericValue(poiType.maxTickets() - ((PoiRecord_scarpetMixin)poi).getFreeTickets()) new NumericValue(poiType.maxTickets() - ((PoiRecord_scarpetMixin)poi).getFreeTickets())
); );
} }
@@ -309,7 +311,7 @@ public class WorldAccess {
String poiType = lv.get(locator.offset+1).getString().toLowerCase(Locale.ROOT); String poiType = lv.get(locator.offset+1).getString().toLowerCase(Locale.ROOT);
if (!"any".equals(poiType)) if (!"any".equals(poiType))
{ {
PoiType type = Registry.POINT_OF_INTEREST_TYPE.getOptional(InputValidator.identifierOf(poiType)) PoiType type = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getOptional(InputValidator.identifierOf(poiType))
.orElseThrow(() -> new ThrowStatement(poiType, Throwables.UNKNOWN_POI)); .orElseThrow(() -> new ThrowStatement(poiType, Throwables.UNKNOWN_POI));
condition = (tt) -> tt.value() == type; condition = (tt) -> tt.value() == type;
} }
@@ -335,7 +337,7 @@ public class WorldAccess {
store.getInRange(condition, pos, radius, status); store.getInRange(condition, pos, radius, status);
return ListValue.wrap(pois.sorted(Comparator.comparingDouble(p -> p.getPos().distSqr(pos))).map(p -> return ListValue.wrap(pois.sorted(Comparator.comparingDouble(p -> p.getPos().distSqr(pos))).map(p ->
ListValue.of( ListValue.of(
ValueConversions.of(Registry.POINT_OF_INTEREST_TYPE.getKey(p.getPoiType().value())), ValueConversions.of(BuiltInRegistries.POINT_OF_INTEREST_TYPE.getKey(p.getPoiType().value())),
new NumericValue(p.getPoiType().value().maxTickets() - ((PoiRecord_scarpetMixin)p).getFreeTickets()), new NumericValue(p.getPoiType().value().maxTickets() - ((PoiRecord_scarpetMixin)p).getFreeTickets()),
ValueConversions.of(p.getPos()) ValueConversions.of(p.getPos())
) )
@@ -360,9 +362,9 @@ public class WorldAccess {
} }
String poiTypeString = poi.getString().toLowerCase(Locale.ROOT); String poiTypeString = poi.getString().toLowerCase(Locale.ROOT);
ResourceLocation resource = InputValidator.identifierOf(poiTypeString); ResourceLocation resource = InputValidator.identifierOf(poiTypeString);
PoiType type = Registry.POINT_OF_INTEREST_TYPE.getOptional(resource) PoiType type = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getOptional(resource)
.orElseThrow(() -> new ThrowStatement(poiTypeString, Throwables.UNKNOWN_POI)); .orElseThrow(() -> new ThrowStatement(poiTypeString, Throwables.UNKNOWN_POI));
Holder<PoiType> holder = Registry.POINT_OF_INTEREST_TYPE.getHolderOrThrow(ResourceKey.create(Registry.POINT_OF_INTEREST_TYPE_REGISTRY, resource)); Holder<PoiType> holder = BuiltInRegistries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, resource));
int occupancy = 0; int occupancy = 0;
if (locator.offset + 1 < lv.size()) if (locator.offset + 1 < lv.size())
@@ -820,7 +822,7 @@ public class WorldAccess {
{ {
playerBreak = true; playerBreak = true;
String itemString = val.getString(); String itemString = val.getString();
item = Registry.ITEM.getOptional(InputValidator.identifierOf(itemString)) item = BuiltInRegistries.ITEM.getOptional(InputValidator.identifierOf(itemString))
.orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM)); .orElseThrow(() -> new ThrowStatement(itemString, Throwables.UNKNOWN_ITEM));
} }
} }
@@ -969,7 +971,7 @@ public class WorldAccess {
attacker = (LivingEntity) attackingEntity; attacker = (LivingEntity) attackingEntity;
} }
else throw new InternalExpressionException("Attacking entity needs to be a living thing, "+ else throw new InternalExpressionException("Attacking entity needs to be a living thing, "+
ValueConversions.of(Registry.ENTITY_TYPE.getKey(attackingEntity.getType())).getString() +" ain't it."); ValueConversions.of(BuiltInRegistries.ENTITY_TYPE.getKey(attackingEntity.getType())).getString() +" ain't it.");
} }
else else
@@ -1129,12 +1131,12 @@ public class WorldAccess {
expression.addContextFunction("block_list", -1, (c, t, lv) -> expression.addContextFunction("block_list", -1, (c, t, lv) ->
{ {
if (lv.size() == 0) if (lv.size() == 0)
return ListValue.wrap(Registry.BLOCK.keySet().stream().map(ValueConversions::of).collect(Collectors.toList())); return ListValue.wrap(BuiltInRegistries.BLOCK.keySet().stream().map(ValueConversions::of).collect(Collectors.toList()));
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
ResourceLocation tag = InputValidator.identifierOf(lv.get(0).getString()); ResourceLocation tag = InputValidator.identifierOf(lv.get(0).getString());
Registry<Block> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY); Registry<Block> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registries.BLOCK);
Optional<HolderSet.Named<Block>> tagset = blocks.getTag(TagKey.create(Registry.BLOCK_REGISTRY, tag)); Optional<HolderSet.Named<Block>> tagset = blocks.getTag(TagKey.create(Registries.BLOCK, tag));
if (tagset.isEmpty()) return Value.NULL; if (tagset.isEmpty()) return Value.NULL;
return ListValue.wrap(tagset.get().stream().map(b -> ValueConversions.of(blocks.getKey(b.value()))).collect(Collectors.toList())); return ListValue.wrap(tagset.get().stream().map(b -> ValueConversions.of(blocks.getKey(b.value()))).collect(Collectors.toList()));
}); });
@@ -1142,7 +1144,7 @@ public class WorldAccess {
expression.addContextFunction("block_tags", -1, (c, t, lv) -> expression.addContextFunction("block_tags", -1, (c, t, lv) ->
{ {
CarpetContext cc = (CarpetContext)c; CarpetContext cc = (CarpetContext)c;
Registry<Block> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registry.BLOCK_REGISTRY); Registry<Block> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registries.BLOCK);
if (lv.size() == 0) if (lv.size() == 0)
return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of).collect(Collectors.toList())); return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of).collect(Collectors.toList()));
BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true); BlockArgument blockLocator = BlockArgument.findIn(cc, lv, 0, true);
@@ -1152,7 +1154,7 @@ public class WorldAccess {
return ListValue.wrap( blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == target))).map(e -> ValueConversions.of(e.getFirst())).collect(Collectors.toList())); return ListValue.wrap( blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == target))).map(e -> ValueConversions.of(e.getFirst())).collect(Collectors.toList()));
} }
String tag = lv.get(blockLocator.offset).getString(); String tag = lv.get(blockLocator.offset).getString();
Optional<HolderSet.Named<Block>> tagSet = blocks.getTag(TagKey.create(Registry.BLOCK_REGISTRY, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Block>> tagSet = blocks.getTag(TagKey.create(Registries.BLOCK, InputValidator.identifierOf(tag)));
if (tagSet.isEmpty()) return Value.NULL; if (tagSet.isEmpty()) return Value.NULL;
return BooleanValue.of(blockLocator.block.getBlockState().is(tagSet.get())); return BooleanValue.of(blockLocator.block.getBlockState().is(tagSet.get()));
@@ -1178,7 +1180,7 @@ public class WorldAccess {
CarpetContext cc = (CarpetContext) c; CarpetContext cc = (CarpetContext) c;
ServerLevel world = cc.s.getLevel(); ServerLevel world = cc.s.getLevel();
if (lv.size() == 0) if (lv.size() == 0)
return ListValue.wrap(world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).keySet().stream().map(ValueConversions::of)); return ListValue.wrap(world.registryAccess().registryOrThrow(Registries.BIOME).keySet().stream().map(ValueConversions::of));
Biome biome; Biome biome;
BiomeSource biomeSource = world.getChunkSource().getGenerator().getBiomeSource(); BiomeSource biomeSource = world.getChunkSource().getGenerator().getBiomeSource();
@@ -1213,7 +1215,7 @@ public class WorldAccess {
Climate.quantizeCoord(numberGetOrThrow(weirdness)) Climate.quantizeCoord(numberGetOrThrow(weirdness))
); );
biome = mnbs.getNoiseBiome(point).value(); biome = mnbs.getNoiseBiome(point).value();
ResourceLocation biomeId = cc.s.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome); ResourceLocation biomeId = cc.s.getServer().registryAccess().registryOrThrow(Registries.BIOME).getKey(biome);
return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId)); return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId));
} }
@@ -1221,7 +1223,7 @@ public class WorldAccess {
if (locator.replacement != null) if (locator.replacement != null)
{ {
biome = world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(InputValidator.identifierOf(locator.replacement)); biome = world.registryAccess().registryOrThrow(Registries.BIOME).get(InputValidator.identifierOf(locator.replacement));
if (biome == null) throw new ThrowStatement(locator.replacement, Throwables.UNKNOWN_BIOME); if (biome == null) throw new ThrowStatement(locator.replacement, Throwables.UNKNOWN_BIOME);
} }
else else
@@ -1232,7 +1234,7 @@ public class WorldAccess {
// in locatebiome // in locatebiome
if (locator.offset == lv.size()) if (locator.offset == lv.size())
{ {
ResourceLocation biomeId = cc.s.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome); ResourceLocation biomeId = cc.s.getServer().registryAccess().registryOrThrow(Registries.BIOME).getKey(biome);
return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId)); return new StringValue(NBTSerializableValue.nameFromRegistryId(biomeId));
} }
String biomeFeature = lv.get(locator.offset).getString(); String biomeFeature = lv.get(locator.offset).getString();
@@ -1250,7 +1252,7 @@ public class WorldAccess {
throw new InternalExpressionException("'set_biome' needs a biome name as an argument"); throw new InternalExpressionException("'set_biome' needs a biome name as an argument");
String biomeName = lv.get(locator.offset+0).getString(); String biomeName = lv.get(locator.offset+0).getString();
// from locatebiome command code // from locatebiome command code
Holder<Biome> biome = cc.s.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getHolder(ResourceKey.create(Registry.BIOME_REGISTRY, InputValidator.identifierOf(biomeName))) Holder<Biome> biome = cc.s.getServer().registryAccess().registryOrThrow(Registries.BIOME).getHolder(ResourceKey.create(Registries.BIOME, InputValidator.identifierOf(biomeName)))
.orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME)); .orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME));
@@ -1294,7 +1296,7 @@ public class WorldAccess {
ServerLevel world = cc.s.getLevel(); ServerLevel world = cc.s.getLevel();
BlockPos pos = locator.block.getPos(); BlockPos pos = locator.block.getPos();
Map<Structure, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences(); Map<Structure, LongSet> references = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_REFERENCES).getAllReferences();
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registries.STRUCTURE);
if (lv.size() == locator.offset) if (lv.size() == locator.offset)
return ListValue.wrap(references.entrySet().stream(). return ListValue.wrap(references.entrySet().stream().
filter(e -> e.getValue()!= null && !e.getValue().isEmpty()). filter(e -> e.getValue()!= null && !e.getValue().isEmpty()).
@@ -1325,7 +1327,7 @@ public class WorldAccess {
final List<Structure> structure = new ArrayList<>(); final List<Structure> structure = new ArrayList<>();
boolean needSize = false; boolean needSize = false;
boolean singleOutput = false; boolean singleOutput = false;
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registries.STRUCTURE);
if (lv.size() > locator.offset) if (lv.size() > locator.offset)
{ {
Value requested = lv.get(locator.offset+0); Value requested = lv.get(locator.offset+0);
@@ -1341,7 +1343,7 @@ public class WorldAccess {
} }
else else
{ {
StructureType<?> sss = Registry.STRUCTURE_TYPES.get(id); StructureType<?> sss = BuiltInRegistries.STRUCTURE_TYPE.get(id);
reg.entrySet().stream().filter(e -> e.getValue().type() ==sss).forEach(e -> structure.add(e.getValue())); reg.entrySet().stream().filter(e -> e.getValue().type() ==sss).forEach(e -> structure.add(e.getValue()));
} }
if (structure.isEmpty()) if (structure.isEmpty())
@@ -1399,7 +1401,7 @@ public class WorldAccess {
ServerLevel world = cc.s.getLevel(); ServerLevel world = cc.s.getLevel();
BlockPos pos = locator.block.getPos(); BlockPos pos = locator.block.getPos();
Map<Structure, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getAllStarts(); Map<Structure, StructureStart> structures = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.STRUCTURE_STARTS).getAllStarts();
Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); Registry<Structure> reg = cc.s.getServer().registryAccess().registryOrThrow(Registries.STRUCTURE);
if (lv.size() == locator.offset) if (lv.size() == locator.offset)
{ {
Map<Value, Value> structureList = new HashMap<>(); Map<Value, Value> structureList = new HashMap<>();
@@ -95,6 +95,8 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet; import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@@ -160,7 +162,7 @@ public abstract class CommandArgument
new VanillaUnconfigurableArgument("anchor", EntityAnchorArgument::anchor, new VanillaUnconfigurableArgument("anchor", EntityAnchorArgument::anchor,
(c, p) -> StringValue.of(EntityAnchorArgument.getAnchor(c, p).name()), false (c, p) -> StringValue.of(EntityAnchorArgument.getAnchor(c, p).name()), false
), ),
new VanillaUnconfigurableArgument("entitytype", c -> ResourceArgument.resource(c, Registry.ENTITY_TYPE_REGISTRY), new VanillaUnconfigurableArgument("entitytype", c -> ResourceArgument.resource(c, Registries.ENTITY_TYPE),
(c, p) -> ValueConversions.of(ResourceArgument.getSummonableEntityType(c, p).key()), SuggestionProviders.SUMMONABLE_ENTITIES (c, p) -> ValueConversions.of(ResourceArgument.getSummonableEntityType(c, p).key()), SuggestionProviders.SUMMONABLE_ENTITIES
), ),
new VanillaUnconfigurableArgument("floatrange", RangeArgument::floatRange, new VanillaUnconfigurableArgument("floatrange", RangeArgument::floatRange,
@@ -172,7 +174,7 @@ public abstract class CommandArgument
new VanillaUnconfigurableArgument("intrange", RangeArgument::intRange, new VanillaUnconfigurableArgument("intrange", RangeArgument::intRange,
(c, p) -> ValueConversions.of(RangeArgument.Ints.getRange(c, p)), true (c, p) -> ValueConversions.of(RangeArgument.Ints.getRange(c, p)), true
), ),
new VanillaUnconfigurableArgument("enchantment", Registry.ENCHANTMENT_REGISTRY), new VanillaUnconfigurableArgument("enchantment", Registries.ENCHANTMENT),
// item_predicate ?? //same as item but accepts tags, not sure right now // item_predicate ?? //same as item but accepts tags, not sure right now
new SlotArgument(), new SlotArgument(),
@@ -183,7 +185,7 @@ public abstract class CommandArgument
new VanillaUnconfigurableArgument("message", MessageArgument::message, new VanillaUnconfigurableArgument("message", MessageArgument::message,
(c, p) -> new FormattedTextValue(MessageArgument.getMessage(c, p)), true (c, p) -> new FormattedTextValue(MessageArgument.getMessage(c, p)), true
), ),
new VanillaUnconfigurableArgument("effect", Registry.MOB_EFFECT_REGISTRY), new VanillaUnconfigurableArgument("effect", Registries.MOB_EFFECT),
new TagArgument(), // for nbt_compound_tag and nbt_tag new TagArgument(), // for nbt_compound_tag and nbt_tag
new VanillaUnconfigurableArgument("path", NbtPathArgument::nbtPath, new VanillaUnconfigurableArgument("path", NbtPathArgument::nbtPath,
@@ -197,7 +199,7 @@ public abstract class CommandArgument
), ),
// operation // not sure if we need it, you have scarpet for that // operation // not sure if we need it, you have scarpet for that
new VanillaUnconfigurableArgument("particle", ParticleArgument::particle, new VanillaUnconfigurableArgument("particle", ParticleArgument::particle,
(c, p) -> ValueConversions.of(ParticleArgument.getParticle(c, p)), (c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().registryOrThrow(Registry.PARTICLE_TYPE_REGISTRY).keySet(), b) (c, p) -> ValueConversions.of(ParticleArgument.getParticle(c, p)), (c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().registryOrThrow(Registries.PARTICLE_TYPE).keySet(), b)
), ),
// resource / identifier section // resource / identifier section
@@ -209,20 +211,20 @@ public abstract class CommandArgument
(c, p) -> ValueConversions.of( ResourceLocationArgument.getAdvancement(c, p).getId()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(Advancement::getId), builder) (c, p) -> ValueConversions.of( ResourceLocationArgument.getAdvancement(c, p).getId()), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getAdvancements().getAllAdvancements().stream().map(Advancement::getId), builder)
), ),
new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id, new VanillaUnconfigurableArgument("lootcondition", ResourceLocationArgument::id,
(c, p) -> ValueConversions.of( Registry.LOOT_CONDITION_TYPE.getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getPredicateManager().getKeys(), builder) (c, p) -> ValueConversions.of( BuiltInRegistries.LOOT_CONDITION_TYPE.getKey(ResourceLocationArgument.getPredicate(c, p).getType())), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getPredicateManager().getKeys(), builder)
), ),
new VanillaUnconfigurableArgument("loottable", ResourceLocationArgument::id, new VanillaUnconfigurableArgument("loottable", ResourceLocationArgument::id,
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootTables().getIds(), builder) (c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().getLootTables().getIds(), builder)
), ),
new VanillaUnconfigurableArgument("attribute", Registry.ATTRIBUTE_REGISTRY), new VanillaUnconfigurableArgument("attribute", Registries.ATTRIBUTE),
new VanillaUnconfigurableArgument("boss", ResourceLocationArgument::id, new VanillaUnconfigurableArgument("boss", ResourceLocationArgument::id,
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), BossBarCommands.SUGGEST_BOSS_BAR (c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), BossBarCommands.SUGGEST_BOSS_BAR
), ),
new VanillaUnconfigurableArgument("biome", (c) -> ResourceOrTagArgument.resourceOrTag(c, Registry.BIOME_REGISTRY), new VanillaUnconfigurableArgument("biome", (c) -> ResourceOrTagArgument.resourceOrTag(c, Registries.BIOME),
(c, p) -> { (c, p) -> {
ResourceOrTagArgument.Result<Biome> result = ResourceOrTagArgument.getResourceOrTag(c, "biome", Registry.BIOME_REGISTRY); ResourceOrTagArgument.Result<Biome> result = ResourceOrTagArgument.getResourceOrTag(c, "biome", Registries.BIOME);
Either<Holder.Reference<Biome>, HolderSet.Named<Biome>> res = result.unwrap(); Either<Holder.Reference<Biome>, HolderSet.Named<Biome>> res = result.unwrap();
if (res.left().isPresent()) if (res.left().isPresent())
{ {
@@ -233,7 +235,7 @@ public abstract class CommandArgument
return ValueConversions.of(res.right().get().key()); return ValueConversions.of(res.right().get().key());
} }
return Value.NULL; return Value.NULL;
}, (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).keySet(), builder) }, (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().registryAccess().registryOrThrow(Registries.BIOME).keySet(), builder)
), ),
new VanillaUnconfigurableArgument("sound", ResourceLocationArgument::id, new VanillaUnconfigurableArgument("sound", ResourceLocationArgument::id,
(c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_SOUNDS (c, p) -> ValueConversions.of( ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
@@ -12,12 +12,11 @@ import java.util.Map;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
public class BiomeInfo public class BiomeInfo
{ {
@@ -25,7 +24,7 @@ public class BiomeInfo
//put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings(). getSurfaceConfig().getTopMaterial(), null, null)); //put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings(). getSurfaceConfig().getTopMaterial(), null, null));
//put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null)); //put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
//put("category", (w, b) -> StringValue.of(Biome.getBiomeCategory(Holder.direct(b)).getName())); //put("category", (w, b) -> StringValue.of(Biome.getBiomeCategory(Holder.direct(b)).getName()));
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getTags().filter(p -> p.getSecond().stream().anyMatch(h -> h.value() == b)).map(p -> p.getFirst().location()).map(ValueConversions::of).collect(Collectors.toList()))); put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.getSecond().stream().anyMatch(h -> h.value() == b)).map(p -> p.getFirst().location()).map(ValueConversions::of).collect(Collectors.toList())));
put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature())); put("temperature", (w, b) -> NumericValue.of(b.getBaseTemperature()));
put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor())); put("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
@@ -39,7 +38,7 @@ public class BiomeInfo
//put("scale", (w, b) -> NumericValue.of(b.getScale())); //put("scale", (w, b) -> NumericValue.of(b.getScale()));
put("features", (w, b) -> { put("features", (w, b) -> {
Registry<ConfiguredFeature<?,?>> registry = w.registryAccess().registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY); Registry<ConfiguredFeature<?,?>> registry = w.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE);
return ListValue.wrap( return ListValue.wrap(
b.getGenerationSettings().features().stream().map(step -> b.getGenerationSettings().features().stream().map(step ->
ListValue.wrap(step.stream().map(cfp -> ListValue.wrap(step.stream().map(cfp ->
@@ -29,9 +29,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.arguments.ParticleArgument; import net.minecraft.commands.arguments.ParticleArgument;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.ByteTag;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.DoubleTag; import net.minecraft.nbt.DoubleTag;
@@ -179,7 +180,7 @@ public class ShapeDispatcher
return particle; return particle;
try try
{ {
particle = ParticleArgument.readParticle(new StringReader(name), regs.lookupOrThrow(Registry.PARTICLE_TYPE_REGISTRY)); particle = ParticleArgument.readParticle(new StringReader(name), regs.lookupOrThrow(Registries.PARTICLE_TYPE));
} }
catch (CommandSyntaxException e) catch (CommandSyntaxException e)
{ {
@@ -348,7 +349,7 @@ public class ShapeDispatcher
key = 0; key = 0;
followEntity = -1; followEntity = -1;
shapeDimension = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(options.get("dim").getString())); shapeDimension = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(options.get("dim").getString()));
if (options.containsKey("follow")) if (options.containsKey("follow"))
{ {
followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt(); followEntity = NumericValue.asNumber(options.getOrDefault("follow", optional.get("follow"))).getInt();
@@ -650,11 +651,11 @@ public class ShapeDispatcher
if(this.isitem) if(this.isitem)
{ {
if (Block.byItem(this.item.getItem()).defaultBlockState().isAir()) return; if (Block.byItem(this.item.getItem()).defaultBlockState().isAir()) return;
particle = getParticleData("block_marker "+Registry.BLOCK.getKey(Block.byItem(this.item.getItem())), p.level.registryAccess()); particle = getParticleData("block_marker "+ BuiltInRegistries.BLOCK.getKey(Block.byItem(this.item.getItem())), p.level.registryAccess());
} }
else else
{ {
particle = getParticleData("block_marker "+Registry.BLOCK.getKey(this.blockState.getBlock()), p.level.registryAccess()); particle = getParticleData("block_marker "+BuiltInRegistries.BLOCK.getKey(this.blockState.getBlock()), p.level.registryAccess());
} }
Vec3 v = relativiseRender(p.level, this.pos, 0); Vec3 v = relativiseRender(p.level, this.pos, 0);
@@ -1324,7 +1325,7 @@ public class ShapeDispatcher
@Override @Override
public Value decode(Tag tag, Level level) { public Value decode(Tag tag, Level level) {
BlockState bs = NbtUtils.readBlockState(level.holderLookup(Registry.BLOCK_REGISTRY), (CompoundTag) tag); BlockState bs = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), (CompoundTag) tag);
CompoundTag compoundTag2 = null; CompoundTag compoundTag2 = null;
if (((CompoundTag) tag).contains("TileEntityData", 10)) { if (((CompoundTag) tag).contains("TileEntityData", 10)) {
compoundTag2 = ((CompoundTag) tag).getCompound("TileEntityData"); compoundTag2 = ((CompoundTag) tag).getCompound("TileEntityData");
@@ -18,8 +18,9 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.GlobalPos; import net.minecraft.core.GlobalPos;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag; import net.minecraft.nbt.Tag;
@@ -60,7 +61,7 @@ public class BlockValue extends Value
{ {
BlockValue bv = bvCache.get(str); // [SCARY SHIT] persistent caches over server reloads BlockValue bv = bvCache.get(str); // [SCARY SHIT] persistent caches over server reloads
if (bv != null) return bv; if (bv != null) return bv;
BlockStateParser.BlockResult foo = BlockStateParser.parseForBlock(regs.lookupOrThrow(Registry.BLOCK_REGISTRY), new StringReader(str), true ); BlockStateParser.BlockResult foo = BlockStateParser.parseForBlock(regs.lookupOrThrow(Registries.BLOCK), new StringReader(str), true );
if (foo.blockState() != null) if (foo.blockState() != null)
{ {
CompoundTag bd = foo.nbt(); CompoundTag bd = foo.nbt();
@@ -150,7 +151,7 @@ public class BlockValue extends Value
@Override @Override
public String getString() public String getString()
{ {
return nameFromRegistryId(Registry.BLOCK.getKey(getBlockState().getBlock())); return nameFromRegistryId(BuiltInRegistries.BLOCK.getKey(getBlockState().getBlock()));
} }
@Override @Override
@@ -194,7 +195,7 @@ public class BlockValue extends Value
CompoundTag tag = new CompoundTag(); CompoundTag tag = new CompoundTag();
CompoundTag state = new CompoundTag(); CompoundTag state = new CompoundTag();
BlockState s = getBlockState(); BlockState s = getBlockState();
state.put("Name", StringTag.valueOf(Registry.BLOCK.getKey(s.getBlock()).toString())); state.put("Name", StringTag.valueOf(BuiltInRegistries.BLOCK.getKey(s.getBlock()).toString()));
Collection<Property<?>> properties = s.getProperties(); Collection<Property<?>> properties = s.getProperties();
if (!properties.isEmpty()) if (!properties.isEmpty())
{ {
@@ -24,7 +24,8 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet; import net.minecraft.core.HolderSet;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.StringTag; import net.minecraft.nbt.StringTag;
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket; import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
@@ -255,8 +256,8 @@ public class EntityValue extends Value
who = who.substring(1); who = who.substring(1);
} }
String booWho = who; String booWho = who;
HolderSet.Named<EntityType<?>> eTagValue = server.registryAccess().registryOrThrow(Registry.ENTITY_TYPE_REGISTRY) HolderSet.Named<EntityType<?>> eTagValue = server.registryAccess().registryOrThrow(Registries.ENTITY_TYPE)
.getTag(TagKey.create(Registry.ENTITY_TYPE_REGISTRY, InputValidator.identifierOf(who))) .getTag(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(who)))
.orElseThrow( () -> new InternalExpressionException(booWho+" is not a valid entity descriptor")); .orElseThrow( () -> new InternalExpressionException(booWho+" is not a valid entity descriptor"));
Set<EntityType<?>> eTag = eTagValue.stream().map(Holder::value).collect(Collectors.toUnmodifiableSet()); Set<EntityType<?>> eTag = eTagValue.stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
if (positive) if (positive)
@@ -273,7 +274,7 @@ public class EntityValue extends Value
} }
else else
{ {
return new EntityClassDescriptor(ANY, e -> !eTag.contains(e.getType()) && e.isAlive(), Registry.ENTITY_TYPE.stream().filter(et -> !eTag.contains(et))); return new EntityClassDescriptor(ANY, e -> !eTag.contains(e.getType()) && e.isAlive(), BuiltInRegistries.ENTITY_TYPE.stream().filter(et -> !eTag.contains(et)));
} }
} }
return eDesc; return eDesc;
@@ -300,11 +301,11 @@ public class EntityValue extends Value
} }
public Value listValue() { public Value listValue() {
return ListValue.wrap(types.stream().map(et -> StringValue.of(nameFromRegistryId(Registry.ENTITY_TYPE.getKey(et))))); return ListValue.wrap(types.stream().map(et -> StringValue.of(nameFromRegistryId(BuiltInRegistries.ENTITY_TYPE.getKey(et)))));
} }
public final static Map<String, EntityClassDescriptor> byName = new HashMap<>() {{ public final static Map<String, EntityClassDescriptor> byName = new HashMap<>() {{
List<EntityType<?>> allTypes = Registry.ENTITY_TYPE.stream().toList(); List<EntityType<?>> allTypes = BuiltInRegistries.ENTITY_TYPE.stream().toList();
// nonliving types // nonliving types
Set<EntityType<?>> projectiles = Set.of( Set<EntityType<?>> projectiles = Set.of(
EntityType.ARROW, EntityType.DRAGON_FIREBALL, EntityType.FIREWORK_ROCKET, EntityType.ARROW, EntityType.DRAGON_FIREBALL, EntityType.FIREWORK_ROCKET,
@@ -387,9 +388,9 @@ public class EntityValue extends Value
put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(regular::contains))); put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() == MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(regular::contains)));
put("!regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et)))); put("!regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (((LivingEntity) e).getMobType() != MobType.UNDEFINED && e.isAlive()), allTypes.stream().filter(et -> !regular.contains(et) && living.contains(et))));
for (ResourceLocation typeId : Registry.ENTITY_TYPE.keySet()) for (ResourceLocation typeId : BuiltInRegistries.ENTITY_TYPE.keySet())
{ {
EntityType<?> type = Registry.ENTITY_TYPE.get(typeId); EntityType<?> type = BuiltInRegistries.ENTITY_TYPE.get(typeId);
String mobType = ValueConversions.simplify(typeId); String mobType = ValueConversions.simplify(typeId);
put( mobType, new EntityClassDescriptor(type, net.minecraft.world.entity.EntitySelector.ENTITY_STILL_ALIVE, Stream.of(type))); put( mobType, new EntityClassDescriptor(type, net.minecraft.world.entity.EntitySelector.ENTITY_STILL_ALIVE, Stream.of(type)));
put("!"+mobType, new EntityClassDescriptor(ANY, (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type))); put("!"+mobType, new EntityClassDescriptor(ANY, (e) -> e.getType() != type && e.isAlive(), allTypes.stream().filter(et -> et != type)));
@@ -448,7 +449,7 @@ public class EntityValue extends Value
put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName())); put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName()));
put("command_name", (e, a) -> new StringValue(e.getScoreboardName())); put("command_name", (e, a) -> new StringValue(e.getScoreboardName()));
put("custom_name", (e, a) -> e.hasCustomName()?new StringValue(e.getCustomName().getString()):Value.NULL); put("custom_name", (e, a) -> e.hasCustomName()?new StringValue(e.getCustomName().getString()):Value.NULL);
put("type", (e, a) -> new StringValue(nameFromRegistryId(Registry.ENTITY_TYPE.getKey(e.getType())))); put("type", (e, a) -> new StringValue(nameFromRegistryId(BuiltInRegistries.ENTITY_TYPE.getKey(e.getType()))));
put("is_riding", (e, a) -> BooleanValue.of(e.isPassenger())); put("is_riding", (e, a) -> BooleanValue.of(e.isPassenger()));
put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle())); put("is_ridden", (e, a) -> BooleanValue.of(e.isVehicle()));
put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new).collect(Collectors.toList()))); put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new).collect(Collectors.toList())));
@@ -460,14 +461,14 @@ public class EntityValue extends Value
put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new).collect(Collectors.toList()))); put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new).collect(Collectors.toList())));
put("entity_tags", (e, a) -> { put("entity_tags", (e, a) -> {
EntityType<?> type = e.getType(); EntityType<?> type = e.getType();
return ListValue.wrap(e.getServer().registryAccess().registryOrThrow(Registry.ENTITY_TYPE_REGISTRY).getTags().filter(entry -> entry.getSecond().stream().anyMatch(h -> h.value()==type)).map(entry -> ValueConversions.of(entry.getFirst())).collect(Collectors.toList())); return ListValue.wrap(e.getServer().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.getSecond().stream().anyMatch(h -> h.value()==type)).map(entry -> ValueConversions.of(entry.getFirst())).collect(Collectors.toList()));
}); });
// deprecated // deprecated
put("has_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString()))); put("has_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString())));
put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString()))); put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString())));
put("has_entity_tag", (e, a) -> { put("has_entity_tag", (e, a) -> {
Optional<HolderSet.Named<EntityType<?>>> tag = e.getServer().registryAccess().registryOrThrow(Registry.ENTITY_TYPE_REGISTRY).getTag(TagKey.create(Registry.ENTITY_TYPE_REGISTRY, InputValidator.identifierOf(a.getString()))); Optional<HolderSet.Named<EntityType<?>>> tag = e.getServer().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getTag(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(a.getString())));
if (tag.isEmpty()) return Value.NULL; if (tag.isEmpty()) return Value.NULL;
//Tag<EntityType<?>> tag = e.getServer().getTags().getOrEmpty(Registry.ENTITY_TYPE_REGISTRY).getTag(InputValidator.identifierOf(a.getString())); //Tag<EntityType<?>> tag = e.getServer().getTags().getOrEmpty(Registry.ENTITY_TYPE_REGISTRY).getTag(InputValidator.identifierOf(a.getString()));
//if (tag == null) return Value.NULL; //if (tag == null) return Value.NULL;
@@ -656,7 +657,7 @@ public class EntityValue extends Value
put("brain", (e, a) -> { put("brain", (e, a) -> {
String module = a.getString(); String module = a.getString();
MemoryModuleType<?> moduleType = Registry.MEMORY_MODULE_TYPE.get(InputValidator.identifierOf(module)); MemoryModuleType<?> moduleType = BuiltInRegistries.MEMORY_MODULE_TYPE.get(InputValidator.identifierOf(module));
if (moduleType == MemoryModuleType.DUMMY) return Value.NULL; if (moduleType == MemoryModuleType.DUMMY) return Value.NULL;
if (e instanceof LivingEntity livingEntity) if (e instanceof LivingEntity livingEntity)
{ {
@@ -748,7 +749,7 @@ public class EntityValue extends Value
return ListValue.wrap(effects); return ListValue.wrap(effects);
} }
String effectName = a.getString(); String effectName = a.getString();
MobEffect potion = Registry.MOB_EFFECT.get(InputValidator.identifierOf(effectName)); MobEffect potion = BuiltInRegistries.MOB_EFFECT.get(InputValidator.identifierOf(effectName));
if (potion == null) if (potion == null)
throw new InternalExpressionException("No such an effect: "+effectName); throw new InternalExpressionException("No such an effect: "+effectName);
if (!((LivingEntity) e).hasEffect(potion)) if (!((LivingEntity) e).hasEffect(potion))
@@ -933,10 +934,10 @@ public class EntityValue extends Value
if (a == null) if (a == null)
{ {
AttributeMap container = el.getAttributes(); AttributeMap container = el.getAttributes();
return MapValue.wrap(Registry.ATTRIBUTE.stream().filter(container::hasAttribute).collect(Collectors.toMap(aa -> ValueConversions.of(Registry.ATTRIBUTE.getKey(aa)), aa -> NumericValue.of(container.getValue(aa))))); return MapValue.wrap(BuiltInRegistries.ATTRIBUTE.stream().filter(container::hasAttribute).collect(Collectors.toMap(aa -> ValueConversions.of(BuiltInRegistries.ATTRIBUTE.getKey(aa)), aa -> NumericValue.of(container.getValue(aa)))));
} }
ResourceLocation id = InputValidator.identifierOf(a.getString()); ResourceLocation id = InputValidator.identifierOf(a.getString());
Attribute attrib = Registry.ATTRIBUTE.getOptional(id).orElseThrow( Attribute attrib = BuiltInRegistries.ATTRIBUTE.getOptional(id).orElseThrow(
() -> new InternalExpressionException("Unknown attribute: "+a.getString()) () -> new InternalExpressionException("Unknown attribute: "+a.getString())
); );
if (!el.getAttributes().hasAttribute(attrib)) return Value.NULL; if (!el.getAttributes().hasAttribute(attrib)) return Value.NULL;
@@ -1503,7 +1504,7 @@ public class EntityValue extends Value
if (lv.size() >= 1 && lv.size() <= 6) if (lv.size() >= 1 && lv.size() <= 6)
{ {
String effectName = lv.get(0).getString(); String effectName = lv.get(0).getString();
MobEffect effect = Registry.MOB_EFFECT.get(InputValidator.identifierOf(effectName)); MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(InputValidator.identifierOf(effectName));
if (effect == null) if (effect == null)
throw new InternalExpressionException("Wrong effect name: "+effectName); throw new InternalExpressionException("Wrong effect name: "+effectName);
if (lv.size() == 1) if (lv.size() == 1)
@@ -1536,7 +1537,7 @@ public class EntityValue extends Value
else else
{ {
String effectName = v.getString(); String effectName = v.getString();
MobEffect effect = Registry.MOB_EFFECT.get(InputValidator.identifierOf(effectName)); MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(InputValidator.identifierOf(effectName));
if (effect == null) if (effect == null)
throw new InternalExpressionException("Wrong effect name: "+effectName); throw new InternalExpressionException("Wrong effect name: "+effectName);
le.removeEffect(effect); le.removeEffect(effect);
@@ -1716,7 +1717,7 @@ public class EntityValue extends Value
if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this); if (!force) throw new NBTSerializableValue.IncompatibleTypeException(this);
CompoundTag tag = new CompoundTag(); CompoundTag tag = new CompoundTag();
tag.put("Data", getEntity().saveWithoutId( new CompoundTag())); tag.put("Data", getEntity().saveWithoutId( new CompoundTag()));
tag.put("Name", StringTag.valueOf(Registry.ENTITY_TYPE.getKey(getEntity().getType()).toString())); tag.put("Name", StringTag.valueOf(BuiltInRegistries.ENTITY_TYPE.getKey(getEntity().getType()).toString()));
return tag; return tag;
} }
} }
@@ -23,8 +23,8 @@ import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.commands.arguments.item.ItemParser; import net.minecraft.commands.arguments.item.ItemParser;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CollectionTag; import net.minecraft.nbt.CollectionTag;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.EndTag; import net.minecraft.nbt.EndTag;
@@ -305,7 +305,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
return res; return res;
else else
return new ItemInput(Holder.direct(res.getItem()), customTag); return new ItemInput(Holder.direct(res.getItem()), customTag);
ItemParser.ItemResult parser = ItemParser.parseForItem(regs.lookupOrThrow(Registry.ITEM_REGISTRY), new StringReader(itemString)); ItemParser.ItemResult parser = ItemParser.parseForItem(regs.lookupOrThrow(Registries.ITEM), new StringReader(itemString));
res = new ItemInput(parser.item(), parser.nbt()); res = new ItemInput(parser.item(), parser.nbt());
itemCache.put(itemString, res); itemCache.put(itemString, res);
@@ -11,10 +11,11 @@ import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.arguments.item.ItemInput; import net.minecraft.commands.arguments.item.ItemInput;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.GlobalPos; import net.minecraft.core.GlobalPos;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@@ -84,7 +85,7 @@ public class ValueConversions
if (stack == null || stack.isEmpty()) if (stack == null || stack.isEmpty())
return Value.NULL; return Value.NULL;
return ListValue.of( return ListValue.of(
of(Registry.ITEM.getKey(stack.getItem())), of(BuiltInRegistries.ITEM.getKey(stack.getItem())),
new NumericValue(stack.getCount()), new NumericValue(stack.getCount()),
NBTSerializableValue.fromStack(stack) NBTSerializableValue.fromStack(stack)
); );
@@ -331,7 +332,7 @@ public class ValueConversions
if (box.maxX() >= box.minX() && box.maxY() >= box.minY() && box.maxZ() >= box.minZ()) if (box.maxX() >= box.minX() && box.maxY() >= box.minY() && box.maxZ() >= box.minZ())
{ {
pieces.add(ListValue.of( pieces.add(ListValue.of(
new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getKey(piece.getType()))), new StringValue(NBTSerializableValue.nameFromRegistryId(BuiltInRegistries.STRUCTURE_PIECE.getKey(piece.getType()))),
(piece.getOrientation() == null) ? Value.NULL : new StringValue(piece.getOrientation().getName()), (piece.getOrientation() == null) ? Value.NULL : new StringValue(piece.getOrientation().getName()),
ListValue.fromTriple(box.minX(), box.minY(), box.minZ()), ListValue.fromTriple(box.minX(), box.minY(), box.minZ()),
ListValue.fromTriple(box.maxX(), box.maxY(), box.maxZ()) ListValue.fromTriple(box.maxX(), box.maxY(), box.maxZ())
@@ -406,8 +407,8 @@ public class ValueConversions
{ {
BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate; BlockPredicateInterface predicateData = (BlockPredicateInterface) blockPredicate;
return ListValue.of( return ListValue.of(
predicateData.getCMBlockState()==null?Value.NULL:of(Registry.BLOCK.getKey(predicateData.getCMBlockState().getBlock())), predicateData.getCMBlockState()==null?Value.NULL:of(BuiltInRegistries.BLOCK.getKey(predicateData.getCMBlockState().getBlock())),
predicateData.getCMBlockTagKey()==null?Value.NULL:of(registryAccess.registryOrThrow(Registry.BLOCK_REGISTRY).getTag(predicateData.getCMBlockTagKey()).get().key()), predicateData.getCMBlockTagKey()==null?Value.NULL:of(registryAccess.registryOrThrow(Registries.BLOCK).getTag(predicateData.getCMBlockTagKey()).get().key()),
MapValue.wrap(predicateData.getCMProperties()), MapValue.wrap(predicateData.getCMProperties()),
predicateData.getCMDataTag() == null?Value.NULL:new NBTSerializableValue(predicateData.getCMDataTag()) predicateData.getCMDataTag() == null?Value.NULL:new NBTSerializableValue(predicateData.getCMDataTag())
); );
+2 -2
View File
@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@@ -234,7 +234,7 @@ public class BlockInfo
List<Component> lst = new ArrayList<>(); List<Component> lst = new ArrayList<>();
lst.add(Messenger.s("")); lst.add(Messenger.s(""));
lst.add(Messenger.s("=====================================")); lst.add(Messenger.s("====================================="));
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):",Registry.BLOCK.getKey(block),metastring, Registry.BLOCK.getId(block), metastring ))); lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):", BuiltInRegistries.BLOCK.getKey(block),metastring, BuiltInRegistries.BLOCK.getId(block), metastring )));
lst.add(Messenger.s(String.format(" - Material: %s", materialName.get(material)))); lst.add(Messenger.s(String.format(" - Material: %s", materialName.get(material))));
lst.add(Messenger.s(String.format(" - Map colour: %s", mapColourName.get(state.getMapColor(world, pos))))); lst.add(Messenger.s(String.format(" - Map colour: %s", mapColourName.get(state.getMapColor(world, pos)))));
lst.add(Messenger.s(String.format(" - Sound type: %s", soundName.get(block.getSoundType(state))))); lst.add(Messenger.s(String.format(" - Sound type: %s", soundName.get(block.getSoundType(state)))));
@@ -3,7 +3,7 @@ package carpet.utils;
import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@@ -276,11 +276,11 @@ public class CarpetProfiler
ResourceLocation id; ResourceLocation id;
if (section.getValue() instanceof EntityType) if (section.getValue() instanceof EntityType)
{ {
id = Registry.ENTITY_TYPE.getKey((EntityType<?>) section.getValue()); id = BuiltInRegistries.ENTITY_TYPE.getKey((EntityType<?>) section.getValue());
} }
else else
{ {
id = Registry.BLOCK_ENTITY_TYPE.getKey((BlockEntityType<?>) section.getValue()); id = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey((BlockEntityType<?>) section.getValue());
} }
String name = "minecraft".equals(id.getNamespace())?id.getPath():id.toString(); String name = "minecraft".equals(id.getNamespace())?id.getPath():id.toString();
if (section.getKey().isClientSide) if (section.getKey().isClientSide)
+2 -2
View File
@@ -9,7 +9,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@@ -61,7 +61,7 @@ public class MobAI
{ {
types.addAll(type.types); types.addAll(type.types);
} }
return types.stream().map(t -> Registry.ENTITY_TYPE.getKey(t).getPath()).collect(Collectors.toList()); return types.stream().map(t -> BuiltInRegistries.ENTITY_TYPE.getKey(t).getPath()).collect(Collectors.toList());
} }
public static List<String> availableFor(EntityType<?> entityType) public static List<String> availableFor(EntityType<?> entityType)
@@ -3,8 +3,8 @@ package carpet.utils;
import carpet.CarpetSettings; import carpet.CarpetSettings;
import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.longs.LongSet;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.SectionPos; import net.minecraft.core.SectionPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -54,8 +54,8 @@ public class SpawnOverrides {
public static WeightedRandomList<MobSpawnSettings.SpawnerData> test(StructureManager structureFeatureManager, LongSet foo, public static WeightedRandomList<MobSpawnSettings.SpawnerData> test(StructureManager structureFeatureManager, LongSet foo,
MobCategory cat, Structure confExisting, BlockPos where) { MobCategory cat, Structure confExisting, BlockPos where) {
ResourceLocation resource = structureFeatureManager.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).getKey(confExisting); ResourceLocation resource = structureFeatureManager.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(confExisting);
ResourceKey<Structure> key = ResourceKey.create(Registry.STRUCTURE_REGISTRY, resource); ResourceKey<Structure> key = ResourceKey.create(Registries.STRUCTURE, resource);
final Pair<BooleanSupplier, StructureSpawnOverride> spawnData = carpetOverrides.get(Pair.of(cat, key)); final Pair<BooleanSupplier, StructureSpawnOverride> spawnData = carpetOverrides.get(Pair.of(cat, key));
if (spawnData == null || !spawnData.getKey().getAsBoolean()) return null; if (spawnData == null || !spawnData.getKey().getAsBoolean()) return null;
StructureSpawnOverride override = spawnData.getRight(); StructureSpawnOverride override = spawnData.getRight();
@@ -76,7 +76,7 @@ public class SpawnOverrides {
public static boolean isStructureAtPosition(ServerLevel level, ResourceKey<Structure> structureKey, BlockPos pos) public static boolean isStructureAtPosition(ServerLevel level, ResourceKey<Structure> structureKey, BlockPos pos)
{ {
final Structure fortressFeature = level.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY).get(structureKey); final Structure fortressFeature = level.registryAccess().registryOrThrow(Registries.STRUCTURE).get(structureKey);
if (fortressFeature == null) { if (fortressFeature == null) {
return false; return false;
} }