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