Removed generics from IModel subinterfaces, add ed ModelProcessingHelper instead.

This commit is contained in:
RainWarrior 2016-03-06 01:31:54 +03:00
parent 0f2cead3c8
commit 70670d70ea
13 changed files with 63 additions and 37 deletions

View File

@ -148,21 +148,10 @@ public class BlockStateLoader
private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
{
if (!customData.isEmpty() && base instanceof IModelCustomData)
{
base = ((IModelCustomData<?>)base).process(customData);
}
if (!textureMap.isEmpty() && base instanceof IRetexturableModel)
{
base = ((IRetexturableModel<?>)base).retexture(textureMap);
}
if (base instanceof IModelSimpleProperties<?>)
{
base = ((IModelSimpleProperties<?>) base).smoothLighting(smooth).gui3d(gui3d);
}
base = ModelProcessingHelper.customData(base, customData);
base = ModelProcessingHelper.retexture(base, textureMap);
base = ModelProcessingHelper.smoothLighting(base, smooth);
base = ModelProcessingHelper.gui3d(base, gui3d);
return base;
}

View File

@ -2,12 +2,12 @@ package net.minecraftforge.client.model;
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.
* If unknown data is encountered it should be skipped.
* @return a new model, with data applied.
*/
M process(ImmutableMap<String, String> customData);
IModel process(ImmutableMap<String, String> customData);
}

View File

@ -3,8 +3,8 @@ package net.minecraftforge.client.model;
/**
* 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);
M gui3d(boolean value);
IModel smoothLighting(boolean value);
IModel gui3d(boolean value);
}

View File

@ -2,7 +2,7 @@ package net.minecraftforge.client.model;
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.
@ -21,5 +21,5 @@ public interface IRetexturableModel<M extends IRetexturableModel<M>> extends IMo
* @param textures New
* @return Model with textures applied.
*/
M retexture(ImmutableMap<String, String> textures);
IModel retexture(ImmutableMap<String, String> textures);
}

View File

@ -29,7 +29,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
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());

View File

@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
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");

View File

@ -43,7 +43,7 @@ import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
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 lavaModel = new ModelFluid(FluidRegistry.LAVA);

View File

@ -409,7 +409,7 @@ public class ModelLoader extends ModelBakery
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 ModelBlock model;

View File

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

View File

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
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());

View File

@ -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 B3DModel model;

View File

@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
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 MaterialLibrary matLib;

View File

@ -33,6 +33,7 @@ import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.IRetexturableModel;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.ModelProcessingHelper;
import net.minecraftforge.client.model.MultiModel;
import net.minecraftforge.client.model.TRSRTransformation;
import net.minecraftforge.client.model.animation.Animation;
@ -212,14 +213,8 @@ public class ModelAnimationDebug
"chamber", "blocks/redstone_block",
"trunk", "blocks/end_stone"
);
if(base instanceof IRetexturableModel<?>)
{
base = ((IRetexturableModel<?>)base).retexture(textures);
}
if(ring instanceof IRetexturableModel<?>)
{
ring = ((IRetexturableModel<?>)ring).retexture(textures);
}
base = ModelProcessingHelper.retexture(base, textures);
ring = ModelProcessingHelper.retexture(base, textures);
IModel model = new MultiModel(
new ResourceLocation(ModelAnimationDebug.MODID, "builtin/engine"),
ring,