Co-authored-by: Drex <nicknamedrex@gmail.com>
Co-authored-by: embeddedt <42941056+embeddedt@users.noreply.github.com>
This commit is contained in:
modmuss 2024-05-23 10:20:54 +01:00 committed by GitHub
parent 0684cd12de
commit 6573ed8ccc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
161 changed files with 604 additions and 584 deletions

View file

@ -281,10 +281,10 @@ public class ConventionLogWarnings implements ModInitializer {
}
private static <T> TagKey<T> createTagKeyUnderC(RegistryKey<Registry<T>> registryKey, String tagId) {
return TagKey.of(registryKey, new Identifier(TagUtil.C_TAG_NAMESPACE, tagId));
return TagKey.of(registryKey, Identifier.of(TagUtil.C_TAG_NAMESPACE, tagId));
}
private static <T> TagKey<T> createTagKeyUnderFabric(RegistryKey<Registry<T>> registryKey, String tagId) {
return TagKey.of(registryKey, new Identifier(TagUtil.FABRIC_TAG_NAMESPACE, tagId));
return TagKey.of(registryKey, Identifier.of(TagUtil.FABRIC_TAG_NAMESPACE, tagId));
}
}

View file

@ -44,11 +44,11 @@ public class TagRegistration<T> {
@Deprecated
public TagKey<T> registerFabric(String tagId) {
return TagKey.of(registryKey, new Identifier("fabric", tagId));
return TagKey.of(registryKey, Identifier.of("fabric", tagId));
}
@Deprecated
public TagKey<T> registerC(String tagId) {
return TagKey.of(registryKey, new Identifier("c", tagId));
return TagKey.of(registryKey, Identifier.of("c", tagId));
}
}

View file

@ -36,7 +36,7 @@ public interface ExtraModelProvider {
* @param out Accepts paths to be loaded. Arguments that are {@link ModelIdentifier} will be
* loaded through the blockstate JSON system or, if the variant is {@code inventory}, the item model folder.
* Otherwise, the argument is directly loaded as a JSON.
* For example, <pre>new Identifier("mymod", "foo/bar")</pre> will request loading of the file
* For example, <pre>Identifier.of("mymod", "foo/bar")</pre> will request loading of the file
* <pre>/assets/mymod/models/foo/bar.json</pre>
*/
void provideExtraModels(ResourceManager manager, Consumer<Identifier> out);

View file

@ -60,7 +60,7 @@ public abstract class Event<T> {
* The identifier of the default phase.
* Have a look at {@link EventFactory#createWithPhases} for an explanation of event phases.
*/
public static final Identifier DEFAULT_PHASE = new Identifier("fabric", "default");
public static final Identifier DEFAULT_PHASE = Identifier.of("fabric", "default");
/**
* Register a listener to the event for the specified phase.

View file

@ -82,8 +82,8 @@ public class EventTests {
}
private static void testMultipleDefaultPhases() {
Identifier first = new Identifier("fabric", "first");
Identifier second = new Identifier("fabric", "second");
Identifier first = Identifier.of("fabric", "first");
Identifier second = Identifier.of("fabric", "second");
Event<Test> event = EventFactory.createWithPhases(Test.class, INVOKER_FACTORY, first, second, Event.DEFAULT_PHASE);
event.register(second, ensureOrder(1));
@ -100,10 +100,10 @@ public class EventTests {
private static void testAddedPhases() {
Event<Test> event = createEvent();
Identifier veryEarly = new Identifier("fabric", "very_early");
Identifier early = new Identifier("fabric", "early");
Identifier late = new Identifier("fabric", "late");
Identifier veryLate = new Identifier("fabric", "very_late");
Identifier veryEarly = Identifier.of("fabric", "very_early");
Identifier early = Identifier.of("fabric", "early");
Identifier late = Identifier.of("fabric", "late");
Identifier veryLate = Identifier.of("fabric", "very_late");
event.addPhaseOrdering(veryEarly, early);
event.addPhaseOrdering(early, Event.DEFAULT_PHASE);
@ -131,10 +131,10 @@ public class EventTests {
private static void testCycle() {
Event<Test> event = createEvent();
Identifier a = new Identifier("fabric", "a");
Identifier b1 = new Identifier("fabric", "b1");
Identifier b2 = new Identifier("fabric", "b2");
Identifier b3 = new Identifier("fabric", "b3");
Identifier a = Identifier.of("fabric", "a");
Identifier b1 = Identifier.of("fabric", "b1");
Identifier b2 = Identifier.of("fabric", "b2");
Identifier b3 = Identifier.of("fabric", "b3");
Identifier c = Event.DEFAULT_PHASE;
// A always first and C always last.
@ -184,13 +184,13 @@ public class EventTests {
* We get for the final order: [a, d, e, cycle [b, y, z], f].
*/
private static void testDeterministicOrdering() {
Identifier a = new Identifier("fabric", "a");
Identifier b = new Identifier("fabric", "b");
Identifier d = new Identifier("fabric", "d");
Identifier e = new Identifier("fabric", "e");
Identifier f = new Identifier("fabric", "f");
Identifier y = new Identifier("fabric", "y");
Identifier z = new Identifier("fabric", "z");
Identifier a = Identifier.of("fabric", "a");
Identifier b = Identifier.of("fabric", "b");
Identifier d = Identifier.of("fabric", "d");
Identifier e = Identifier.of("fabric", "e");
Identifier f = Identifier.of("fabric", "f");
Identifier y = Identifier.of("fabric", "y");
Identifier z = Identifier.of("fabric", "z");
List<Consumer<Event<Test>>> dependencies = List.of(
ev -> ev.addPhaseOrdering(a, z),
@ -229,11 +229,11 @@ public class EventTests {
* </pre>
*/
private static void testTwoCycles() {
Identifier a = new Identifier("fabric", "a");
Identifier b = new Identifier("fabric", "b");
Identifier c = new Identifier("fabric", "c");
Identifier d = new Identifier("fabric", "d");
Identifier e = new Identifier("fabric", "e");
Identifier a = Identifier.of("fabric", "a");
Identifier b = Identifier.of("fabric", "b");
Identifier c = Identifier.of("fabric", "c");
Identifier d = Identifier.of("fabric", "d");
Identifier e = Identifier.of("fabric", "e");
List<Consumer<Event<Test>>> dependencies = List.of(
ev -> ev.addPhaseOrdering(e, a),

View file

@ -56,12 +56,12 @@ public class FabricApiLookupTest implements ModInitializer {
@Override
public void onInitialize() {
Identifier chute = new Identifier(MOD_ID, "chute");
Identifier chute = Identifier.of(MOD_ID, "chute");
Registry.register(Registries.BLOCK, chute, CHUTE_BLOCK);
Registry.register(Registries.ITEM, chute, CHUTE_ITEM);
CHUTE_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, chute, FabricBlockEntityTypeBuilder.create(ChuteBlockEntity::new, CHUTE_BLOCK).build());
Identifier cobbleGen = new Identifier(MOD_ID, "cobble_gen");
Identifier cobbleGen = Identifier.of(MOD_ID, "cobble_gen");
Registry.register(Registries.BLOCK, cobbleGen, COBBLE_GEN_BLOCK);
Registry.register(Registries.ITEM, cobbleGen, COBBLE_GEN_ITEM);
COBBLE_GEN_BLOCK_ENTITY_TYPE = Registry.register(Registries.BLOCK_ENTITY_TYPE, cobbleGen, FabricBlockEntityTypeBuilder.create(CobbleGenBlockEntity::new, COBBLE_GEN_BLOCK).build());
@ -76,7 +76,7 @@ public class FabricApiLookupTest implements ModInitializer {
testLookupRegistry();
testSelfRegistration();
Identifier inspector = new Identifier(FabricApiLookupTest.MOD_ID, "inspector");
Identifier inspector = Identifier.of(FabricApiLookupTest.MOD_ID, "inspector");
Registry.register(Registries.BLOCK, inspector, INSPECTOR_BLOCK);
Registry.register(Registries.ITEM, inspector, INSPECTOR_ITEM);
@ -85,18 +85,18 @@ public class FabricApiLookupTest implements ModInitializer {
}
private static void testLookupRegistry() {
BlockApiLookup<ItemInsertable, @NotNull Direction> insertable2 = BlockApiLookup.get(new Identifier("testmod:item_insertable"), ItemInsertable.class, Direction.class);
BlockApiLookup<ItemInsertable, @NotNull Direction> insertable2 = BlockApiLookup.get(Identifier.of("testmod", "item_insertable"), ItemInsertable.class, Direction.class);
if (insertable2 != ItemApis.INSERTABLE) {
throw new AssertionError("The registry should have returned the same instance.");
}
ensureException(() -> {
BlockApiLookup<Void, Void> wrongInsertable = BlockApiLookup.get(new Identifier("testmod:item_insertable"), Void.class, Void.class);
BlockApiLookup<Void, Void> wrongInsertable = BlockApiLookup.get(Identifier.of("testmod", "item_insertable"), Void.class, Void.class);
wrongInsertable.registerFallback((world, pos, state, be, nocontext) -> null);
}, "The registry should have prevented creation of another instance with different classes, but same id.");
if (!insertable2.getId().equals(new Identifier("testmod:item_insertable"))) {
if (!insertable2.getId().equals(Identifier.of("testmod", "item_insertable"))) {
throw new AssertionError("Incorrect identifier was returned.");
}

View file

@ -25,9 +25,9 @@ import net.fabricmc.fabric.api.lookup.v1.block.BlockApiLookup;
public final class ItemApis {
public static final BlockApiLookup<ItemInsertable, @NotNull Direction> INSERTABLE =
BlockApiLookup.get(new Identifier("testmod:item_insertable"), ItemInsertable.class, Direction.class);
BlockApiLookup.get(Identifier.of("testmod", "item_insertable"), ItemInsertable.class, Direction.class);
public static final BlockApiLookup<ItemExtractable, @NotNull Direction> EXTRACTABLE =
BlockApiLookup.get(new Identifier("testmod:item_extractable"), ItemExtractable.class, Direction.class);
BlockApiLookup.get(Identifier.of("testmod", "item_extractable"), ItemExtractable.class, Direction.class);
private ItemApis() {
}

View file

@ -34,7 +34,7 @@ import net.fabricmc.fabric.test.lookup.api.Inspectable;
public class FabricEntityApiLookupTest {
public static final EntityApiLookup<Inspectable, Void> INSPECTABLE =
EntityApiLookup.get(new Identifier(FabricApiLookupTest.MOD_ID, "inspectable"), Inspectable.class, Void.class);
EntityApiLookup.get(Identifier.of(FabricApiLookupTest.MOD_ID, "inspectable"), Inspectable.class, Void.class);
public static final EntityType<InspectablePigEntity> INSPECTABLE_PIG = FabricEntityTypeBuilder.create()
.spawnGroup(SpawnGroup.CREATURE)
@ -44,7 +44,7 @@ public class FabricEntityApiLookupTest {
.build();
public static void onInitialize() {
Registry.register(Registries.ENTITY_TYPE, new Identifier(FabricApiLookupTest.MOD_ID, "inspectable_pig"), INSPECTABLE_PIG);
Registry.register(Registries.ENTITY_TYPE, Identifier.of(FabricApiLookupTest.MOD_ID, "inspectable_pig"), INSPECTABLE_PIG);
FabricDefaultAttributeRegistry.register(INSPECTABLE_PIG, PigEntity.createPigAttributes());
INSPECTABLE.registerSelf(INSPECTABLE_PIG);

View file

@ -33,12 +33,12 @@ import net.fabricmc.fabric.test.lookup.api.Inspectable;
public class FabricItemApiLookupTest {
public static final ItemApiLookup<Inspectable, Void> INSPECTABLE =
ItemApiLookup.get(new Identifier("testmod:inspectable"), Inspectable.class, Void.class);
ItemApiLookup.get(Identifier.of("testmod", "inspectable"), Inspectable.class, Void.class);
public static final InspectableItem HELLO_ITEM = new InspectableItem("Hello Fabric API tester!");
public static void onInitialize() {
Registry.register(Registries.ITEM, new Identifier(FabricApiLookupTest.MOD_ID, "hello"), HELLO_ITEM);
Registry.register(Registries.ITEM, Identifier.of(FabricApiLookupTest.MOD_ID, "hello"), HELLO_ITEM);
// Diamonds and diamond blocks can be inspected and will also print their name.
INSPECTABLE.registerForItems((stack, ignored) -> () -> {

View file

@ -22,7 +22,7 @@ import net.minecraft.entity.passive.PigEntity;
import net.minecraft.util.Identifier;
public class InspectablePigEntityRenderer extends PigEntityRenderer {
private static final Identifier TEXTURE = new Identifier("missingno");
private static final Identifier TEXTURE = Identifier.ofDefaultNamespace("missingno");
public InspectablePigEntityRenderer(EntityRendererFactory.Context context) {
super(context);

View file

@ -43,19 +43,19 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
public class DataGeneratorEntrypoint implements net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint {
public static final RegistryKey<ConfiguredFeature<?, ?>> COMMON_DESERT_WELL = RegistryKey.of(
RegistryKeys.CONFIGURED_FEATURE,
new Identifier(FabricBiomeTest.MOD_ID, "fab_desert_well")
Identifier.of(FabricBiomeTest.MOD_ID, "fab_desert_well")
);
public static final RegistryKey<PlacedFeature> PLACED_COMMON_DESERT_WELL = RegistryKey.of(
RegistryKeys.PLACED_FEATURE,
new Identifier(FabricBiomeTest.MOD_ID, "fab_desert_well")
Identifier.of(FabricBiomeTest.MOD_ID, "fab_desert_well")
);
public static final RegistryKey<ConfiguredFeature<?, ?>> COMMON_ORE = RegistryKey.of(
RegistryKeys.CONFIGURED_FEATURE,
new Identifier(FabricBiomeTest.MOD_ID, "common_ore")
Identifier.of(FabricBiomeTest.MOD_ID, "common_ore")
);
public static final RegistryKey<PlacedFeature> PLACED_COMMON_ORE = RegistryKey.of(
RegistryKeys.PLACED_FEATURE,
new Identifier(FabricBiomeTest.MOD_ID, "common_ore")
Identifier.of(FabricBiomeTest.MOD_ID, "common_ore")
);
@Override

View file

@ -66,7 +66,7 @@ public class FabricBiomeTest implements ModInitializer {
TheEndBiomes.addMidlandsBiome(TestBiomes.TEST_END_HIGHLANDS, TestBiomes.TEST_END_MIDLANDS, 10.0);
TheEndBiomes.addBarrensBiome(TestBiomes.TEST_END_HIGHLANDS, TestBiomes.TEST_END_BARRRENS, 10.0);
BiomeModifications.create(new Identifier("fabric:test_mod"))
BiomeModifications.create(Identifier.of("fabric", "test_mod"))
.add(ModificationPhase.ADDITIONS,
BiomeSelectors.foundInOverworld(),
modification -> modification.getWeather().setDownfall(100))
@ -78,7 +78,7 @@ public class FabricBiomeTest implements ModInitializer {
);
})
.add(ModificationPhase.ADDITIONS,
BiomeSelectors.tag(TagKey.of(RegistryKeys.BIOME, new Identifier(MOD_ID, "tag_selector_test"))),
BiomeSelectors.tag(TagKey.of(RegistryKeys.BIOME, Identifier.of(MOD_ID, "tag_selector_test"))),
context -> context.getEffects().setSkyColor(0x770000))
.add(ModificationPhase.ADDITIONS, BiomeSelectors.foundInOverworld(), context ->
context.getGenerationSettings().addFeature(GenerationStep.Feature.UNDERGROUND_ORES, PLACED_COMMON_ORE)
@ -89,7 +89,7 @@ public class FabricBiomeTest implements ModInitializer {
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.VEGETAL_DECORATION,
RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier(MOD_ID, "concrete_pile"))
RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(MOD_ID, "concrete_pile"))
);
// Make sure data packs can define biomes

View file

@ -34,7 +34,7 @@ public class TestBiomeTagProvider extends FabricTagProvider<Biome> {
@Override
protected void configure(RegistryWrapper.WrapperLookup registries) {
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "biome_tag_test")))
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "biome_tag_test")))
.add(TestBiomes.CUSTOM_PLAINS)
.add(TestBiomes.TEST_END_HIGHLANDS);
}

View file

@ -35,12 +35,12 @@ import net.minecraft.world.gen.feature.EndPlacedFeatures;
import net.minecraft.world.gen.feature.PlacedFeature;
public final class TestBiomes {
public static final RegistryKey<Biome> EXAMPLE_BIOME = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "example_biome"));
public static final RegistryKey<Biome> TEST_CRIMSON_FOREST = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "test_crimson_forest"));
public static final RegistryKey<Biome> CUSTOM_PLAINS = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "custom_plains"));
public static final RegistryKey<Biome> TEST_END_HIGHLANDS = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "test_end_highlands"));
public static final RegistryKey<Biome> TEST_END_MIDLANDS = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "test_end_midlands"));
public static final RegistryKey<Biome> TEST_END_BARRRENS = RegistryKey.of(RegistryKeys.BIOME, new Identifier(FabricBiomeTest.MOD_ID, "test_end_barrens"));
public static final RegistryKey<Biome> EXAMPLE_BIOME = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "example_biome"));
public static final RegistryKey<Biome> TEST_CRIMSON_FOREST = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "test_crimson_forest"));
public static final RegistryKey<Biome> CUSTOM_PLAINS = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "custom_plains"));
public static final RegistryKey<Biome> TEST_END_HIGHLANDS = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "test_end_highlands"));
public static final RegistryKey<Biome> TEST_END_MIDLANDS = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "test_end_midlands"));
public static final RegistryKey<Biome> TEST_END_BARRRENS = RegistryKey.of(RegistryKeys.BIOME, Identifier.of(FabricBiomeTest.MOD_ID, "test_end_barrens"));
private TestBiomes() {
}

