Removed generics from IModel subinterfaces, add ed ModelProcessingHelper instead.
This commit is contained in:
parent
0f2cead3c8
commit
70670d70ea
|
@ -148,21 +148,10 @@ public class BlockStateLoader
|
||||||
|
|
||||||
private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
|
private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
|
||||||
{
|
{
|
||||||
if (!customData.isEmpty() && base instanceof IModelCustomData)
|
base = ModelProcessingHelper.customData(base, customData);
|
||||||
{
|
base = ModelProcessingHelper.retexture(base, textureMap);
|
||||||
base = ((IModelCustomData<?>)base).process(customData);
|
base = ModelProcessingHelper.smoothLighting(base, smooth);
|
||||||
}
|
base = ModelProcessingHelper.gui3d(base, gui3d);
|
||||||
|
|
||||||
if (!textureMap.isEmpty() && base instanceof IRetexturableModel)
|
|
||||||
{
|
|
||||||
base = ((IRetexturableModel<?>)base).retexture(textureMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (base instanceof IModelSimpleProperties<?>)
|
|
||||||
{
|
|
||||||
base = ((IModelSimpleProperties<?>) base).smoothLighting(smooth).gui3d(gui3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@ package net.minecraftforge.client.model;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
public interface IModelCustomData<M extends IModelCustomData<M>> extends IModel
|
public interface IModelCustomData extends IModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Allows the model to process custom data from the variant definition.
|
* Allows the model to process custom data from the variant definition.
|
||||||
* If unknown data is encountered it should be skipped.
|
* If unknown data is encountered it should be skipped.
|
||||||
* @return a new model, with data applied.
|
* @return a new model, with data applied.
|
||||||
*/
|
*/
|
||||||
M process(ImmutableMap<String, String> customData);
|
IModel process(ImmutableMap<String, String> customData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package net.minecraftforge.client.model;
|
||||||
/**
|
/**
|
||||||
* Implement this if the model can process "smooth_lighting" or "gui3d" attributes from the json.
|
* Implement this if the model can process "smooth_lighting" or "gui3d" attributes from the json.
|
||||||
*/
|
*/
|
||||||
public interface IModelSimpleProperties<M extends IModelSimpleProperties<M>> extends IModel
|
public interface IModelSimpleProperties extends IModel
|
||||||
{
|
{
|
||||||
M smoothLighting(boolean value);
|
IModel smoothLighting(boolean value);
|
||||||
M gui3d(boolean value);
|
IModel gui3d(boolean value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package net.minecraftforge.client.model;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
public interface IRetexturableModel<M extends IRetexturableModel<M>> extends IModel
|
public interface IRetexturableModel extends IModel
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Applies new textures to the model.
|
* Applies new textures to the model.
|
||||||
|
@ -21,5 +21,5 @@ public interface IRetexturableModel<M extends IRetexturableModel<M>> extends IMo
|
||||||
* @param textures New
|
* @param textures New
|
||||||
* @return Model with textures applied.
|
* @return Model with textures applied.
|
||||||
*/
|
*/
|
||||||
M retexture(ImmutableMap<String, String> textures);
|
IModel retexture(ImmutableMap<String, String> textures);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
|
public class ItemLayerModel implements IRetexturableModel
|
||||||
{
|
{
|
||||||
public static final ItemLayerModel instance = new ItemLayerModel(ImmutableList.<ResourceLocation>of());
|
public static final ItemLayerModel instance = new ItemLayerModel(ImmutableList.<ResourceLocation>of());
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>, IRetexturableModel<ModelDynBucket>
|
public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableModel
|
||||||
{
|
{
|
||||||
public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation("forge", "dynbucket"), "inventory");
|
public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation("forge", "dynbucket"), "inventory");
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.google.common.collect.Maps;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
public class ModelFluid implements IModelCustomData<ModelFluid>
|
public class ModelFluid implements IModelCustomData
|
||||||
{
|
{
|
||||||
public static final ModelFluid waterModel = new ModelFluid(FluidRegistry.WATER);
|
public static final ModelFluid waterModel = new ModelFluid(FluidRegistry.WATER);
|
||||||
public static final ModelFluid lavaModel = new ModelFluid(FluidRegistry.LAVA);
|
public static final ModelFluid lavaModel = new ModelFluid(FluidRegistry.LAVA);
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class ModelLoader extends ModelBakery
|
||||||
textures.addAll(model.getTextures());
|
textures.addAll(model.getTextures());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VanillaModelWrapper implements IRetexturableModel<VanillaModelWrapper>, IModelSimpleProperties<VanillaModelWrapper>, IAnimatedModel
|
private class VanillaModelWrapper implements IRetexturableModel, IModelSimpleProperties, IAnimatedModel
|
||||||
{
|
{
|
||||||
private final ResourceLocation location;
|
private final ResourceLocation location;
|
||||||
private final ModelBlock model;
|
private final ModelBlock model;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package net.minecraftforge.client.model;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
public class ModelProcessingHelper
|
||||||
|
{
|
||||||
|
public static IModel retexture(IModel model, ImmutableMap<String, String> textures)
|
||||||
|
{
|
||||||
|
if(model instanceof IRetexturableModel)
|
||||||
|
{
|
||||||
|
model = ((IRetexturableModel)model).retexture(textures);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IModel customData(IModel model, ImmutableMap<String, String> customData)
|
||||||
|
{
|
||||||
|
if(model instanceof IModelCustomData)
|
||||||
|
{
|
||||||
|
model = ((IModelCustomData)model).process(customData);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IModel smoothLighting(IModel model, boolean smooth)
|
||||||
|
{
|
||||||
|
if(model instanceof IModelSimpleProperties)
|
||||||
|
{
|
||||||
|
model = ((IModelSimpleProperties)model).smoothLighting(smooth);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IModel gui3d(IModel model, boolean gui3d)
|
||||||
|
{
|
||||||
|
if(model instanceof IModelSimpleProperties)
|
||||||
|
{
|
||||||
|
model = ((IModelSimpleProperties)model).gui3d(gui3d);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
|
public class MultiLayerModel implements IModelCustomData
|
||||||
{
|
{
|
||||||
public static final MultiLayerModel instance = new MultiLayerModel(ImmutableMap.<Optional<BlockRenderLayer>, ModelResourceLocation>of());
|
public static final MultiLayerModel instance = new MultiLayerModel(ImmutableMap.<Optional<BlockRenderLayer>, ModelResourceLocation>of());
|
||||||
|
|
||||||
|
|
|
@ -400,7 +400,7 @@ public class B3DLoader implements ICustomModelLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ModelWrapper implements IRetexturableModel<ModelWrapper>, IModelCustomData<ModelWrapper>, IModelSimpleProperties<ModelWrapper>, IAnimatedModel
|
public static class ModelWrapper implements IRetexturableModel, IModelCustomData, IModelSimpleProperties, IAnimatedModel
|
||||||
{
|
{
|
||||||
private final ResourceLocation modelLocation;
|
private final ResourceLocation modelLocation;
|
||||||
private final B3DModel model;
|
private final B3DModel model;
|
||||||
|
|
|
@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
public class OBJModel implements IRetexturableModel<OBJModel>, IModelCustomData<OBJModel>
|
public class OBJModel implements IRetexturableModel, IModelCustomData
|
||||||
{
|
{
|
||||||
//private Gson GSON = new GsonBuilder().create();
|
//private Gson GSON = new GsonBuilder().create();
|
||||||
private MaterialLibrary matLib;
|
private MaterialLibrary matLib;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraftforge.client.model.IModelState;
|
||||||
import net.minecraftforge.client.model.IRetexturableModel;
|
import net.minecraftforge.client.model.IRetexturableModel;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||||
|
import net.minecraftforge.client.model.ModelProcessingHelper;
|
||||||
import net.minecraftforge.client.model.MultiModel;
|
import net.minecraftforge.client.model.MultiModel;
|
||||||
import net.minecraftforge.client.model.TRSRTransformation;
|
import net.minecraftforge.client.model.TRSRTransformation;
|
||||||
import net.minecraftforge.client.model.animation.Animation;
|
import net.minecraftforge.client.model.animation.Animation;
|
||||||
|
@ -212,14 +213,8 @@ public class ModelAnimationDebug
|
||||||
"chamber", "blocks/redstone_block",
|
"chamber", "blocks/redstone_block",
|
||||||
"trunk", "blocks/end_stone"
|
"trunk", "blocks/end_stone"
|
||||||
);
|
);
|
||||||
if(base instanceof IRetexturableModel<?>)
|
base = ModelProcessingHelper.retexture(base, textures);
|
||||||
{
|
ring = ModelProcessingHelper.retexture(base, textures);
|
||||||
base = ((IRetexturableModel<?>)base).retexture(textures);
|
|
||||||
}
|
|
||||||
if(ring instanceof IRetexturableModel<?>)
|
|
||||||
{
|
|
||||||
ring = ((IRetexturableModel<?>)ring).retexture(textures);
|
|
||||||
}
|
|
||||||
IModel model = new MultiModel(
|
IModel model = new MultiModel(
|
||||||
new ResourceLocation(ModelAnimationDebug.MODID, "builtin/engine"),
|
new ResourceLocation(ModelAnimationDebug.MODID, "builtin/engine"),
|
||||||
ring,
|
ring,
|
||||||
|
|
Loading…
Reference in New Issue