Missing Import

Discussion in 'Spigot Plugin Development' started by Eliminator, May 19, 2015.

  1. I am trying to update a plugin from 1.7 to 1.8, but an import no longer exists:

    Code (Text):
    import net.minecraft.server.v1_7_R3.Facing;
    This was in 1.7.

    But this does not exist:
    Code (Text):
    net.minecraft.server.v1_8_R2.Facing;
    Help anyone?

    And yes, I am including the full spigot build in my build path, I can import all the other "net.minecraft.server.v1_8_R2" things, just not that one.
     
  2. Are you referring to this: https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/Facing.java?
     
  3. Everything was moved to BlockPosition AFAIK
     
  4. I was using it like this:
    Code (Text):
    if (isPowered(world, x + Facing.b[dir], y + Facing.c[dir], z + Facing.d[dir], Facing.OPPOSITE_FACING[dir], color, true)) {
     
  5. @Eliminator but what class was this? I am willing to look it up for you, but I'm not going to search all NMS classes if I can just get a direction :p.

    Though, I did find EnumDirection, perhaps that's what you need?
     
  6. I am actually updating a plugin I did not make, so I am not aware of how/where the Facing class is.

    All I know is that it was used in 1.7, and now in 1.8 it no longer exists.
     
  7. In what context are you using it? Could you post more code?
     
  8. Here is the full function:
    Code (Text):
                        if ((fromDir == 6) || (powerDirection == Facing.OPPOSITE_FACING[fromDir])) { // the block powering us turned off
                            for (int dir = 0; dir < 6; dir++) {
                                if (isPowered(world, x + Facing.b[dir], y + Facing.c[dir], z + Facing.d[dir], Facing.OPPOSITE_FACING[dir], color, false)) {
                                    setPoweredBy(world, x, y, z, color, dir); // we were powered, something unpowered, but we found a new block
                                    return;
                                }
                                // we were powered, and there is nothing else powering us
                                setUnpowered(world, x, y, z, color);
                            }
                        }
     
  9. @Eliminator looks like some redstone-related code. NMS is using the EnumDirection enum in it's current classes.
     
  10. OK, so how do I convert it for 1.8?
    I can't just replace the Facing with EnumDirection.
     
  11. @Eliminator use dir to find the right EnumDirection, and then add the modifiers to the x, y and z coordinates. (I'm sure the EnumDirection class has some functions for that)
     
  12. The code has all kind of stiff it uses Facing for, EnumDirection is nothing like facing, it has none of the stuff I need.
     
  13. It has all been encapsulated in the enum fields most likely.