net.minecraft.util.Direction#UP源码实例Demo

下面列出了net.minecraft.util.Direction#UP 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CodeChickenLib   文件: CustomParticleHandler.java
@OnlyIn (Dist.CLIENT)
public static boolean handleRunningEffects(World world, BlockPos pos, BlockState state, Entity entity) {
    //Spoof a raytrace from the feet.
    BlockRayTraceResult traceResult = new BlockRayTraceResult(entity.getPositionVec().add(0, 1, 0), Direction.UP, pos, false);
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        ParticleManager particleManager = Minecraft.getInstance().particles;
        List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData));
        TextureAtlasSprite rolledSprite = sprites.get(world.rand.nextInt(sprites.size()));
        double x = entity.getPosX() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        double y = entity.getBoundingBox().minY + 0.1D;
        double z = entity.getPosZ() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        particleManager.addEffect(new CustomBreakingParticle(world, x, y, z, -entity.getMotion().x * 4.0D, 1.5D, -entity.getMotion().z * 4.0D, rolledSprite));
        return true;
    }

    return false;
}
 
源代码2 项目: CodeChickenLib   文件: CustomParticleHandler.java
@OnlyIn (Dist.CLIENT)
public static void addLandingEffects(World world, BlockPos pos, BlockState state, Vector3 entityPos, int numParticles) {
    //Spoof a raytrace from the feet.
    BlockRayTraceResult traceResult = new BlockRayTraceResult(new Vec3d(entityPos.x, pos.getY() + 1, entityPos.z), Direction.UP, pos, false);
    ParticleManager manager = Minecraft.getInstance().particles;
    Random randy = new Random();
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData));

        double speed = 0.15000000596046448D;
        if (numParticles != 0) {
            for (int i = 0; i < numParticles; i++) {
                double mX = randy.nextGaussian() * speed;
                double mY = randy.nextGaussian() * speed;
                double mZ = randy.nextGaussian() * speed;
                manager.addEffect(CustomBreakingParticle.newLandingParticle(world, entityPos.x, entityPos.y, entityPos.z, mX, mY, mZ, sprites.get(randy.nextInt(sprites.size()))));
            }
        }
    }
}
 
源代码3 项目: CodeChickenLib   文件: RotationUtils.java
/**
 * Gets rotation for placing a block, Will use Up and Down.
 *
 * @param pos    Pos placement is happening.
 * @param entity Entity placing block.
 * @return Direction placed.
 */
