From c5ee4e6451bad3bfc936a7cb211dc6af18cd83db Mon Sep 17 00:00:00 2001 From: RainWarrior Date: Fri, 13 Nov 2015 17:23:37 +0300 Subject: [PATCH] Model stuff: updated to generics, fixed various warnings, added handling of new perspective types. --- .../resources/model/IBakedModel.java.patch | 14 +------------ .../client/ForgeHooksClient.java | 4 +++- .../client/model/BlockStateLoader.java | 3 +-- .../client/model/ForgeBlockStateV1.java | 20 +++++++++++++++---- .../client/model/IFlexibleBakedModel.java | 5 ----- .../client/model/IPerspectiveAwareModel.java | 1 - .../client/model/IPerspectiveState.java | 9 ++++----- .../client/model/ItemLayerModel.java | 1 - .../client/model/ModelLoader.java | 9 +++++---- .../client/model/b3d/B3DModel.java | 9 ++++----- 10 files changed, 34 insertions(+), 41 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch index 94444e80c..d032f72eb 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch @@ -1,18 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/resources/model/IBakedModel.java +++ ../src-work/minecraft/net/minecraft/client/resources/model/IBakedModel.java -@@ -8,7 +8,11 @@ - 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 getFaceQuads(EnumFacing p_177551_1_); -@@ -23,5 +27,6 @@ +@@ -23,5 +23,6 @@ TextureAtlasSprite getTexture(); diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 2fc962352..2b58deec7 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -42,6 +42,7 @@ import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelBakery; 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.settings.GameSettings; import net.minecraft.entity.Entity; @@ -90,6 +91,7 @@ import org.lwjgl.opengl.GL11; + import com.google.common.collect.Maps; 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 modelRegistry, ModelBakery modelBakery) { ModelLoader loader = (ModelLoader)modelBakery; MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, loader)); diff --git a/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java b/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java index cd3e1d221..007fefc38 100644 --- a/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java +++ b/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java @@ -43,7 +43,6 @@ public class BlockStateLoader * * @return Model definition including variants for all known combinations. */ - @SuppressWarnings("rawtypes") public static ModelBlockDefinition load(Reader reader, final Gson vanillaGSON) { try @@ -75,7 +74,7 @@ public class BlockStateLoader 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. return vanillaGSON.fromJson(reader, ModelBlockDefinition.class); diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java index 59598c289..b5ced65a6 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java @@ -534,17 +534,29 @@ public class ForgeBlockStateV1 extends Marker transform.remove("firstperson"); 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")) { TRSRTransformation t = context.deserialize(transform.get("gui"), TRSRTransformation.class); transform.remove("gui"); transforms.put(TransformType.GUI, TRSRTransformation.blockCenterToCorner(t)); } - if(transform.has("head")) + if(transform.has("ground")) { - TRSRTransformation t = context.deserialize(transform.get("head"), TRSRTransformation.class); - transform.remove("head"); - transforms.put(TransformType.HEAD, TRSRTransformation.blockCenterToCorner(t)); + TRSRTransformation t = context.deserialize(transform.get("ground"), TRSRTransformation.class); + transform.remove("ground"); + 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(); if(transform.has("matrix")) k--; diff --git a/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java b/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java index e01989a56..4d921fa0c 100644 --- a/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java +++ b/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java @@ -14,9 +14,6 @@ import net.minecraft.util.EnumFacing; */ public interface IFlexibleBakedModel extends IBakedModel { - // non-erased versions of the IBakedModel methods - List getFaceQuads(EnumFacing side); - List getGeneralQuads(); /* * Specifies the format which BakedQuads' getVertexData will have. */ @@ -36,13 +33,11 @@ public interface IFlexibleBakedModel extends IBakedModel this.format = format; } - @SuppressWarnings("unchecked") public List getFaceQuads(EnumFacing side) { return parent.getFaceQuads(side); } - @SuppressWarnings("unchecked") public List getGeneralQuads() { return parent.getGeneralQuads(); diff --git a/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java b/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java index be4a2ad33..d78326724 100644 --- a/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java +++ b/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java @@ -14,7 +14,6 @@ import net.minecraft.util.EnumFacing; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; /* diff --git a/src/main/java/net/minecraftforge/client/model/IPerspectiveState.java b/src/main/java/net/minecraftforge/client/model/IPerspectiveState.java index 1dbeb77f2..838090f6c 100644 --- a/src/main/java/net/minecraftforge/client/model/IPerspectiveState.java +++ b/src/main/java/net/minecraftforge/client/model/IPerspectiveState.java @@ -38,11 +38,10 @@ public interface IPerspectiveState extends IModelState private static ImmutableMap getMap(ItemCameraTransforms transforms) { Map map = Maps.newHashMap(); - map.put(TransformType.NONE, TRSRTransformation.identity()); - map.put(TransformType.THIRD_PERSON, transforms.thirdPerson); - map.put(TransformType.FIRST_PERSON, transforms.firstPerson); - map.put(TransformType.GUI, transforms.gui); - map.put(TransformType.HEAD, transforms.head); + for(TransformType type : TransformType.values()) + { + map.put(type, transforms.func_181688_b(type)); + } return Maps.immutableEnumMap(map); } diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java index 89301016f..396c4e659 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java @@ -3,7 +3,6 @@ package net.minecraftforge.client.model; import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.Map; import javax.vecmath.Matrix4f; import javax.vecmath.Vector4f; diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index fda396881..4e0fdef2c 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -38,6 +38,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; 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.ModelResourceLocation; import net.minecraft.client.resources.model.ModelRotation; @@ -85,7 +86,7 @@ public class ModelLoader extends ModelBakery } @Override - public IRegistry setupModelRegistry() + public IRegistry setupModelRegistry() { isLoading = true; loadBlocks(); @@ -717,12 +718,12 @@ public class ModelLoader extends ModelBakery } } - public void onPostBakeEvent(IRegistry modelRegistry) + public void onPostBakeEvent(IRegistry modelRegistry) { - Object missingModel = modelRegistry.getObject(MODEL_MISSING); + IBakedModel missingModel = modelRegistry.getObject(MODEL_MISSING); for(ModelResourceLocation missing : missingVariants) { - Object model = modelRegistry.getObject(missing); + IBakedModel model = modelRegistry.getObject(missing); if(model == null || model == missingModel) { FMLLog.severe("Model definition for location %s not found", missing); diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java index c9b889a34..60af64849 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java @@ -185,12 +185,12 @@ public class B3DModel { chunk("BB3D"); 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)); - if(version % 100 > this.version % 100) + if(version % 100 > Parser.version % 100) logger.warn(String.format("Minor version differnce in model: ", ((float)version / 100))); - List textures = Collections.EMPTY_LIST; - List brushes = Collections.EMPTY_LIST; + List textures = Collections.emptyList(); + List brushes = Collections.emptyList(); Node root = null; while(buf.hasRemaining()) { @@ -400,7 +400,6 @@ public class B3DModel chunk("NODE"); animations.push(HashBasedTable.>, Key>create()); Triple animData = null; - Animation animation = null; Pair> mesh = null; List> bone = null; Map keys = new HashMap();