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
# check https://fabricmc.net/develop/
minecraft_version=24w34a
minecraft_version=24w35a
loader_version=0.15.11
jsr305_version=3.0.2
fabric_version=0.102.0+1.21
+1 -1
View File
@@ -908,7 +908,7 @@ public class CarpetSettings
@Override
public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
if (source == null) return newValue; // closing or sync
Optional<Block> ignoredBlock = source.registryAccess().registryOrThrow(Registries.BLOCK).getOptional(ResourceLocation.tryParse(newValue));
Optional<Block> ignoredBlock = source.registryAccess().lookupOrThrow(Registries.BLOCK).getOptional(ResourceLocation.tryParse(newValue));
if (!ignoredBlock.isPresent()) {
Messenger.m(source, "r Unknown block '" + newValue + "'.");
return null;
@@ -58,7 +58,7 @@ public interface FertilizableCoral extends BonemealableBlock {
MapColor color = blockUnder.getMapColor(worldIn, pos);
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)
{
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 (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col));
Block block = null;
final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM);
final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK);
final Registry<Item> itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM);
final Registry<Block> blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK);
ResourceLocation id = itemRegistry.getKey(item);
if (item instanceof BlockItem blockItem)
{
@@ -349,7 +349,7 @@ public class HopperCounter
}
else if (blockRegistry.getOptional(id).isPresent())
{
block = blockRegistry.get(id);
block = blockRegistry.getValue(id);
}
if (block != null)
{
@@ -370,8 +370,8 @@ public class HopperCounter
if (direct != null) return direct;
if (CarpetServer.minecraft_server == null) return WHITE;
ResourceLocation id = registryAccess.registryOrThrow(Registries.ITEM).getKey(item);
for (RecipeType<?> type: registryAccess.registryOrThrow(Registries.RECIPE_TYPE))
ResourceLocation id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item);
for (RecipeType<?> type: registryAccess.lookupOrThrow(Registries.RECIPE_TYPE))
{
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 - ",
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),
"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
if (CarpetSettings.movableAmethyst &&
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());
}
@@ -41,8 +41,8 @@ public class RecipeManager_scarpetMixin implements RecipeManagerInterface
return List.of();
}
Collection<RecipeHolder<?>> typeRecipes = byType.get(type);
Registry<Item> regs = registryAccess.registryOrThrow(Registries.ITEM);
Item item = regs.get(itemId);
Registry<Item> regs = registryAccess.lookupOrThrow(Registries.ITEM);
Item item = regs.getValue(itemId);
if (item == Items.AIR)
{
return List.of();
@@ -62,7 +62,7 @@ public class CarpetContext extends Context
public <T> Registry<T> registry(ResourceKey<? extends Registry<? extends T>> resourceKey)
{
return registryAccess().registryOrThrow(resourceKey);
return registryAccess().lookupOrThrow(resourceKey);
}
public CommandSourceStack source()
@@ -999,7 +999,7 @@ public class CarpetEventServer
{
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(
new EntityValue(player),
NBTSerializableValue.nameFromRegistryId(registry.getKey(stat.getType())),
@@ -131,7 +131,7 @@ public class Auxiliary
CarpetContext cc = (CarpetContext) c;
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();
ResourceLocation soundName = InputValidator.identifierOf(rawString);
@@ -176,7 +176,7 @@ public class Auxiliary
CarpetContext cc = (CarpetContext) c;
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();
ServerLevel world = cc.level();
@@ -1062,7 +1062,7 @@ public class Auxiliary
ResourceLocation statName;
category = InputValidator.identifierOf(lv.get(1).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)
{
return Value.NULL;
@@ -1382,7 +1382,7 @@ public class Auxiliary
@Nullable
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))
{
return null;
@@ -69,10 +69,10 @@ public class Inventories
Registry<Item> items = cc.registry(Registries.ITEM);
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();
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));
});
@@ -91,7 +91,7 @@ public class Inventories
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == item))).map(ValueConversions::of));
}
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));
});
@@ -107,7 +107,7 @@ public class Inventories
if (lv.size() > 1)
{
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)
{
throw new InternalExpressionException("Unknown recipe type: " + recipeType);
@@ -403,7 +403,7 @@ public class WorldAccess
Registry<PoiType> poiReg = cc.registry(Registries.POINT_OF_INTEREST_TYPE);
PoiType type = poiReg.getOptional(resource)
.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;
if (locator.offset + 1 < lv.size())
@@ -932,7 +932,7 @@ public class WorldAccess
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()));
}
@@ -940,7 +940,7 @@ public class WorldAccess
{
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)
{
@@ -1222,10 +1222,10 @@ public class WorldAccess
Registry<Block> blocks = cc.registry(Registries.BLOCK);
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());
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()))));
});
@@ -1244,7 +1244,7 @@ public class WorldAccess
return ListValue.wrap(blocks.getTags().filter(e -> e.stream().anyMatch(h -> (h.value() == target))).map(ValueConversions::of));
}
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()));
});
@@ -1253,7 +1253,7 @@ public class WorldAccess
ServerLevel world = cc.level();
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;
@@ -1298,7 +1298,7 @@ public class WorldAccess
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)
{
throw new ThrowStatement(locator.replacement, Throwables.UNKNOWN_BIOME);
@@ -1333,7 +1333,7 @@ public class WorldAccess
}
String biomeName = lv.get(locator.offset).getString();
// 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));
boolean doImmediateUpdate = true;
if (lv.size() > locator.offset + 1)
@@ -1390,7 +1390,7 @@ public class WorldAccess
);
}
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)
{
return Value.NULL;
@@ -1428,7 +1428,7 @@ public class WorldAccess
{
String reqString = requested.getString();
ResourceLocation id = InputValidator.identifierOf(reqString);
Structure requestedStructure = reg.get(id);
Structure requestedStructure = reg.getValue(id);
if (requestedStructure != null)
{
singleOutput = true;
@@ -1436,7 +1436,7 @@ public class WorldAccess
}
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()));
}
if (structure.isEmpty())
@@ -1515,7 +1515,7 @@ public class WorldAccess
return MapValue.wrap(structureList);
}
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) ->
@@ -1759,7 +1759,7 @@ public class WorldAccess
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();
DensityFunction densityFunction = switch (densityFunctionQuery)
{
@@ -1779,7 +1779,7 @@ public class WorldAccess
case "vein_ridged" -> router.veinRidged();
case "vein_gap" -> router.veinGap();
default -> {
DensityFunction result = densityFunctionRegistry.get(InputValidator.identifierOf(densityFunctionQuery));
DensityFunction result = densityFunctionRegistry.getValue(InputValidator.identifierOf(densityFunctionQuery));
if (result == null)
{
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
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
@@ -235,7 +235,7 @@ public abstract class CommandArgument
return ValueConversions.of(res.right().get().key());
}
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,
(c, p) -> ValueConversions.of(ResourceLocationArgument.getId(c, p)), SuggestionProviders.AVAILABLE_SOUNDS
@@ -1278,7 +1278,7 @@ public abstract class CommandArgument
suffix,
c -> ResourceArgument.resource(c, registry),
(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<>()
{{
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("fog_color", (w, b) -> ValueConversions.ofRGB(b.getSpecialEffects().getFogColor()));
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("precipitation", (w, b) -> StringValue.of(b.getPrecipitationAt(new BlockPos(0, w.getSeaLevel(), 0), w.getSeaLevel()).name().toLowerCase(Locale.ROOT)));
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(
b.getGenerationSettings().features().stream().map(step ->
ListValue.wrap(step.stream().map(cfp ->
@@ -76,13 +76,13 @@ public class FeatureGenerator
return custom.apply(world).plop(world, pos);
}
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)
{
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)
{
ThreadLocal<Boolean> checks = Vanilla.skipGenerationChecks(world);
@@ -96,7 +96,7 @@ public class FeatureGenerator
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())
{
Structure configuredStandard = getDefaultFeature(structureType.get(), world, pos);
@@ -105,7 +105,7 @@ public class FeatureGenerator
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)
{
ConfiguredFeature<?, ?> configuredStandard = getDefaultFeature(feature, world, pos, true);
@@ -130,12 +130,12 @@ public class FeatureGenerator
public static Structure resolveConfiguredStructure(String name, ServerLevel world, BlockPos pos)
{
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)
{
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)
{
return null;
@@ -197,7 +197,7 @@ public class FeatureGenerator
// TODO allow old types, like vaillage, or bastion
Holder<Biome> existingBiome = world.getBiome(pos);
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())
{
result = confstr;
@@ -226,7 +226,7 @@ public class FeatureGenerator
{
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).
findFirst().map(Map.Entry::getValue).orElse(null);
}
@@ -434,7 +434,7 @@ public class FeatureGenerator
if (!wireOnly)
{
Registry<Structure> registry3 = world.registryAccess().registryOrThrow(Registries.STRUCTURE);
Registry<Structure> registry3 = world.registryAccess().lookupOrThrow(Registries.STRUCTURE);
world.setCurrentlyGenerating(() -> {
Objects.requireNonNull(structure);
return registry3.getResourceKey(structure).map(Object::toString).orElseGet(structure::toString);
@@ -760,7 +760,7 @@ public class ShapeDispatcher
{
return p -> {
ParticleOptions particle;
Registry<Block> blocks = p.getServer().registryAccess().registryOrThrow(Registries.BLOCK);
Registry<Block> blocks = p.getServer().registryAccess().lookupOrThrow(Registries.BLOCK);
if (this.isitem)
{
if (Block.byItem(this.item.getItem()).defaultBlockState().isAir())
@@ -199,7 +199,7 @@ public class BlockValue extends Value
@Override
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()));
}
@@ -250,7 +250,7 @@ public class BlockValue extends Value
CompoundTag tag = new CompoundTag();
CompoundTag state = new CompoundTag();
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();
if (!properties.isEmpty())
{
@@ -239,8 +239,8 @@ public class EntityValue extends Value
who = who.substring(1);
}
String booWho = who;
HolderSet.Named<EntityType<?>> eTagValue = server.registryAccess().registryOrThrow(Registries.ENTITY_TYPE)
.getTag(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(who)))
HolderSet.Named<EntityType<?>> eTagValue = server.registryAccess().lookupOrThrow(Registries.ENTITY_TYPE)
.get(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(who)))
.orElseThrow(() -> new InternalExpressionException(booWho + " is not a valid entity descriptor"));
Set<EntityType<?>> eTag = eTagValue.stream().map(Holder::value).collect(Collectors.toUnmodifiableSet());
if (positive)
@@ -257,7 +257,7 @@ public class EntityValue extends Value
}
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;
@@ -285,7 +285,7 @@ public class EntityValue extends Value
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))));
}
@@ -382,7 +382,7 @@ public class EntityValue extends Value
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);
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)));
@@ -445,7 +445,7 @@ public class EntityValue extends Value
put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName()));
put("command_name", (e, a) -> new StringValue(e.getScoreboardName()));
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_ridden", (e, a) -> BooleanValue.of(e.isVehicle()));
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("entity_tags", (e, a) -> {
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
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_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())
{
return Value.NULL;
@@ -572,7 +572,7 @@ public class EntityValue extends Value
put("brain", (e, a) -> {
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)
{
return Value.NULL;
@@ -663,7 +663,7 @@ public class EntityValue extends Value
return ListValue.wrap(effects);
}
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))
{
return Value.NULL;
@@ -833,14 +833,14 @@ public class EntityValue extends Value
{
return Value.NULL;
}
Registry<Attribute> attributes = e.level().registryAccess().registryOrThrow(Registries.ATTRIBUTE);
Registry<Attribute> attributes = e.level().registryAccess().lookupOrThrow(Registries.ATTRIBUTE);
if (a == null)
{
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());
Holder<Attribute> attrib = attributes.getHolder(id).orElseThrow(
Holder<Attribute> attrib = attributes.get(id).orElseThrow(
() -> new InternalExpressionException("Unknown attribute: " + a.getString())
);
if (!el.getAttributes().hasAttribute(attrib))
@@ -1474,7 +1474,7 @@ public class EntityValue extends Value
if (list.size() >= 1 && list.size() <= 6)
{
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)
{
le.removeEffect(effect);
@@ -1517,7 +1517,7 @@ public class EntityValue extends Value
else
{
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);
return;
}
@@ -1743,7 +1743,7 @@ public class EntityValue extends Value
}
CompoundTag tag = 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()));
return tag;
}
@@ -99,7 +99,7 @@ public class ValueConversions
public static Value of(ItemStack stack, RegistryAccess regs)
{
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()),
NBTSerializableValue.fromStack(stack, regs)
);
@@ -368,7 +368,7 @@ public class ValueConversions
if (box.maxX() >= box.minX() && box.maxY() >= box.minY() && box.maxZ() >= box.minZ())
{
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()),
ListValue.fromTriple(box.minX(), box.minY(), box.minZ()),
ListValue.fromTriple(box.maxX(), box.maxY(), box.maxZ())
@@ -457,10 +457,10 @@ public class ValueConversions
public static Value ofBlockPredicate(RegistryAccess registryAccess, Predicate<BlockInWorld> 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(
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()),
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);
Block block = state.getBlock();
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())
{
metastring += ", "+iproperty.getName() + '='+state.getValue(iproperty);
@@ -279,11 +279,11 @@ public class CarpetProfiler
final RegistryAccess regs = section.getKey().registryAccess();
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
{
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();
if (section.getKey().isClientSide)
+1 -1
View File
@@ -64,7 +64,7 @@ public class MobAI
{
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)
@@ -54,7 +54,7 @@ public class SpawnOverrides {
public static WeightedRandomList<MobSpawnSettings.SpawnerData> test(StructureManager structureFeatureManager, LongSet foo,
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);
final Pair<BooleanSupplier, StructureSpawnOverride> spawnData = carpetOverrides.get(Pair.of(cat, key));
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)
{
final Structure fortressFeature = level.registryAccess().registryOrThrow(Registries.STRUCTURE).get(structureKey);
final Structure fortressFeature = level.registryAccess().lookupOrThrow(Registries.STRUCTURE).getValue(structureKey);
if (fortressFeature == null) {
return false;
}