View file

@ -20,6 +20,9 @@ import java.util.ConcurrentModificationException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,12 +31,12 @@ import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.render.chunk.ChunkRendererRegion;
import net.minecraft.client.render.chunk.ChunkRendererRegionBuilder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
@ -44,19 +47,8 @@ public abstract class ChunkRendererRegionBuilderMixin {
private static final AtomicInteger ERROR_COUNTER = new AtomicInteger();
private static final Logger LOGGER = LoggerFactory.getLogger(ChunkRendererRegionBuilderMixin.class);
@Inject(method = "build", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
private void createDataMap(World world, BlockPos startPos, BlockPos endPos, int offset, CallbackInfoReturnable<ChunkRendererRegion> cir, int startX, int startZ, int endX, int endZ, ChunkRendererRegionBuilder.ClientChunk[][] chunksXZ) {
ChunkRendererRegion rendererRegion = cir.getReturnValue();
if (rendererRegion == null) {
return;
}
// instantiated lazily - avoids allocation for chunks without any data objects - which is most of them!
Long2ObjectOpenHashMap<Object> map = null;
for (ChunkRendererRegionBuilder.ClientChunk[] chunksZ : chunksXZ) {
for (ChunkRendererRegionBuilder.ClientChunk chunk : chunksZ) {
@Inject(method = "build", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/chunk/ChunkRendererRegionBuilder$ClientChunk;getRenderedChunk()Lnet/minecraft/client/render/chunk/RenderedChunk;"))
private void copyDataForChunk(World world, ChunkSectionPos chunkSectionPos, CallbackInfoReturnable<ChunkRendererRegion> cir, @Local(ordinal = 1) ChunkRendererRegionBuilder.ClientChunk clientChunk, @Share("dataMap") LocalRef<Long2ObjectOpenHashMap<Object>> mapRef) {
// Hash maps in chunks should generally not be modified outside of client thread
// but does happen in practice, due to mods or inconsistent vanilla behaviors, causing
// CMEs when we iterate the map. (Vanilla does not iterate these maps when it builds
@ -65,7 +57,7 @@ public abstract class ChunkRendererRegionBuilderMixin {
// We handle this simply by retrying until it works. Ugly but effective.
while (true) {
try {
map = mapChunk(chunk.getChunk(), startPos, endPos, map);
mapRef.set(mapChunk(clientChunk.getChunk(), chunkSectionPos, mapRef.get()));
break;
} catch (ConcurrentModificationException e) {
final int count = ERROR_COUNTER.incrementAndGet();
@ -80,7 +72,11 @@ public abstract class ChunkRendererRegionBuilderMixin {
}
}
}
}
@Inject(method = "build", at = @At(value = "RETURN", ordinal = 1))
private void createDataMap(World world, ChunkSectionPos chunkSectionPos, CallbackInfoReturnable<ChunkRendererRegion> cir, @Share("dataMap") LocalRef<Long2ObjectOpenHashMap<Object>> mapRef) {
ChunkRendererRegion rendererRegion = cir.getReturnValue();
Long2ObjectOpenHashMap<Object> map = mapRef.get();
if (map != null) {
((RenderDataMapConsumer) rendererRegion).fabric_acceptRenderDataMap(map);
@ -88,13 +84,18 @@ public abstract class ChunkRendererRegionBuilderMixin {
}
@Unique
private static Long2ObjectOpenHashMap<Object> mapChunk(WorldChunk chunk, BlockPos posFrom, BlockPos posTo, Long2ObjectOpenHashMap<Object> map) {
final int xMin = posFrom.getX();
final int xMax = posTo.getX();
final int yMin = posFrom.getY();
final int yMax = posTo.getY();
final int zMin = posFrom.getZ();
final int zMax = posTo.getZ();
private static Long2ObjectOpenHashMap<Object> mapChunk(WorldChunk chunk, ChunkSectionPos chunkSectionPos, Long2ObjectOpenHashMap<Object> map) {
// Skip the math below if the chunk contains no block entities
if (chunk.getBlockEntities().isEmpty()) {
return map;
}
final int xMin = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionX() - 1);
final int yMin = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionY() - 1);
final int zMin = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionZ() - 1);
final int xMax = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionX() + 1);
final int yMax = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionY() + 1);
final int zMax = ChunkSectionPos.getBlockCoord(chunkSectionPos.getSectionZ() + 1);
for (Map.Entry<BlockPos, BlockEntity> entry : chunk.getBlockEntities().entrySet()) {
final BlockPos pos = entry.getKey();

View file

@ -35,10 +35,10 @@ import org.slf4j.LoggerFactory;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagEntry;
import net.minecraft.registry.tag.TagFile;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.registry.tag.TagManagerLoader;
import net.minecraft.util.Identifier;
import net.fabricmc.loader.api.FabricLoader;
@ -111,7 +111,7 @@ public class ClientTagsLoader {
* @return the paths to all tag json files within the available mods
*/
private static HashSet<Path> getTagFiles(RegistryKey<? extends Registry<?>> registryKey, Identifier identifier) {
return getTagFiles(TagManagerLoader.getPath(registryKey), identifier);
return getTagFiles(RegistryKeys.getTagPath(registryKey), identifier);
}
/**

View file

@ -45,7 +45,7 @@ public class ClientTagTest implements ClientModInitializer {
public void onInitializeClient() {
final ModContainer container = FabricLoader.getInstance().getModContainer(MODID).get();
if (!ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(MODID, "test2"),
if (!ResourceManagerHelper.registerBuiltinResourcePack(Identifier.of(MODID, "test2"),
container, ResourcePackActivationType.ALWAYS_ENABLED)) {
throw new IllegalStateException("Could not register built-in resource pack.");
}
@ -68,7 +68,7 @@ public class ClientTagTest implements ClientModInitializer {
}
if (ClientTags.isInWithLocalFallback(TagKey.of(Registries.BLOCK.getKey(),
new Identifier("fabric", "sword_efficient")), Blocks.DIRT)) {
Identifier.of("fabric", "sword_efficient")), Blocks.DIRT)) {
throw new AssertionError("Expected not to find dirt in fabric:sword_efficient, but it was found!");
}
@ -83,7 +83,7 @@ public class ClientTagTest implements ClientModInitializer {
// but the this test should pass as minecraft:sword_efficient will contain dirt on the server
ClientTickEvents.END_WORLD_TICK.register(client -> {
if (!ClientTags.isInWithLocalFallback(TagKey.of(Registries.BLOCK.getKey(),
new Identifier("fabric", "sword_efficient")), Blocks.DIRT)) {
Identifier.of("fabric", "sword_efficient")), Blocks.DIRT)) {
throw new AssertionError("Expected to find dirt in fabric:sword_efficient, but it was not found!");
}
});

View file

@ -40,7 +40,7 @@ public final class EntitySelectorOptionRegistry {
* {@code example_min_health} and can be used like {@code @e[example_min_health=5]}.
* <pre>{@code
* EntitySelectorOptionRegistry.register(
* new Identifier("example", "min_health"),
* Identifier.of("example", "min_health"),
* Text.literal("Minimum entity health"),
* (reader) -> {
* final float minHealth = reader.getReader().readFloat();

View file

@ -38,7 +38,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
public final class CommandTest implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandTest.class);
static final Identifier SELECTOR_ID = new Identifier("fabric-command-api-v2-testmod", "min_health");
static final Identifier SELECTOR_ID = Identifier.of("fabric-command-api-v2-testmod", "min_health");
private static final SimpleCommandExceptionType WRONG_SIDE_SHOULD_BE_INTEGRATED = new SimpleCommandExceptionType(Text.literal("This command was registered incorrectly. Should only be present on an integrated server but was ran on a dedicated server!"));
private static final SimpleCommandExceptionType WRONG_SIDE_SHOULD_BE_DEDICATED = new SimpleCommandExceptionType(Text.literal("This command was registered incorrectly. Should only be present on an dedicated server but was ran on an integrated server!"));

View file

@ -37,7 +37,7 @@ public class CustomArgumentTest implements ModInitializer {
@Override
public void onInitialize() {
ArgumentTypeRegistry.registerArgumentType(new Identifier("fabric-command-test", "smiley"), SmileyArgumentType.class, ConstantArgumentSerializer.of(SmileyArgumentType::smiley));
ArgumentTypeRegistry.registerArgumentType(Identifier.of("fabric-command-test", "smiley"), SmileyArgumentType.class, ConstantArgumentSerializer.of(SmileyArgumentType::smiley));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(

View file

@ -65,7 +65,7 @@ import net.fabricmc.fabric.api.registry.VillagerInteractionRegistries;
public final class ContentRegistryTest implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(ContentRegistryTest.class);
public static final Identifier TEST_EVENT_ID = new Identifier("fabric-content-registries-v0-testmod", "test_event");
public static final Identifier TEST_EVENT_ID = Identifier.of("fabric-content-registries-v0-testmod", "test_event");
public static final RegistryEntry.Reference<GameEvent> TEST_EVENT = Registry.registerReference(Registries.GAME_EVENT, TEST_EVENT_ID, new GameEvent(GameEvent.DEFAULT_RANGE));
@Override
@ -140,7 +140,7 @@ public final class ContentRegistryTest implements ModInitializer {
VillagerInteractionRegistries.registerCollectable(Items.OAK_SAPLING);
VillagerInteractionRegistries.registerGiftLootTable(VillagerProfession.NITWIT, RegistryKey.of(RegistryKeys.LOOT_TABLE, new Identifier("fake_loot_table")));
VillagerInteractionRegistries.registerGiftLootTable(VillagerProfession.NITWIT, RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.ofDefaultNamespace("fake_loot_table")));
Registry.register(Registries.BLOCK, TEST_EVENT_ID, new TestEventBlock(AbstractBlock.Settings.copy(Blocks.STONE)));
SculkSensorFrequencyRegistry.register(TEST_EVENT.registryKey(), 2);
@ -156,7 +156,7 @@ public final class ContentRegistryTest implements ModInitializer {
}
var dirtyPotion = new DirtyPotionItem(new Item.Settings().maxCount(1));
Registry.register(Registries.ITEM, new Identifier("fabric-content-registries-v0-testmod", "dirty_potion"),
Registry.register(Registries.ITEM, Identifier.of("fabric-content-registries-v0-testmod", "dirty_potion"),
dirtyPotion);
/* Mods should use BrewingRecipeRegistry.registerPotionType(Item), which is access widened by fabric-transitive-access-wideners-v1
* This testmod uses an accessor due to Loom limitations that prevent TAWs from applying across Gradle subproject boundaries */

View file

@ -283,7 +283,7 @@ public final class BiomeTagGenerator extends FabricTagProvider<Biome> {
.addOptionalTag(ConventionalBiomeTags.IS_FLOWER_FOREST);
getOrCreateTagBuilder(ConventionalBiomeTags.IS_FLOWER_FOREST)
.add(BiomeKeys.FLOWER_FOREST)
.addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "flower_forests"));
.addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "flower_forests"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_OLD_GROWTH)
.add(BiomeKeys.OLD_GROWTH_BIRCH_FOREST)
.add(BiomeKeys.OLD_GROWTH_PINE_TAIGA)
@ -322,25 +322,25 @@ public final class BiomeTagGenerator extends FabricTagProvider<Biome> {
// Backwards compat with pre-1.21 tags. Done after so optional tag is last for better readability.
// TODO: Remove backwards compat tag entries in 1.22
getOrCreateTagBuilder(ConventionalBiomeTags.IS_NETHER).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "in_nether"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_END).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "in_the_end"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "in_the_overworld"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_CAVE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "caves"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_COLD_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "climate_cold"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_TEMPERATE_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "climate_temperate"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_HOT_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "climate_hot"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_WET_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "climate_wet"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_DRY_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "climate_dry"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_VEGETATION_DENSE_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "vegetation_dense"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_VEGETATION_SPARSE_OVERWORLD).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "vegetation_sparse"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_CONIFEROUS_TREE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "tree_coniferous"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_DECIDUOUS_TREE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "tree_deciduous"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_JUNGLE_TREE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "tree_jungle"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_SAVANNA_TREE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "tree_savanna"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_MOUNTAIN_PEAK).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "mountain_peak"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_MOUNTAIN_SLOPE).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "mountain_slope"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_OUTER_END_ISLAND).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "end_islands"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_NETHER_FOREST).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "nether_forests"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_FLOWER_FOREST).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "flower_forests"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_NETHER).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "in_nether"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_END).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "in_the_end"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "in_the_overworld"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_CAVE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "caves"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_COLD_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "climate_cold"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_TEMPERATE_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "climate_temperate"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_HOT_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "climate_hot"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_WET_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "climate_wet"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_DRY_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "climate_dry"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_VEGETATION_DENSE_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "vegetation_dense"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_VEGETATION_SPARSE_OVERWORLD).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "vegetation_sparse"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_CONIFEROUS_TREE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "tree_coniferous"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_DECIDUOUS_TREE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "tree_deciduous"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_JUNGLE_TREE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "tree_jungle"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_SAVANNA_TREE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "tree_savanna"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_MOUNTAIN_PEAK).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "mountain_peak"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_MOUNTAIN_SLOPE).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "mountain_slope"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_OUTER_END_ISLAND).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "end_islands"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_NETHER_FOREST).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "nether_forests"));
getOrCreateTagBuilder(ConventionalBiomeTags.IS_FLOWER_FOREST).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "flower_forests"));
}
}

