Beispiel #1
0
 /**
  * Checks if a machine is in it's active state.
  *
  * @param world
  * @param x
  * @param y
  * @param z
  * @return if machine is active
  */
 public boolean isActive(IBlockAccess world, int x, int y, int z) {
   TileEntityBasicMachine tileEntity = (TileEntityBasicMachine) world.getBlockTileEntity(x, y, z);
   if (tileEntity != null) {
     return tileEntity.isActive;
   }
   return false;
 }
 /** Is this block indirectly powering the block on the specified side */
 @Override
 public boolean isProvidingWeakPower(IBlockAccess blocks, int x, int y, int z, int side) {
   // TODO: Make this only power in directions parallel to the surface it's attached to?
   TileEntity tile = blocks.getBlockTileEntity(x, y, z);
   if (tile instanceof TileReceiver) {
     return ((TileReceiver) tile).isActive();
   }
   return false;
 }
 /** Is this block powering the block on the specified side */
 @Override
 public boolean isProvidingStrongPower(IBlockAccess blocks, int x, int y, int z, int side) {
   // TODO: Make this only return true for the block it's attached to, so it acts like
   // levers/buttons.
   TileEntity tile = blocks.getBlockTileEntity(x, y, z);
   if (tile instanceof TileReceiver) {
     return ((TileReceiver) tile).isActive();
   }
   return false;
 }
Beispiel #4
0
  @Override
  @SideOnly(Side.CLIENT)
  public int getBlockTexture(IBlockAccess world, int x, int y, int z, int side) {
    int metadata = world.getBlockMetadata(x, y, z);
    TileEntityBasicMachine tileEntity = (TileEntityBasicMachine) world.getBlockTileEntity(x, y, z);

    if (metadata == 0) {
      if (side == tileEntity.facing) {
        return isActive(world, x, y, z) ? 8 : 9;
      } else {
        return 2;
      }
    } else if (metadata == 1) {
      if (side == tileEntity.facing) {
        return isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX : 14;

      } else {
        return 2;
      }
    } else if (metadata == 2) {
      if (side == tileEntity.facing) {
        return isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX + 1 : 15;
      } else {
        return 2;
      }
    } else if (metadata == 3) {
      if (side == tileEntity.facing) {
        return isActive(world, x, y, z) ? 12 : 13;
      } else {
        return 2;
      }
    } else if (metadata == 4) {
      if (side == 0 || side == 1) {
        return isActive(world, x, y, z) ? 20 : 18;
      } else {
        if (side == tileEntity.facing) {
          return isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX + 2 : 16;
        } else if (side
            == ForgeDirection.getOrientation(tileEntity.facing).getOpposite().ordinal()) {
          return isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX + 3 : 17;
        } else {
          return isActive(world, x, y, z) ? Mekanism.ANIMATED_TEXTURE_INDEX + 4 : 19;
        }
      }
    } else {
      return 0;
    }
  }