Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: FabricMC/fabric
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.95.1+1.20.5
Choose a base ref
...
head repository: FabricMC/fabric
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.95.3+1.20.5
Choose a head ref
  • 7 commits
  • 58 files changed
  • 4 contributors

Commits on Jan 24, 2024

  1. Fix some registries being unsynced (#3550)

    apple502j authored Jan 24, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3945d7a View commit details
  2. 24w04a

    modmuss50 committed Jan 24, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9bfa344 View commit details

Commits on Jan 28, 2024

  1. Fix porting issues in Dynamic Registries API (#3555)

    * Fix TAGS_LOADED event not being invoked on client join
    
    * Skip loading empty dynamic registries (client-side)
    
    * Update ClientTest to handle 24w04a
    
    * Skip syncing empty dynamic registries (server-side)
    
    * Fix dynamic registry using wrong codec, tag syncing depending on class load order
    
    * Fix DynamicRegistrySetupEvent being called on client
    
    * Test syncing empty registry's tag
    
    * Actually check skipOnEmpty
    
    * Downgrade AssertionError to log due to MC-268096
    apple502j authored Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bbf5165 View commit details
  2. Refactor resource loader internals (#3473)

    * First step toward fixing resource pack grouping
    
    * Placeholder pack and pack dependency
    
    * Various fixes
    
    * Fix wrong variable in serialization code
    
    * Hide packs in PackScreen and DatapackCommand
    
    * Apparently Japanese people aren't alone in having their currency signs used as special chars...
    
    * Inject directly to Pack
    
    * Add temporary logging, fix bug
    
    * Add proper sorting
    
    * Improve logging
    
    * Fix duplicate name registration
    
    * Fix client pack handling
    
    * Fix FMJ
    
    * Stop using interface injection for internal interface
    
    * Delete unused GroupResourcePack
    
    * Move refreshAutoEnabledPacks to util
    
    * Improve logging
    
    * Make a few things private
    
    * Use vanilla metadata serialization logic
    
    * Improve javadoc
    
    * Add junit test
    
    * Some final refactors
    
    * Update ja_jp.json
    
    ---------
    
    Co-authored-by: modmuss <modmuss50@gmail.com>
    (cherry picked from commit 707e4d1)
    apple502j authored and modmuss50 committed Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3feeb09 View commit details
  3. Allow FabricCodecDataProvider to access dynamic registries (#3522)

    * Add CompletableFuture to FabricCodecDataProvider
    
    * Deprecate the old method and constructor, and fix the style
    
    * Fix the style for real this time
    
    * Add exceptions to the configure methods
    
    * Apply suggestions from code review
    
    ---------
    
    Co-authored-by: modmuss <modmuss50@gmail.com>
    
    (cherry picked from commit 5c01334)
    ErrorCraft authored and modmuss50 committed Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b667967 View commit details
  4. Make chunk sections only convert vanilla air blocks to AIR (#3535)

    * Make chunk sections only convert vanilla air blocks to AIR
    
    * angry checkstyles calmed
    
    * Comments added for future reference
    
    (cherry picked from commit 3e2216c)
    TelepathicGrunt authored and modmuss50 committed Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6dfe4c9 View commit details
  5. Bump version

    modmuss50 committed Jan 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f3561f0 View commit details
Showing with 1,343 additions and 842 deletions.
  1. +37 −0 ...lock-api-v1/src/main/java/net/fabricmc/fabric/mixin/block/ChunkSectionBlockStateCounterMixin.java
  2. +38 −0 fabric-block-api-v1/src/main/java/net/fabricmc/fabric/mixin/block/ChunkSectionMixin.java
  3. +3 −1 fabric-block-api-v1/src/main/resources/fabric-block-api-v1.mixins.json
  4. +57 −3 ...ion-api-v1/src/main/java/net/fabricmc/fabric/api/datagen/v1/provider/FabricCodecDataProvider.java
  5. +56 −0 ...eration-api-v1/src/testmod/java/net/fabricmc/fabric/test/datagen/DataGeneratorTestEntrypoint.java
  6. +5 −10 ...c/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java
  7. +5 −4 ...pi-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity/FabricEntityTypeBuilder.java
  8. +1 −1 fabric-object-builder-api-v1/src/main/resources/fabric-object-builder-api-v1.accesswidener
  9. +53 −0 ...t/java/net/fabricmc/fabric/mixin/registry/sync/client/ClientRegistriesDynamicRegistriesMixin.java
  10. +1 −0 fabric-registry-sync-v0/src/client/resources/fabric-registry-sync-v0.client.mixins.json
  11. +0 −7 ...ic-registry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/DynamicRegistryView.java
  12. +0 −32 ...ry-sync-v0/src/main/java/net/fabricmc/fabric/api/event/registry/RegistryEntryRemovedCallback.java
  13. +14 −8 ...-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistriesImpl.java
  14. +0 −11 ...egistry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/DynamicRegistryViewImpl.java
  15. +11 −2 fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/FabricRegistryInit.java
  16. +0 −2 fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/ListenableRegistry.java
  17. +1 −12 ...registry-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/IdListTracker.java
  18. +1 −12 ...y-sync-v0/src/main/java/net/fabricmc/fabric/impl/registry/sync/trackers/Int2ObjectMapTracker.java
  19. +29 −11 ...c-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/RegistryLoaderMixin.java
  20. +29 −13 ...ry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SerializableRegistriesMixin.java
  21. +30 −89 ...c-registry-sync-v0/src/main/java/net/fabricmc/fabric/mixin/registry/sync/SimpleRegistryMixin.java
  22. +6 −4 fabric-registry-sync-v0/src/main/resources/fabric-registry-sync-v0.accesswidener
  23. +1 −1 ...ry-sync-v0/src/testmod/java/net/fabricmc/fabric/test/registry/sync/CustomDynamicRegistryTest.java
  24. +5 −0 ...d/resources/data/fabric-registry-sync-v0-testmod/tags/fabric/test_dynamic_synced_empty/empty.json
  25. +5 −6 ...c/testmodClient/java/net/fabricmc/fabric/test/registry/sync/client/DynamicRegistryClientTest.java
  26. +0 −63 ...client/java/net/fabricmc/fabric/impl/client/resource/loader/FabricWrappedVanillaResourcePack.java
  27. +0 −77 ...java/net/fabricmc/fabric/mixin/resource/loader/client/DefaultClientResourcePackProviderMixin.java
  28. +1 −1 ...-loader-v0/src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/GameOptionsMixin.java
  29. +63 −0 ...rc/client/java/net/fabricmc/fabric/mixin/resource/loader/client/GameOptionsWriteVisitorMixin.java
  30. +61 −0 .../src/client/java/net/fabricmc/fabric/mixin/resource/loader/client/ResourcePackOrganizerMixin.java
  31. +4 −3 fabric-resource-loader-v0/src/client/resources/fabric-resource-loader-v0.client.mixins.json
  32. +2 −0 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/ModResourcePack.java
  33. +37 −16 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/api/resource/package-info.java
  34. +0 −86 ...ource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java
  35. +47 −0 ...e-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricResourcePackProfile.java
  36. +0 −123 ...-resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/GroupResourcePack.java
  37. +31 −20 ...resource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModNioResourcePack.java
  38. +62 −42 ...urce-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackCreator.java
  39. +48 −0 ...urce-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackFactory.java
  40. +77 −10 ...esource-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ModResourcePackUtil.java
  41. +110 −0 ...rce-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/PlaceholderResourcePack.java
  42. +2 −2 ...e-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourceManagerHelperImpl.java
  43. +0 −1 ...e-loader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/ResourcePackSourceTracker.java
  44. +68 −0 ...ource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/DatapackCommandMixin.java
  45. +0 −63 ...der-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/NamespaceResourceManagerMixin.java
  46. +0 −46 ...0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ReloadableResourceManagerImplMixin.java
  47. +0 −2 fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourceMixin.java
  48. +40 −2 ...e-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackManagerMixin.java
  49. +25 −1 ...e-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/ResourcePackProfileMixin.java
  50. +3 −1 fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/en_us.json
  51. +2 −1 fabric-resource-loader-v0/src/main/resources/assets/fabric-resource-loader-v0/lang/ja_jp.json
  52. +1 −2 fabric-resource-loader-v0/src/main/resources/fabric-resource-loader-v0.mixins.json
  53. +248 −0 ...ader-v0/src/test/java/net/fabricmc/fabric/test/resource/loader/unit/ModResourcePackUtilTests.java
  54. +0 −28 ...ader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/BuiltinResourcePackTestMod.java
  55. +1 −1 fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/DebugMessages.java
  56. +1 −1 ...ansitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener
  57. +1 −1 fabric-transitive-access-wideners-v1/template.accesswidener
  58. +20 −20 gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.block;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;

@Mixin(targets = "net/minecraft/world/chunk/ChunkSection$BlockStateCounter")
public class ChunkSectionBlockStateCounterMixin {
/**
* Makes Chunk Sections not have isAir = true modded blocks be replaced with AIR against their will.
* Mojang report: https://bugs.mojang.com/browse/MC-232360
*/
@Redirect(method = "accept(Lnet/minecraft/block/BlockState;I)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isAir()Z"))
private boolean modifyAirCheck(BlockState blockState) {
return blockState.isOf(Blocks.AIR) || blockState.isOf(Blocks.CAVE_AIR) || blockState.isOf(Blocks.VOID_AIR);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.fabricmc.fabric.mixin.block;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.world.chunk.ChunkSection;

@Mixin(ChunkSection.class)
public class ChunkSectionMixin {
/**
* Makes Chunk Sections not have isAir = true modded blocks be replaced with AIR against their will.
* Mojang report: https://bugs.mojang.com/browse/MC-232360
*/
@Redirect(method = "setBlockState(IIILnet/minecraft/block/BlockState;Z)Lnet/minecraft/block/BlockState;",
at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;isAir()Z"))
private boolean modifyAirCheck(BlockState blockState) {
return blockState.isOf(Blocks.AIR) || blockState.isOf(Blocks.CAVE_AIR) || blockState.isOf(Blocks.VOID_AIR);
}
}
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockMixin",
"BlockStateMixin"
"BlockStateMixin",
"ChunkSectionBlockStateCounterMixin",
"ChunkSectionMixin"
],
"injectors": {
"defaultRequire": 1
Original file line number Diff line number Diff line change
@@ -19,38 +19,74 @@
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;

import com.google.gson.JsonElement;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.JsonOps;

import net.minecraft.data.DataOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.registry.RegistryOps;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;

/**
* Extend this class and implement {@link FabricCodecDataProvider#configure}.
* Extend this class and implement {@link FabricCodecDataProvider#configure(BiConsumer, RegistryWrapper.WrapperLookup)}.
*
* <p>Register an instance of the class with {@link FabricDataGenerator.Pack#addProvider} in a {@link net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint}.
*/
public abstract class FabricCodecDataProvider<T> implements DataProvider {
private final DataOutput.PathResolver pathResolver;
private final CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture;
private final Codec<T> codec;

/**
* @deprecated Please use {@link FabricCodecDataProvider#FabricCodecDataProvider(FabricDataOutput, CompletableFuture, DataOutput.OutputType, String, Codec)}.
*/
@Deprecated()
protected FabricCodecDataProvider(FabricDataOutput dataOutput, DataOutput.OutputType outputType, String directoryName, Codec<T> codec) {
this.pathResolver = dataOutput.getResolver(outputType, directoryName);
this.registriesFuture = null;
this.codec = codec;
}

protected FabricCodecDataProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture, DataOutput.OutputType outputType, String directoryName, Codec<T> codec) {
this.pathResolver = dataOutput.getResolver(outputType, directoryName);
this.registriesFuture = Objects.requireNonNull(registriesFuture);
this.codec = codec;
}

@Override
public CompletableFuture<?> run(DataWriter writer) {
// TODO: Remove the null check once the deprecated method and constructor are removed.
if (this.registriesFuture != null) {
return this.registriesFuture.thenCompose(lookup -> {
Map<Identifier, JsonElement> entries = new HashMap<>();
RegistryOps<JsonElement> ops = RegistryOps.of(JsonOps.INSTANCE, lookup);

BiConsumer<Identifier, T> provider = (id, value) -> {
JsonElement json = this.convert(id, value, ops);
JsonElement existingJson = entries.put(id, json);

if (existingJson != null) {
throw new IllegalArgumentException("Duplicate entry " + id);
}
};

this.configure(provider, lookup);
return this.write(writer, entries);
});
}

Map<Identifier, JsonElement> entries = new HashMap<>();
BiConsumer<Identifier, T> provider = (id, value) -> {
JsonElement json = this.convert(id, value);
@@ -69,11 +105,29 @@ public CompletableFuture<?> run(DataWriter writer) {
* Implement this method to register entries to generate.
*
* @param provider A consumer that accepts an {@link Identifier} and a value to register.
* @deprecated Please use {@link FabricCodecDataProvider#configure(BiConsumer, RegistryWrapper.WrapperLookup)}.
*/
protected abstract void configure(BiConsumer<Identifier, T> provider);
@Deprecated()
protected void configure(BiConsumer<Identifier, T> provider) {
throw new UnsupportedOperationException("Override this method.");
}

/**
* Implement this method to register entries to generate using a {@link RegistryWrapper.WrapperLookup}.
* @param provider A consumer that accepts an {@link Identifier} and a value to register.
* @param lookup A lookup for registries.
*/
protected void configure(BiConsumer<Identifier, T> provider, RegistryWrapper.WrapperLookup lookup) {
// TODO: Make abstract once the deprecated method is removed.
throw new UnsupportedOperationException("Override this method.");
}

private JsonElement convert(Identifier id, T value) {
DataResult<JsonElement> dataResult = this.codec.encodeStart(JsonOps.INSTANCE, value);
return this.convert(id, value, JsonOps.INSTANCE);
}

private JsonElement convert(Identifier id, T value, DynamicOps<JsonElement> ops) {
DataResult<JsonElement> dataResult = this.codec.encodeStart(ops, value);
return dataResult.get()
.mapRight(partial -> "Invalid entry %s: %s".formatted(id, partial.message()))
.orThrow();
Original file line number Diff line number Diff line change
@@ -34,11 +34,17 @@
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementEntry;
import net.minecraft.advancement.AdvancementFrame;
import net.minecraft.advancement.criterion.OnKilledCriterion;
import net.minecraft.block.Block;
import net.minecraft.block.BlockKeys;
import net.minecraft.block.Blocks;
import net.minecraft.data.DataOutput;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.server.recipe.RecipeExporter;
@@ -50,15 +56,21 @@
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.condition.BlockStatePropertyLootCondition;
import net.minecraft.loot.condition.LootCondition;
import net.minecraft.loot.condition.LootConditionTypes;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryBuilder;
import net.minecraft.registry.RegistryEntryLookup;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryFixedCodec;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.registry.tag.TagKey;
@@ -75,6 +87,7 @@
import net.fabricmc.fabric.api.datagen.v1.JsonKeySortOrderCallback;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricCodecDataProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
@@ -107,6 +120,8 @@ public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
pack.addProvider(ExistingEnglishLangProvider::new);
pack.addProvider(JapaneseLangProvider::new);
pack.addProvider(TestDynamicRegistryProvider::new);
pack.addProvider(TestPredicateProvider::new);
pack.addProvider(TestCustomCodecProvider::new);

TestBlockTagProvider blockTagProvider = pack.addProvider(TestBlockTagProvider::new);
pack.addProvider((output, registries) -> new TestItemTagProvider(output, registries, blockTagProvider));
@@ -420,4 +435,45 @@ public String getName() {
return "Test Dynamic Registry";
}
}

private static class TestPredicateProvider extends FabricCodecDataProvider<LootCondition> {
private TestPredicateProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "predicates", LootConditionTypes.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(
blocks.getOrThrow(BlockKeys.MELON).value()).build()); // Pretend this actually does something and we cannot access the blocks directly
}

@Override
public String getName() {
return "Predicates";
}
}

private static class TestCustomCodecProvider extends FabricCodecDataProvider<TestCustomCodecProvider.Entry> {
private TestCustomCodecProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "biome_entry", Entry.CODEC);
}

@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)));
}

@Override
public String getName() {
return "Codec Test Using Dynamic Registry";
}

private record Entry(RegistryEntry<Biome> biome) {
private static final Codec<Entry> CODEC = RecordCodecBuilder.create(instance -> instance.group(
RegistryFixedCodec.of(RegistryKeys.BIOME).fieldOf("biome").forGetter(Entry::biome)
).apply(instance, Entry::new));
}
}
}
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.network.packet.s2c.common.SynchronizeTagsS2CPacket;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket;
import net.minecraft.world.chunk.WorldChunk;
@@ -96,16 +95,12 @@ private void onClearWorld(CallbackInfo ci) {
}
}

/**
* Also invoked during GameJoin, but before Networking API fires the Ready event.
*/
@SuppressWarnings("ConstantConditions")
@Inject(
method = "onSynchronizeTags",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;onSynchronizeTags(Lnet/minecraft/network/packet/s2c/common/SynchronizeTagsS2CPacket;)V",
shift = At.Shift.AFTER, by = 1
)
)
private void hookOnSynchronizeTags(SynchronizeTagsS2CPacket packet, CallbackInfo ci) {
@Inject(method = "refreshTagBasedData", at = @At("RETURN"))
private void hookOnSynchronizeTags(CallbackInfo ci) {
ClientPlayNetworkHandler self = (ClientPlayNetworkHandler) (Object) this;
CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(self.getRegistryManager(), true);
}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.Block;
import net.minecraft.class_9168;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
@@ -422,7 +423,7 @@ public EntityType<T> build() {
* @param <T> Entity class.
*/
public static class Mob<T extends MobEntity> extends FabricEntityTypeBuilder.Living<T> {
private SpawnRestriction.Location restrictionLocation;
private class_9168 spawnLocation;
private Heightmap.Type restrictionHeightmap;
private SpawnRestriction.SpawnPredicate<T> spawnPredicate;

@@ -535,8 +536,8 @@ public FabricEntityTypeBuilder.Mob<T> defaultAttributes(Supplier<DefaultAttribut
*
* @return this builder for chaining.
*/
public FabricEntityTypeBuilder.Mob<T> spawnRestriction(SpawnRestriction.Location location, Heightmap.Type heightmap, SpawnRestriction.SpawnPredicate<T> spawnPredicate) {
this.restrictionLocation = Objects.requireNonNull(location, "Location cannot be null.");
public FabricEntityTypeBuilder.Mob<T> spawnRestriction(class_9168 spawnLocation, Heightmap.Type heightmap, SpawnRestriction.SpawnPredicate<T> spawnPredicate) {
this.spawnLocation = Objects.requireNonNull(spawnLocation, "Spawn location cannot be null.");
this.restrictionHeightmap = Objects.requireNonNull(heightmap, "Heightmap type cannot be null.");
this.spawnPredicate = Objects.requireNonNull(spawnPredicate, "Spawn predicate cannot be null.");
return this;
@@ -547,7 +548,7 @@ public EntityType<T> build() {
EntityType<T> type = super.build();

if (this.spawnPredicate != null) {
SpawnRestriction.register(type, this.restrictionLocation, this.restrictionHeightmap, this.spawnPredicate);
SpawnRestriction.register(type, this.spawnLocation, this.restrictionHeightmap, this.spawnPredicate);
}

return type;
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ accessible class net/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFact
mutable field net/minecraft/village/TradeOffers REBALANCED_PROFESSION_TO_LEVELED_TRADE Ljava/util/Map;
mutable field net/minecraft/village/TradeOffers REBALANCED_WANDERING_TRADER_TRADES Ljava/util/List;

accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/entity/SpawnRestriction$Location;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V
accessible method net/minecraft/entity/SpawnRestriction register (Lnet/minecraft/entity/EntityType;Lnet/minecraft/class_9168;Lnet/minecraft/world/Heightmap$Type;Lnet/minecraft/entity/SpawnRestriction$SpawnPredicate;)V

accessible field net/minecraft/village/VillagerType BIOME_TO_TYPE Ljava/util/Map;
accessible method net/minecraft/village/VillagerType <init> (Ljava/lang/String;)V
Loading