View file

@ -449,18 +449,18 @@ public final class BlockTagGenerator extends FabricTagProvider.BlockTagProvider
// Backwards compat with pre-1.21 tags. Done after so optional tag is last for better readability.
// TODO: Remove backwards compat tag entries in 1.22
getOrCreateTagBuilder(ConventionalBlockTags.RELOCATION_NOT_SUPPORTED).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "movement_restricted"));
getOrCreateTagBuilder(ConventionalBlockTags.QUARTZ_ORES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "quartz_ores"));
getOrCreateTagBuilder(ConventionalBlockTags.WOODEN_BARRELS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "wooden_barrels"));
getOrCreateTagBuilder(ConventionalBlockTags.WOODEN_CHESTS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "wooden_chests"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_BLOCKS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_SLABS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_STAIRS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "sandstone_stairs"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_BLOCKS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "red_sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_SLABS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "red_sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_STAIRS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "red_sandstone_stairs"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_BLOCKS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_SLABS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_STAIRS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_stairs"));
getOrCreateTagBuilder(ConventionalBlockTags.RELOCATION_NOT_SUPPORTED).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "movement_restricted"));
getOrCreateTagBuilder(ConventionalBlockTags.QUARTZ_ORES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "quartz_ores"));
getOrCreateTagBuilder(ConventionalBlockTags.WOODEN_BARRELS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "wooden_barrels"));
getOrCreateTagBuilder(ConventionalBlockTags.WOODEN_CHESTS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "wooden_chests"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_BLOCKS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_SLABS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.SANDSTONE_STAIRS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "sandstone_stairs"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_BLOCKS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "red_sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_SLABS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "red_sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.RED_SANDSTONE_STAIRS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "red_sandstone_stairs"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_BLOCKS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_blocks"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_SLABS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_slabs"));
getOrCreateTagBuilder(ConventionalBlockTags.UNCOLORED_SANDSTONE_STAIRS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "uncolored_sandstone_stairs"));
}
}

View file

@ -61,8 +61,8 @@ public final class EnchantmentTagGenerator extends FabricTagProvider.Enchantment
// Backwards compat with pre-1.21 tags. Done after so optional tag is last for better readability.
// TODO: Remove backwards compat tag entries in 1.22
getOrCreateTagBuilder(ConventionalEnchantmentTags.ENTITY_SPEED_ENHANCEMENTS)
.addOptionalTag(new Identifier("c", "entity_movement_enhancement"));
.addOptionalTag(Identifier.of("c", "entity_movement_enhancement"));
getOrCreateTagBuilder(ConventionalEnchantmentTags.ENTITY_DEFENSE_ENHANCEMENTS)
.addOptionalTag(new Identifier("c", "entity_defense_enhancement"));
.addOptionalTag(Identifier.of("c", "entity_defense_enhancement"));
}
}

View file

@ -603,37 +603,37 @@ public final class ItemTagGenerator extends FabricTagProvider.ItemTagProvider {
// Backwards compat with pre-1.21 tags. Done after so optional tag is last for better readability.
// TODO: Remove backwards compat tag entries in 1.22
getOrCreateTagBuilder(ConventionalItemTags.WOODEN_BARRELS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "wooden_barrels"));
getOrCreateTagBuilder(ConventionalItemTags.WOODEN_CHESTS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "wooden_chests"));
getOrCreateTagBuilder(ConventionalItemTags.BLACK_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "black_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.BLUE_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "blue_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.BROWN_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "brown_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.GREEN_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "green_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.RED_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "red_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.WHITE_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "white_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.YELLOW_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "yellow_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIGHT_BLUE_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "light_blue_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIGHT_GRAY_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "light_gray_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIME_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "lime_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.MAGENTA_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "magenta_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.ORANGE_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "orange_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.PINK_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "pink_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.CYAN_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "cyan_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.GRAY_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "gray_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.PURPLE_DYES).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "purple_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.IRON_RAW_MATERIALS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "raw_iron_ores"));
getOrCreateTagBuilder(ConventionalItemTags.COPPER_RAW_MATERIALS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "raw_copper_ores"));
getOrCreateTagBuilder(ConventionalItemTags.GOLD_RAW_MATERIALS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "raw_gold_ores"));
getOrCreateTagBuilder(ConventionalItemTags.GLOWSTONE_DUSTS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "glowstone_dusts"));
getOrCreateTagBuilder(ConventionalItemTags.REDSTONE_DUSTS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "redstone_dusts"));
getOrCreateTagBuilder(ConventionalItemTags.DIAMOND_GEMS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "diamonds"));
getOrCreateTagBuilder(ConventionalItemTags.LAPIS_GEMS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "lapis"));
getOrCreateTagBuilder(ConventionalItemTags.EMERALD_GEMS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "emeralds"));
getOrCreateTagBuilder(ConventionalItemTags.QUARTZ_GEMS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "quartz"));
getOrCreateTagBuilder(ConventionalItemTags.SHEARS_TOOLS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "shears"));
getOrCreateTagBuilder(ConventionalItemTags.SPEARS_TOOLS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "spears"));
getOrCreateTagBuilder(ConventionalItemTags.BOWS_TOOLS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "bows"));
getOrCreateTagBuilder(ConventionalItemTags.SHIELDS_TOOLS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "shields"));
getOrCreateTagBuilder(ConventionalItemTags.STRINGS).addOptionalTag(new Identifier(TagUtil.C_TAG_NAMESPACE, "string"));
getOrCreateTagBuilder(ConventionalItemTags.WOODEN_BARRELS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "wooden_barrels"));
getOrCreateTagBuilder(ConventionalItemTags.WOODEN_CHESTS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "wooden_chests"));
getOrCreateTagBuilder(ConventionalItemTags.BLACK_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "black_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.BLUE_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "blue_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.BROWN_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "brown_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.GREEN_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "green_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.RED_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "red_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.WHITE_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "white_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.YELLOW_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "yellow_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIGHT_BLUE_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "light_blue_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIGHT_GRAY_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "light_gray_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.LIME_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "lime_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.MAGENTA_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "magenta_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.ORANGE_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "orange_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.PINK_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "pink_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.CYAN_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "cyan_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.GRAY_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "gray_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.PURPLE_DYES).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "purple_dyes"));
getOrCreateTagBuilder(ConventionalItemTags.IRON_RAW_MATERIALS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "raw_iron_ores"));
getOrCreateTagBuilder(ConventionalItemTags.COPPER_RAW_MATERIALS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "raw_copper_ores"));
getOrCreateTagBuilder(ConventionalItemTags.GOLD_RAW_MATERIALS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "raw_gold_ores"));
getOrCreateTagBuilder(ConventionalItemTags.GLOWSTONE_DUSTS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "glowstone_dusts"));
getOrCreateTagBuilder(ConventionalItemTags.REDSTONE_DUSTS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "redstone_dusts"));
getOrCreateTagBuilder(ConventionalItemTags.DIAMOND_GEMS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "diamonds"));
getOrCreateTagBuilder(ConventionalItemTags.LAPIS_GEMS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "lapis"));
getOrCreateTagBuilder(ConventionalItemTags.EMERALD_GEMS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "emeralds"));
getOrCreateTagBuilder(ConventionalItemTags.QUARTZ_GEMS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "quartz"));
getOrCreateTagBuilder(ConventionalItemTags.SHEARS_TOOLS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "shears"));
getOrCreateTagBuilder(ConventionalItemTags.SPEARS_TOOLS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "spears"));
getOrCreateTagBuilder(ConventionalItemTags.BOWS_TOOLS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "bows"));
getOrCreateTagBuilder(ConventionalItemTags.SHIELDS_TOOLS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "shields"));
getOrCreateTagBuilder(ConventionalItemTags.STRINGS).addOptionalTag(Identifier.of(TagUtil.C_TAG_NAMESPACE, "string"));
}
}

View file

@ -41,10 +41,10 @@ public record TagRegistration<T>(RegistryKey<Registry<T>> registryKey) {
public static final TagRegistration<Enchantment> ENCHANTMENT_TAG = new TagRegistration<>(RegistryKeys.ENCHANTMENT);
public TagKey<T> registerFabric(String tagId) {
return TagKey.of(registryKey, new Identifier(TagUtil.FABRIC_TAG_NAMESPACE, tagId));
return TagKey.of(registryKey, Identifier.of(TagUtil.FABRIC_TAG_NAMESPACE, tagId));
}
public TagKey<T> registerC(String tagId) {
return TagKey.of(registryKey, new Identifier(TagUtil.C_TAG_NAMESPACE, tagId));
return TagKey.of(registryKey, Identifier.of(TagUtil.C_TAG_NAMESPACE, tagId));
}
}

View file

