Changed the turntable to be rotated when placed
This commit is contained in:
parent
08bd443857
commit
4faf6c72ef
1 changed files with 23 additions and 31 deletions
|
@ -45,50 +45,43 @@ public class BlockTurntable extends BlockAssembly
|
||||||
this.updateTurntableState(world, x, y, z);
|
this.updateTurntableState(world, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
|
|
||||||
{
|
|
||||||
if (side == ForgeDirection.UP.ordinal())
|
|
||||||
return this.top;
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public Icon getIcon(int side, int meta)
|
public Icon getIcon(int side, int meta)
|
||||||
{
|
{
|
||||||
if (side == ForgeDirection.UP.ordinal())
|
if (side == meta)
|
||||||
|
{
|
||||||
return this.top;
|
return this.top;
|
||||||
|
}
|
||||||
return this.blockIcon;
|
return this.blockIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int determineOrientation(World world, int x, int y, int z, EntityPlayer entityPlayer)
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack stack)
|
||||||
{
|
{
|
||||||
if (MathHelper.abs((float) entityPlayer.posX - x) < 2.0F && MathHelper.abs((float) entityPlayer.posZ - z) < 2.0F)
|
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||||
|
int change = 3;
|
||||||
|
|
||||||
|
switch (angle)
|
||||||
{
|
{
|
||||||
double var5 = entityPlayer.posY + 1.82D - entityPlayer.yOffset;
|
case 0:
|
||||||
|
change = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
if (var5 - y > 2.0D)
|
case 1:
|
||||||
{
|
change = 5;
|
||||||
return 1;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (y - var5 > 0.0D)
|
case 2:
|
||||||
{
|
change = 3;
|
||||||
return 0;
|
break;
|
||||||
}
|
|
||||||
|
case 3:
|
||||||
|
change = 4;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int var7 = MathHelper.floor_double((entityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
world.setBlockMetadataWithNotify(x, y, z, change, 3);
|
||||||
return var7 == 0 ? 2 : (var7 == 1 ? 5 : (var7 == 2 ? 3 : (var7 == 3 ? 4 : 0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack stack)
|
|
||||||
{
|
|
||||||
int metadata = determineOrientation(world, x, y, z, (EntityPlayer) par5EntityLiving);
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, metadata, 3);
|
|
||||||
|
|
||||||
world.scheduleBlockUpdate(x, y, z, this.blockID, 20);
|
world.scheduleBlockUpdate(x, y, z, this.blockID, 20);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +108,6 @@ public class BlockTurntable extends BlockAssembly
|
||||||
if (tileEntity instanceof IRotatable)
|
if (tileEntity instanceof IRotatable)
|
||||||
{
|
{
|
||||||
currentDirection = ((IRotatable) tileEntity).getDirection();
|
currentDirection = ((IRotatable) tileEntity).getDirection();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (Block.blocksList[blockID] instanceof IRotatableBlock)
|
else if (Block.blocksList[blockID] instanceof IRotatableBlock)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue