Skip to content

Commit

Permalink
Finish porting Model Loading, FRAPI, and Indigo (#4043)
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 authored Aug 21, 2024
1 parent 1bb677a commit 236902d
Show file tree
Hide file tree
Showing 37 changed files with 380 additions and 653 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.util.Identifier;

/**
* Block state resolvers are responsible for mapping each {@link BlockState} of a block to an {@link UnbakedModel}.
Expand Down Expand Up @@ -69,18 +67,5 @@ interface Context {
* @param model the unbaked model for this block state
*/
void setModel(BlockState state, UnbakedModel model);

/**
* Loads a model using an {@link Identifier}, or gets it if it was already loaded.
*
* @param id the model identifier
* @return the unbaked model, or a missing model if it is not present
*/
UnbakedModel getOrLoadModel(Identifier id);

/**
* The current model loader instance, which changes between resource reloads.
*/
ModelLoader loader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.fabricmc.fabric.api.client.model.loading.v1;

import java.util.Collection;
import java.util.List;
import java.util.function.Function;

import org.jetbrains.annotations.Nullable;
Expand All @@ -37,7 +35,6 @@
*/
public final class DelegatingUnbakedModel implements UnbakedModel {
private final Identifier delegate;
private final List<Identifier> dependencies;

/**
* Constructs a new delegating model.
Expand All @@ -46,23 +43,11 @@ public final class DelegatingUnbakedModel implements UnbakedModel {
*/
public DelegatingUnbakedModel(Identifier delegate) {
this.delegate = delegate;
this.dependencies = List.of(delegate);
}

/*@Override
public Collection<Identifier> getModelDependencies() {
return dependencies;
}

@Override
public void setParents(Function<Identifier, UnbakedModel> modelLoader) {
modelLoader.apply(delegate).setParents(modelLoader);
}*/

// TODO 24w44a
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {

arg.method_62642(delegate);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void register(ModelLoadingPlugin plugin) {
* Called towards the beginning of the model loading process, every time resource are (re)loaded.
* Use the context object to extend model loading as desired.
*/
void onInitializeModelLoader(Context pluginContext);
void initialize(Context pluginContext);

@ApiStatus.NonExtendable
interface Context {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.ModelIdentifier;
Expand Down Expand Up @@ -109,19 +108,6 @@ interface Context {
*/
@UnknownNullability("#resourceId() != null")
ModelIdentifier topLevelId();

/**
* Loads a model using an {@link Identifier}, or gets it if it was already loaded.
*
* @param id the model identifier
* @return the unbaked model, or a missing model if it is not present
*/
UnbakedModel getOrLoadModel(Identifier id);

/**
* The current model loader instance, which changes between resource reloads.
*/
ModelLoader loader();
}
}

Expand Down Expand Up @@ -177,11 +163,6 @@ interface Context {
* {@linkplain Baker#bake load baked models}.
*/
Baker baker();

/**
* The current model loader instance, which changes between resource reloads.
*/
ModelLoader loader();
}
}

Expand Down Expand Up @@ -250,11 +231,6 @@ interface Context {
* {@linkplain Baker#bake load baked models}.
*/
Baker baker();

/**
* The current model loader instance, which changes between resource reloads.
*/
ModelLoader loader();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -61,18 +60,5 @@ interface Context {
* The identifier of the model to be loaded.
*/
Identifier id();

/**
* Loads a model using an {@link Identifier}, or gets it if it was already loaded.
*
* @param id the model identifier
* @return the unbaked model, or a missing model if it is not present
*/
UnbakedModel getOrLoadModel(Identifier id);

/**
* The current model loader instance, which changes between resource reloads.
*/
ModelLoader loader();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static <T> void register(DataLoader<T> loader, PreparableModelLoadingPlugin<T> p
* @param data The data loaded by the {@link DataLoader}.
* @param pluginContext The context that can be used to extend model loading.
*/
void onInitializeModelLoader(T data, ModelLoadingPlugin.Context pluginContext);
void initialize(T data, ModelLoadingPlugin.Context pluginContext);

@FunctionalInterface
interface DataLoader<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@

package net.fabricmc.fabric.impl.client.model.loading;

import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier;

public interface ModelLoaderHooks {
ModelLoadingEventDispatcher fabric_getDispatcher();

UnbakedModel fabric_getMissingModel();

UnbakedModel fabric_getOrLoadModel(Identifier id);

void fabric_add(ModelIdentifier id, UnbakedModel model);
}
Loading

0 comments on commit 236902d

Please sign in to comment.