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


Java Direction.DOWN属性代码示例

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


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

示例1: 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

示例2: tryInteract

@Override
public BehaviorResult tryInteract(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    BehaviorResult result = super.tryInteract(pipeline, context);
    if (result != BehaviorResult.SUCCESS && result != BehaviorResult.CONTINUE) {
        return result;
    }

    final Location<World> location = context.requireContext(ContextKeys.BLOCK_LOCATION);
    final BlockState baseState = location.getBlock();
    final LanternDoorHalf half = baseState.get(LanternKeys.DOOR_HALF).orElse(null);
    if (half == null) {
        return result;
    }

    final Direction dir = half == LanternDoorHalf.LOWER ? Direction.UP : Direction.DOWN;
    final LanternDoorHalf other = half == LanternDoorHalf.LOWER ? LanternDoorHalf.UPPER : LanternDoorHalf.LOWER;
    final Location<World> loc = location.getBlockRelative(dir);

    BlockState otherState = loc.getBlock();
    if (otherState.get(LanternKeys.DOOR_HALF).orElse(null) == other &&
            otherState.with(LanternKeys.DOOR_HALF, half).orElse(null) == baseState) {
        result = super.tryInteract(pipeline, context);
    }

    return result;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:26,代码来源:OpenableDoorInteractionBehavior.java

示例3: 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

示例4: 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

示例5: join

private void join(CustomWorld world, Vector3i pos, Direction side, Vector3i pos2) {
    StructureInstance struct1 = getStructure(world, pos);
    if (struct1 == null) {
        return;
    }
    StructureInstance struct2 = getStructure(world, pos2);
    if (struct2 == null) {
        connect(struct1, null, side);
    } else if (side == Direction.DOWN || side == Direction.NORTH || side == Direction.WEST) {
        connect(struct1, struct2, side);
    } else {
        connect(struct2, struct1, side.getOpposite());
    }
    struct1.remove(side.name());
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:15,代码来源:PipeBlock.java

示例6: getVisibleLocation

private static Location<World> getVisibleLocation(World world, int x, int y, int z, boolean waterIsTransparent) {
    Location<World> location = world.getLocation(x, y, z);
    Direction direction = (isTransparent(location.getBlock(), waterIsTransparent)) ? Direction.DOWN : Direction.UP;

    while (location.getPosition().getY() >= 1 &&
            location.getPosition().getY() < world.getDimension().getBuildHeight() - 1 &&
            (!isTransparent(location.getRelative(Direction.UP).getBlock(), waterIsTransparent)
                    || isTransparent(location.getBlock(), waterIsTransparent))) {
        location = location.getRelative(direction);
    }

    return location;
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:13,代码来源:Visualization.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) {
    Direction face = context.requireContext(ContextKeys.INTERACTION_FACE).getOpposite();
    if (face == Direction.UP) {
        face = Direction.DOWN;
    }
    final Direction face1 = face;
    context.transformBlockChanges((snapshot, builder) -> builder.add(Keys.DIRECTION, face1));
    return BehaviorResult.CONTINUE;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:HopperPlacementBehavior.java

示例9: tryBreak

@Override
public BehaviorResult tryBreak(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    final Location<World> location = context.getContext(ContextKeys.BLOCK_LOCATION).get();

    final BlockState baseState = location.getBlock();
    final LanternDoorHalf half = baseState.get(LanternKeys.DOOR_HALF).get();

    final BlockSnapshotBuilder builder = BlockSnapshotBuilder.create();
    builder.blockState(BlockTypes.AIR.getDefaultState());
    context.populateBlockSnapshot(builder, BehaviorContext.PopulationFlags.CREATOR_AND_NOTIFIER);

    builder.location(location);
    context.addBlockChange(builder.build());

    final Direction dir = half == LanternDoorHalf.LOWER ? Direction.UP : Direction.DOWN;
    final LanternDoorHalf other = half == LanternDoorHalf.LOWER ? LanternDoorHalf.UPPER : LanternDoorHalf.LOWER;
    final Location<World> loc = location.getBlockRelative(dir);

    BlockState otherState = loc.getBlock();
    if (otherState.get(LanternKeys.DOOR_HALF).orElse(null) == other &&
            otherState.with(LanternKeys.DOOR_HALF, half).orElse(null) == baseState) {
        builder.location(loc);
        context.addBlockChange(builder.build());
        return BehaviorResult.CONTINUE;
    }

    return BehaviorResult.CONTINUE;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:28,代码来源:DoorBehavior.java

示例10: tryPlace

@Override
public BehaviorResult tryPlace(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    Direction face = context.requireContext(ContextKeys.INTERACTION_FACE).getOpposite();
    if (face == Direction.DOWN) {
        return BehaviorResult.PASS;
    }
    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 Location<World> clickLocation = context.requireContext(ContextKeys.INTERACTION_LOCATION);
    boolean flag = clickLocation.getExtent().getProperty(
            clickLocation.getBlockPosition(), face, SolidSideProperty.class).get().getValue();
    BlockSnapshotBuilder builder = BlockSnapshotBuilder.create().from(snapshot);
    if (!flag) {
        for (Direction direction : HORIZONTAL_DIRECTIONS) {
            flag = location.getExtent().getProperty(location.getBlockRelative(direction).getBlockPosition(),
                    direction.getOpposite(), SolidSideProperty.class).get().getValue();
            if (flag) {
                face = direction;
                break;
            }
        }
    }
    if (flag) {
        builder.add(Keys.DIRECTION, face.getOpposite());
    }
    context.addBlockChange(builder.location(location).build());
    return BehaviorResult.CONTINUE;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:29,代码来源:TorchPlacementBehavior.java

示例11: tryPlace

@Override
public BehaviorResult tryPlace(BehaviorPipeline<Behavior> pipeline, BehaviorContext context) {
    final Location<World> location = context.requireContext(ContextKeys.BLOCK_LOCATION);
    final Direction face = context.requireContext(ContextKeys.INTERACTION_FACE);

    // Door can only be placed by clicking in the floor
    if (face != Direction.DOWN) {
        return BehaviorResult.PASS;
    }
    final Location<World> down = location.getBlockRelative(Direction.DOWN);
    final SolidCubeProperty solidProp = down.getProperty(SolidCubeProperty.class).get();
    // The door must be placed on a solid block
    if (!solidProp.getValue()) {
        return BehaviorResult.PASS;
    }
    final Location<World> up = location.getBlockRelative(Direction.UP);
    final ReplaceableProperty replaceableProp = up.getProperty(ReplaceableProperty.class).get();
    if (!replaceableProp.getValue()) {
        return BehaviorResult.PASS;
    }
    final BlockSnapshot snapshot = context.getContext(ContextKeys.BLOCK_SNAPSHOT)
            .orElseThrow(() -> new IllegalStateException("The BlockSnapshotRetrieveBehavior BlockSnapshot isn't present."));
    final BlockSnapshotBuilder builder = BlockSnapshotBuilder.create().from(snapshot);
    context.populateBlockSnapshot(builder, BehaviorContext.PopulationFlags.CREATOR_AND_NOTIFIER);

    Direction facing = Direction.NORTH;
    Vector3i left = Vector3i.UNIT_X;
    final Optional<Entity> optSource = context.first(Entity.class);
    if (optSource.isPresent()) {
        final Entity source = optSource.get();
        final Vector3d rotVector;
        if (source instanceof Living) {
            rotVector = ((Living) source).getHeadRotation();
        } else {
            rotVector = optSource.get().getRotation();
        }

        // Calculate the direction the entity is looking
        final Vector3d dir = Quaternions.fromAxesAnglesDeg(rotVector.mul(-1)).rotate(Vector3d.FORWARD);
        facing = Direction.getClosestHorizontal(dir, Direction.Division.CARDINAL);
        left = LEFT_ANGLE.rotate(facing.asOffset()).toInt();
        facing = facing.getOpposite();
    }

    builder.add(Keys.DIRECTION, facing);
    // TODO: Hinges

    context.addBlockChange(builder.location(location).build());
    context.addBlockChange(builder.add(LanternKeys.DOOR_HALF, LanternDoorHalf.UPPER).location(up).build());
    return BehaviorResult.SUCCESS;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:51,代码来源:DoorBehavior.java


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