Fixed NPE is B3D loader caused by the missing vertex normal; updated the example chest model - it's now has 2 meshes; Updated ModelAnimationDebug - it now uses the new chest model, renders the base with the static world renderer, and only the lid with the TESR.
This commit is contained in:
parent
918d59d6a6
commit
9815d729b5
|
@ -636,13 +636,19 @@ public class B3DModel
|
||||||
Vector3f rPos = new Vector3f(newPos.x / newPos.w, newPos.y / newPos.w, newPos.z / newPos.w);
|
Vector3f rPos = new Vector3f(newPos.x / newPos.w, newPos.y / newPos.w, newPos.z / newPos.w);
|
||||||
|
|
||||||
// normal
|
// normal
|
||||||
|
Vector3f rNormal = null;
|
||||||
|
|
||||||
|
if(this.normal != null)
|
||||||
|
{
|
||||||
Matrix3f tm = new Matrix3f();
|
Matrix3f tm = new Matrix3f();
|
||||||
t.getRotationScale(tm);
|
t.getRotationScale(tm);
|
||||||
tm.invert();
|
tm.invert();
|
||||||
tm.transpose();
|
tm.transpose();
|
||||||
Vector3f normal = new Vector3f(this.normal), rNormal = new Vector3f();
|
Vector3f normal = new Vector3f(this.normal);
|
||||||
|
rNormal = new Vector3f();
|
||||||
tm.transform(normal, rNormal);
|
tm.transform(normal, rNormal);
|
||||||
rNormal.normalize();
|
rNormal.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
// texCoords TODO
|
// texCoords TODO
|
||||||
return new Vertex(rPos, rNormal, color, texCoords);
|
return new Vertex(rPos, rNormal, color, texCoords);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockPistonBase;
|
import net.minecraft.block.BlockPistonBase;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.properties.PropertyDirection;
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -25,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.model.ISmartBlockModel;
|
import net.minecraftforge.client.model.ISmartBlockModel;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
|
@ -52,6 +54,7 @@ public class ModelAnimationDebug
|
||||||
|
|
||||||
public static String blockName = "test_animation_block";
|
public static String blockName = "test_animation_block";
|
||||||
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
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")
|
@SidedProxy(serverSide = "net.minecraftforge.debug.ModelAnimationDebug$CommonProxy", clientSide = "net.minecraftforge.debug.ModelAnimationDebug$ClientProxy")
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
@ -71,12 +74,9 @@ public class ModelAnimationDebug
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBlockState createBlockState()
|
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
|
@Override
|
||||||
public boolean isOpaqueCube() { return false; }
|
public boolean isOpaqueCube() { return false; }
|
||||||
|
|
||||||
|
@ -109,6 +109,11 @@ public class ModelAnimationDebug
|
||||||
return new Chest(state);
|
return new Chest(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
|
return state.withProperty(STATIC, true);
|
||||||
|
}
|
||||||
|
|
||||||
/*@Override
|
/*@Override
|
||||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
TileEntity te = world.getTileEntity(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)
|
public void renderTileEntityAt(Chest te, double x, double y, double z, float partialTick, int breakStage)
|
||||||
{
|
{
|
||||||
IBlockState state = te.getWorld().getBlockState(te.getPos());
|
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)
|
if(state instanceof IExtendedBlockState)
|
||||||
{
|
{
|
||||||
IExtendedBlockState exState = (IExtendedBlockState)state;
|
IExtendedBlockState exState = (IExtendedBlockState)state;
|
||||||
|
|
|
@ -6,13 +6,20 @@
|
||||||
},
|
},
|
||||||
"model": "forgedebugmodelloaderregistry:chest.b3d",
|
"model": "forgedebugmodelloaderregistry:chest.b3d",
|
||||||
"custom": {
|
"custom": {
|
||||||
"mesh": ["Cube.001"]
|
"mesh": ["Base", "Lid"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
"normal": [{}],
|
"normal": [{}],
|
||||||
"inventory": [{
|
"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": {
|
"facing": {
|
||||||
"down": { "transform": { "rotation": { "x": 90 } } },
|
"down": { "transform": { "rotation": { "x": 90 } } },
|
||||||
|
@ -21,6 +28,18 @@
|
||||||
"south": { "transform": "identity" },
|
"south": { "transform": "identity" },
|
||||||
"west": { "transform": { "rotation": { "y": 90 } } },
|
"west": { "transform": { "rotation": { "y": 90 } } },
|
||||||
"east": { "transform": { "rotation": { "y": 270 } } }
|
"east": { "transform": { "rotation": { "y": 270 } } }
|
||||||
|
},
|
||||||
|
"static": {
|
||||||
|
"true": {
|
||||||
|
"custom": {
|
||||||
|
"mesh": ["Base"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
"custom": {
|
||||||
|
"mesh": ["Lid"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
"#chest": "entity/chest/normal"
|
"#chest": "entity/chest/normal"
|
||||||
},
|
},
|
||||||
"model": "forgedebugmodelloaderregistry:chest.b3d",
|
"model": "forgedebugmodelloaderregistry:chest.b3d",
|
||||||
"transform": "forge:default-block"
|
"transform": "forge:default-block",
|
||||||
|
"custom": {
|
||||||
|
"mesh": ["Base", "Lid"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
"normal": [{}],
|
"normal": [{}],
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue