Example #1
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
    TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(x, y, z);

    int side =
        MathHelper.floor_double((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    int change = 3;

    switch (side) {
      case 0:
        change = 2;
        break;
      case 1:
        change = 5;
        break;
      case 2:
        change = 3;
        break;
      case 3:
        change = 4;
        break;
    }

    tileEntity.setFacing((short) change);
    tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
  }
Example #2
0
 public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileEntityBasicBlock) {
     TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile;
     if (basicTile.canSetFacing(axis.ordinal())) {
       basicTile.setFacing((short) axis.ordinal());
       return true;
     }
   }
   return false;
 }