Skip to content

Instantly share code, notes, and snippets.

@ItsDoot
Created July 10, 2020 21:55
Show Gist options
  • Save ItsDoot/e6f4b040ba91a3924cfdcf3946c1b648 to your computer and use it in GitHub Desktop.
Save ItsDoot/e6f4b040ba91a3924cfdcf3946c1b648 to your computer and use it in GitHub Desktop.
enum annoyances
public final class MinecraftConversions {
public static PistonMoveReaction fromMojang(final PushReaction reaction) {
switch (reaction) {
case NORMAL:
return PistonMoveReaction.MOVE;
case DESTROY:
return PistonMoveReaction.BREAK;
case BLOCK:
return PistonMoveReaction.BLOCK;
case IGNORE:
return PistonMoveReaction.IGNORE;
case PUSH_ONLY:
return PistonMoveReaction.PUSH_ONLY;
default:
throw new IllegalArgumentException("Unhandled enum value: " + reaction);
}
}
public static BlockFace fromMojang(final Direction direction) {
switch (direction) {
case DOWN:
return BlockFace.DOWN;
case UP:
return BlockFace.UP;
case NORTH:
return BlockFace.NORTH;
case SOUTH:
return BlockFace.SOUTH;
case WEST:
return BlockFace.WEST;
case EAST:
return BlockFace.EAST;
default:
throw new IllegalArgumentException("Unhandled enum value: " + direction);
}
}
public static Pose fromMojang(final net.minecraft.entity.Pose pose) {
switch (pose) {
case STANDING:
return Pose.STANDING;
case FALL_FLYING:
return Pose.FALL_FLYING;
case SLEEPING:
return Pose.SLEEPING;
case SWIMMING:
return Pose.SWIMMING;
case SPIN_ATTACK:
return Pose.SPIN_ATTACK;
case CROUCHING:
return Pose.SNEAKING;
case DYING:
return Pose.DYING;
default:
throw new IllegalArgumentException("Unhandled enum value: " + pose);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment