当前位置: 首页>>代码示例>>Java>>正文


Java Direction.EAST属性代码示例

本文整理汇总了Java中org.spongepowered.api.util.Direction.EAST属性的典型用法代码示例。如果您正苦于以下问题:Java Direction.EAST属性的具体用法?Java Direction.EAST怎么用?Java Direction.EAST使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.spongepowered.api.util.Direction的用法示例。


在下文中一共展示了Direction.EAST属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPickaxeRot

private Vector3d getPickaxeRot() {
    Direction facing = Utils.rotationToDirection(this.rotation.getY());
    if (facing == Direction.NORTH) {
        return new Vector3d(0, 180, 0);
    }
    if (facing == Direction.EAST) {
        return new Vector3d(0, 270, 0);
    }
    if (facing == Direction.SOUTH) {
        return Vector3d.ZERO;
    }
    if (facing == Direction.WEST) {
        return new Vector3d(0, 90, 0);
    }
    return this.rotation;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:16,代码来源:TurtleEntity.java

示例2: getPickaxePos

private Vector3d getPickaxePos() {
    Direction facing = Utils.rotationToDirection(this.rotation.getY());
    if (facing == Direction.NORTH) {
        return this.pos.add(0.17, -0.7, 0.4);
    }
    if (facing == Direction.EAST) {
        return this.pos.add(-0.4, -0.7, 0.17);
    }
    if (facing == Direction.SOUTH) {
        return this.pos.add(-0.15, -0.7, -0.4);
    }
    if (facing == Direction.WEST) {
        return this.pos.add(0.4, -0.7, -0.15);
    }
    return this.pos;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:16,代码来源:TurtleEntity.java

示例3: isSideSolid

private static boolean isSideSolid(AABB boundingBox, @Nullable Direction face) {
    final Vector3d min = boundingBox.getMin();
    final Vector3d max = boundingBox.getMax();

    if (face == Direction.NORTH) {
        return min.getZ() == 0.0 && min.getX() == 0.0 && min.getY() == 0.0 && max.getX() >= 1.0 && max.getY() >= 1.0;
    } else if (face == Direction.SOUTH) {
        return min.getZ() == 1.0 && min.getX() == 0.0 && min.getY() == 0.0 && max.getX() >= 1.0 && max.getY() >= 1.0;
    } else if (face == Direction.WEST) {
        return min.getZ() == 0.0 && min.getY() == 0.0 && min.getZ() == 0.0 && max.getY() >= 1.0 && max.getZ() >= 1.0;
    } else if (face == Direction.EAST) {
        return min.getZ() == 1.0 && min.getY() == 0.0 && min.getZ() == 0.0 && max.getY() >= 1.0 && max.getZ() >= 1.0;
    } else if (face == Direction.DOWN) {
        return min.getZ() == 0.0 && min.getX() == 0.0 && min.getZ() == 0.0 && max.getX() == 1.0 && max.getZ() == 1.0;
    } else if (face == Direction.UP) {
        return min.getZ() == 1.0 && min.getX() == 0.0 && min.getZ() == 0.0 && max.getX() == 1.0 && max.getZ() == 1.0;
    } else {
        return false;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:BlockTypeBuilderImpl.java

示例4: of

public static Direction of(double pitch, double yaw) {
	yaw = (yaw) % 360;
       if (yaw < 0) {
       	yaw += 360.0;
       }
	
       if (pitch > 67.5) {
           return Direction.DOWN;
       } else if (pitch < -67.5) {
           return Direction.UP;
       } else if (0 <= yaw && yaw < 22.5) {
           return Direction.SOUTH;
       } else if (22.5 <= yaw && yaw < 67.5) {
           return Direction.SOUTHWEST;
       } else if (67.5 <= yaw && yaw < 112.5) {
           return Direction.WEST;
       } else if (112.5 <= yaw && yaw < 157.5) {
           return Direction.NORTHWEST;
       } else if (157.5 <= yaw && yaw < 202.5) {
           return Direction.NORTH;
       } else if (202.5 <= yaw && yaw < 247.5) {
           return Direction.NORTHEAST;
       } else if (247.5 <= yaw && yaw < 292.5) {
           return Direction.EAST;
       } else if (292.5 <= yaw && yaw < 337.5) {
           return Direction.SOUTHEAST;
       } else if (337.5 <= yaw && yaw < 360.0) {
           return Direction.SOUTH;
       } else {
           return Direction.NONE;
       }
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:32,代码来源:UtilsDirection.java

示例5: updateProgress

private void updateProgress(Vector3i pipePos, Direction dest, boolean toCenter) {
    Vector3d target = pipePos.toDouble().add(0.5, 0.3, 0.5);
    if (!toCenter) {
        target = target.add(dest.asOffset().mul(0.5));
    }

    double dist;
    if (dest == Direction.WEST) {// (-1, 0, 0)
        dist = this.pos.getX() - pipePos.getX();
    } else if (dest == Direction.EAST) {// (1, 0, 0)
        dist = (pipePos.getX() + 1) - this.pos.getX();
    } else if (dest == Direction.NORTH) {// (0, 0, -1
        dist = this.pos.getZ() - pipePos.getZ();
    } else if (dest == Direction.SOUTH) {// (0, 0, 1)
        dist = (pipePos.getZ() + 1) - this.pos.getZ();
    } else if (dest == Direction.UP) {// (0, 1, 0)
        dist = (pipePos.getY() + 0.8) - this.pos.getY();
    } else if (dest == Direction.DOWN) {// (0, -1, 0)
        dist = (this.pos.getY() + 0.3) - pipePos.getY();
    } else {
        return;
    }
    if (toCenter) {
        dist -= 0.5;
    }
    if (dist <= 0) { // On or past the target
        this.pos = target;
        this.itemStand.setLocation(this.itemStand.getLocation().setPosition(target));
        this.finish = true;
    } else {
        this.finish = false;
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:33,代码来源:ItemStackHolder.java

示例6: rotationToDirection

public static Direction rotationToDirection(double rotation) {
    rotation = Math.round(rotation);
    if (rotation < 45 || rotation > 315) {
        return Direction.SOUTH;
    }
    if (rotation < 135) {
        return Direction.WEST;
    }
    if (rotation < 225) {
        return Direction.NORTH;
    }
    return Direction.EAST;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:13,代码来源:Utils.java

示例7: fromFace

public static Direction fromFace(int face) {
    switch (face) {
        case 0: return Direction.DOWN;
        case 1: return Direction.UP;
        case 2: return Direction.NORTH;
        case 3: return Direction.SOUTH;
        case 4: return Direction.WEST;
        case 5: return Direction.EAST;
        default:
            throw new IllegalStateException("Unknown face: " + face);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:CodecUtils.java

示例8: tryPlace

@Override
public BehaviorResult tryPlace(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    final BlockSnapshot snapshot = context.getContext(ContextKeys.BLOCK_SNAPSHOT)
            .orElseThrow(() -> new IllegalStateException("The BlockSnapshotProviderPlaceBehavior's BlockSnapshot isn't present."));
    final Location<World> location = context.requireContext(ContextKeys.BLOCK_LOCATION);
    final LanternPlayer player = (LanternPlayer) context.getContext(ContextKeys.PLAYER).orElse(null);

    // Get the direction the chest should face
    Direction facing;
    if (player != null) {
        facing = player.getHorizontalDirection(Direction.Division.CARDINAL).getOpposite();
    } else {
        facing = Direction.NORTH;
    }

    Location<World> otherChestLoc;
    // Check whether the chest already a double chest is,
    // and fail if this is the case
    for (Direction directionToCheck : HORIZONTAL_DIRECTIONS) {
        otherChestLoc = location.getRelative(directionToCheck);
        // We found a chest
        if (otherChestLoc.getBlock().getType() == snapshot.getState().getType()) {
            // Check if it isn't already double
            for (Direction directionToCheck1 : HORIZONTAL_DIRECTIONS) {
                final Location<World> loc1 = otherChestLoc.getRelative(directionToCheck1);
                if (loc1.getBlock().getType() == snapshot.getState().getType()) {
                    return BehaviorResult.FAIL;
                }
            }
            final Direction otherFacing = otherChestLoc.get(Keys.DIRECTION).get();
            // The chests don't have the same facing direction, we need to fix it
            boolean flag = directionToCheck != facing && directionToCheck.getOpposite() != facing;
            if (!(facing == otherFacing && flag)) {
                // The rotation of the chests is completely wrong, fix it
                if (!flag) {
                    if (player != null) {
                        final Vector3d dir = player.getHorizontalDirectionVector();
                        if (directionToCheck == Direction.EAST || directionToCheck == Direction.WEST) {
                            facing = dir.getZ() >= 0 ? Direction.NORTH : Direction.SOUTH;
                        } else {
                            facing = dir.getX() >= 0 ? Direction.WEST : Direction.EAST;
                        }
                    } else {
                        facing = directionToCheck == Direction.EAST || directionToCheck == Direction.WEST ? Direction.SOUTH : Direction.EAST;
                    }
                }
                context.addBlockChange(BlockSnapshot.builder()
                        .from(otherChestLoc.createSnapshot())
                        .add(Keys.DIRECTION, facing)
                        .build());
            }
            break;
        }
    }

    context.addBlockChange(BlockSnapshotBuilder.create().from(snapshot)
            .location(location).add(Keys.DIRECTION, facing).build());
    return BehaviorResult.SUCCESS;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:59,代码来源:ChestPlacementBehavior.java

示例9: execute

@Override
public final CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    try {
        if (args.hasAny("username")) {
            String username = args.<String>getOne("username").get();
            Profile profile = profileResolver.findByName(username);
            if (profile == null) {
                src.sendMessage(Texts.of(TextColors.RED,"Sorry failed to find a profile for that username."));
                return CommandResult.empty();
            }
            src.sendMessage(Texts.of(TextColors.GREEN, "Found a profile for the provided username."));
            ClickAction.SuggestCommand clickAction = new ClickAction.SuggestCommand(profile.getUniqueId().toString());
            Text clickableUUID = Texts.builder()
                    .append(Texts.of(TextColors.GREEN, profile.getUniqueId().toString()))
                    .onClick(clickAction).build();
            src.sendMessage(Texts.of(TextColors.BLUE, profile.getName(), TextColors.GRAY, ": ", clickableUUID));

            MinecraftSkin skin = game.getServiceManager().provideUnchecked(SkinResolverService.class).getSkin(profile.getUniqueId());
            if (skin == null) {
                src.sendMessage(Texts.of(TextColors.RED, "Failed to resolve skin for the profile."));
            } else {
                src.sendMessage(Texts.of(TextColors.GREEN, "Skin type: ", skin.type));
                ColorMapping mapping = ColorMapping.matchColor(new Color(skin.texture.getRGB(12, 12)));
                String message = String.format("The matching block was %s and the color was %s", mapping.equivalentBlock.toString(), mapping.dyeColor.orNull() == null ? "null" : mapping.dyeColor.toString());

                if (src instanceof Player) {
                    Player player = (Player) src;
                    Vector3d rot = player.getRotation();
                    int value = floor_double((double)(rot.getX() * 4.0F / 360.0F) + 0.5D) & 3;
                    System.out.println(value);
                    player.sendMessage(Texts.of((rot.getX() * 4.0F / 360.0F) + 0.5D));
                    player.sendMessage(Texts.of(rot.getX() * 4.0F / 360.0F));
                    player.sendMessage(Texts.of(value));
                    int pos = ((value < 0 ? -value : value) % 4);
                    Direction buildDirection = null;
                    switch (pos) {
                        case 0:
                            // South
                            System.out.println("SOUTH");
                            player.sendMessage(Texts.of("SOUTH"));
                            buildDirection = Direction.SOUTH;
                            break;
                        case 1:
                            // WEST
                            System.out.println("WEST");
                            player.sendMessage(Texts.of("WEST"));
                            buildDirection = Direction.WEST;
                            break;
                        case 2:
                            // NORTH
                            System.out.println("NORTH");
                            player.sendMessage(Texts.of("NORTH"));
                            buildDirection = Direction.NORTH;
                            break;
                        case 3:
                            // EAST
                            System.out.println("EAST");
                            player.sendMessage(Texts.of("EAST"));
                            buildDirection = Direction.EAST;
                            break;
                    }

                }
            }
            return CommandResult.success();
        }
        return CommandResult.empty();
    } catch (Throwable th) {
        th.printStackTrace();
        return CommandResult.empty();
    }
}
 
开发者ID:modwizcode,项目名称:Statue,代码行数:72,代码来源:TestResolveCommand.java


注:本文中的org.spongepowered.api.util.Direction.EAST属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。