public static Direction getPlacedRotation(BlockPos pos, LivingEntity entity) {
    int entityRotation = (int) Math.floor(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    if (Math.abs(entity.getPosX() - pos.getX()) < 2.0D && Math.abs(entity.getPosZ() - pos.getZ()) < 2.0D) {

        double eyeDistance = entity.getPosY() + 1.82D - pos.getY();

        if (eyeDistance > 2.0D) {
            return Direction.DOWN;
        }

        if (eyeDistance < 0.0D) {
            return Direction.UP;
        }
    }

    return entityRotationToSide(entityRotation);
}
 
源代码4 项目: CodeChickenLib   文件: RotationUtils.java
/**
 * Rotate this Facing around all axises counter-clockwise (NORTH => SOUTH => EAST => WEST => UP => DOWN => NORTH)
 *
 * @param facing Current facing.
 * @return Next facing.
 */
public static Direction rotateForward(Direction facing) {
    switch (facing) {
        case NORTH:
            return Direction.DOWN;
        case DOWN:
            return Direction.UP;
        case UP:
            return Direction.WEST;
        case WEST:
            return Direction.EAST;
        case EAST:
            return Direction.SOUTH;
        case SOUTH:
            return Direction.NORTH;
    }
    return Direction.NORTH;
}
 
源代码5 项目: CodeChickenLib   文件: RotationUtils.java
/**
 * Rotate this Facing around all axises counter-clockwise (NORTH => DOWN => UP => WEST => EAST => SOUTH => NORTH)
 *
 * @param facing Current facing.
 * @return Next facing.
 */
public static Direction rotateBackwards(Direction facing) {
    switch (facing) {
        case NORTH:
            return Direction.SOUTH;
        case SOUTH:
            return Direction.EAST;
        case EAST:
            return Direction.WEST;
        case WEST:
            return Direction.UP;
        case UP:
            return Direction.DOWN;
        case DOWN:
            return Direction.NORTH;
    }
    return Direction.NORTH;
}
 
源代码6 项目: CodeChickenLib   文件: VectorUtils.java
/**
 * Calculates the EnumFacing for a given normal.
 *
 * @param normal The normal to calculate from.
 * @return The direction the normal is facing.
 */
public static Direction calcNormalSide(Vector3 normal) {
    if (normal.y <= -0.99) {
        return Direction.DOWN;
    }
    if (normal.y >= 0.99) {
        return Direction.UP;
    }
    if (normal.z <= -0.99) {
        return Direction.NORTH;
    }
    if (normal.z >= 0.99) {
        return Direction.SOUTH;
    }
    if (normal.x <= -0.99) {
        return Direction.WEST;
    }
    if (normal.x >= 0.99) {
        return Direction.EAST;
    }
    return null;
}
 
源代码7 项目: MiningGadgets   文件: MiningCollect.java
public static List<BlockPos> collect(PlayerEntity player, BlockRayTraceResult startBlock, World world, int range) {
    List<BlockPos> coordinates = new ArrayList<>();
    BlockPos startPos = startBlock.getPos();

    if (range == 1) {
        if( !isValid(player, startBlock.getPos(), world) )
            return coordinates;

        coordinates.add(startBlock.getPos());
        return coordinates;
    }

    Direction side = startBlock.getFace();
    boolean vertical = side.getAxis().isVertical();
    Direction up = vertical ? player.getHorizontalFacing() : Direction.UP;
    Direction down = up.getOpposite();
    Direction right = vertical ? up.rotateY() : side.rotateYCCW();
    Direction left = right.getOpposite();

    coordinates.add(startPos.offset(up).offset(left));
    coordinates.add(startPos.offset(up));
    coordinates.add(startPos.offset(up).offset(right));
    coordinates.add(startPos.offset(left));
    coordinates.add(startPos);
    coordinates.add(startPos.offset(right));
    coordinates.add(startPos.offset(down).offset(left));
    coordinates.add(startPos.offset(down));
    coordinates.add(startPos.offset(down).offset(right));

    return coordinates.stream().filter(e -> isValid(player, e, world)).collect(Collectors.toList());
}
 
源代码8 项目: CodeChickenLib   文件: CustomParticleHandler.java
@OnlyIn (Dist.CLIENT)
public static void addBlockHitEffects(World world, Cuboid6 bounds, Direction side, TextureAtlasSprite icon, ParticleManager particleManager) {
    float border = 0.1F;
    Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border);
    diff.x *= world.rand.nextDouble();
    diff.y *= world.rand.nextDouble();
    diff.z *= world.rand.nextDouble();
    Vector3 pos = diff.add(bounds.min).add(border);

    if (side == Direction.DOWN) {
        diff.y = bounds.min.y - border;
    }
    if (side == Direction.UP) {
        diff.y = bounds.max.y + border;
    }
    if (side == Direction.NORTH) {
        diff.z = bounds.min.z - border;
    }
    if (side == Direction.SOUTH) {
        diff.z = bounds.max.z + border;
    }
    if (side == Direction.WEST) {
        diff.x = bounds.min.x - border;
    }
    if (side == Direction.EAST) {
        diff.x = bounds.max.x + border;
    }

    particleManager.addEffect(new CustomBreakingParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
}
 
源代码9 项目: Survivalist   文件: SawmillTileEntity.java
@Override
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing)
{
    if (capability == ITEMS_CAP)
    {
        if (facing == Direction.UP) return top_provider.cast();
        if (facing == Direction.DOWN) return bottom_provider.cast();
        if (facing != null) return sides_provider.cast();
        return combined_provider.cast();
    }

    return super.getCapability(capability, facing);
}