Model stuff: updated to generics, fixed various warnings, added handling of new perspective types.
This commit is contained in:
parent
fe7f713b67
commit
c5ee4e6451
10 changed files with 34 additions and 41 deletions
|
@ -1,18 +1,6 @@
|
||||||
--- ../src-base/minecraft/net/minecraft/client/resources/model/IBakedModel.java
|
--- ../src-base/minecraft/net/minecraft/client/resources/model/IBakedModel.java
|
||||||
+++ ../src-work/minecraft/net/minecraft/client/resources/model/IBakedModel.java
|
+++ ../src-work/minecraft/net/minecraft/client/resources/model/IBakedModel.java
|
||||||
@@ -8,7 +8,11 @@
|
@@ -23,5 +23,6 @@
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
+/*
|
|
||||||
+ * @deprecated use {@link net.minecraftforge.client.model.IFlexibleBakedModel}, {@link net.minecraftforge.client.model.IPerspectiveAwareModel}
|
|
||||||
+ */
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
+@Deprecated
|
|
||||||
public interface IBakedModel
|
|
||||||
{
|
|
||||||
List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_);
|
|
||||||
@@ -23,5 +27,6 @@
|
|
||||||
|
|
||||||
TextureAtlasSprite getTexture();
|
TextureAtlasSprite getTexture();
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.resources.model.IBakedModel;
|
import net.minecraft.client.resources.model.IBakedModel;
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
import net.minecraft.client.resources.model.ModelManager;
|
import net.minecraft.client.resources.model.ModelManager;
|
||||||
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.resources.model.ModelRotation;
|
import net.minecraft.client.resources.model.ModelRotation;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -90,6 +91,7 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
public class ForgeHooksClient
|
public class ForgeHooksClient
|
||||||
|
@ -510,7 +512,7 @@ public class ForgeHooksClient
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void onModelBake(ModelManager modelManager, IRegistry modelRegistry, ModelBakery modelBakery)
|
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelBakery modelBakery)
|
||||||
{
|
{
|
||||||
ModelLoader loader = (ModelLoader)modelBakery;
|
ModelLoader loader = (ModelLoader)modelBakery;
|
||||||
MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, loader));
|
MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, loader));
|
||||||
|
|
|
@ -43,7 +43,6 @@ public class BlockStateLoader
|
||||||
*
|
*
|
||||||
* @return Model definition including variants for all known combinations.
|
* @return Model definition including variants for all known combinations.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static ModelBlockDefinition load(Reader reader, final Gson vanillaGSON)
|
public static ModelBlockDefinition load(Reader reader, final Gson vanillaGSON)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -75,7 +74,7 @@ public class BlockStateLoader
|
||||||
variants.add(new ModelBlockDefinition.Variants(entry.getKey(), mcVars));
|
variants.add(new ModelBlockDefinition.Variants(entry.getKey(), mcVars));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ModelBlockDefinition((Collection)variants); //Damn lists being collections!
|
return new ModelBlockDefinition(variants);
|
||||||
|
|
||||||
default: //Unknown version.. try loading it as normal.
|
default: //Unknown version.. try loading it as normal.
|
||||||
return vanillaGSON.fromJson(reader, ModelBlockDefinition.class);
|
return vanillaGSON.fromJson(reader, ModelBlockDefinition.class);
|
||||||
|
|
|
@ -534,17 +534,29 @@ public class ForgeBlockStateV1 extends Marker
|
||||||
transform.remove("firstperson");
|
transform.remove("firstperson");
|
||||||
transforms.put(TransformType.FIRST_PERSON, TRSRTransformation.blockCenterToCorner(t));
|
transforms.put(TransformType.FIRST_PERSON, TRSRTransformation.blockCenterToCorner(t));
|
||||||
}
|
}
|
||||||
|
if(transform.has("head"))
|
||||||
|
{
|
||||||
|
TRSRTransformation t = context.deserialize(transform.get("head"), TRSRTransformation.class);
|
||||||
|
transform.remove("head");
|
||||||
|
transforms.put(TransformType.HEAD, TRSRTransformation.blockCenterToCorner(t));
|
||||||
|
}
|
||||||
if(transform.has("gui"))
|
if(transform.has("gui"))
|
||||||
{
|
{
|
||||||
TRSRTransformation t = context.deserialize(transform.get("gui"), TRSRTransformation.class);
|
TRSRTransformation t = context.deserialize(transform.get("gui"), TRSRTransformation.class);
|
||||||
transform.remove("gui");
|
transform.remove("gui");
|
||||||
transforms.put(TransformType.GUI, TRSRTransformation.blockCenterToCorner(t));
|
transforms.put(TransformType.GUI, TRSRTransformation.blockCenterToCorner(t));
|
||||||
}
|
}
|
||||||
if(transform.has("head"))
|
if(transform.has("ground"))
|
||||||
{
|
{
|
||||||
TRSRTransformation t = context.deserialize(transform.get("head"), TRSRTransformation.class);
|
TRSRTransformation t = context.deserialize(transform.get("ground"), TRSRTransformation.class);
|
||||||
transform.remove("head");
|
transform.remove("ground");
|
||||||
transforms.put(TransformType.HEAD, TRSRTransformation.blockCenterToCorner(t));
|
transforms.put(TransformType.GROUND, TRSRTransformation.blockCenterToCorner(t));
|
||||||
|
}
|
||||||
|
if(transform.has("fixed"))
|
||||||
|
{
|
||||||
|
TRSRTransformation t = context.deserialize(transform.get("fixed"), TRSRTransformation.class);
|
||||||
|
transform.remove("fixed");
|
||||||
|
transforms.put(TransformType.FIXED, TRSRTransformation.blockCenterToCorner(t));
|
||||||
}
|
}
|
||||||
int k = transform.entrySet().size();
|
int k = transform.entrySet().size();
|
||||||
if(transform.has("matrix")) k--;
|
if(transform.has("matrix")) k--;
|
||||||
|
|
|
@ -14,9 +14,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
*/
|
*/
|
||||||
public interface IFlexibleBakedModel extends IBakedModel
|
public interface IFlexibleBakedModel extends IBakedModel
|
||||||
{
|
{
|
||||||
// non-erased versions of the IBakedModel methods
|
|
||||||
List<BakedQuad> getFaceQuads(EnumFacing side);
|
|
||||||
List<BakedQuad> getGeneralQuads();
|
|
||||||
/*
|
/*
|
||||||
* Specifies the format which BakedQuads' getVertexData will have.
|
* Specifies the format which BakedQuads' getVertexData will have.
|
||||||
*/
|
*/
|
||||||
|
@ -36,13 +33,11 @@ public interface IFlexibleBakedModel extends IBakedModel
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<BakedQuad> getFaceQuads(EnumFacing side)
|
public List<BakedQuad> getFaceQuads(EnumFacing side)
|
||||||
{
|
{
|
||||||
return parent.getFaceQuads(side);
|
return parent.getFaceQuads(side);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public List<BakedQuad> getGeneralQuads()
|
public List<BakedQuad> getGeneralQuads()
|
||||||
{
|
{
|
||||||
return parent.getGeneralQuads();
|
return parent.getGeneralQuads();
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,11 +38,10 @@ public interface IPerspectiveState extends IModelState
|
||||||
private static ImmutableMap<TransformType, IModelState> getMap(ItemCameraTransforms transforms)
|
private static ImmutableMap<TransformType, IModelState> getMap(ItemCameraTransforms transforms)
|
||||||
{
|
{
|
||||||
Map<TransformType, IModelState> map = Maps.newHashMap();
|
Map<TransformType, IModelState> map = Maps.newHashMap();
|
||||||
map.put(TransformType.NONE, TRSRTransformation.identity());
|
for(TransformType type : TransformType.values())
|
||||||
map.put(TransformType.THIRD_PERSON, transforms.thirdPerson);
|
{
|
||||||
map.put(TransformType.FIRST_PERSON, transforms.firstPerson);
|
map.put(type, transforms.func_181688_b(type));
|
||||||
map.put(TransformType.GUI, transforms.gui);
|
}
|
||||||
map.put(TransformType.HEAD, transforms.head);
|
|
||||||
return Maps.immutableEnumMap(map);
|
return Maps.immutableEnumMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package net.minecraftforge.client.model;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.vecmath.Matrix4f;
|
import javax.vecmath.Matrix4f;
|
||||||
import javax.vecmath.Vector4f;
|
import javax.vecmath.Vector4f;
|
||||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||||
import net.minecraft.client.resources.IResourceManager;
|
import net.minecraft.client.resources.IResourceManager;
|
||||||
import net.minecraft.client.resources.model.BuiltInModel;
|
import net.minecraft.client.resources.model.BuiltInModel;
|
||||||
|
import net.minecraft.client.resources.model.IBakedModel;
|
||||||
import net.minecraft.client.resources.model.ModelBakery;
|
import net.minecraft.client.resources.model.ModelBakery;
|
||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.resources.model.ModelRotation;
|
import net.minecraft.client.resources.model.ModelRotation;
|
||||||
|
@ -85,7 +86,7 @@ public class ModelLoader extends ModelBakery
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IRegistry setupModelRegistry()
|
public IRegistry<ModelResourceLocation, IBakedModel> setupModelRegistry()
|
||||||
{
|
{
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
loadBlocks();
|
loadBlocks();
|
||||||
|
@ -717,12 +718,12 @@ public class ModelLoader extends ModelBakery
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPostBakeEvent(IRegistry modelRegistry)
|
public void onPostBakeEvent(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry)
|
||||||
{
|
{
|
||||||
Object missingModel = modelRegistry.getObject(MODEL_MISSING);
|
IBakedModel missingModel = modelRegistry.getObject(MODEL_MISSING);
|
||||||
for(ModelResourceLocation missing : missingVariants)
|
for(ModelResourceLocation missing : missingVariants)
|
||||||
{
|
{
|
||||||
Object model = modelRegistry.getObject(missing);
|
IBakedModel model = modelRegistry.getObject(missing);
|
||||||
if(model == null || model == missingModel)
|
if(model == null || model == missingModel)
|
||||||
{
|
{
|
||||||
FMLLog.severe("Model definition for location %s not found", missing);
|
FMLLog.severe("Model definition for location %s not found", missing);
|
||||||
|
|
|
@ -185,12 +185,12 @@ public class B3DModel
|
||||||
{
|
{
|
||||||
chunk("BB3D");
|
chunk("BB3D");
|
||||||
int version = buf.getInt();
|
int version = buf.getInt();
|
||||||
if(version / 100 > this.version / 100)
|
if(version / 100 > Parser.version / 100)
|
||||||
throw new IOException("Unsupported major model version: " + ((float)version / 100));
|
throw new IOException("Unsupported major model version: " + ((float)version / 100));
|
||||||
if(version % 100 > this.version % 100)
|
if(version % 100 > Parser.version % 100)
|
||||||
logger.warn(String.format("Minor version differnce in model: ", ((float)version / 100)));
|
logger.warn(String.format("Minor version differnce in model: ", ((float)version / 100)));
|
||||||
List<Texture> textures = Collections.EMPTY_LIST;
|
List<Texture> textures = Collections.emptyList();
|
||||||
List<Brush> brushes = Collections.EMPTY_LIST;
|
List<Brush> brushes = Collections.emptyList();
|
||||||
Node<?> root = null;
|
Node<?> root = null;
|
||||||
while(buf.hasRemaining())
|
while(buf.hasRemaining())
|
||||||
{
|
{
|
||||||
|
@ -400,7 +400,6 @@ public class B3DModel
|
||||||
chunk("NODE");
|
chunk("NODE");
|
||||||
animations.push(HashBasedTable.<Integer, Optional<Node<?>>, Key>create());
|
animations.push(HashBasedTable.<Integer, Optional<Node<?>>, Key>create());
|
||||||
Triple<Integer, Integer, Float> animData = null;
|
Triple<Integer, Integer, Float> animData = null;
|
||||||
Animation animation = null;
|
|
||||||
Pair<Brush, List<Face>> mesh = null;
|
Pair<Brush, List<Face>> mesh = null;
|
||||||
List<Pair<Vertex, Float>> bone = null;
|
List<Pair<Vertex, Float>> bone = null;
|
||||||
Map<Integer, Key> keys = new HashMap<Integer, Key>();
|
Map<Integer, Key> keys = new HashMap<Integer, Key>();
|
||||||
|
|
Loading…
Reference in a new issue