From 13da0c4be13787cdb6f4c4feecf55e32a5d7b539 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 17 Dec 2015 19:02:13 +0100 Subject: [PATCH] Update to forge model changes --- build.properties | 4 +- .../mantle/client/ModelHelper.java | 75 ++++++++----------- .../client/model/BlockItemModelWrapper.java | 4 +- 3 files changed, 36 insertions(+), 47 deletions(-) diff --git a/build.properties b/build.properties index 2138119..a14d236 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ mod_version=0.5 minecraft_version=1.8.8 -forge_version=11.15.0.1609-1.8.8 -mappings=snapshot_20151204 +forge_version=11.15.0.1635-1.8.8 +mappings=snapshot_20151212 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java index b375511..94370b6 100644 --- a/src/main/java/slimeknights/mantle/client/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client; import com.google.common.base.Charsets; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -24,7 +25,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IColoredBakedQuad; import net.minecraftforge.client.model.IModelPart; import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.IPerspectiveState; +import net.minecraftforge.client.model.SimpleModelState; import net.minecraftforge.client.model.TRSRTransformation; import java.io.IOException; @@ -42,8 +43,8 @@ public class ModelHelper { GSON = new GsonBuilder().registerTypeAdapter(maptype, ModelTextureDeserializer.INSTANCE).create(); - public static final IPerspectiveState DEFAULT_ITEM_STATE; - public static final IPerspectiveState DEFAULT_TOOL_STATE; + public static final Optional DEFAULT_ITEM_STATE; + public static final Optional DEFAULT_TOOL_STATE; public static TextureAtlasSprite getTextureFromBlock(Block block, int meta) { IBlockState state = block.getStateFromMeta(meta); @@ -100,47 +101,35 @@ public class ModelHelper { return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath() + ".json"); } - public static ImmutableMap getTransformsFromState(IModelState state, IModelPart part) { - if(state instanceof IPerspectiveState) { - IPerspectiveState ps = (IPerspectiveState) state; - Map map = Maps.newHashMap(); - for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) { - map.put(type, ps.forPerspective(type).apply(part)); - } - return Maps.immutableEnumMap(map); - } - return ImmutableMap.of(); - } - static { - // equals forge:default-item - IModelState thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1f / 16, -3f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), - new Vector3f(0.55f, 0.55f, 0.55f), - null)); - IModelState firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - DEFAULT_ITEM_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap - .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, - ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); - - thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1.25f / 16, -3.5f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), - new Vector3f(0.85f, 0.85f, 0.85f), - null)); - firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - DEFAULT_TOOL_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap - .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, - ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); + { + // equals forge:default-item + TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1f / 16, -3f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), + new Vector3f(0.55f, 0.55f, 0.55f), + null)); + TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_ITEM_STATE = Optional.of(new SimpleModelState(ImmutableMap.of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson))); + } + { + TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1.25f / 16, -3.5f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), + new Vector3f(0.85f, 0.85f, 0.85f), + null)); + TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_TOOL_STATE = Optional.of(new SimpleModelState(ImmutableMap + .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson))); + } } /** diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index 4c6e691..032be4c 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -35,14 +35,14 @@ public class BlockItemModelWrapper implements IPerspectiveAwareModel, IFlexibleB } @Override - public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { + public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Matrix4f matrix = null; // fix transformation in hand if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON) { matrix = THIRD_PERSON_BLOCK_TRANSFORM; } - return Pair.of((IBakedModel) this, matrix); + return Pair.of(this, matrix); } @Override