@ -70,7 +70,7 @@ public class AttachmentSerializingImpl {
NbtCompound compound = nbt.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY);
for (String key : compound.getKeys()) {
AttachmentType<?> type = AttachmentRegistryImpl.get(new Identifier(key));
AttachmentType<?> type = AttachmentRegistryImpl.get(Identifier.of(key));
if (type == null) {
LOGGER.warn("Unknown attachment type " + key + " found when deserializing, skipping");

View file

@ -65,7 +65,7 @@ import net.fabricmc.fabric.impl.attachment.AttachmentTargetImpl;
public class CommonAttachmentTests {
private static final String MOD_ID = "example";
private static final AttachmentType<Integer> PERSISTENT = AttachmentRegistry.createPersistent(
new Identifier(MOD_ID, "persistent"),
Identifier.of(MOD_ID, "persistent"),
Codec.INT
);
@ -77,7 +77,7 @@ public class CommonAttachmentTests {
@Test
void testTargets() {
AttachmentType<String> basic = AttachmentRegistry.create(new Identifier(MOD_ID, "basic_attachment"));
AttachmentType<String> basic = AttachmentRegistry.create(Identifier.of(MOD_ID, "basic_attachment"));
// Attachment targets
/*
* CALLS_REAL_METHODS makes sense here because AttachmentTarget does not refer to anything in the underlying
@ -117,7 +117,7 @@ public class CommonAttachmentTests {
@Test
void testDefaulted() {
AttachmentType<Integer> defaulted = AttachmentRegistry.createDefaulted(
new Identifier(MOD_ID, "defaulted_attachment"),
Identifier.of(MOD_ID, "defaulted_attachment"),
() -> 0
);
Entity target = mock(Entity.class, CALLS_REAL_METHODS);
@ -131,7 +131,7 @@ public class CommonAttachmentTests {
@Test
void testStaticReadWrite() {
AttachmentType<Double> dummy = AttachmentRegistry.createPersistent(
new Identifier(MOD_ID, "dummy"),
Identifier.of(MOD_ID, "dummy"),
Codec.DOUBLE
);
var map = new IdentityHashMap<AttachmentType<?>, Object>();
@ -156,7 +156,7 @@ public class CommonAttachmentTests {
var nbt = new NbtCompound();
assertNull(AttachmentSerializingImpl.deserializeAttachmentData(nbt, mockDRM()));
nbt.put(new Identifier("test").toString(), new NbtCompound());
nbt.put(Identifier.ofDefaultNamespace("test").toString(), new NbtCompound());
assertNull(AttachmentSerializingImpl.deserializeAttachmentData(nbt, mockDRM()));
}
@ -173,11 +173,11 @@ public class CommonAttachmentTests {
@Test
void testEntityCopy() {
AttachmentType<Boolean> notCopiedOnRespawn = AttachmentRegistry.create(
new Identifier(MOD_ID, "not_copied_on_respawn")
Identifier.of(MOD_ID, "not_copied_on_respawn")
);
AttachmentType<Boolean> copiedOnRespawn = AttachmentRegistry.<Boolean>builder()
.copyOnDeath()
.buildAndRegister(new Identifier(MOD_ID, "copied_on_respawn"));
.buildAndRegister(Identifier.of(MOD_ID, "copied_on_respawn"));
Entity original = mock(Entity.class, CALLS_REAL_METHODS);
original.setAttached(notCopiedOnRespawn, true);

View file

@ -51,11 +51,11 @@ public class AttachmentTestMod implements ModInitializer {
public static final String MOD_ID = "fabric-data-attachment-api-v1-testmod";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static final AttachmentType<String> PERSISTENT = AttachmentRegistry.createPersistent(
new Identifier(MOD_ID, "persistent"),
Identifier.of(MOD_ID, "persistent"),
Codec.STRING
);
public static final AttachmentType<String> FEATURE_ATTACHMENT = AttachmentRegistry.create(
new Identifier(MOD_ID, "feature")
Identifier.of(MOD_ID, "feature")
);
public static final ChunkPos FAR_CHUNK_POS = new ChunkPos(300, 0);
@ -65,12 +65,12 @@ public class AttachmentTestMod implements ModInitializer {
@Override
public void onInitialize() {
Registry.register(Registries.FEATURE, new Identifier(MOD_ID, "set_attachment"), new SetAttachmentFeature(DefaultFeatureConfig.CODEC));
Registry.register(Registries.FEATURE, Identifier.of(MOD_ID, "set_attachment"), new SetAttachmentFeature(DefaultFeatureConfig.CODEC));
BiomeModifications.addFeature(
BiomeSelectors.foundInOverworld(),
GenerationStep.Feature.VEGETAL_DECORATION,
RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier(MOD_ID, "set_attachment"))
RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(MOD_ID, "set_attachment"))
);
ServerLifecycleEvents.SERVER_STARTED.register(server -> {

View file

@ -39,11 +39,11 @@ import net.fabricmc.fabric.test.attachment.AttachmentTestMod;
public class AttachmentCopyTests implements FabricGameTest {
// using a lambda type because serialization shouldn't play a role in this
public static AttachmentType<IntSupplier> DUMMY = AttachmentRegistry.create(
new Identifier(AttachmentTestMod.MOD_ID, "dummy")
Identifier.of(AttachmentTestMod.MOD_ID, "dummy")
);
public static AttachmentType<IntSupplier> COPY_ON_DEATH = AttachmentRegistry.<IntSupplier>builder()
.copyOnDeath()
.buildAndRegister(new Identifier(AttachmentTestMod.MOD_ID, "copy_test"));
.buildAndRegister(Identifier.of(AttachmentTestMod.MOD_ID, "copy_test"));
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testCrossWorldTeleport(TestContext context) {
@ -57,7 +57,7 @@ public class AttachmentCopyTests implements FabricGameTest {
entity.setAttached(DUMMY, () -> 10);
entity.setAttached(COPY_ON_DEATH, () -> 10);
Entity moved = entity.moveToWorld(() -> new TeleportTarget(end));
Entity moved = entity.teleportTo(new TeleportTarget(end));
if (moved == null) throw new GameTestException("Cross-world teleportation failed");
IntSupplier attached1 = moved.getAttached(DUMMY);

View file

@ -34,6 +34,7 @@ import net.minecraft.advancement.AdvancementEntry;
import net.minecraft.data.DataOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryOps;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.util.Identifier;
@ -55,7 +56,7 @@ public abstract class FabricAdvancementProvider implements DataProvider {
protected FabricAdvancementProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
this.output = output;
this.pathResolver = output.getResolver(DataOutput.OutputType.DATA_PACK, "advancements");
this.pathResolver = output.getResolver(RegistryKeys.ADVANCEMENT);
this.registryLookup = registryLookup;
}

View file

@ -110,7 +110,7 @@ public abstract class FabricLanguageProvider implements DataProvider {
private Path getLangFilePath(String code) {
return dataOutput
.getResolver(DataOutput.OutputType.RESOURCE_PACK, "lang")
.resolveJson(new Identifier(dataOutput.getModId(), code));
.resolveJson(Identifier.of(dataOutput.getModId(), code));
}
@Override

View file

@ -125,6 +125,6 @@ public abstract class FabricRecipeProvider extends RecipeProvider {
* Override this method to change the recipe identifier. The default implementation normalizes the namespace to the mod ID.
*/
protected Identifier getRecipeIdentifier(Identifier identifier) {
return new Identifier(output.getModId(), identifier.getPath());
return Identifier.of(output.getModId(), identifier.getPath());
}
}

View file

@ -81,7 +81,7 @@ public final class FabricLootTableProviderImpl {
}
private static Path getOutputPath(FabricDataOutput dataOutput, Identifier lootTableId) {
return dataOutput.getResolver(DataOutput.OutputType.DATA_PACK, "loot_tables").resolveJson(lootTableId);
return dataOutput.getResolver(DataOutput.OutputType.DATA_PACK, "loot_table").resolveJson(lootTableId);
}
private FabricLootTableProviderImpl() {

View file

@ -117,6 +117,7 @@ transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider off
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmithingTemplateCopyingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/registry/tag/TagKey;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmithingTemplateCopyingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider method_60922 (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateCookingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;Lnet/minecraft/recipe/AbstractCookingRecipe$RecipeFactory;I)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerFoodCookingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;Lnet/minecraft/recipe/AbstractCookingRecipe$RecipeFactory;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerWaxingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V

View file

@ -48,21 +48,21 @@ public class DataGeneratorTestContent implements ModInitializer {
public static Block BLOCK_WITH_VANILLA_LOOT_TABLE;
public static Block BLOCK_THAT_DROPS_NOTHING;
public static final RegistryKey<ItemGroup> SIMPLE_ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MOD_ID, "simple"));
public static final RegistryKey<ItemGroup> SIMPLE_ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(MOD_ID, "simple"));
public static final RegistryKey<Registry<TestDatagenObject>> TEST_DATAGEN_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_datagen_dynamic"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_datagen_dynamic"));
public static final RegistryKey<TestDatagenObject> TEST_DYNAMIC_REGISTRY_ITEM_KEY = RegistryKey.of(
TEST_DATAGEN_DYNAMIC_REGISTRY_KEY,
new Identifier(MOD_ID, "tiny_potato")
Identifier.of(MOD_ID, "tiny_potato")
);
public static final RegistryKey<TestDatagenObject> TEST_DYNAMIC_REGISTRY_EXTRA_ITEM_KEY = RegistryKey.of(
TEST_DATAGEN_DYNAMIC_REGISTRY_KEY,
new Identifier(MOD_ID, "tinier_potato")
Identifier.of(MOD_ID, "tinier_potato")
);
// Empty registry
public static final RegistryKey<Registry<TestDatagenObject>> TEST_DATAGEN_DYNAMIC_EMPTY_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_datagen_dynamic_empty"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_datagen_dynamic_empty"));
@Override
public void onInitialize() {
@ -84,7 +84,7 @@ public class DataGeneratorTestContent implements ModInitializer {
}
private static Block createBlock(String name, boolean hasItem, AbstractBlock.Settings settings) {
Identifier identifier = new Identifier(MOD_ID, name);
Identifier identifier = Identifier.of(MOD_ID, name);
Block block = Registry.register(Registries.BLOCK, identifier, new Block(settings));
if (hasItem) {

View file

@ -142,7 +142,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
}
}
FabricDataGenerator.Pack extraPack = dataGenerator.createBuiltinResourcePack(new Identifier(MOD_ID, "extra"));
FabricDataGenerator.Pack extraPack = dataGenerator.createBuiltinResourcePack(Identifier.of(MOD_ID, "extra"));
CompletableFuture<RegistryWrapper.WrapperLookup> extraRegistries = ExperimentalRegistriesValidator.validate(dataGenerator.getRegistries(), new RegistryBuilder()
.addRegistry(TEST_DATAGEN_DYNAMIC_REGISTRY_KEY, c ->
c.register(TEST_DYNAMIC_REGISTRY_EXTRA_ITEM_KEY, new DataGeneratorTestContent.TestDatagenObject(":tiny_potato:"))
@ -255,7 +255,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
@Override
public void generateTranslations(RegistryWrapper.WrapperLookup registryLookup, TranslationBuilder translationBuilder) {
translationBuilder.add(SIMPLE_BLOCK, "Simple Block");
translationBuilder.add(new Identifier(MOD_ID, "identifier_test"), "Identifier Test");
translationBuilder.add(Identifier.of(MOD_ID, "identifier_test"), "Identifier Test");
translationBuilder.add(EntityType.ALLAY, "Allay");
translationBuilder.add(EntityAttributes.GENERIC_ARMOR, "Generic Armor");
@ -343,7 +343,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
@Override
protected void configure(RegistryWrapper.WrapperLookup registries) {
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BIOME, new Identifier(MOD_ID, "biome_tag_test")))
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BIOME, Identifier.of(MOD_ID, "biome_tag_test")))
.add(BiomeKeys.BADLANDS, BiomeKeys.BAMBOO_JUNGLE)
.add(BiomeKeys.BASALT_DELTAS);
}
@ -356,7 +356,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
@Override
protected void configure(RegistryWrapper.WrapperLookup registries) {
getOrCreateTagBuilder(TagKey.of(RegistryKeys.GAME_EVENT, new Identifier(MOD_ID, "game_event_tag_test")))
getOrCreateTagBuilder(TagKey.of(RegistryKeys.GAME_EVENT, Identifier.of(MOD_ID, "game_event_tag_test")))
.add(GameEvent.SHRIEK.registryKey());
}
}
@ -373,7 +373,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
SIMPLE_BLOCK,
Text.translatable("advancements.test.root.title"),
Text.translatable("advancements.test.root.description"),
new Identifier("textures/gui/advancements/backgrounds/end.png"),
Identifier.ofDefaultNamespace("textures/gui/advancements/backgrounds/end.png"),
AdvancementFrame.TASK,
false, false, false)
.criterion("killed_something", OnKilledCriterion.Conditions.createPlayerKilledEntity())
@ -383,7 +383,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
SIMPLE_BLOCK,
Text.translatable("advancements.test.root_not_loaded.title"),
Text.translatable("advancements.test.root_not_loaded.description"),
new Identifier("textures/gui/advancements/backgrounds/end.png"),
Identifier.ofDefaultNamespace("textures/gui/advancements/backgrounds/end.png"),
AdvancementFrame.TASK,
false, false, false)
.criterion("killed_something", OnKilledCriterion.Conditions.createPlayerKilledEntity())
@ -466,13 +466,13 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
private static class TestPredicateProvider extends FabricCodecDataProvider<LootCondition> {
private TestPredicateProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "predicates", LootCondition.CODEC);
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "predicate", LootCondition.CODEC);
}
@Override
protected void configure(BiConsumer<Identifier, LootCondition> provider, RegistryWrapper.WrapperLookup lookup) {
RegistryEntryLookup<Block> blocks = lookup.createRegistryLookup().getOrThrow(RegistryKeys.BLOCK);
provider.accept(new Identifier(MOD_ID, "predicate_test"), BlockStatePropertyLootCondition.builder(
provider.accept(Identifier.of(MOD_ID, "predicate_test"), BlockStatePropertyLootCondition.builder(
blocks.getOrThrow(BlockKeys.MELON).value()).build()); // Pretend this actually does something and we cannot access the blocks directly
}
@ -490,7 +490,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
@Override
protected void configure(BiConsumer<Identifier, Entry> provider, RegistryWrapper.WrapperLookup lookup) {
RegistryEntryLookup<Biome> biomes = lookup.createRegistryLookup().getOrThrow(RegistryKeys.BIOME);
provider.accept(new Identifier(MOD_ID, "custom_codec_test"), new Entry(biomes.getOrThrow(BiomeKeys.PLAINS)));
provider.accept(Identifier.of(MOD_ID, "custom_codec_test"), new Entry(biomes.getOrThrow(BiomeKeys.PLAINS)));
}
@Override

View file

@ -44,7 +44,7 @@ public class DataGeneratorClientTestEntrypoint implements DataGeneratorEntrypoin
@Override
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
final FabricDataGenerator.Pack pack = dataGenerator.createBuiltinResourcePack(new Identifier(MOD_ID, "example_builtin"));
final FabricDataGenerator.Pack pack = dataGenerator.createBuiltinResourcePack(Identifier.of(MOD_ID, "example_builtin"));
pack.addProvider(TestAtlasSourceProvider::new);
}
@ -55,7 +55,7 @@ public class DataGeneratorClientTestEntrypoint implements DataGeneratorEntrypoin
@Override
protected void configure(BiConsumer<Identifier, List<AtlasSource>> provider, RegistryWrapper.WrapperLookup lookup) {
provider.accept(new Identifier(MOD_ID, "atlas_source_test"), List.of(new DirectoryAtlasSource("example", "example/")));
provider.accept(Identifier.of(MOD_ID, "atlas_source_test"), List.of(new DirectoryAtlasSource("example", "example/")));
}
@Override

View file

@ -34,7 +34,7 @@ public final class FabricDimensionInternals {
Preconditions.checkArgument(Thread.currentThread() == ((ServerWorld) teleported.getWorld()).getServer().getThread(), "Entities must be teleported from the main server thread");
// Fast path for teleporting within the same dimension.
if (teleported.getWorld() == target.newDimension()) {
if (teleported.getWorld() == target.world()) {
if (teleported instanceof ServerPlayerEntity serverPlayerEntity) {
serverPlayerEntity.networkHandler.requestTeleport(target.pos().x, target.pos().y, target.pos().z, target.yaw(), target.pitch());
} else {
@ -47,6 +47,6 @@ public final class FabricDimensionInternals {
return teleported;
}
return (E) teleported.moveToWorld(() -> target);
return (E) teleported.teleportTo(target);
}
}

View file

@ -51,16 +51,16 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
public class FabricDimensionTest implements ModInitializer {
// The dimension options refer to the JSON-file in the dimension subfolder of the data pack,
// which will always share its ID with the world that is created from it
private static final RegistryKey<DimensionOptions> DIMENSION_KEY = RegistryKey.of(RegistryKeys.DIMENSION, new Identifier("fabric_dimension", "void"));
private static final RegistryKey<DimensionOptions> DIMENSION_KEY = RegistryKey.of(RegistryKeys.DIMENSION, Identifier.of("fabric_dimension", "void"));
private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.literal("Teleportation failed!"));
private static RegistryKey<World> WORLD_KEY = RegistryKey.of(RegistryKeys.WORLD, DIMENSION_KEY.getValue());
@Override
public void onInitialize() {
Registry.register(Registries.CHUNK_GENERATOR, new Identifier("fabric_dimension", "void"), VoidChunkGenerator.CODEC);
Registry.register(Registries.CHUNK_GENERATOR, Identifier.of("fabric_dimension", "void"), VoidChunkGenerator.CODEC);
WORLD_KEY = RegistryKey.of(RegistryKeys.WORLD, new Identifier("fabric_dimension", "void"));
WORLD_KEY = RegistryKey.of(RegistryKeys.WORLD, Identifier.of("fabric_dimension", "void"));
if (System.getProperty("fabric-api.gametest") != null) {
// The gametest server does not support custom worlds

View file

@ -28,6 +28,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.entity.Entity;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
@ -35,10 +36,10 @@ import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
@Mixin(Entity.class)
abstract class EntityMixin {
@Shadow
public World world;
private World world;
@Inject(method = "moveToWorld", at = @At("RETURN"))
private void afterWorldChanged(Entity.TeleportTargetSupplier targetSupplier, CallbackInfoReturnable<Entity> cir) {
@Inject(method = "teleportTo", at = @At("RETURN"))
private void afterWorldChanged(TeleportTarget targetSupplier, CallbackInfoReturnable<Entity> cir) {
// Ret will only have an entity if the teleport worked (entity not removed, teleportTarget was valid, entity was successfully created)
Entity ret = cir.getReturnValue();

View file

@ -56,9 +56,9 @@ public final class EntityEventTests implements ModInitializer {
@Override
public void onInitialize() {
Registry.register(Registries.BLOCK, new Identifier("fabric-entity-events-v1-testmod", "test_bed"), TEST_BED);
Registry.register(Registries.ITEM, new Identifier("fabric-entity-events-v1-testmod", "test_bed"), new BlockItem(TEST_BED, new Item.Settings()));
Registry.register(Registries.ITEM, new Identifier("fabric-entity-events-v1-testmod", "diamond_elytra"), DIAMOND_ELYTRA);
Registry.register(Registries.BLOCK, Identifier.of("fabric-entity-events-v1-testmod", "test_bed"), TEST_BED);
Registry.register(Registries.ITEM, Identifier.of("fabric-entity-events-v1-testmod", "test_bed"), new BlockItem(TEST_BED, new Item.Settings()));
Registry.register(Registries.ITEM, Identifier.of("fabric-entity-events-v1-testmod", "diamond_elytra"), DIAMOND_ELYTRA);
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, entity, killed) -> {
LOGGER.info("Entity {} Killed: {}", entity, killed);

View file

@ -44,8 +44,8 @@ import net.fabricmc.fabric.api.gamerule.v1.rule.EnumRule;
public class GameRulesTestMod implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(GameRulesTestMod.class);
private static final Direction[] CARDINAL_DIRECTIONS = Arrays.stream(Direction.values()).filter(direction -> direction != Direction.UP && direction != Direction.DOWN).toArray(Direction[]::new);
public static final CustomGameRuleCategory GREEN_CATEGORY = new CustomGameRuleCategory(new Identifier("fabric", "green"), Text.literal("This One is Green").styled(style -> style.withBold(true).withColor(Formatting.DARK_GREEN)));
public static final CustomGameRuleCategory RED_CATEGORY = new CustomGameRuleCategory(new Identifier("fabric", "red"), Text.literal("This One is Red").styled(style -> style.withBold(true).withColor(Formatting.DARK_RED)));
public static final CustomGameRuleCategory GREEN_CATEGORY = new CustomGameRuleCategory(Identifier.of("fabric", "green"), Text.literal("This One is Green").styled(style -> style.withBold(true).withColor(Formatting.DARK_GREEN)));
public static final CustomGameRuleCategory RED_CATEGORY = new CustomGameRuleCategory(Identifier.of("fabric", "red"), Text.literal("This One is Red").styled(style -> style.withBold(true).withColor(Formatting.DARK_RED)));
// Bounded, Integer, Double and Float rules
public static final GameRules.Key<GameRules.IntRule> POSITIVE_ONLY_TEST_INT = register("positiveOnlyTestInteger", GameRules.Category.UPDATES, GameRuleFactory.createIntRule(2, 0));

View file

@ -34,11 +34,11 @@ import net.minecraft.util.Util;
import net.fabricmc.api.ModInitializer;
public class ArmorKnockbackResistanceTest implements ModInitializer {
private static final RegistryEntry<ArmorMaterial> WOOD_ARMOR = Registry.registerReference(Registries.ARMOR_MATERIAL, new Identifier("fabric-item-api-v1-testmod", "wood"), createTestArmorMaterial());
private static final RegistryEntry<ArmorMaterial> WOOD_ARMOR = Registry.registerReference(Registries.ARMOR_MATERIAL, Identifier.of("fabric-item-api-v1-testmod", "wood"), createTestArmorMaterial());
@Override
public void onInitialize() {
Registry.register(Registries.ITEM, new Identifier("fabric-item-api-v1-testmod",
Registry.register(Registries.ITEM, Identifier.of("fabric-item-api-v1-testmod",
"wooden_boots"), new ArmorItem(WOOD_ARMOR, ArmorItem.Type.BOOTS, new Item.Settings()));
}
@ -53,7 +53,7 @@ public class ArmorKnockbackResistanceTest implements ModInitializer {
0,
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
() -> Ingredient.ofItems(Items.LEATHER),
List.of(new ArmorMaterial.Layer(new Identifier("fabric-item-api-v1-testmod", "wood"))),
List.of(new ArmorMaterial.Layer(Identifier.of("fabric-item-api-v1-testmod", "wood"))),
0,
0.5F
);

View file

@ -44,7 +44,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.util.TriState;
public class CustomDamageTest implements ModInitializer {
public static final ComponentType<Integer> WEIRD = Registry.register(Registries.DATA_COMPONENT_TYPE, new Identifier("fabric-item-api-v1-testmod", "weird"),
public static final ComponentType<Integer> WEIRD = Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of("fabric-item-api-v1-testmod", "weird"),
ComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
public static final CustomDamageHandler WEIRD_DAMAGE_HANDLER = (stack, amount, entity, slot, breakCallback) -> {
// If sneaking, apply all damage to vanilla. Otherwise, increment a tag on the stack by one and don't apply any damage
@ -60,7 +60,7 @@ public class CustomDamageTest implements ModInitializer {
@Override
public void onInitialize() {
Registry.register(Registries.ITEM, new Identifier("fabric-item-api-v1-testmod", "weird_pickaxe"), WEIRD_PICK);
Registry.register(Registries.ITEM, Identifier.of("fabric-item-api-v1-testmod", "weird_pickaxe"), WEIRD_PICK);
FuelRegistry.INSTANCE.add(WEIRD_PICK, 200);
FabricBrewingRecipeRegistryBuilder.BUILD.register(builder -> builder.registerPotionRecipe(Potions.WATER, WEIRD_PICK, Potions.AWKWARD));
EnchantmentEvents.ALLOW_ENCHANTING.register(((enchantment, target, enchantingContext) -> {

View file

@ -35,7 +35,7 @@ import net.fabricmc.fabric.api.item.v1.DefaultItemComponentEvents;
public class DefaultItemComponentTest implements ModInitializer {
@Override
public void onInitialize() {
Identifier latePhase = new Identifier("fabric-item-api-v1-testmod", "late");
Identifier latePhase = Identifier.of("fabric-item-api-v1-testmod", "late");
DefaultItemComponentEvents.MODIFY.addPhaseOrdering(Event.DEFAULT_PHASE, latePhase);
DefaultItemComponentEvents.MODIFY.register(context -> {

View file

@ -26,12 +26,12 @@ import net.minecraft.util.dynamic.Codecs;
import net.fabricmc.api.ModInitializer;
public class ItemUpdateAnimationTest implements ModInitializer {
public static final ComponentType<Integer> TICKS = Registry.register(Registries.DATA_COMPONENT_TYPE, new Identifier("fabric-item-api-v1-testmod", "ticks"),
public static final ComponentType<Integer> TICKS = Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of("fabric-item-api-v1-testmod", "ticks"),
ComponentType.<Integer>builder().codec(Codecs.NONNEGATIVE_INT).packetCodec(PacketCodecs.VAR_INT).build());
@Override
public void onInitialize() {
Registry.register(Registries.ITEM, new Identifier("fabric-item-api-v1-testmod", "updating_allowed"), new UpdatingItem(true));
Registry.register(Registries.ITEM, new Identifier("fabric-item-api-v1-testmod", "updating_disallowed"), new UpdatingItem(false));
Registry.register(Registries.ITEM, Identifier.of("fabric-item-api-v1-testmod", "updating_allowed"), new UpdatingItem(true));
Registry.register(Registries.ITEM, Identifier.of("fabric-item-api-v1-testmod", "updating_disallowed"), new UpdatingItem(false));
}
}

View file

@ -30,7 +30,7 @@ import net.minecraft.world.World;
public class UpdatingItem extends Item {
private static final EntityAttributeModifier PLUS_FIVE = new EntityAttributeModifier(
ATTACK_DAMAGE_MODIFIER_ID, "updating item", 5, EntityAttributeModifier.Operation.ADD_VALUE);
BASE_ATTACK_DAMAGE_MODIFIER_ID, 5, EntityAttributeModifier.Operation.ADD_VALUE);
private final boolean allowUpdateAnimation;

View file

@ -33,7 +33,7 @@ import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.itemgroup.FabricItemGroup;
public class FabricCreativeGuiComponents {
private static final Identifier BUTTON_TEX = new Identifier("fabric", "textures/gui/creative_buttons.png");
private static final Identifier BUTTON_TEX = Identifier.of("fabric", "textures/gui/creative_buttons.png");
private static final double TABS_PER_PAGE = FabricItemGroup.TABS_PER_PAGE;
public static final Set<ItemGroup> COMMON_GROUPS = Set.of(ItemGroups.SEARCH, ItemGroups.INVENTORY, ItemGroups.HOTBAR).stream()
.map(Registries.ITEM_GROUP::getOrThrow)

View file

@ -40,7 +40,7 @@ public final class FabricItemGroup {
* <p>Example:
*
* <pre>{@code
* private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MOD_ID, "test_group"));
* private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(MOD_ID, "test_group"));
*
* @Override
* public void onInitialize() {

View file

@ -39,11 +39,11 @@ public class ItemGroupTest implements ModInitializer {
private static final String MOD_ID = "fabric-item-group-api-v1-testmod";
private static Item TEST_ITEM;
private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, new Identifier(MOD_ID, "test_group"));
private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(MOD_ID, "test_group"));
@Override
public void onInitialize() {
TEST_ITEM = Registry.register(Registries.ITEM, new Identifier("fabric-item-groups-v0-testmod", "item_test_group"), new Item(new Item.Settings()));
TEST_ITEM = Registry.register(Registries.ITEM, Identifier.of("fabric-item-groups-v0-testmod", "item_test_group"), new Item(new Item.Settings()));
Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder()
.displayName(Text.literal("Test Item Group"))
@ -86,7 +86,7 @@ public class ItemGroupTest implements ModInitializer {
for (int j = 0; j < 20; j++) {
Registry.register(
Registries.ITEM_GROUP,
new Identifier(MOD_ID, "empty_group_" + j),
Identifier.of(MOD_ID, "empty_group_" + j),
FabricItemGroup.builder()
.displayName(Text.literal("Empty Item Group: " + j))
.build()
@ -96,7 +96,7 @@ public class ItemGroupTest implements ModInitializer {
for (int i = 0; i < 100; i++) {
final int index = i;
Registry.register(Registries.ITEM_GROUP, new Identifier(MOD_ID, "test_group_" + i), FabricItemGroup.builder()
Registry.register(Registries.ITEM_GROUP, Identifier.of(MOD_ID, "test_group_" + i), FabricItemGroup.builder()
.displayName(Text.literal("Test Item Group: " + i))
.icon((Supplier<ItemStack>) () -> new ItemStack(Registries.BLOCK.get(index)))
.entries((context, entries) -> {

View file

@ -38,7 +38,7 @@ import net.fabricmc.fabric.impl.loot.LootUtil;
public class JsonDataLoaderMixin {
@Inject(method = "load", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/resource/ResourceFinder;toResourceId(Lnet/minecraft/util/Identifier;)Lnet/minecraft/util/Identifier;", shift = At.Shift.AFTER))
private static void fillSourceMap(ResourceManager manager, String dataType, Gson gson, Map<Identifier, JsonElement> results, CallbackInfo ci, @Local Map.Entry<Identifier, Resource> entry, @Local(ordinal = 1) Identifier id) {
if (!LootDataType.LOOT_TABLES.directory().equals(dataType)) return;
if (!LootDataType.LOOT_TABLES.registryKey().getValue().getPath().equals(dataType)) return;
LootUtil.SOURCES.get().put(id, LootUtil.determineSource(entry.getValue()));
}

View file

@ -66,12 +66,12 @@ public final class ServerMessageDecoratorEvent {
* The content phase of the event, passed when registering a message decorator. Use this when
* the decorator modifies the text content of the message.
*/
public static final Identifier CONTENT_PHASE = new Identifier("fabric", "content");
public static final Identifier CONTENT_PHASE = Identifier.of("fabric", "content");
/**
* The styling phase of the event, passed when registering a message decorator. Use this when
* the decorator only modifies the styling of the message with the text intact.
*/
public static final Identifier STYLING_PHASE = new Identifier("fabric", "styling");
public static final Identifier STYLING_PHASE = Identifier.of("fabric", "styling");
public static final Event<MessageDecorator> EVENT = EventFactory.createWithPhases(MessageDecorator.class, decorators -> (sender, message) -> {
Text decorated = message;

View file

@ -57,7 +57,7 @@ public final class ModelModifier {
/**
* Recommended phase to use when overriding models, e.g. replacing a model with another model.
*/
public static final Identifier OVERRIDE_PHASE = new Identifier("fabric", "override");
public static final Identifier OVERRIDE_PHASE = Identifier.of("fabric", "override");
/**
* Recommended phase to use for transformations that need to happen before wrapping, but after model overrides.
*/
@ -65,12 +65,12 @@ public final class ModelModifier {
/**
* Recommended phase to use when wrapping models.
*/
public static final Identifier WRAP_PHASE = new Identifier("fabric", "wrap");
public static final Identifier WRAP_PHASE = Identifier.of("fabric", "wrap");
/**
* Recommended phase to use when wrapping models with transformations that want to happen last,
* e.g. for connected textures or other similar visual effects that should be the final processing step.
*/
public static final Identifier WRAP_LAST_PHASE = new Identifier("fabric", "wrap_last");
public static final Identifier WRAP_LAST_PHASE = Identifier.of("fabric", "wrap_last");
@FunctionalInterface
public interface OnLoad {

View file

@ -47,7 +47,7 @@ import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
public class ModelTestModClient implements ClientModInitializer {
public static final String ID = "fabric-model-loading-api-v1-testmod";
public static final Identifier MODEL_ID = new Identifier(ID, "half_red_sand");
public static final Identifier MODEL_ID = Identifier.of(ID, "half_red_sand");
static class DownQuadRemovingModel extends ForwardingBakedModel {
DownQuadRemovingModel(BakedModel model) {
@ -99,7 +99,7 @@ public class ModelTestModClient implements ClientModInitializer {
// All the block state models are top-level...
// Use a delegating unbaked model to make sure the identical models only get baked a single time.
Identifier wheatStage0Id = new Identifier("block/wheat_stage0");
Identifier wheatStage0Id = Identifier.ofDefaultNamespace("block/wheat_stage0");
UnbakedModel stage0Model = new DelegatingUnbakedModel(wheatStage0Id);
@ -107,7 +107,7 @@ public class ModelTestModClient implements ClientModInitializer {
context.setModel(state.with(CropBlock.AGE, age), stage0Model);
}
context.setModel(state.with(CropBlock.AGE, 7), context.getOrLoadModel(new Identifier("block/wheat_stage7")));
context.setModel(state.with(CropBlock.AGE, 7), context.getOrLoadModel(Identifier.ofDefaultNamespace("block/wheat_stage7")));
});
});

View file

@ -33,7 +33,7 @@ public class NestedModelLoadingTest implements ClientModInitializer {
private static final Logger LOGGER = LogUtils.getLogger();
private static Identifier id(String path) {
return new Identifier("fabric-model-loading-api-v1-testmod", path);
return Identifier.of("fabric-model-loading-api-v1-testmod", path);
}
private static final Identifier BASE_MODEL = id("nested_base");
@ -42,7 +42,7 @@ public class NestedModelLoadingTest implements ClientModInitializer {
private static final Identifier NESTED_MODEL_3 = id("nested_3");
private static final Identifier NESTED_MODEL_4 = id("nested_4");
private static final Identifier NESTED_MODEL_5 = id("nested_5");
private static final Identifier TARGET_MODEL = new Identifier("minecraft", "block/stone");
private static final Identifier TARGET_MODEL = Identifier.ofDefaultNamespace("block/stone");
@Override
public void onInitializeClient() {

View file

@ -32,7 +32,7 @@ import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys;
public class SpecificModelReloadListener extends SinglePreparationResourceReloader<Unit> implements IdentifiableResourceReloadListener {
public static final SpecificModelReloadListener INSTANCE = new SpecificModelReloadListener();
public static final Identifier ID = new Identifier(ModelTestModClient.ID, "specific_model");
public static final Identifier ID = Identifier.of(ModelTestModClient.ID, "specific_model");
private BakedModel specificModel;

View file

@ -25,7 +25,7 @@ import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
public record CommonRegisterPayload(int version, String phase, Set<Identifier> channels) implements CustomPayload {
public static final CustomPayload.Id<CommonRegisterPayload> ID = CustomPayload.id("c:register");
public static final CustomPayload.Id<CommonRegisterPayload> ID = new Id<>(Identifier.of("c:register"));
public static final PacketCodec<PacketByteBuf, CommonRegisterPayload> CODEC = CustomPayload.codecOf(CommonRegisterPayload::write, CommonRegisterPayload::new);
public static final String PLAY_PHASE = "play";

View file

@ -19,10 +19,11 @@ package net.fabricmc.fabric.impl.networking;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
public record CommonVersionPayload(int[] versions) implements CustomPayload {
public static final PacketCodec<PacketByteBuf, CommonVersionPayload> CODEC = CustomPayload.codecOf(CommonVersionPayload::write, CommonVersionPayload::new);
public static final CustomPayload.Id<CommonVersionPayload> ID = CustomPayload.id("c:version");
public static final CustomPayload.Id<CommonVersionPayload> ID = new Id<>(Identifier.of("c:version"));
private CommonVersionPayload(PacketByteBuf buf) {
this(buf.readIntArray());

View file

@ -30,12 +30,12 @@ public final class NetworkingImpl {
/**
* Id of packet used to register supported channels.
*/
public static final Identifier REGISTER_CHANNEL = new Identifier("minecraft", "register");
public static final Identifier REGISTER_CHANNEL = Identifier.ofDefaultNamespace("register");
/**
* Id of packet used to unregister supported channels.
*/
public static final Identifier UNREGISTER_CHANNEL = new Identifier("minecraft", "unregister");
public static final Identifier UNREGISTER_CHANNEL = Identifier.ofDefaultNamespace("unregister");
public static boolean isReservedCommonChannel(Identifier channelName) {
return channelName.equals(REGISTER_CHANNEL) || channelName.equals(UNREGISTER_CHANNEL);

View file

@ -77,7 +77,7 @@ public record RegistrationPayload(Id<RegistrationPayload> id, List<Identifier> c
String literal = sb.toString();
try {
ids.add(new Identifier(literal));
ids.add(Identifier.of(literal));
} catch (InvalidIdentifierException ex) {
NetworkingImpl.LOGGER.warn("Received invalid channel identifier \"{}\"", literal);
}

View file

@ -99,7 +99,7 @@ abstract class ClientConnectionMixin implements ChannelInfoHolder {
}
}
@Inject(method = "handleDisconnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/PacketListener;onDisconnected(Lnet/minecraft/text/Text;)V"))
@Inject(method = "handleDisconnection", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/listener/PacketListener;onDisconnected(Lnet/minecraft/class_9812;)V"))
private void disconnectAddon(CallbackInfo ci) {
if (packetListener instanceof NetworkHandlerExtensions extension) {
extension.getAddon().handleDisconnect();

View file

@ -96,7 +96,7 @@ public class CommonPacketTests {
}
private record TestPayload(String data) implements CustomPayload {
static final CustomPayload.Id<TestPayload> ID = new CustomPayload.Id<>(new Identifier("fabric", "global_client"));
static final CustomPayload.Id<TestPayload> ID = new CustomPayload.Id<>(Identifier.of("fabric", "global_client"));
static final PacketCodec<RegistryByteBuf, TestPayload> CODEC = CustomPayload.codecOf(TestPayload::write, TestPayload::new);
TestPayload(RegistryByteBuf buf) {
@ -236,20 +236,20 @@ public class CommonPacketTests {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeVarInt(1); // Version
buf.writeString("play"); // Target phase
buf.writeCollection(List.of(new Identifier("fabric", "test")), PacketByteBuf::writeIdentifier);
buf.writeCollection(List.of(Identifier.of("fabric", "test")), PacketByteBuf::writeIdentifier);
CommonRegisterPayload payload = CommonRegisterPayload.CODEC.decode(buf);
packetHandler.receive(payload, clientContext);
// Assert the entire packet was read
assertEquals(0, buf.readableBytes());
assertIterableEquals(List.of(new Identifier("fabric", "test")), channelInfoHolder.fabric_getPendingChannelsNames(NetworkPhase.PLAY));
assertIterableEquals(List.of(Identifier.of("fabric", "test")), channelInfoHolder.fabric_getPendingChannelsNames(NetworkPhase.PLAY));
// Check the response we are sending back to the server
PacketByteBuf response = readResponse(packetSender, REGISTER_PAYLOAD_TYPE);
assertEquals(1, response.readVarInt());
assertEquals("play", response.readString());
assertIterableEquals(List.of(new Identifier("fabric", "global_client")), response.readCollection(HashSet::new, PacketByteBuf::readIdentifier));
assertIterableEquals(List.of(Identifier.of("fabric", "global_client")), response.readCollection(HashSet::new, PacketByteBuf::readIdentifier));
assertEquals(0, response.readableBytes());
}
@ -260,13 +260,13 @@ public class CommonPacketTests {
assertNotNull(packetHandler);
when(clientAddon.getNegotiatedVersion()).thenReturn(1);
when(clientAddon.createRegisterPayload()).thenAnswer(i -> new CommonRegisterPayload(1, "configuration", Set.of(new Identifier("fabric", "global_configuration_client"))));
when(clientAddon.createRegisterPayload()).thenAnswer(i -> new CommonRegisterPayload(1, "configuration", Set.of(Identifier.of("fabric", "global_configuration_client"))));
// Receive a packet from the server
PacketByteBuf buf = PacketByteBufs.create();
buf.writeVarInt(1); // Version
buf.writeString("configuration"); // Target phase
buf.writeCollection(List.of(new Identifier("fabric", "test")), PacketByteBuf::writeIdentifier);
buf.writeCollection(List.of(Identifier.of("fabric", "test")), PacketByteBuf::writeIdentifier);
CommonRegisterPayload payload = CommonRegisterPayload.CODEC.decode(buf);
packetHandler.receive(payload, clientContext);
@ -279,7 +279,7 @@ public class CommonPacketTests {
PacketByteBuf response = readResponse(packetSender, REGISTER_PAYLOAD_TYPE);
assertEquals(1, response.readVarInt());
assertEquals("configuration", response.readString());
assertIterableEquals(List.of(new Identifier("fabric", "global_configuration_client")), response.readCollection(HashSet::new, PacketByteBuf::readIdentifier));
assertIterableEquals(List.of(Identifier.of("fabric", "global_configuration_client")), response.readCollection(HashSet::new, PacketByteBuf::readIdentifier));
assertEquals(0, response.readableBytes());
}
@ -295,14 +295,14 @@ public class CommonPacketTests {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeVarInt(1); // Version
buf.writeString("play"); // Target phase
buf.writeCollection(List.of(new Identifier("fabric", "test")), PacketByteBuf::writeIdentifier);
buf.writeCollection(List.of(Identifier.of("fabric", "test")), PacketByteBuf::writeIdentifier);
CommonRegisterPayload payload = CommonRegisterPayload.CODEC.decode(buf);
packetHandler.receive(payload, serverContext);
// Assert the entire packet was read
assertEquals(0, buf.readableBytes());
assertIterableEquals(List.of(new Identifier("fabric", "test")), channelInfoHolder.fabric_getPendingChannelsNames(NetworkPhase.PLAY));
assertIterableEquals(List.of(Identifier.of("fabric", "test")), channelInfoHolder.fabric_getPendingChannelsNames(NetworkPhase.PLAY));
}
// Test handing the configuration registry packet on the server configuration handler
@ -317,7 +317,7 @@ public class CommonPacketTests {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeVarInt(1); // Version
buf.writeString("configuration"); // Target phase
buf.writeCollection(List.of(new Identifier("fabric", "test")), PacketByteBuf::writeIdentifier);
buf.writeCollection(List.of(Identifier.of("fabric", "test")), PacketByteBuf::writeIdentifier);
CommonRegisterPayload payload = CommonRegisterPayload.CODEC.decode(buf);
packetHandler.receive(payload, serverContext);

View file

@ -31,6 +31,7 @@ import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
@ -113,7 +114,7 @@ public class PayloadTypeRegistryTests {
}
private record C2SPlayPayload(String value) implements CustomPayload {
public static final CustomPayload.Id<C2SPlayPayload> ID = CustomPayload.id("fabric:c2s_play");
public static final CustomPayload.Id<C2SPlayPayload> ID = new Id<>(Identifier.of("fabric:c2s_play"));
public static final PacketCodec<RegistryByteBuf, C2SPlayPayload> CODEC = PacketCodecs.STRING.xmap(C2SPlayPayload::new, C2SPlayPayload::value).cast();
@Override
@ -123,7 +124,7 @@ public class PayloadTypeRegistryTests {
}
private record S2CPlayPayload(String value) implements CustomPayload {
public static final CustomPayload.Id<S2CPlayPayload> ID = CustomPayload.id("fabric:s2c_play");
public static final CustomPayload.Id<S2CPlayPayload> ID = new Id<>(Identifier.of("fabric:s2c_play"));
public static final PacketCodec<RegistryByteBuf, S2CPlayPayload> CODEC = PacketCodecs.STRING.xmap(S2CPlayPayload::new, S2CPlayPayload::value).cast();
@Override
@ -133,7 +134,7 @@ public class PayloadTypeRegistryTests {
}
private record C2SConfigPayload(String value) implements CustomPayload {
public static final CustomPayload.Id<C2SConfigPayload> ID = CustomPayload.id("fabric:c2s_config");
public static final CustomPayload.Id<C2SConfigPayload> ID = new Id<>(Identifier.of("fabric:c2s_config"));
public static final PacketCodec<PacketByteBuf, C2SConfigPayload> CODEC = PacketCodecs.STRING.xmap(C2SConfigPayload::new, C2SConfigPayload::value).cast();
@Override
@ -143,7 +144,7 @@ public class PayloadTypeRegistryTests {
}
private record S2CConfigPayload(String value) implements CustomPayload {
public static final CustomPayload.Id<S2CConfigPayload> ID = CustomPayload.id("fabric:s2c_config");
public static final CustomPayload.Id<S2CConfigPayload> ID = new Id<>(Identifier.of("fabric:s2c_config"));
public static final PacketCodec<PacketByteBuf, S2CConfigPayload> CODEC = PacketCodecs.STRING.xmap(S2CConfigPayload::new, S2CConfigPayload::value).cast();
@Override

View file

@ -26,7 +26,7 @@ public final class NetworkingTestmods {
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
public static Identifier id(String name) {
return new Identifier(ID, name);
return Identifier.of(ID, name);
}
private NetworkingTestmods() {

View file

@ -36,6 +36,7 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.test.networking.NetworkingTestmods;
public class NetworkingCommonTest implements ModInitializer {
private boolean firstLoad = true;
private List<String> receivedPlay = new ArrayList<>();
private List<String> receivedConfig = new ArrayList<>();
@ -57,6 +58,13 @@ public class NetworkingCommonTest implements ModInitializer {
// Ensure that the packets were received on the server
ServerEntityEvents.ENTITY_LOAD.register((entity, world) -> {
if (!firstLoad) {
// No need to check again if the player changes dimensions
return;
}
firstLoad = false;
if (entity instanceof ServerPlayerEntity player) {
final String uuid = player.getUuidAsString();

View file

@ -57,7 +57,7 @@ public class NetworkingConfigurationTest implements ModInitializer {
}
public record TestConfigurationTask(String data) implements ServerPlayerConfigurationTask {
public static final Key KEY = new Key(new Identifier(NetworkingTestmods.ID, "configure").toString());
public static final Key KEY = new Key(Identifier.of(NetworkingTestmods.ID, "configure").toString());
@Override
public void sendPacket(Consumer<Packet<?>> sender) {
@ -72,7 +72,7 @@ public class NetworkingConfigurationTest implements ModInitializer {
}
public record ConfigurationPacket(String data) implements CustomPayload {
public static final CustomPayload.Id<ConfigurationPacket> ID = new Id<>(new Identifier(NetworkingTestmods.ID, "configure"));
public static final CustomPayload.Id<ConfigurationPacket> ID = new Id<>(Identifier.of(NetworkingTestmods.ID, "configure"));
public static final PacketCodec<PacketByteBuf, ConfigurationPacket> CODEC = CustomPayload.codecOf(ConfigurationPacket::write, ConfigurationPacket::new);
public ConfigurationPacket(PacketByteBuf buf) {
@ -91,7 +91,7 @@ public class NetworkingConfigurationTest implements ModInitializer {
public static class ConfigurationCompletePacket implements CustomPayload {
public static final ConfigurationCompletePacket INSTANCE = new ConfigurationCompletePacket();
public static final CustomPayload.Id<ConfigurationCompletePacket> ID = new Id<>(new Identifier(NetworkingTestmods.ID, "configure_complete"));
public static final CustomPayload.Id<ConfigurationCompletePacket> ID = new Id<>(Identifier.of(NetworkingTestmods.ID, "configure_complete"));
public static final PacketCodec<PacketByteBuf, ConfigurationCompletePacket> CODEC = PacketCodec.unit(INSTANCE);
private ConfigurationCompletePacket() {

View file

@ -31,16 +31,16 @@ public class EntityModelLayersMixin {
@Inject(method = "createSign", at = @At("HEAD"), cancellable = true)
private static void createSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = new Identifier(type.name());
cir.setReturnValue(new EntityModelLayer(new Identifier(identifier.getNamespace(), "sign/" + identifier.getPath()), "main"));
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new EntityModelLayer(Identifier.of(identifier.getNamespace(), "sign/" + identifier.getPath()), "main"));
}
}
@Inject(method = "createHangingSign", at = @At("HEAD"), cancellable = true)
private static void createHangingSign(WoodType type, CallbackInfoReturnable<EntityModelLayer> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = new Identifier(type.name());
cir.setReturnValue(new EntityModelLayer(new Identifier(identifier.getNamespace(), "hanging_sign/" + identifier.getPath()), "main"));
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new EntityModelLayer(Identifier.of(identifier.getNamespace(), "hanging_sign/" + identifier.getPath()), "main"));
}
}
}

View file

@ -16,9 +16,10 @@
package net.fabricmc.fabric.mixin.object.builder.client;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import net.minecraft.block.entity.SignBlockEntity;
import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen;
@ -31,13 +32,13 @@ public abstract class HangingSignEditScreenMixin extends AbstractSignEditScreen
super(blockEntity, filtered, bl);
}
@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;<init>(Ljava/lang/String;)V"))
private String init(String id) {
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;ofDefaultNamespace(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"))
private Identifier init(String id, Operation<Identifier> original) {
if (signType.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = new Identifier(signType.name());
return identifier.getNamespace() + ":textures/gui/hanging_signs/" + identifier.getPath() + ".png";
Identifier identifier = Identifier.of(signType.name());
return Identifier.of(identifier.getNamespace(), "textures/gui/hanging_signs/" + identifier.getPath() + ".png");
}
return id;
return original.call(id);
}
}

View file

@ -37,16 +37,16 @@ public class TexturedRenderLayersMixin {
@Inject(method = "createSignTextureId", at = @At("HEAD"), cancellable = true)
private static void modifyTextureId(WoodType type, CallbackInfoReturnable<SpriteIdentifier> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = new Identifier(type.name());
cir.setReturnValue(new SpriteIdentifier(SIGNS_ATLAS_TEXTURE, new Identifier(identifier.getNamespace(), "entity/signs/" + identifier.getPath())));
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new SpriteIdentifier(SIGNS_ATLAS_TEXTURE, Identifier.of(identifier.getNamespace(), "entity/signs/" + identifier.getPath())));
}
}
@Inject(method = "createHangingSignTextureId", at = @At("HEAD"), cancellable = true)
private static void modifyHangingTextureId(WoodType type, CallbackInfoReturnable<SpriteIdentifier> cir) {
if (type.name().indexOf(Identifier.NAMESPACE_SEPARATOR) != -1) {
Identifier identifier = new Identifier(type.name());
cir.setReturnValue(new SpriteIdentifier(SIGNS_ATLAS_TEXTURE, new Identifier(identifier.getNamespace(), "entity/signs/hanging/" + identifier.getPath())));
Identifier identifier = Identifier.of(type.name());
cir.setReturnValue(new SpriteIdentifier(SIGNS_ATLAS_TEXTURE, Identifier.of(identifier.getNamespace(), "entity/signs/hanging/" + identifier.getPath())));
}
}
}

View file

@ -137,21 +137,21 @@ public final class TradeOfferHelper {
* <p>In vanilla, this pool contains offers to buy water buckets, baked potatoes, etc.
* for emeralds.
*/
Identifier BUY_ITEMS_POOL = new Identifier("minecraft", "buy_items");
Identifier BUY_ITEMS_POOL = Identifier.ofDefaultNamespace("buy_items");
/**
* The pool ID for the "sell special items" pool.
* Two trade offers are picked from this pool.
*
* <p>In vanilla, this pool contains offers to sell logs, enchanted iron pickaxes, etc.
*/
Identifier SELL_SPECIAL_ITEMS_POOL = new Identifier("minecraft", "sell_special_items");
Identifier SELL_SPECIAL_ITEMS_POOL = Identifier.ofDefaultNamespace("sell_special_items");
/**
* The pool ID for the "sell common items" pool.
* Five trade offers are picked from this pool.
*
* <p>In vanilla, this pool contains offers to sell flowers, saplings, etc.
*/
Identifier SELL_COMMON_ITEMS_POOL = new Identifier("minecraft", "sell_common_items");
Identifier SELL_COMMON_ITEMS_POOL = Identifier.ofDefaultNamespace("sell_common_items");
/**
* Adds a new pool to the offer list. Exactly {@code count} offers are picked from

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.mixin.object.builder;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.ToIntFunction;
@ -98,7 +97,7 @@ public interface AbstractBlockSettingsAccessor {
AbstractBlock.ContextPredicate getEmissiveLightingPredicate();
@Accessor
Optional<AbstractBlock.Offsetter> getOffsetter();
AbstractBlock.Offsetter getOffsetter();
@Accessor
RegistryKey<LootTable> getLootTableKey();
@ -162,7 +161,7 @@ public interface AbstractBlockSettingsAccessor {
void setRequiredFeatures(FeatureSet requiredFeatures);
@Accessor
void setOffsetter(Optional<AbstractBlock.Offsetter> offsetter);
void setOffsetter(AbstractBlock.Offsetter offsetter);
@Accessor
void setBurnable(boolean burnable);

View file

@ -26,6 +26,6 @@ public final class ObjectBuilderTestConstants {
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static Identifier id(String name) {
return new Identifier(MOD_ID, name);
return Identifier.of(MOD_ID, name);
}
}

View file

@ -37,8 +37,8 @@ import net.minecraft.particle.SimpleParticleType;
*
* {@literal @}Override
* public void onInitialize() {
* Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "simple"), SIMPLE_TEST_PARTICLE);
* Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "custom"), CUSTOM_TEST_PARTICLE);
* Registry.register(Registry.PARTICLE_TYPE, Identifier.of("testmod", "simple"), SIMPLE_TEST_PARTICLE);
* Registry.register(Registry.PARTICLE_TYPE, Identifier.of("testmod", "custom"), CUSTOM_TEST_PARTICLE);
* }}
* </pre>
* </blockquote>

View file

@ -58,7 +58,7 @@ public final class ParticleTestSetup implements ModInitializer {
}
private static void registerBlock(String path, Block block) {
Identifier id = new Identifier("fabric-particles-v1-testmod", path);
Identifier id = Identifier.of("fabric-particles-v1-testmod", path);
Registry.register(Registries.BLOCK, id, block);
Registry.register(Registries.ITEM, id, new BlockItem(block, new Item.Settings()));
}

View file

@ -46,7 +46,7 @@ import net.fabricmc.fabric.mixin.recipe.ingredient.EncoderHandlerMixin;
* </ul>
*/
public class CustomIngredientSync implements ModInitializer {
public static final Identifier PACKET_ID = new Identifier("fabric", "custom_ingredient_sync");
public static final Identifier PACKET_ID = Identifier.of("fabric", "custom_ingredient_sync");
public static final int PROTOCOL_VERSION_1 = 1;
public static final ThreadLocal<Set<Identifier>> CURRENT_SUPPORTED_INGREDIENTS = new ThreadLocal<>();

View file

@ -41,7 +41,7 @@ public class AllIngredient extends CombinedIngredient {
}
public static final CustomIngredientSerializer<AllIngredient> SERIALIZER =
new Serializer<>(new Identifier("fabric", "all"), AllIngredient::new, ALLOW_EMPTY_CODEC, DISALLOW_EMPTY_CODEC);
new Serializer<>(Identifier.of("fabric", "all"), AllIngredient::new, ALLOW_EMPTY_CODEC, DISALLOW_EMPTY_CODEC);
public AllIngredient(List<Ingredient> ingredients) {
super(ingredients);

View file

@ -41,7 +41,7 @@ public class AnyIngredient extends CombinedIngredient {
}
public static final CustomIngredientSerializer<AnyIngredient> SERIALIZER =
new CombinedIngredient.Serializer<>(new Identifier("fabric", "any"), AnyIngredient::new, ALLOW_EMPTY_CODEC, DISALLOW_EMPTY_CODEC);
new CombinedIngredient.Serializer<>(Identifier.of("fabric", "any"), AnyIngredient::new, ALLOW_EMPTY_CODEC, DISALLOW_EMPTY_CODEC);
public AnyIngredient(List<Ingredient> ingredients) {
super(ingredients);

View file

@ -116,7 +116,7 @@ public class ComponentsIngredient implements CustomIngredient {
}
private static class Serializer implements CustomIngredientSerializer<ComponentsIngredient> {
private static final Identifier ID = new Identifier("fabric", "components");
private static final Identifier ID = Identifier.of("fabric", "components");
private static final MapCodec<ComponentsIngredient> ALLOW_EMPTY_CODEC = createCodec(Ingredient.ALLOW_EMPTY_CODEC);
private static final MapCodec<ComponentsIngredient> DISALLOW_EMPTY_CODEC = createCodec(Ingredient.DISALLOW_EMPTY_CODEC);
private static final PacketCodec<RegistryByteBuf, ComponentsIngredient> PACKET_CODEC = PacketCodec.tuple(

View file

@ -89,7 +89,7 @@ public class CustomDataIngredient implements CustomIngredient {
}
private static class Serializer implements CustomIngredientSerializer<CustomDataIngredient> {
private static final Identifier ID = new Identifier("fabric", "custom_data");
private static final Identifier ID = Identifier.of("fabric", "custom_data");
private static final MapCodec<CustomDataIngredient> ALLOW_EMPTY_CODEC = createCodec(Ingredient.ALLOW_EMPTY_CODEC);
private static final MapCodec<CustomDataIngredient> DISALLOW_EMPTY_CODEC = createCodec(Ingredient.DISALLOW_EMPTY_CODEC);

View file

@ -74,7 +74,7 @@ public class DifferenceIngredient implements CustomIngredient {
}
private static class Serializer implements CustomIngredientSerializer<DifferenceIngredient> {
private static final Identifier ID = new Identifier("fabric", "difference");
private static final Identifier ID = Identifier.of("fabric", "difference");
private static final MapCodec<DifferenceIngredient> ALLOW_EMPTY_CODEC = createCodec(Ingredient.ALLOW_EMPTY_CODEC);
private static final MapCodec<DifferenceIngredient> DISALLOW_EMPTY_CODEC = createCodec(Ingredient.DISALLOW_EMPTY_CODEC);
private static final PacketCodec<RegistryByteBuf, DifferenceIngredient> PACKET_CODEC = PacketCodec.tuple(

View file

@ -37,7 +37,7 @@ public class ShapelessRecipeMatchTests {
*/
@GameTest(templateName = FabricGameTest.EMPTY_STRUCTURE)
public void testShapelessMatch(TestContext context) {
Identifier recipeId = new Identifier("fabric-recipe-api-v1-testmod", "test_shapeless_match");
Identifier recipeId = Identifier.of("fabric-recipe-api-v1-testmod", "test_shapeless_match");
ShapelessRecipe recipe = (ShapelessRecipe) context.getWorld().getRecipeManager().get(recipeId).get().value();
ItemStack undamagedPickaxe = new ItemStack(Items.DIAMOND_PICKAXE);

View file

@ -58,7 +58,7 @@ import net.fabricmc.fabric.impl.registry.sync.DynamicRegistriesImpl;
* // @link region substring=RegistryKey target=RegistryKey
* // @link region substring=ofRegistry target="RegistryKey#ofRegistry"
* // @link region substring=Identifier target="net.minecraft.util.Identifier#Identifier(String, String)"
* public static final RegistryKey<Registry<MyData>> MY_DATA_KEY = RegistryKey.ofRegistry(new Identifier("my_mod", "my_data"));
* public static final RegistryKey<Registry<MyData>> MY_DATA_KEY = RegistryKey.ofRegistry(Identifier.of("my_mod", "my_data"));
* // @end @end @end
*
* // Option 1: Register a non-synced registry

View file

@ -38,7 +38,7 @@ import net.fabricmc.fabric.mixin.registry.sync.RegistriesAccessor;
*
* <pre>
* {@code
* RegistryKey<Registry<String>> registryKey = RegistryKey.ofRegistry(new Identifier("modid", "registry_name"));
* RegistryKey<Registry<String>> registryKey = RegistryKey.ofRegistry(Identifier.of("modid", "registry_name"));
* Registry<String> registry = FabricRegistryBuilder.createSimple(registryKey)
* .attribute(RegistryAttribute.SYNCED)
* .buildAndRegister();

View file

@ -37,10 +37,10 @@ public class RegistryMapSerializer {
NbtCompound idNbt = mainNbt.getCompound(registryId);
for (String id : idNbt.getKeys()) {
idMap.put(new Identifier(id), idNbt.getInt(id));
idMap.put(Identifier.of(id), idNbt.getInt(id));
}
map.put(new Identifier(registryId), idMap);
map.put(Identifier.of(registryId), idMap);
}
return map;

View file

@ -23,7 +23,7 @@ import net.minecraft.util.Identifier;
public class SyncCompletePayload implements CustomPayload {
public static final SyncCompletePayload INSTANCE = new SyncCompletePayload();
public static final CustomPayload.Id<SyncCompletePayload> ID = new CustomPayload.Id<>(new Identifier("fabric", "registry/sync/complete"));
public static final CustomPayload.Id<SyncCompletePayload> ID = new CustomPayload.Id<>(Identifier.of("fabric", "registry/sync/complete"));
public static final PacketCodec<PacketByteBuf, SyncCompletePayload> CODEC = PacketCodec.unit(INSTANCE);
private SyncCompletePayload() { }

View file

@ -207,14 +207,14 @@ public class DirectRegistryPacketHandler extends RegistryPacketHandler<DirectReg
for (int m = 0; m < bulkSize; m++) {
currentRawId++;
String idPath = combinedBuf.readString();
idMap.put(new Identifier(idNamespace, idPath), currentRawId);
idMap.put(Identifier.of(idNamespace, idPath), currentRawId);
}
lastBulkLastRawId = currentRawId;
}
}
syncedRegistryMap.put(new Identifier(regNamespace, regPath), idMap);
syncedRegistryMap.put(Identifier.of(regNamespace, regPath), idMap);
}
}
@ -261,7 +261,7 @@ public class DirectRegistryPacketHandler extends RegistryPacketHandler<DirectReg
}
public record Payload(byte[] data) implements RegistrySyncPayload {
public static CustomPayload.Id<Payload> ID = new Id<>(new Identifier("fabric", "registry/sync/direct"));
public static CustomPayload.Id<Payload> ID = new Id<>(Identifier.of("fabric", "registry/sync/direct"));
public static PacketCodec<PacketByteBuf, Payload> CODEC = CustomPayload.codecOf(Payload::write, Payload::new);
Payload(PacketByteBuf buf) {

View file

@ -81,12 +81,24 @@ public class RegistryLoaderMixin {
// Vanilla doesn't mark namespaces in the directories of dynamic registries at all,
// so we prepend the directories with the namespace if it's a modded registry registered using the Fabric API.
@Inject(method = "getPath", at = @At("RETURN"), cancellable = true)
private static void prependDirectoryWithNamespace(Identifier id, CallbackInfoReturnable<String> info) {
@WrapOperation(
method = {
"loadFromNetwork(Ljava/util/Map;Lnet/minecraft/resource/ResourceFactory;Lnet/minecraft/registry/RegistryOps$RegistryInfoGetter;Lnet/minecraft/registry/MutableRegistry;Lcom/mojang/serialization/Decoder;Ljava/util/Map;)V",
"loadFromResource(Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/registry/RegistryOps$RegistryInfoGetter;Lnet/minecraft/registry/MutableRegistry;Lcom/mojang/serialization/Decoder;Ljava/util/Map;)V"
},
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/registry/RegistryKeys;getPath(Lnet/minecraft/registry/RegistryKey;)Ljava/lang/String;"
)
)
private static String prependDirectoryWithNamespace(RegistryKey<? extends Registry<?>> registryKey, Operation<String> original) {
String originalDirectory = original.call(registryKey);
Identifier id = registryKey.getValue();
if (!id.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)
&& DynamicRegistriesImpl.FABRIC_DYNAMIC_REGISTRY_KEYS.contains(RegistryKey.ofRegistry(id))) {
final String newPath = id.getNamespace() + "/" + info.getReturnValue();
info.setReturnValue(newPath);
}
&& DynamicRegistriesImpl.FABRIC_DYNAMIC_REGISTRY_KEYS.contains(registryKey)) {
return id.getNamespace() + "/" + originalDirectory;
}
return originalDirectory;
}
}

View file

@ -16,10 +16,10 @@
package net.fabricmc.fabric.mixin.registry.sync;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
@ -29,15 +29,23 @@ import net.minecraft.util.Identifier;
// Adds namespaces to tag directories for registries added by mods.
@Mixin(TagManagerLoader.class)
abstract class TagManagerLoaderMixin {
@Inject(method = "getPath", at = @At("HEAD"), cancellable = true)
private static void onGetPath(RegistryKey<? extends Registry<?>> registry, CallbackInfoReturnable<String> info) {
Identifier id = registry.getValue();
@WrapOperation(
method = "buildRequiredGroup",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/registry/RegistryKeys;getTagPath(Lnet/minecraft/registry/RegistryKey;)Ljava/lang/String;"
)
)
private String prependDirectoryWithNamespace(RegistryKey<? extends Registry<?>> registryKey, Operation<String> original) {
Identifier id = registryKey.getValue();
// Vanilla doesn't mark namespaces in the directories of tags at all,
// so we prepend the directories with the namespace if it's a modded registry id.
// No need to check DIRECTORIES, since this is only used by vanilla registries.
if (!id.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) {
info.setReturnValue("tags/" + id.getNamespace() + "/" + id.getPath());
}
return "tags/" + id.getNamespace() + "/" + id.getPath();
}
return original.call(registryKey);
}
}

View file

@ -56,7 +56,7 @@ public class DirectRegistryPacketHandlerTest {
DirectRegistryPacketHandler handler = new DirectRegistryPacketHandler();
Map<Identifier, Object2IntMap<Identifier>> registry = new HashMap<>();
registry.put(new Identifier("test"), createRegistry(150));
registry.put(Identifier.of("test"), createRegistry(150));
var payloads = new ArrayList<DirectRegistryPacketHandler.Payload>();
handler.sendPacket(payloads::add, registry);
@ -78,7 +78,7 @@ public class DirectRegistryPacketHandlerTest {
Map<Identifier, Object2IntMap<Identifier>> registry = new HashMap<>();
for (int i = 0; i < 50; i++) {
registry.put(new Identifier("test", "namespace_" + i), createRegistry(15000));
registry.put(Identifier.of("test", "namespace_" + i), createRegistry(15000));
}
var payloads = new ArrayList<DirectRegistryPacketHandler.Payload>();
@ -100,7 +100,7 @@ public class DirectRegistryPacketHandlerTest {
Object2IntMap<Identifier> entries = new Object2IntOpenHashMap<>();
for (int i = 0; i < size; i++) {
entries.put(new Identifier("test", "entry_" + i), i);
entries.put(Identifier.of("test", "entry_" + i), i);
}
return entries;

View file

@ -35,20 +35,20 @@ public final class CustomDynamicRegistryTest implements ModInitializer {
private static final Logger LOGGER = LogUtils.getLogger();
public static final RegistryKey<Registry<TestDynamicObject>> TEST_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_dynamic"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_dynamic"));
public static final RegistryKey<Registry<TestNestedDynamicObject>> TEST_NESTED_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_dynamic_nested"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_dynamic_nested"));
public static final RegistryKey<Registry<TestDynamicObject>> TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_dynamic_synced_1"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_dynamic_synced_1"));
public static final RegistryKey<Registry<TestDynamicObject>> TEST_SYNCED_2_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_dynamic_synced_2"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_dynamic_synced_2"));
public static final RegistryKey<Registry<TestDynamicObject>> TEST_EMPTY_SYNCED_DYNAMIC_REGISTRY_KEY =
RegistryKey.ofRegistry(new Identifier("fabric", "test_dynamic_synced_empty"));
RegistryKey.ofRegistry(Identifier.of("fabric", "test_dynamic_synced_empty"));
private static final RegistryKey<TestDynamicObject> SYNCED_ENTRY_KEY =
RegistryKey.of(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY, new Identifier("fabric-registry-sync-v0-testmod", "synced"));
RegistryKey.of(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY, Identifier.of("fabric-registry-sync-v0-testmod", "synced"));
private static final TagKey<TestDynamicObject> TEST_DYNAMIC_OBJECT_TAG =
TagKey.of(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY, new Identifier("fabric-registry-sync-v0-testmod", "test"));
TagKey.of(TEST_SYNCED_1_DYNAMIC_REGISTRY_KEY, Identifier.of("fabric-registry-sync-v0-testmod", "test"));
@Override
public void onInitialize() {

View file

@ -80,14 +80,14 @@ public class RegistrySyncTest implements ModInitializer {
}
}
RegistryKey<Registry<String>> fabricRegistryKey = RegistryKey.ofRegistry(new Identifier("registry_sync", "fabric_registry"));
RegistryKey<Registry<String>> fabricRegistryKey = RegistryKey.ofRegistry(Identifier.of("registry_sync", "fabric_registry"));
SimpleRegistry<String> fabricRegistry = FabricRegistryBuilder.createSimple(fabricRegistryKey)
.attribute(RegistryAttribute.SYNCED)
.buildAndRegister();
Registry.register(fabricRegistry, new Identifier("registry_sync", "test"), "test");
Registry.register(fabricRegistry, Identifier.of("registry_sync", "test"), "test");
Validate.isTrue(Registries.REGISTRIES.getIds().contains(new Identifier("registry_sync", "fabric_registry")));
Validate.isTrue(Registries.REGISTRIES.getIds().contains(Identifier.of("registry_sync", "fabric_registry")));
Validate.isTrue(RegistryAttributeHolder.get(fabricRegistry).hasAttribute(RegistryAttribute.MODDED));
Validate.isTrue(RegistryAttributeHolder.get(fabricRegistry).hasAttribute(RegistryAttribute.SYNCED));
@ -155,11 +155,11 @@ public class RegistrySyncTest implements ModInitializer {
private static void registerBlocks(String namespace, int amount, int startingId) {
for (int i = 0; i < amount; i++) {
Block block = new Block(AbstractBlock.Settings.create());
Registry.register(Registries.BLOCK, new Identifier(namespace, "block_" + (i + startingId)), block);
Registry.register(Registries.BLOCK, Identifier.of(namespace, "block_" + (i + startingId)), block);
if (REGISTER_ITEMS) {
BlockItem blockItem = new BlockItem(block, new Item.Settings());
Registry.register(Registries.ITEM, new Identifier(namespace, "block_" + (i + startingId)), blockItem);
Registry.register(Registries.ITEM, Identifier.of(namespace, "block_" + (i + startingId)), blockItem);
}
}
}
@ -168,7 +168,7 @@ public class RegistrySyncTest implements ModInitializer {
Object2IntMap<Identifier> map = new Object2IntOpenHashMap<>();
for (int i = 0; i < 12; i++) {
map.put(new Identifier("mod_" + i, "entry"), 0);
map.put(Identifier.of("mod_" + i, "entry"), 0);
}
return map;

View file

@ -35,7 +35,7 @@ import net.fabricmc.fabric.test.registry.sync.TestNestedDynamicObject;
public final class DynamicRegistryClientTest implements ClientModInitializer {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Identifier SYNCED_ID = new Identifier("fabric-registry-sync-v0-testmod", "synced");
private static final Identifier SYNCED_ID = Identifier.of("fabric-registry-sync-v0-testmod", "synced");
@Override
public void onInitializeClient() {

View file

@ -73,7 +73,7 @@ public interface RenderMaterial extends MaterialView {
*
* <p>All standard, non-fluid baked models are rendered using this material.
*/
Identifier MATERIAL_STANDARD = new Identifier("fabric", "standard");
Identifier MATERIAL_STANDARD = Identifier.of("fabric", "standard");
/**
* Do not use. Always returns 1.

View file

@ -37,7 +37,7 @@ import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
*/
public interface QuadView {
/** Count of integers in a conventional (un-modded) block or item vertex. */
int VANILLA_VERTEX_STRIDE = VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL.getVertexSizeInteger();
int VANILLA_VERTEX_STRIDE = VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL.getVertexSizeByte() / 4;
/** Count of integers in a conventional (un-modded) block or item quad. */
int VANILLA_QUAD_STRIDE = VANILLA_VERTEX_STRIDE * 4;

View file

@ -45,7 +45,7 @@ public class FrameBlockEntity extends BlockEntity implements RenderDataBlockEnti
super.readNbt(tag, wrapperLookup);
if (tag.contains("block", NbtElement.STRING_TYPE)) {
this.block = Registries.BLOCK.get(new Identifier(tag.getString("block")));
this.block = Registries.BLOCK.get(Identifier.of(tag.getString("block")));
} else {
this.block = null;
}

View file

@ -49,6 +49,6 @@ public final class RendererTest implements ModInitializer {
}
public static Identifier id(String path) {
return new Identifier("fabric-renderer-api-v1-testmod", path);
return Identifier.of("fabric-renderer-api-v1-testmod", path);
}
}

Some files were not shown because too many files have changed in this diff Show more