Add DeferredRegistryData to help with generating data driven registry entries.

Revive GameTest system and make all but one Forge Test mod pass.
This commit is contained in:
LexManos committed 2025-03-27 20:52:35 -07:00
1 parent b4b6e48a7a
commit 0f3b8ee830
102 files changed
+1229 -469

No files matched your search

@@ -22,6 +22,18 @@ public class DatapackBuiltinEntriesProvider extends RegistriesDatapackGenerator
private final CompletableFuture<HolderLookup.Provider> fullRegistries;
/**
* Constructs a new datapack provider which generates all registry objects
* from the provided mods using the holder.
*
* @param output the target directory of the data generator
* @param registries a future of patched registries
* @param modId The mod id to generate the dynamic registry objects of
*/
public DatapackBuiltinEntriesProvider(PackOutput output, CompletableFuture<RegistrySetBuilder.PatchedRegistries> registries, String modId) {
this(output, registries, Set.of(modId));
}
/**
* Constructs a new datapack provider which generates all registry objects
* from the provided mods using the holder.
@@ -35,6 +47,20 @@ public class DatapackBuiltinEntriesProvider extends RegistriesDatapackGenerator
this.fullRegistries = registries.thenApply(RegistrySetBuilder.PatchedRegistries::full);
}
/**
* Constructs a new datapack provider which generates all registry objects
* from the provided mods using the holder. All entries that need to be
* bootstrapped are provided within the {@link RegistrySetBuilder}.
*
* @param output the target directory of the data generator
* @param registries a future of a lookup for registries and their objects
* @param registryBuilder a builder containing the dynamic registry objects added by this provider
* @param modId The mod id to generate the dynamic registry objects of
*/
public DatapackBuiltinEntriesProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, RegistrySetBuilder registryBuilder, String modId) {
this(output, registries, registryBuilder, Set.of(modId));
}
/**
* Constructs a new datapack provider which generates all registry objects
* from the provided mods using the holder. All entries that need to be
@@ -87,7 +87,7 @@ public interface IForgeBlockEntity extends ICapabilityProvider {
bb = AABB.encapsulatingFullBlocks(pos.offset(-1, 0, -1), pos.offset(1, 0, 1));
} else if (block == Blocks.STRUCTURE_BLOCK) {
bb = INFINITE_EXTENT_AABB;
} else if (block != null && block != Blocks.BEACON) {
} else if (block != null && block != Blocks.BEACON && block != Blocks.TEST_INSTANCE_BLOCK) {
AABB cbb = null;
try {
VoxelShape collisionShape = state.getCollisionShape(self().getLevel(), pos);
@@ -0,0 +1,25 @@
/*
* Copyright (c) Forge Development LLC and contributors
* SPDX-License-Identifier: LGPL-2.1-only
*/
package net.minecraftforge.common.extensions;
import com.mojang.serialization.Lifecycle;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraftforge.registries.DeferredRegisterData;
public interface IForgeRegistrySetBuilder {
private RegistrySetBuilder self() {
return (RegistrySetBuilder)this;
}
default <T> RegistrySetBuilder add(DeferredRegisterData<T> dr) {
return self().add(dr.getRegistryKey(), dr);
}
default <T> RegistrySetBuilder add(DeferredRegisterData<T> dr, Lifecycle lifecycle) {
return self().add(dr.getRegistryKey(), lifecycle, dr);
}
}