Пример #1
0
 public void setBlockMaterial(int xx, int yy, int zz, BlockMaterial material, short data) {
   final Vector3f transformed = transform(xx, yy, zz);
   position
       .getWorld()
       .setBlockMaterial(
           transformed.getFloorX(),
           transformed.getFloorY(),
           transformed.getFloorZ(),
           material,
           data,
           null);
   if (material instanceof Directional) {
     final Directional directional = (Directional) material;
     final Block block = position.getWorld().getBlock(transformed);
     final BlockFace face = directional.getFacing(block);
     if (face != BlockFace.BOTTOM && face != BlockFace.TOP) {
       directional.setFacing(
           block,
           BlockFace.fromYaw(
               face.getDirection().getAxesAngleDeg().getY() + rotation.getAxesAngleDeg().getY()));
     }
   } else if (material instanceof Attachable) {
     final Attachable attachable = (Attachable) material;
     final Block block = position.getWorld().getBlock(transformed);
     final BlockFace face = attachable.getAttachedFace(block);
     if (face != BlockFace.BOTTOM && face != BlockFace.TOP) {
       attachable.setAttachedFace(
           block,
           BlockFace.fromYaw(
               face.getDirection().getAxesAngleDeg().getY() + rotation.getAxesAngleDeg().getY()),
           null);
     }
   }
 }
Пример #2
0
 @Override
 public List<StructurePiece> getNextPieces() {
   final StructurePiece piece = getNextPiece();
   if (left) {
     piece.setPosition(position.add(rotate(5, 0, 4)));
     piece.setRotation(Quaternionf.fromAngleDegAxis(90, 0, 1, 0).mul(rotation));
   } else {
     piece.setPosition(position.add(rotate(-1, 0, 0)));
     piece.setRotation(Quaternionf.fromAngleDegAxis(-90, 0, 1, 0).mul(rotation));
   }
   piece.randomize();
   return Lists.newArrayList(piece);
 }
Пример #3
0
 @Override
 protected Point[] generatePoints(Point center, int number) {
   Vector3f offset = Point.FORWARD.mul(radius);
   int angle = number == 0 ? 0 : (360 / number);
   Matrix3f rotate = Matrix3f.createRotation(Quaternionf.fromAngleDegAxis(angle, 0, 1, 0));
   if (halfRotate) {
     offset =
         Matrix3f.createRotation(Quaternionf.fromAngleDegAxis(angle * 0.5f, 0, 1, 0))
             .transform(offset);
   }
   Point[] points = new Point[number];
   for (int i = 0; i < number; i++) {
     points[i] = center.add(offset);
     offset = rotate.transform(offset);
   }
   return points;
 }
Пример #4
0
 public void placeDoor(int xx, int yy, int zz, DoorBlock door, BlockFace facing) {
   final Block bottom = getBlock(xx, yy, zz);
   door.create(
       getBlock(xx, yy, zz),
       bottom.translate(BlockFace.TOP),
       BlockFace.fromYaw(
           facing.getDirection().getAxesAngleDeg().getY() + rotation.getAxesAngleDeg().getY()),
       false,
       false);
 }
Пример #5
0
 @Override
 public List<StructurePiece> getNextPieces() {
   final List<StructurePiece> pieces = new ArrayList<StructurePiece>(3);
   final StructurePiece front = getNextPiece();
   front.setPosition(position.add(rotate(0, 0, 5)));
   front.setRotation(rotation);
   front.randomize();
   pieces.add(front);
   final StructurePiece right = getNextPiece();
   right.setPosition(position.add(rotate(-1, 0, 0)));
   right.setRotation(Quaternionf.fromAngleDegAxis(-90, 0, 1, 0).mul(rotation));
   right.randomize();
   pieces.add(right);
   final StructurePiece left = getNextPiece();
   left.setPosition(position.add(rotate(5, 0, 4)));
   left.setRotation(Quaternionf.fromAngleDegAxis(90, 0, 1, 0).mul(rotation));
   left.randomize();
   pieces.add(left);
   return pieces;
 }
  @Override
  public void onTick(float dt) {
    final Client client = (Client) Spout.getEngine();
    final Transform playerTransform = client.getPlayer().getPhysics().getTransform();
    final PlayerInputState state = client.getPlayer().input();
    final float speed = 50f;
    Vector3f motion = Vector3f.ZERO;
    if (state.getForward()) {
      motion = motion.add(playerTransform.forwardVector().mul(speed * -dt));
    }
    if (state.getBackward()) {
      motion = motion.add(playerTransform.forwardVector().mul(speed * dt));
    }
    if (state.getLeft()) {
      motion = motion.add(playerTransform.rightVector().mul(speed * -dt)); // TODO getLeftVector
    }
    if (state.getRight()) {
      motion = motion.add(playerTransform.rightVector().mul(speed * dt));
    }
    if (state.getJump()) {
      motion = motion.add(playerTransform.upVector().mul(speed * dt));
    }
    if (state.getCrouch()) {
      motion = motion.add(playerTransform.upVector().mul(speed * -dt));
    }

    client
        .getPlayer()
        .getPhysics()
        .setRotation(
            Quaternionf.fromAxesAnglesDeg(
                state.pitch(),
                state.yaw(),
                playerTransform.getRotation().getAxesAngleDeg().getZ()));

    if (!motion.equals(Vector3f.ZERO)) {
      client.getPlayer().getPhysics().translate(motion);
    }
  }