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 60af648494..06c297099b 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java @@ -636,13 +636,19 @@ public class B3DModel Vector3f rPos = new Vector3f(newPos.x / newPos.w, newPos.y / newPos.w, newPos.z / newPos.w); // normal - Matrix3f tm = new Matrix3f(); - t.getRotationScale(tm); - tm.invert(); - tm.transpose(); - Vector3f normal = new Vector3f(this.normal), rNormal = new Vector3f(); - tm.transform(normal, rNormal); - rNormal.normalize(); + Vector3f rNormal = null; + + if(this.normal != null) + { + Matrix3f tm = new Matrix3f(); + t.getRotationScale(tm); + tm.invert(); + tm.transpose(); + Vector3f normal = new Vector3f(this.normal); + rNormal = new Vector3f(); + tm.transform(normal, rNormal); + rNormal.normalize(); + } // texCoords TODO return new Vertex(rPos, rNormal, color, texCoords); diff --git a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java index 48b8ec2a1d..fbdb0e2540 100644 --- a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java +++ b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -25,6 +26,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.model.ISmartBlockModel; import net.minecraftforge.client.model.ModelLoader; @@ -52,6 +54,7 @@ public class ModelAnimationDebug public static String blockName = "test_animation_block"; public static final PropertyDirection FACING = PropertyDirection.create("facing"); + public static final PropertyBool STATIC = PropertyBool.create("static");; @SidedProxy(serverSide = "net.minecraftforge.debug.ModelAnimationDebug$CommonProxy", clientSide = "net.minecraftforge.debug.ModelAnimationDebug$ClientProxy") public static CommonProxy proxy; @@ -71,12 +74,9 @@ public class ModelAnimationDebug @Override public ExtendedBlockState createBlockState() { - return new ExtendedBlockState(this, new IProperty[]{ FACING }, new IUnlistedProperty[]{ B3DFrameProperty.instance }); + return new ExtendedBlockState(this, new IProperty[]{ FACING, STATIC }, new IUnlistedProperty[]{ B3DFrameProperty.instance }); } - @Override - public int getRenderType() { return -1; } - @Override public boolean isOpaqueCube() { return false; } @@ -109,6 +109,11 @@ public class ModelAnimationDebug return new Chest(state); } + @Override + public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { + return state.withProperty(STATIC, true); + } + /*@Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); @@ -239,7 +244,8 @@ public class ModelAnimationDebug public void renderTileEntityAt(Chest te, double x, double y, double z, float partialTick, int breakStage) { IBlockState state = te.getWorld().getBlockState(te.getPos()); - IBakedModel model = this.blockRenderer.getModelFromBlockState(state, te.getWorld(), te.getPos()); + state = state.withProperty(STATIC, false); + IBakedModel model = this.blockRenderer.getBlockModelShapes().getModelForState(state); if(state instanceof IExtendedBlockState) { IExtendedBlockState exState = (IExtendedBlockState)state; diff --git a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json index b12b0913d7..2b46abd6c8 100644 --- a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json +++ b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json @@ -6,13 +6,20 @@ }, "model": "forgedebugmodelloaderregistry:chest.b3d", "custom": { - "mesh": ["Cube.001"] + "mesh": ["Base", "Lid"] } }, "variants": { "normal": [{}], "inventory": [{ - "transform": "forge:default-block" + "transform": { + "rotation": { "y": 180 }, + "thirdperson": { + "rotation": [ { "z": 170 }, { "y": -45 }, { "z": 20 } ], + "translation": [ 0, 0.09375, -0.171875 ], + "scale": 0.375 + } + } }], "facing": { "down": { "transform": { "rotation": { "x": 90 } } }, @@ -21,6 +28,18 @@ "south": { "transform": "identity" }, "west": { "transform": { "rotation": { "y": 90 } } }, "east": { "transform": { "rotation": { "y": 270 } } } + }, + "static": { + "true": { + "custom": { + "mesh": ["Base"] + } + }, + "false": { + "custom": { + "mesh": ["Lid"] + } + } } } } diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json index b1926396b1..d8e22b4a68 100644 --- a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json +++ b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json @@ -6,7 +6,10 @@ "#chest": "entity/chest/normal" }, "model": "forgedebugmodelloaderregistry:chest.b3d", - "transform": "forge:default-block" + "transform": "forge:default-block", + "custom": { + "mesh": ["Base", "Lid"] + } }, "variants": { "normal": [{}], diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/models/block/chest.b3d b/src/test/resources/assets/forgedebugmodelloaderregistry/models/block/chest.b3d index b070d7a6fa..5e5b658080 100644 Binary files a/src/test/resources/assets/forgedebugmodelloaderregistry/models/block/chest.b3d and b/src/test/resources/assets/forgedebugmodelloaderregistry/models/block/chest.b3d differ