This commit is contained in:
gnembon committed 2024-08-28 23:43:40 +02:00
1 parent 7ee1baab2c
commit 5e89cc6ddb
23 files changed
+80 -80

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check https://fabricmc.net/develop/ # check https://fabricmc.net/develop/
minecraft_version=24w34a minecraft_version=24w35a
loader_version=0.15.11 loader_version=0.15.11
jsr305_version=3.0.2 jsr305_version=3.0.2
fabric_version=0.102.0+1.21 fabric_version=0.102.0+1.21
+1 -1
View File
@@ -908,7 +908,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) {
if (source == null) return newValue; // closing or sync if (source == null) return newValue; // closing or sync
Optional<Block> ignoredBlock = source.registryAccess().registryOrThrow(Registries.BLOCK).getOptional(ResourceLocation.tryParse(newValue)); Optional<Block> ignoredBlock = source.registryAccess().lookupOrThrow(Registries.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;
@@ -58,7 +58,7 @@ public interface FertilizableCoral extends BonemealableBlock {
MapColor color = blockUnder.getMapColor(worldIn, pos); MapColor color = blockUnder.getMapColor(worldIn, pos);
BlockState properBlock = blockUnder; BlockState properBlock = blockUnder;
HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow(); HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().lookupOrThrow(Registries.BLOCK).get(BlockTags.CORAL_BLOCKS).orElseThrow();
for (Holder<Block> block: coralBlocks) for (Holder<Block> block: coralBlocks)
{ {
properBlock = block.value().defaultBlockState(); properBlock = block.value().defaultBlockState();
@@ -340,8 +340,8 @@ public class HopperCounter
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMapColor().col)); if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMapColor().col));
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col)); if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col));
Block block = null; Block block = null;
final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM); final Registry<Item> itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM);
final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK); final Registry<Block> blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK);
ResourceLocation id = itemRegistry.getKey(item); ResourceLocation id = itemRegistry.getKey(item);
if (item instanceof BlockItem blockItem) if (item instanceof BlockItem blockItem)
{ {
@@ -349,7 +349,7 @@ public class HopperCounter
} }
else if (blockRegistry.getOptional(id).isPresent()) else if (blockRegistry.getOptional(id).isPresent())
{ {
block = blockRegistry.get(id); block = blockRegistry.getValue(id);
} }
if (block != null) if (block != null)
{ {
@@ -370,8 +370,8 @@ public class HopperCounter
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 = registryAccess.registryOrThrow(Registries.ITEM).getKey(item); ResourceLocation id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item);
for (RecipeType<?> type: registryAccess.registryOrThrow(Registries.RECIPE_TYPE)) for (RecipeType<?> type: registryAccess.lookupOrThrow(Registries.RECIPE_TYPE))
{ {
for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id, registryAccess)) for (Recipe<?> r: ((RecipeManagerInterface) CarpetServer.minecraft_server.getRecipeManager()).getAllMatching(type, id, registryAccess))
{ {
@@ -80,7 +80,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 "+ regs.registryOrThrow(Registries.ENTITY_TYPE).getKey(k.type).getPath(), (v>1)?"l ("+v+")":"" "w "+ regs.lookupOrThrow(Registries.ENTITY_TYPE).getKey(k.type).getPath(), (v>1)?"l ("+v+")":""
)); ));
}); });
} }
@@ -34,7 +34,7 @@ public class BuddingAmethystBlock_movableAmethystMixin extends Block {
// drawback - not controlled via loottables, but hey // drawback - not controlled via loottables, but hey
if (CarpetSettings.movableAmethyst && if (CarpetSettings.movableAmethyst &&
stack.getItem() instanceof PickaxeItem && stack.getItem() instanceof PickaxeItem &&
EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.SILK_TOUCH), stack) > 0 EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.SILK_TOUCH), stack) > 0
) )
popResource(world, pos, Items.BUDDING_AMETHYST.getDefaultInstance()); popResource(world, pos, Items.BUDDING_AMETHYST.getDefaultInstance());
} }
@@ -41,8 +41,8 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
return List.of(); return List.of();
} }
Collection<RecipeHolder<?>> typeRecipes = byType.get(type); Collection<RecipeHolder<?>> typeRecipes = byType.get(type);
Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM); Registry<Item> regs = registryAccess.lookupOrThrow(Registries.ITEM);
Item item = regs.get(itemId); Item item = regs.getValue(itemId);
if (item == Items.AIR) if (item == Items.AIR)
{ {
return List.of(); return List.of();
@@ -62,7 +62,7 @@ public class CarpetContext extends Context
public <T> Registry<T> registry(ResourceKey<? extends Registry<? extends T>> resourceKey) public <T> Registry<T> registry(ResourceKey<? extends Registry<? extends T>> resourceKey)
{ {
return registryAccess().registryOrThrow(resourceKey); return registryAccess().lookupOrThrow(resourceKey);
} }
public CommandSourceStack source() public CommandSourceStack source()
@@ -999,7 +999,7 @@ public class CarpetEventServer
{ {
return; return;
} }
Registry<StatType<?>> registry = player.level().registryAccess().registryOrThrow(Registries.STAT_TYPE); Registry<StatType<?>> registry = player.level().registryAccess().lookupOrThrow(Registries.STAT_TYPE);
handler.call(() -> Arrays.asList( handler.call(() -> Arrays.asList(
new EntityValue(player), new EntityValue(player),
NBTSerializableValue.nameFromRegistryId(registry.getKey(stat.getType())), NBTSerializableValue.nameFromRegistryId(registry.getKey(stat.getType())),
@@ -131,7 +131,7 @@ public class Auxiliary
CarpetContext cc = (CarpetContext) c; CarpetContext cc = (CarpetContext) c;
if (lv.isEmpty()) if (lv.isEmpty())
{ {
return ListValue.wrap(cc.registry(Registries.SOUND_EVENT).holders().map(soundEventReference -> ValueConversions.of(soundEventReference.key().location()))); return ListValue.wrap(cc.registry(Registries.SOUND_EVENT).listElements().map(soundEventReference -> ValueConversions.of(soundEventReference.key().location())));
} }
String rawString = lv.get(0).getString(); String rawString = lv.get(0).getString();
ResourceLocation soundName = InputValidator.identifierOf(rawString); ResourceLocation soundName = InputValidator.identifierOf(rawString);
@@ -176,7 +176,7 @@ public class Auxiliary
CarpetContext cc = (CarpetContext) c; CarpetContext cc = (CarpetContext) c;
if (lv.isEmpty()) if (lv.isEmpty())
{ {
return ListValue.wrap(cc.registry(Registries.PARTICLE_TYPE).holders().map(particleTypeReference -> ValueConversions.of(particleTypeReference.key().location()))); return ListValue.wrap(cc.registry(Registries.PARTICLE_TYPE).listElements().map(particleTypeReference -> ValueConversions.of(particleTypeReference.key().location())));
} }
MinecraftServer ms = cc.server(); MinecraftServer ms = cc.server();
ServerLevel world = cc.level(); ServerLevel world = cc.level();
@@ -1062,7 +1062,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 = cc.registry(Registries.STAT_TYPE).get(category); StatType<?> type = cc.registry(Registries.STAT_TYPE).getValue(category);
if (type == null) if (type == null)
{ {
return Value.NULL; return Value.NULL;
@@ -1382,7 +1382,7 @@ public class Auxiliary
@Nullable @Nullable
private static <T> Stat<T> getStat(StatType<T> type, ResourceLocation id) private static <T> Stat<T> getStat(StatType<T> type, ResourceLocation id)
{ {
T key = type.getRegistry().get(id); T key = type.getRegistry().getValue(id);
if (key == null || !type.contains(key)) if (key == null || !type.contains(key))
{ {
return null; return null;
@@ -69,10 +69,10 @@ public class Inventories
Registry<Item> items = cc.registry(Registries.ITEM); Registry<Item> items = cc.registry(Registries.ITEM);
if (lv.isEmpty()) if (lv.isEmpty())
{ {
return ListValue.wrap(items.holders().map(itemReference -> ValueConversions.of(itemReference.key().location()))); return ListValue.wrap(items.listElements().map(itemReference -> ValueConversions.of(itemReference.key().location())));
} }
String tag = lv.get(0).getString(); String tag = lv.get(0).getString();
Optional<HolderSet.Named<Item>> itemTag = items.getTag(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Item>> itemTag = items.get(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag)));
return itemTag.isEmpty() ? Value.NULL : ListValue.wrap(itemTag.get().stream().map(b -> items.getKey(b.value())).filter(Objects::nonNull).map(ValueConversions::of)); return itemTag.isEmpty() ? Value.NULL : ListValue.wrap(itemTag.get().stream().map(b -> items.getKey(b.value())).filter(Objects::nonNull).map(ValueConversions::of));
}); });
@@ -91,7 +91,7 @@ public class Inventories
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == item))).map(ValueConversions::of)); return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == item))).map(ValueConversions::of));
} }
String tag = lv.get(1).getString(); String tag = lv.get(1).getString();
Optional<HolderSet.Named<Item>> tagSet = blocks.getTag(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Item>> tagSet = blocks.get(TagKey.create(Registries.ITEM, InputValidator.identifierOf(tag)));
return tagSet.isEmpty() ? Value.NULL : BooleanValue.of(tagSet.get().stream().anyMatch(h -> h.value() == item)); return tagSet.isEmpty() ? Value.NULL : BooleanValue.of(tagSet.get().stream().anyMatch(h -> h.value() == item));
}); });
@@ -107,7 +107,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 = cc.registry(Registries.RECIPE_TYPE).get(InputValidator.identifierOf(recipeType)); type = cc.registry(Registries.RECIPE_TYPE).getValue(InputValidator.identifierOf(recipeType));
if (type == null) if (type == null)
{ {
throw new InternalExpressionException("Unknown recipe type: " + recipeType); throw new InternalExpressionException("Unknown recipe type: " + recipeType);
@@ -403,7 +403,7 @@ public class WorldAccess
Registry<PoiType> poiReg = cc.registry(Registries.POINT_OF_INTEREST_TYPE); Registry<PoiType> poiReg = cc.registry(Registries.POINT_OF_INTEREST_TYPE);
PoiType type = poiReg.getOptional(resource) PoiType type = poiReg.getOptional(resource)
.orElseThrow(() -> new ThrowStatement(poiTypeString, Throwables.UNKNOWN_POI)); .orElseThrow(() -> new ThrowStatement(poiTypeString, Throwables.UNKNOWN_POI));
Holder<PoiType> holder = poiReg.getHolderOrThrow(ResourceKey.create(Registries.POINT_OF_INTEREST_TYPE, resource)); Holder<PoiType> holder = poiReg.getOrThrow(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())
@@ -932,7 +932,7 @@ public class WorldAccess
if (dropLoot) if (dropLoot)
{ {
if (how < 0 || (tag != null && EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.SILK_TOUCH), tool) > 0)) if (how < 0 || (tag != null && EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.SILK_TOUCH), tool) > 0))
{ {
Block.popResource(world, where, new ItemStack(state.getBlock())); Block.popResource(world, where, new ItemStack(state.getBlock()));
} }
@@ -940,7 +940,7 @@ public class WorldAccess
{ {
if (how > 0) if (how > 0)
{ {
tool.enchant(world.registryAccess().registryOrThrow(Registries.ENCHANTMENT).getHolderOrThrow(Enchantments.FORTUNE), (int) how); tool.enchant(world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.FORTUNE), (int) how);
} }
if (DUMMY_ENTITY == null) if (DUMMY_ENTITY == null)
{ {
@@ -1222,10 +1222,10 @@ public class WorldAccess
Registry<Block> blocks = cc.registry(Registries.BLOCK); Registry<Block> blocks = cc.registry(Registries.BLOCK);
if (lv.isEmpty()) if (lv.isEmpty())
{ {
return ListValue.wrap(blocks.holders().map(blockReference -> ValueConversions.of(blockReference.key().location()))); return ListValue.wrap(blocks.listElements().map(blockReference -> ValueConversions.of(blockReference.key().location())));
} }
ResourceLocation tag = InputValidator.identifierOf(lv.get(0).getString()); ResourceLocation tag = InputValidator.identifierOf(lv.get(0).getString());
Optional<HolderSet.Named<Block>> tagset = blocks.getTag(TagKey.create(Registries.BLOCK, tag)); Optional<HolderSet.Named<Block>> tagset = blocks.get(TagKey.create(Registries.BLOCK, tag));
return tagset.isEmpty() ? Value.NULL : ListValue.wrap(tagset.get().stream().map(b -> ValueConversions.of(blocks.getKey(b.value())))); return tagset.isEmpty() ? Value.NULL : ListValue.wrap(tagset.get().stream().map(b -> ValueConversions.of(blocks.getKey(b.value()))));
}); });
@@ -1244,7 +1244,7 @@ public class WorldAccess
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == target))).map(ValueConversions::of)); return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == target))).map(ValueConversions::of));
} }
String tag = lv.get(blockLocator.offset).getString(); String tag = lv.get(blockLocator.offset).getString();
Optional<HolderSet.Named<Block>> tagSet = blocks.getTag(TagKey.create(Registries.BLOCK, InputValidator.identifierOf(tag))); Optional<HolderSet.Named<Block>> tagSet = blocks.get(TagKey.create(Registries.BLOCK, InputValidator.identifierOf(tag)));
return tagSet.isEmpty() ? Value.NULL : BooleanValue.of(blockLocator.block.getBlockState().is(tagSet.get())); return tagSet.isEmpty() ? Value.NULL : BooleanValue.of(blockLocator.block.getBlockState().is(tagSet.get()));
}); });
@@ -1253,7 +1253,7 @@ public class WorldAccess
ServerLevel world = cc.level(); ServerLevel world = cc.level();
if (lv.isEmpty()) if (lv.isEmpty())
{ {
return ListValue.wrap(cc.registry(Registries.BIOME).holders().map(biomeReference -> ValueConversions.of(biomeReference.key().location()))); return ListValue.wrap(cc.registry(Registries.BIOME).listElements().map(biomeReference -> ValueConversions.of(biomeReference.key().location())));
} }
Biome biome; Biome biome;
@@ -1298,7 +1298,7 @@ public class WorldAccess
if (locator.replacement != null) if (locator.replacement != null)
{ {
biome = world.registryAccess().registryOrThrow(Registries.BIOME).get(InputValidator.identifierOf(locator.replacement)); biome = world.registryAccess().lookupOrThrow(Registries.BIOME).getValue(InputValidator.identifierOf(locator.replacement));
if (biome == null) if (biome == null)
{ {
throw new ThrowStatement(locator.replacement, Throwables.UNKNOWN_BIOME); throw new ThrowStatement(locator.replacement, Throwables.UNKNOWN_BIOME);
@@ -1333,7 +1333,7 @@ public class WorldAccess
} }
String biomeName = lv.get(locator.offset).getString(); String biomeName = lv.get(locator.offset).getString();
// from locatebiome command code // from locatebiome command code
Holder<Biome> biome = cc.registry(Registries.BIOME).getHolder(ResourceKey.create(Registries.BIOME, InputValidator.identifierOf(biomeName))) Holder<Biome> biome = cc.registry(Registries.BIOME).get(ResourceKey.create(Registries.BIOME, InputValidator.identifierOf(biomeName)))
.orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME)); .orElseThrow(() -> new ThrowStatement(biomeName, Throwables.UNKNOWN_BIOME));
boolean doImmediateUpdate = true; boolean doImmediateUpdate = true;
if (lv.size() > locator.offset + 1) if (lv.size() > locator.offset + 1)
@@ -1390,7 +1390,7 @@ public class WorldAccess
); );
} }
String simpleStructureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT); String simpleStructureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT);
Structure structureName = reg.get(InputValidator.identifierOf(simpleStructureName)); Structure structureName = reg.getValue(InputValidator.identifierOf(simpleStructureName));
if (structureName == null) if (structureName == null)
{ {
return Value.NULL; return Value.NULL;
@@ -1428,7 +1428,7 @@ public class WorldAccess
{ {
String reqString = requested.getString(); String reqString = requested.getString();
ResourceLocation id = InputValidator.identifierOf(reqString); ResourceLocation id = InputValidator.identifierOf(reqString);
Structure requestedStructure = reg.get(id); Structure requestedStructure = reg.getValue(id);
if (requestedStructure != null) if (requestedStructure != null)
{ {
singleOutput = true; singleOutput = true;
@@ -1436,7 +1436,7 @@ public class WorldAccess
} }
else else
{ {
StructureType<?> sss = cc.registry(Registries.STRUCTURE_TYPE).get(id); StructureType<?> sss = cc.registry(Registries.STRUCTURE_TYPE).getValue(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())
@@ -1515,7 +1515,7 @@ public class WorldAccess
return MapValue.wrap(structureList); return MapValue.wrap(structureList);
} }
String structureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT); String structureName = lv.get(locator.offset).getString().toLowerCase(Locale.ROOT);
return ValueConversions.of(structures.get(reg.get(InputValidator.identifierOf(structureName))), cc.registryAccess()); return ValueConversions.of(structures.get(reg.getValue(InputValidator.identifierOf(structureName))), cc.registryAccess());
}); });
expression.addContextFunction("set_structure", -1, (c, t, lv) -> expression.addContextFunction("set_structure", -1, (c, t, lv) ->
@@ -1759,7 +1759,7 @@ public class WorldAccess
if (generator instanceof final NoiseBasedChunkGenerator noiseBasedChunkGenerator) if (generator instanceof final NoiseBasedChunkGenerator noiseBasedChunkGenerator)
{ {
Registry<DensityFunction> densityFunctionRegistry = level.registryAccess().registryOrThrow(Registries.DENSITY_FUNCTION); Registry<DensityFunction> densityFunctionRegistry = level.registryAccess().lookupOrThrow(Registries.DENSITY_FUNCTION);
NoiseRouter router = noiseBasedChunkGenerator.generatorSettings().value().noiseRouter(); NoiseRouter router = noiseBasedChunkGenerator.generatorSettings().value().noiseRouter();
DensityFunction densityFunction = switch (densityFunctionQuery) DensityFunction densityFunction = switch (densityFunctionQuery)
{ {
@@ -1779,7 +1779,7 @@ public class WorldAccess
case "vein_ridged" -> router.veinRidged(); case "vein_ridged" -> router.veinRidged();
case "vein_gap" -> router.veinGap(); case "vein_gap" -> router.veinGap();
default -> { default -> {
DensityFunction result = densityFunctionRegistry.get(InputValidator.identifierOf(densityFunctionQuery)); DensityFunction result = densityFunctionRegistry.getValue(InputValidator.identifierOf(densityFunctionQuery));
if (result == null) if (result == null)
{ {
throw new InternalExpressionException("Density function '" + densityFunctionQuery + "' is not defined in the registies."); throw new InternalExpressionException("Density function '" + densityFunctionQuery + "' is not defined in the registies.");
@@ -199,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.getSource().registryAccess()), (c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().registryOrThrow(Registries.PARTICLE_TYPE).keySet(), b) (c, p) -> ValueConversions.of(ParticleArgument.getParticle(c, p), c.getSource().registryAccess()), (c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().lookupOrThrow(Registries.PARTICLE_TYPE).keySet(), b)
), ),
// resource / identifier section // resource / identifier section
@@ -235,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(Registries.BIOME).keySet(), builder) }, (ctx, builder) -> SharedSuggestionProvider.suggestResource(ctx.getSource().getServer().registryAccess().lookupOrThrow(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
@@ -1278,7 +1278,7 @@ public abstract class CommandArgument
suffix, suffix,
c -> ResourceArgument.resource(c, registry), c -> ResourceArgument.resource(c, registry),
(c, p) -> ValueConversions.of(ResourceArgument.getResource(c, p, registry).key()), (c, p) -> ValueConversions.of(ResourceArgument.getResource(c, p, registry).key()),
(c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().registryOrThrow(registry).keySet(), b) (c, b) -> SharedSuggestionProvider.suggestResource(c.getSource().getServer().registryAccess().lookupOrThrow(registry).keySet(), b)
); );
} }
@@ -23,7 +23,7 @@ public class BiomeInfo
{ {
public static final Map<String, BiFunction<ServerLevel, Biome, Value>> biomeFeatures = new HashMap<>() public static final Map<String, BiFunction<ServerLevel, Biome, Value>> biomeFeatures = new HashMap<>()
{{ {{
put("tags", (w, b) -> ListValue.wrap(w.registryAccess().registryOrThrow(Registries.BIOME).getTags().filter(p -> p.stream().anyMatch(h -> h.value() == b)).map(ValueConversions::of))); put("tags", (w, b) -> ListValue.wrap(w.registryAccess().lookupOrThrow(Registries.BIOME).getTags().filter(p -> p.stream().anyMatch(h -> h.value() == b)).map(ValueConversions::of)));
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()));
put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor put("foliage_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFoliageColorOverride().orElse(4764952))); // client Biome.getDefaultFoliageColor
@@ -33,7 +33,7 @@ public class BiomeInfo
put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall())); put("humidity", (w, b) -> NumericValue.of(Vanilla.Biome_getClimateSettings(b).downfall()));
put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT))); put("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
put("features", (w, b) -> { put("features", (w, b) -> {
Registry<ConfiguredFeature<?, ?>> registry = w.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE); Registry<ConfiguredFeature<?, ?>> registry = w.registryAccess().lookupOrThrow(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 ->
@@ -76,13 +76,13 @@ public class FeatureGenerator
return custom.apply(world).plop(world, pos); return custom.apply(world).plop(world, pos);
} }
ResourceLocation id = ResourceLocation.parse(featureName); ResourceLocation id = ResourceLocation.parse(featureName);
Structure structure = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id); Structure structure = world.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(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(Registries.CONFIGURED_FEATURE).get(id); ConfiguredFeature<?, ?> configuredFeature = world.registryAccess().lookupOrThrow(Registries.CONFIGURED_FEATURE).getValue(id);
if (configuredFeature != null) if (configuredFeature != null)
{ {
ThreadLocal<Boolean> checks = Vanilla.skipGenerationChecks(world); ThreadLocal<Boolean> checks = Vanilla.skipGenerationChecks(world);
@@ -96,7 +96,7 @@ public class FeatureGenerator
checks.set(false); checks.set(false);
} }
} }
Optional<StructureType<?>> structureType = world.registryAccess().registryOrThrow(Registries.STRUCTURE_TYPE).getOptional(id); Optional<StructureType<?>> structureType = world.registryAccess().lookupOrThrow(Registries.STRUCTURE_TYPE).getOptional(id);
if (structureType.isPresent()) if (structureType.isPresent())
{ {
Structure configuredStandard = getDefaultFeature(structureType.get(), world, pos); Structure configuredStandard = getDefaultFeature(structureType.get(), world, pos);
@@ -105,7 +105,7 @@ public class FeatureGenerator
return plopAnywhere(configuredStandard, world, pos, world.getChunkSource().getGenerator(), false); return plopAnywhere(configuredStandard, world, pos, world.getChunkSource().getGenerator(), false);
} }
} }
Feature<?> feature = world.registryAccess().registryOrThrow(Registries.FEATURE).get(id); Feature<?> feature = world.registryAccess().lookupOrThrow(Registries.FEATURE).getValue(id);
if (feature != null) if (feature != null)
{ {
ConfiguredFeature<?, ?> configuredStandard = getDefaultFeature(feature, world, pos, true); ConfiguredFeature<?, ?> configuredStandard = getDefaultFeature(feature, world, pos, true);
@@ -130,12 +130,12 @@ 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 = ResourceLocation.parse(name); ResourceLocation id = ResourceLocation.parse(name);
Structure configuredStructureFeature = world.registryAccess().registryOrThrow(Registries.STRUCTURE).get(id); Structure configuredStructureFeature = world.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(id);
if (configuredStructureFeature != null) if (configuredStructureFeature != null)
{ {
return configuredStructureFeature; return configuredStructureFeature;
} }
StructureType<?> structureFeature = world.registryAccess().registryOrThrow(Registries.STRUCTURE_TYPE).get(id); StructureType<?> structureFeature = world.registryAccess().lookupOrThrow(Registries.STRUCTURE_TYPE).getValue(id);
if (structureFeature == null) if (structureFeature == null)
{ {
return null; return null;
@@ -197,7 +197,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(Registries.STRUCTURE).entrySet().stream(). for (Structure confstr : world.registryAccess().lookupOrThrow(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;
@@ -226,7 +226,7 @@ public class FeatureGenerator
{ {
return null; return null;
} }
return world.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).entrySet().stream(). return world.registryAccess().lookupOrThrow(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);
} }
@@ -434,7 +434,7 @@ public class FeatureGenerator
if (!wireOnly) if (!wireOnly)
{ {
Registry<Structure> registry3 = world.registryAccess().registryOrThrow(Registries.STRUCTURE); Registry<Structure> registry3 = world.registryAccess().lookupOrThrow(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);
@@ -760,7 +760,7 @@ public class ShapeDispatcher
{ {
return p -> { return p -> {
ParticleOptions particle; ParticleOptions particle;
Registry<Block> blocks = p.getServer().registryAccess().registryOrThrow(Registries.BLOCK); Registry<Block> blocks = p.getServer().registryAccess().lookupOrThrow(Registries.BLOCK);
if (this.isitem) if (this.isitem)
{ {
if (Block.byItem(this.item.getItem()).defaultBlockState().isAir()) if (Block.byItem(this.item.getItem()).defaultBlockState().isAir())
@@ -199,7 +199,7 @@ public class BlockValue extends Value
@Override @Override
public String getString() public String getString()
{ {
Registry<Block> blockRegistry = world.registryAccess().registryOrThrow(Registries.BLOCK); Registry<Block> blockRegistry = world.registryAccess().lookupOrThrow(Registries.BLOCK);
return nameFromResource(blockRegistry.getKey(getBlockState().getBlock())); return nameFromResource(blockRegistry.getKey(getBlockState().getBlock()));
} }
@@ -250,7 +250,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(world.registryAccess().registryOrThrow(Registries.BLOCK).getKey(s.getBlock()).toString())); state.put("Name", StringTag.valueOf(world.registryAccess().lookupOrThrow(Registries.BLOCK).getKey(s.getBlock()).toString()));
Collection<Property<?>> properties = s.getProperties(); Collection<Property<?>> properties = s.getProperties();
if (!properties.isEmpty()) if (!properties.isEmpty())
{ {
@@ -239,8 +239,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(Registries.ENTITY_TYPE) HolderSet.Named<EntityType<?>> eTagValue = server.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE)
.getTag(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(who))) .get(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)
@@ -257,7 +257,7 @@ public class EntityValue extends Value
} }
else else
{ {
return new EntityClassDescriptor(ANY, e -> !eTag.contains(e.getType()) && e.isAlive(), server.registryAccess().registryOrThrow(Registries.ENTITY_TYPE).stream().filter(et -> !eTag.contains(et))); return new EntityClassDescriptor(ANY, e -> !eTag.contains(e.getType()) && e.isAlive(), server.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).stream().filter(et -> !eTag.contains(et)));
} }
} }
return eDesc; return eDesc;
@@ -285,7 +285,7 @@ public class EntityValue extends Value
public Value listValue(RegistryAccess regs) public Value listValue(RegistryAccess regs)
{ {
Registry<EntityType<?>> entityRegs = regs.registryOrThrow(Registries.ENTITY_TYPE); Registry<EntityType<?>> entityRegs = regs.lookupOrThrow(Registries.ENTITY_TYPE);
return ListValue.wrap(types.stream().map(et -> nameFromRegistryId(entityRegs.getKey(et)))); return ListValue.wrap(types.stream().map(et -> nameFromRegistryId(entityRegs.getKey(et))));
} }
@@ -382,7 +382,7 @@ public class EntityValue extends Value
for (ResourceLocation typeId : BuiltInRegistries.ENTITY_TYPE.keySet()) for (ResourceLocation typeId : BuiltInRegistries.ENTITY_TYPE.keySet())
{ {
EntityType<?> type = BuiltInRegistries.ENTITY_TYPE.get(typeId); EntityType<?> type = BuiltInRegistries.ENTITY_TYPE.getValue(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)));
@@ -445,7 +445,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) -> nameFromRegistryId(e.level().registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getKey(e.getType()))); put("type", (e, a) -> nameFromRegistryId(e.level().registryAccess().lookupOrThrow(Registries.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))); put("passengers", (e, a) -> ListValue.wrap(e.getPassengers().stream().map(EntityValue::new)));
@@ -457,14 +457,14 @@ public class EntityValue extends Value
put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new))); put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new)));
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(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry))); return ListValue.wrap(e.getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry)));
}); });
// 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(Registries.ENTITY_TYPE).getTag(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(a.getString()))); Optional<HolderSet.Named<EntityType<?>>> tag = e.getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).get(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(a.getString())));
if (tag.isEmpty()) if (tag.isEmpty())
{ {
return Value.NULL; return Value.NULL;
@@ -572,7 +572,7 @@ public class EntityValue extends Value
put("brain", (e, a) -> { put("brain", (e, a) -> {
String module = a.getString(); String module = a.getString();
MemoryModuleType<?> moduleType = e.level().registryAccess().registryOrThrow(Registries.MEMORY_MODULE_TYPE).get(InputValidator.identifierOf(module)); MemoryModuleType<?> moduleType = e.level().registryAccess().lookupOrThrow(Registries.MEMORY_MODULE_TYPE).getValue(InputValidator.identifierOf(module));
if (moduleType == MemoryModuleType.DUMMY) if (moduleType == MemoryModuleType.DUMMY)
{ {
return Value.NULL; return Value.NULL;
@@ -663,7 +663,7 @@ public class EntityValue extends Value
return ListValue.wrap(effects); return ListValue.wrap(effects);
} }
String effectName = a.getString(); String effectName = a.getString();
Holder<MobEffect> potion = BuiltInRegistries.MOB_EFFECT.getHolder(ResourceKey.create(Registries.MOB_EFFECT, InputValidator.identifierOf(effectName))).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName)); Holder<MobEffect> potion = BuiltInRegistries.MOB_EFFECT.get(ResourceKey.create(Registries.MOB_EFFECT, InputValidator.identifierOf(effectName))).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName));
if (!le.hasEffect(potion)) if (!le.hasEffect(potion))
{ {
return Value.NULL; return Value.NULL;
@@ -833,14 +833,14 @@ public class EntityValue extends Value
{ {
return Value.NULL; return Value.NULL;
} }
Registry<Attribute> attributes = e.level().registryAccess().registryOrThrow(Registries.ATTRIBUTE); Registry<Attribute> attributes = e.level().registryAccess().lookupOrThrow(Registries.ATTRIBUTE);
if (a == null) if (a == null)
{ {
AttributeMap container = el.getAttributes(); AttributeMap container = el.getAttributes();
return MapValue.wrap(attributes.holders().filter(container::hasAttribute).collect(Collectors.toMap(aa -> ValueConversions.of(aa.key()), aa -> NumericValue.of(container.getValue(aa))))); return MapValue.wrap(attributes.listElements().filter(container::hasAttribute).collect(Collectors.toMap(aa -> ValueConversions.of(aa.key()), aa -> NumericValue.of(container.getValue(aa)))));
} }
ResourceLocation id = InputValidator.identifierOf(a.getString()); ResourceLocation id = InputValidator.identifierOf(a.getString());
Holder<Attribute> attrib = attributes.getHolder(id).orElseThrow( Holder<Attribute> attrib = attributes.get(id).orElseThrow(
() -> new InternalExpressionException("Unknown attribute: " + a.getString()) () -> new InternalExpressionException("Unknown attribute: " + a.getString())
); );
if (!el.getAttributes().hasAttribute(attrib)) if (!el.getAttributes().hasAttribute(attrib))
@@ -1474,7 +1474,7 @@ public class EntityValue extends Value
if (list.size() >= 1 && list.size() <= 6) if (list.size() >= 1 && list.size() <= 6)
{ {
String effectName = list.get(0).getString(); String effectName = list.get(0).getString();
Holder<MobEffect> effect = BuiltInRegistries.MOB_EFFECT.getHolder(InputValidator.identifierOf(effectName)).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName)); Holder<MobEffect> effect = BuiltInRegistries.MOB_EFFECT.get(InputValidator.identifierOf(effectName)).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName));
if (list.size() == 1) if (list.size() == 1)
{ {
le.removeEffect(effect); le.removeEffect(effect);
@@ -1517,7 +1517,7 @@ public class EntityValue extends Value
else else
{ {
String effectName = v.getString(); String effectName = v.getString();
Holder<MobEffect> effect = BuiltInRegistries.MOB_EFFECT.getHolder(InputValidator.identifierOf(effectName)).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName)); Holder<MobEffect> effect = BuiltInRegistries.MOB_EFFECT.get(InputValidator.identifierOf(effectName)).orElseThrow(() -> new InternalExpressionException("No such an effect: " + effectName));
le.removeEffect(effect); le.removeEffect(effect);
return; return;
} }
@@ -1743,7 +1743,7 @@ public class EntityValue extends Value
} }
CompoundTag tag = new CompoundTag(); CompoundTag tag = new CompoundTag();
tag.put("Data", getEntity().saveWithoutId(new CompoundTag())); tag.put("Data", getEntity().saveWithoutId(new CompoundTag()));
Registry<EntityType<?>> reg = getEntity().level().registryAccess().registryOrThrow(Registries.ENTITY_TYPE); Registry<EntityType<?>> reg = getEntity().level().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE);
tag.put("Name", StringTag.valueOf(reg.getKey(getEntity().getType()).toString())); tag.put("Name", StringTag.valueOf(reg.getKey(getEntity().getType()).toString()));
return tag; return tag;
} }
@@ -99,7 +99,7 @@ public class ValueConversions
public static Value of(ItemStack stack, RegistryAccess regs) public static Value of(ItemStack stack, RegistryAccess regs)
{ {
return stack == null || stack.isEmpty() ? Value.NULL : ListValue.of( return stack == null || stack.isEmpty() ? Value.NULL : ListValue.of(
of(regs.registryOrThrow(Registries.ITEM).getKey(stack.getItem())), of(regs.lookupOrThrow(Registries.ITEM).getKey(stack.getItem())),
new NumericValue(stack.getCount()), new NumericValue(stack.getCount()),
NBTSerializableValue.fromStack(stack, regs) NBTSerializableValue.fromStack(stack, regs)
); );
@@ -368,7 +368,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(
NBTSerializableValue.nameFromRegistryId(regs.registryOrThrow(Registries.STRUCTURE_PIECE).getKey(piece.getType())), NBTSerializableValue.nameFromRegistryId(regs.lookupOrThrow(Registries.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())
@@ -457,10 +457,10 @@ public class ValueConversions
public static Value ofBlockPredicate(RegistryAccess registryAccess, Predicate<BlockInWorld> blockPredicate) public static Value ofBlockPredicate(RegistryAccess registryAccess, Predicate<BlockInWorld> blockPredicate)
{ {
Vanilla.BlockPredicatePayload payload = Vanilla.BlockPredicatePayload.of(blockPredicate); Vanilla.BlockPredicatePayload payload = Vanilla.BlockPredicatePayload.of(blockPredicate);
Registry<Block> blocks = registryAccess.registryOrThrow(Registries.BLOCK); Registry<Block> blocks = registryAccess.lookupOrThrow(Registries.BLOCK);
return ListValue.of( return ListValue.of(
payload.state() == null ? Value.NULL : of(blocks.getKey(payload.state().getBlock())), payload.state() == null ? Value.NULL : of(blocks.getKey(payload.state().getBlock())),
payload.tagKey() == null ? Value.NULL : of(blocks.getTag(payload.tagKey()).get().key()), payload.tagKey() == null ? Value.NULL : of(blocks.get(payload.tagKey()).get().key()),
MapValue.wrap(payload.properties()), MapValue.wrap(payload.properties()),
payload.tag() == null ? Value.NULL : new NBTSerializableValue(payload.tag()) payload.tag() == null ? Value.NULL : new NBTSerializableValue(payload.tag())
); );
+1 -1
View File
@@ -29,7 +29,7 @@ public class BlockInfo
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
String metastring = ""; String metastring = "";
final Registry<Block> blocks = world.registryAccess().registryOrThrow(Registries.BLOCK); final Registry<Block> blocks = world.registryAccess().lookupOrThrow(Registries.BLOCK);
for (net.minecraft.world.level.block.state.properties.Property<?> iproperty : state.getProperties()) for (net.minecraft.world.level.block.state.properties.Property<?> iproperty : state.getProperties())
{ {
metastring += ", "+iproperty.getName() + '='+state.getValue(iproperty); metastring += ", "+iproperty.getName() + '='+state.getValue(iproperty);
@@ -279,11 +279,11 @@ public class CarpetProfiler
final RegistryAccess regs = section.getKey().registryAccess(); final RegistryAccess regs = section.getKey().registryAccess();
if (section.getValue() instanceof EntityType) if (section.getValue() instanceof EntityType)
{ {
id = regs.registryOrThrow(Registries.ENTITY_TYPE).getKey((EntityType<?>) section.getValue()); id = regs.lookupOrThrow(Registries.ENTITY_TYPE).getKey((EntityType<?>) section.getValue());
} }
else else
{ {
id = regs.registryOrThrow(Registries.BLOCK_ENTITY_TYPE).getKey((BlockEntityType<?>) section.getValue()); id = regs.lookupOrThrow(Registries.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)
+1 -1
View File
@@ -64,7 +64,7 @@ public class MobAI
{ {
types.addAll(type.types); types.addAll(type.types);
} }
return types.stream().map(t -> source.registryAccess().registryOrThrow(Registries.ENTITY_TYPE).getKey(t).getPath()); return types.stream().map(t -> source.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getKey(t).getPath());
} }
public static Stream<String> availableFor(EntityType<?> entityType) public static Stream<String> availableFor(EntityType<?> entityType)
@@ -54,7 +54,7 @@ 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(Registries.STRUCTURE).getKey(confExisting); ResourceLocation resource = structureFeatureManager.registryAccess().lookupOrThrow(Registries.STRUCTURE).getKey(confExisting);
ResourceKey<Structure> key = ResourceKey.create(Registries.STRUCTURE, 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;
@@ -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(Registries.STRUCTURE).get(structureKey); final Structure fortressFeature = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(structureKey);
if (fortressFeature == null) { if (fortressFeature == null) {
return false; return false;
} }