Add hooks for using Vanilla's new Client data generator (#10206)

Add new hook for custom block models that do not have real blocks backing them
Some workspace cleanup fixing log4j annotation processor
This commit is contained in:
LexManos authored and GitHub committed 2024-12-19 10:41:21 -08:00
1 parent 07977ba242
commit 0e74886f8d
55 files changed
+1346 -75

No files matched your search

@@ -16,7 +16,12 @@ import net.minecraftforge.common.data.ExistingFileHelper;
*
* @see ModelProvider
* @see ModelBuilder
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public class BlockModelBuilder extends ModelBuilder<BlockModelBuilder>
{
public BlockModelBuilder(ResourceLocation outputLocation, ExistingFileHelper existingFileHelper)
@@ -12,7 +12,12 @@ import org.jetbrains.annotations.NotNull;
/**
* Stub class to extend for block model data providers, eliminates some
* boilerplate constructor parameters.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class BlockModelProvider extends ModelProvider<BlockModelBuilder> {
public BlockModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) {
@@ -63,10 +63,17 @@ import org.jetbrains.annotations.VisibleForTesting;
/**
* Data provider for blockstate files. Extends {@link BlockModelProvider} so that
* blockstates and their referenced models can be provided in tandem.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class BlockStateProvider implements DataProvider {
@SuppressWarnings("unused")
private static final Logger LOGGER = LogManager.getLogger();
@SuppressWarnings("unused")
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
@VisibleForTesting
@@ -28,7 +28,12 @@ import org.jetbrains.annotations.Nullable;
* Can be manually constructed, created by static factory such as
* {@link #allYRotations(ModelFile, int, boolean)}, or created by builder via
* {@link #builder()}.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public final class ConfiguredModel {
/**
@@ -13,6 +13,16 @@ import net.minecraftforge.common.data.ExistingFileHelper;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
*
* This is the only class that doesn't seem to have a vanilla alternative however, it should be a simple helper
* function to replace this functionality for your custom models
*
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class CustomLoaderBuilder<T extends ModelBuilder<T>>
{
protected final ResourceLocation loaderId;
@@ -8,6 +8,12 @@ package net.minecraftforge.client.model.generators;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.VisibleForTesting;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
@VisibleForTesting
public interface IGeneratedBlockState
{
@@ -20,7 +20,12 @@ import net.minecraftforge.common.data.ExistingFileHelper;
/**
* Builder for item models, adds the ability to build overrides via
* {@link #override()}.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public class ItemModelBuilder extends ModelBuilder<ItemModelBuilder> {
protected List<OverrideBuilder> overrides = new ArrayList<>();
@@ -37,7 +42,7 @@ public class ItemModelBuilder extends ModelBuilder<ItemModelBuilder> {
/**
* Get an existing override builder
*
*
* @param index the index of the existing override builder
* @return the override builder
* @throws IndexOutOfBoundsException if {@code} index is out of bounds
@@ -17,7 +17,12 @@ import java.util.Objects;
/**
* Stub class to extend for item model data providers, eliminates some
* boilerplate constructor parameters.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class ItemModelProvider extends ModelProvider<ItemModelBuilder> {
public ItemModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) {
@@ -50,7 +50,12 @@ import org.joml.Vector3f;
* @see ItemModelBuilder
*
* @param <T> Self type, for simpler chaining of methods.
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
@Nullable
@@ -10,6 +10,12 @@ import com.google.common.base.Preconditions;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.data.ExistingFileHelper;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class ModelFile {
protected ResourceLocation location;
@@ -21,6 +21,12 @@ import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.common.data.ExistingFileHelper.ResourceType;
import org.jetbrains.annotations.VisibleForTesting;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public abstract class ModelProvider<T extends ModelBuilder<T>> implements DataProvider {
public static final String BLOCK_FOLDER = "block";
@@ -21,6 +21,12 @@ import com.google.gson.JsonObject;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.Property;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public final class MultiPartBlockStateBuilder implements IGeneratedBlockState {
private final List<PartBuilder> parts = new ArrayList<>();
private final Block owner;
@@ -50,7 +50,12 @@ import org.jetbrains.annotations.Nullable;
* values.
*
* @see BlockStateProvider
*
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
@Deprecated(since = "1.21.4", forRemoval = true)
public class VariantBlockStateBuilder implements IGeneratedBlockState
{
@@ -284,6 +289,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockState
return true;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String toString() {
StringBuilder ret = new StringBuilder();
@@ -15,6 +15,11 @@ import net.minecraftforge.common.data.ExistingFileHelper;
import java.util.*;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
public class CompositeModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "composite");
@@ -14,6 +14,11 @@ import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
public class DynamicFluidContainerModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "fluid_container");
@@ -24,6 +24,11 @@ import net.minecraftforge.client.model.generators.CustomLoaderBuilder;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "item_layers");
@@ -13,6 +13,11 @@ import net.minecraftforge.client.model.generators.CustomLoaderBuilder;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
public class ObjModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "obj");
@@ -7,7 +7,6 @@ package net.minecraftforge.client.model.generators.loaders;
import com.google.common.base.Preconditions;
import com.google.gson.JsonObject;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraftforge.client.model.generators.CustomLoaderBuilder;
@@ -17,6 +16,11 @@ import net.minecraftforge.common.data.ExistingFileHelper;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
* If you find something lacking feel free to open a PR so that we can extend it.
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
*/
public class SeparateTransformsModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
{
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "separate_transforms");
@@ -35,7 +35,7 @@ public class BakedModelRenderable implements IRenderable<BakedModelRenderable.Co
* Constructs a {@link BakedModelRenderable} from the given model location.
* The model is expected to have been baked ahead of time.
*
* @see net.minecraftforge.client.event.ModelEvent.RegisterAdditional
* @see net.minecraftforge.client.event.ModelEvent.RegisterModelStateDefinitions
*/
public static BakedModelRenderable of(ModelResourceLocation model) {
return of(Minecraft.getInstance().getModelManager().getModel(model));