Fixes #2414: Sky Compass not respecting placement face.
This commit is contained in:
parent
c590e7f6e6
commit
877f87afe4
4 changed files with 72 additions and 20 deletions
|
@ -58,7 +58,7 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
|||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] { ROTATION } );
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] { FORWARD, UP, ROTATION } );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,8 +40,6 @@ public class SkyCompassRendering extends BlockRenderingCustomizer
|
|||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.tesr( new SkyCompassTESR() );
|
||||
// This disables the default smart-rotating model
|
||||
rendering.modelCustomizer( ( loc, model ) -> model );
|
||||
itemRendering.model( ITEM_MODEL );
|
||||
itemRendering.builtInModel( "models/block/builtin/sky_compass", new SkyCompassModel() );
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package appeng.client.render.model;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
|
@ -80,7 +79,15 @@ public class AutoRotatingModel implements IBakedModel
|
|||
VertexRotator rot = new VertexRotator( f2r, quad.getFace() );
|
||||
rot.setParent( builder );
|
||||
quad.pipe( rot );
|
||||
if( quad.getFace() != null )
|
||||
{
|
||||
builder.setQuadOrientation( f2r.rotate( quad.getFace() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.setQuadOrientation( null );
|
||||
|
||||
}
|
||||
BakedQuad q = builder.build();
|
||||
rotated.add( q );
|
||||
}
|
||||
|
@ -237,23 +244,59 @@ public class AutoRotatingModel implements IBakedModel
|
|||
}
|
||||
|
||||
private float[] transformNormal( float[] fs )
|
||||
{
|
||||
if( face == null )
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vec3i vec = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] { vec.getX(), vec.getY(), vec.getZ()
|
||||
Vector3f vec = new Vector3f( fs );
|
||||
f2r.getMat().transform( vec );
|
||||
return new float[] {
|
||||
vec.getX(),
|
||||
vec.getY(),
|
||||
vec.getZ()
|
||||
};
|
||||
case 4:
|
||||
Vector4f veccc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
Vec3i vecc = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] { vecc.getX(), vecc.getY(), vecc.getZ(), veccc.w
|
||||
Vector4f vec4 = new Vector4f( fs );
|
||||
f2r.getMat().transform( vec4 );
|
||||
return new float[] {
|
||||
vec4.getX(),
|
||||
vec4.getY(),
|
||||
vec4.getZ(),
|
||||
0
|
||||
};
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( fs.length )
|
||||
{
|
||||
case 3:
|
||||
Vec3i vec = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] {
|
||||
vec.getX(),
|
||||
vec.getY(),
|
||||
vec.getZ()
|
||||
};
|
||||
case 4:
|
||||
Vector4f veccc = new Vector4f( fs[0], fs[1], fs[2], fs[3] );
|
||||
Vec3i vecc = f2r.rotate( face ).getDirectionVec();
|
||||
return new float[] {
|
||||
vecc.getX(),
|
||||
vecc.getY(),
|
||||
vecc.getZ(),
|
||||
veccc.w
|
||||
};
|
||||
|
||||
default:
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuadTint( int tint )
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.minecraftforge.common.property.Properties;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.client.render.model.SkyCompassBakedModel;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
|
@ -69,11 +70,21 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
|
|||
|
||||
if( state instanceof IExtendedBlockState )
|
||||
{
|
||||
IExtendedBlockState exState = (IExtendedBlockState) state;
|
||||
IExtendedBlockState exState = (IExtendedBlockState) state.getBlock().getExtendedState( state, world, pos );
|
||||
|
||||
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState( exState.getClean() );
|
||||
exState = exState.withProperty( BlockSkyCompass.ROTATION, getRotation( te ) );
|
||||
|
||||
// Flip forward/up for rendering, the base model is facing up without any rotation
|
||||
EnumFacing forward = exState.getValue( AEBaseTileBlock.FORWARD );
|
||||
EnumFacing up = exState.getValue( AEBaseTileBlock.UP );
|
||||
// This ensures the needle isn't flipped by the model rotator. Since the model is symmetrical, this should not affect the appearance
|
||||
if ( forward == EnumFacing.UP || forward == EnumFacing.DOWN ) {
|
||||
up = EnumFacing.NORTH;
|
||||
}
|
||||
exState = exState.withProperty( AEBaseTileBlock.FORWARD, up )
|
||||
.withProperty( AEBaseTileBlock.UP, forward );
|
||||
|
||||
buffer.setTranslation( x - pos.getX(), y - pos.getY(), z - pos.getZ() );
|
||||
|
||||
blockRenderer.getBlockModelRenderer().renderModel( world, model, exState, pos, buffer, false );
|
||||
|
@ -84,7 +95,7 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
|
|||
{
|
||||
float rotation;
|
||||
|
||||
if( skyCompass.getUp() == EnumFacing.UP || skyCompass.getUp() == EnumFacing.DOWN )
|
||||
if( skyCompass.getForward() == EnumFacing.UP || skyCompass.getForward() == EnumFacing.DOWN )
|
||||
{
|
||||
rotation = SkyCompassBakedModel.getAnimatedRotation( skyCompass.getPos(), false );
|
||||
}
|
||||
|
@ -93,7 +104,7 @@ public class SkyCompassTESR extends FastTESR<TileSkyCompass>
|
|||
rotation = SkyCompassBakedModel.getAnimatedRotation( null, false );
|
||||
}
|
||||
|
||||
if( skyCompass.getUp() == EnumFacing.DOWN )
|
||||
if( skyCompass.getForward() == EnumFacing.DOWN )
|
||||
{
|
||||
rotation = flipidiy( rotation );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue