Java 类net.minecraft.util.Rotation 实例源码

项目:CustomWorldGen    文件:BlockRotatedPillar.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case COUNTERCLOCKWISE_90:
        case CLOCKWISE_90:

            switch ((EnumFacing.Axis)state.getValue(AXIS))
            {
                case X:
                    return state.withProperty(AXIS, EnumFacing.Axis.Z);
                case Z:
                    return state.withProperty(AXIS, EnumFacing.Axis.X);
                default:
                    return state;
            }

        default:
            return state;
    }
}
项目:CustomWorldGen    文件:BlockLog.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case COUNTERCLOCKWISE_90:
        case CLOCKWISE_90:

            switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
            {
                case X:
                    return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
                case Z:
                    return state.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
                default:
                    return state;
            }

        default:
            return state;
    }
}
项目:harshencastle    文件:HarshenTemplate.java   
public static BlockPos getZeroPositionWithTransform(BlockPos p_191157_0_, Mirror p_191157_1_, Rotation p_191157_2_, int p_191157_3_, int p_191157_4_)
{
    --p_191157_3_;
    --p_191157_4_;
    int i = p_191157_1_ == Mirror.FRONT_BACK ? p_191157_3_ : 0;
    int j = p_191157_1_ == Mirror.LEFT_RIGHT ? p_191157_4_ : 0;
    BlockPos blockpos = p_191157_0_;

    switch (p_191157_2_)
    {
        case COUNTERCLOCKWISE_90:
            blockpos = p_191157_0_.add(j, 0, p_191157_3_ - i);
            break;
        case CLOCKWISE_90:
            blockpos = p_191157_0_.add(p_191157_4_ - j, 0, i);
            break;
        case CLOCKWISE_180:
            blockpos = p_191157_0_.add(p_191157_3_ - i, 0, p_191157_4_ - j);
            break;
        case NONE:
            blockpos = p_191157_0_.add(i, 0, j);
    }

    return blockpos;
}
项目:Backmemed    文件:StructureComponent.java   
protected void setBlockState(World worldIn, IBlockState blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn)
{
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));

    if (boundingboxIn.isVecInside(blockpos))
    {
        if (this.mirror != Mirror.NONE)
        {
            blockstateIn = blockstateIn.withMirror(this.mirror);
        }

        if (this.rotation != Rotation.NONE)
        {
            blockstateIn = blockstateIn.withRotation(this.rotation);
        }

        worldIn.setBlockState(blockpos, blockstateIn, 2);
    }
}
项目:Backmemed    文件:BlockStainedGlassPane.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case CLOCKWISE_180:
            return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));

        case COUNTERCLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));

        case CLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));

        default:
            return state;
    }
}
项目:Backmemed    文件:BlockVine.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case CLOCKWISE_180:
            return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));

        case COUNTERCLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));

        case CLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));

        default:
            return state;
    }
}
项目:Backmemed    文件:BlockRedstoneWire.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case CLOCKWISE_180:
            return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));

        case COUNTERCLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));

        case CLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));

        default:
            return state;
    }
}
项目:Loot-Slash-Conquer    文件:DungeonRoomPosition.java   
public DungeonRoomPosition(BlockPos pos, Template template, Rotation templateRotation, Rotation side, StructureBoundingBox boundingBox)
{
    this.pos = pos;
    this.template = template;
    this.templateRotation = templateRotation;
    this.side = side;
    this.boundingBox = boundingBox;
}
项目:Loot-Slash-Conquer    文件:Dungeon.java   
/** Generates the staircase underneath the entrance. */
// WORKING
private List<DungeonRoomPosition> generateStaircase(TemplateManager manager, World world, BlockPos entranceCenter)
{
    Template encasedStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/encased_staircase"));
    Template bottomStaircase = manager.getTemplate(world.getMinecraftServer(), new ResourceLocation(Reference.MODID, "dungeons/bottom_staircase"));
    PlacementSettings settings = new PlacementSettings();
    int depth = 4; // how many staircases are generated?

    List<DungeonRoomPosition> list = null;

    for (int i = 0; i < depth; i++)
    {
        if (i < depth - 1) // make sure we aren't at the last staircase
        {
            BlockPos encasedStaircasePos = DungeonHelper.translateToCorner(encasedStaircase, entranceCenter.add(0, -4 * (i + 1), 0), Rotation.NONE); // get the staircase position; offset by height and multiply by depth.
            encasedStaircase.addBlocksToWorld(world, encasedStaircasePos, new DungeonBlockProcessor(encasedStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);
        }
        else // we know this is the bottom staircase, so spawn bottom staircase and store potential rooms.
        {
            BlockPos bottomStaircaseCenteredPos = entranceCenter.add(0, -4 * (depth - 1) + -5, 0);
            BlockPos bottomStaircasePos = DungeonHelper.translateToCorner(bottomStaircase, bottomStaircaseCenteredPos, Rotation.NONE);
            bottomStaircase.addBlocksToWorld(world, bottomStaircasePos, new DungeonBlockProcessor(bottomStaircasePos, settings, Blocks.NETHER_BRICK, Blocks.NETHERRACK), settings, 2);
            roomList.add(DungeonHelper.getStructureBoundingBox(bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos)); // add StructureBoundingBox to room list. Used to make sure we don't generate rooms inside of other bounding boxes.

            list = this.generatePotentialRooms(manager, world, bottomStaircase, Rotation.NONE, bottomStaircaseCenteredPos, null);
        }
    }

    return list;
}
项目:Loot-Slash-Conquer    文件:DungeonHelper.java   
public static BlockPos translateWallPos(Template template, BlockPos wallPos, Rotation wallRotation)
{
    int x = wallPos.getX();
    int z = wallPos.getZ();

    if (wallRotation == Rotation.NONE) x += template.getSize().getX() / 2;
    else if (wallRotation == Rotation.CLOCKWISE_90) z += template.getSize().getZ() / 2;
    else if (wallRotation == Rotation.CLOCKWISE_180) x -= template.getSize().getX() / 2;
    else if (wallRotation == Rotation.COUNTERCLOCKWISE_90) z -= template.getSize().getZ() / 2;

    return new BlockPos(x, wallPos.getY(), z);
}
项目:CustomWorldGen    文件:BlockPane.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case CLOCKWISE_180:
            return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));
        case COUNTERCLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));
        case CLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));
        default:
            return state;
    }
}
项目:CustomWorldGen    文件:StructureEndCityPieces.java   
public boolean generate(int p_186185_1_, StructureEndCityPieces.CityTemplate p_186185_2_, BlockPos p_186185_3_, List<StructureComponent> p_186185_4_, Random rand)
{
    if (p_186185_1_ > 8)
    {
        return false;
    }
    else
    {
        Rotation rotation = p_186185_2_.placeSettings.getRotation();
        StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(p_186185_2_, p_186185_3_, "base_floor", rotation, true));
        int i = rand.nextInt(3);

        if (i == 0)
        {
            StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "base_roof", rotation, true));
        }
        else if (i == 1)
        {
            structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor_2", rotation, false));
            structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "second_roof", rotation, false));
            StructureEndCityPieces.recursiveChildren(StructureEndCityPieces.TOWER_GENERATOR, p_186185_1_ + 1, structureendcitypieces$citytemplate, (BlockPos)null, p_186185_4_, rand);
        }
        else if (i == 2)
        {
            structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor_2", rotation, false));
            structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "third_floor_c", rotation, false));
            structureendcitypieces$citytemplate = StructureEndCityPieces.func_189935_b(p_186185_4_, StructureEndCityPieces.addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "third_roof", rotation, true));
            StructureEndCityPieces.recursiveChildren(StructureEndCityPieces.TOWER_GENERATOR, p_186185_1_ + 1, structureendcitypieces$citytemplate, (BlockPos)null, p_186185_4_, rand);
        }

        return true;
    }
}
项目:harshencastle    文件:HarshenTemplate.java   
private static BlockPos transformedBlockPos(BlockPos pos, Mirror mirrorIn, Rotation rotationIn)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();
    boolean flag = true;

    switch (mirrorIn)
    {
        case LEFT_RIGHT:
            k = -k;
            break;
        case FRONT_BACK:
            i = -i;
            break;
        default:
            flag = false;
    }

    switch (rotationIn)
    {
        case COUNTERCLOCKWISE_90:
            return new BlockPos(k, j, -i);
        case CLOCKWISE_90:
            return new BlockPos(-k, j, i);
        case CLOCKWISE_180:
            return new BlockPos(-i, j, -k);
        default:
            return flag ? new BlockPos(i, j, k) : pos;
    }
}
项目:harshencastle    文件:HarshenTemplate.java   
private static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn)
{
    double d0 = vec.x;
    double d1 = vec.y;
    double d2 = vec.z;
    boolean flag = true;

    switch (mirrorIn)
    {
        case LEFT_RIGHT:
            d2 = 1.0D - d2;
            break;
        case FRONT_BACK:
            d0 = 1.0D - d0;
            break;
        default:
            flag = false;
    }

    switch (rotationIn)
    {
        case COUNTERCLOCKWISE_90:
            return new Vec3d(d2, d1, 1.0D - d0);
        case CLOCKWISE_90:
            return new Vec3d(1.0D - d2, d1, d0);
        case CLOCKWISE_180:
            return new Vec3d(1.0D - d0, d1, 1.0D - d2);
        default:
            return flag ? new Vec3d(d0, d1, d2) : vec;
    }
}
项目:Backmemed    文件:TileEntitySkull.java   
public void rotate(Rotation p_189667_1_)
{
    if (this.world != null && this.world.getBlockState(this.getPos()).getValue(BlockSkull.FACING) == EnumFacing.UP)
    {
        this.skullRotation = p_189667_1_.rotate(this.skullRotation, 16);
    }
}
项目:craftsman    文件:Stairs.java   
private Rotation fromFacingForDown(FstPlayer player) {
    EnumFacing facing = player.getAdjustedHorizontalFacing();
    if(facing == EnumFacing.EAST) {
        return Rotation.COUNTERCLOCKWISE_90;
    } 
    else if(facing == EnumFacing.WEST) {
        return Rotation.CLOCKWISE_90;
    }
    else if(facing == EnumFacing.NORTH) {
        return Rotation.CLOCKWISE_180;
    }
    else {
        return Rotation.NONE;
    }
}
项目:PurificatiMagicae    文件:CPacketSpawnMultiblockParticles.java   
@Override
public void fromBytes(ByteBuf buf)
{
    pos = ByteBufTools.readBlockPos(buf);
    multiblockId = new ResourceLocation(ByteBufUtils.readUTF8String(buf));
    rot = Rotation.values()[buf.readInt()];
}
项目:PurificatiMagicae    文件:MultiblockRegistry.java   
public static void setup()
{
    {
        BlockArray arr = new BlockArray();
        BlockArrayEntry rope = new BlockArrayEntry(BlockRegistry.rope_coil.getDefaultState().withProperty(AxisController.AXIS, EnumFacing.Axis.Z), new ItemStack(ItemRegistry.rope_coil));
        BlockArrayEntry rope_cog = new BlockArrayEntry(BlockRegistry.rope_coil.getDefaultState().withProperty(AxisController.AXIS, EnumFacing.Axis.Z).withProperty(BlockRopeCoil.TYPE, BlockRopeCoil.Type.COG), new ItemStack(ItemRegistry.rope_coil, 1, 1));

        arr.getCheckers().add((BlockArrayEntry entr, IBlockState state, IBlockState worldState, World w, BlockPos pos, Rotation rot) ->
        {
            for(IProperty<?> prop : state.getPropertyKeys())
            {
                if(prop == BlockAnvil.DAMAGE || prop == BlockRopeCoil.TYPE)
                    return state.getValue(prop).equals(worldState.getValue(prop));
            }
            return true;
        });
        arr.getMap().putAll(CollectionUtils.createMap(BlockPos.class, BlockArrayEntry.class,
                new BlockPos(0, 0, 0), new BlockArrayEntry(Blocks.ANVIL, new ItemStack(Blocks.ANVIL)),
                new BlockPos(0, 2, 0), rope,
                new BlockPos(1, 2, 0), rope,
                new BlockPos(1, 0, 0), rope_cog,
                new BlockPos(2, 0, 0), new BlockArrayEntry(Blocks.LEVER.getDefaultState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.UP_X).withProperty(BlockLever.POWERED, true), new ItemStack(Blocks.LEVER)),
                new BlockPos(1, 0, 1), new BlockArrayEntry(Blocks.LEVER.getDefaultState().withProperty(BlockLever.FACING, BlockLever.EnumOrientation.SOUTH), new ItemStack(Blocks.LEVER))
        ));
        Multiblock.REGISTRY.register(STONE_CRUSHER = new PMMultiblock(0, arr, new BlockPos(1, 0, 0), BlockRegistry.stone_crusher.getDefaultState(), new ModelResourceLocation(Utils.gRL("stone_crusher"), "normal"), Utils.gRL("stone_crusher")));
    }
}
项目:PurificatiMagicae    文件:PMMultiblock.java   
@Override
public Optional<Rotation> checkMultiblock(World w, BlockPos pos, @Nullable EntityPlayer p, @Nullable EnumHand hand)
{
    if(p != null && hand != null)
    {
        ItemStack st = p.getHeldItem(hand);
        if(!(st.getItem() instanceof ItemTinkeringKit && ((ItemTinkeringKit) st.getItem()).getTier() >= getTier()))
        {
            return Optional.empty();
        }
    }
    return super.checkMultiblock(w, pos, p, hand);
}
项目:PurificatiMagicae    文件:WGLabMedium.java   
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
    if (dimList.contains(world.provider.getDimension()) == dimListMode)
    {
        if (random.nextFloat() <= chance)
        {
            int x = chunkX * 16 + 16;
            int z = chunkZ * 16 + 16;
            BlockPos pos = new BlockPos(x, world.getHeight(x, z) - 1, z);
            if (pos.getY() >= minY && pos.getY() <= maxY)
            {
                try
                {
                    NBTTagCompound tag = StructureApi.INSTANCE.getStructureNbt(Utils.gRL("lab_medium"));
                    PurMag.INSTANCE.debug("WG START [lab_medium]");
                    StructureApi.INSTANCE.spawnStructure(tag, pos, null, Rotation.values()[random.nextInt(Rotation.values().length)], (WorldServer) world, random);
                    PurMag.INSTANCE.debug("WG END AT " + pos);
                }
                catch (IOException e)
                {
                    PurMag.INSTANCE.log.error("An IOException occurred when spawning the small lab structure!", e);
                }
            }
        }
    }
}
项目:UniversalRemote    文件:EntityPlayerMPProxy.java   
@Override
public float getRotatedYaw(Rotation transformRotation) {
    if (m_realPlayer == null) {
        return super.getRotatedYaw(transformRotation);
    } else {
        syncToRealPlayer();
        return syncPublicFieldsFromRealAndReturn(m_realPlayer.getRotatedYaw(transformRotation));
    }
}
项目:Solar    文件:FacingHelper.java   
public static Rotation getHorizontalRotation(EnumFacing from, EnumFacing to) {
    if(from.getAxis().isVertical() || to.getAxis().isVertical()) return Rotation.NONE;
    if(from.getOpposite() == to) {
        return Rotation.CLOCKWISE_180;
    } else if(from != to) {
        int indexFrom = from.getHorizontalIndex();
        int indexTo = to.getHorizontalIndex();
        if(indexFrom < indexTo || (indexFrom == 3 && indexTo == 0)) {
            return Rotation.CLOCKWISE_90;
        } else {
            return Rotation.COUNTERCLOCKWISE_90;
        }
    }
    return Rotation.NONE;
}
项目:CustomWorldGen    文件:StructureEndCityPieces.java   
private static StructureEndCityPieces.CityTemplate addPiece(StructureEndCityPieces.CityTemplate p_186189_0_, BlockPos p_186189_1_, String p_186189_2_, Rotation p_186189_3_, boolean p_186189_4_)
{
    StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = new StructureEndCityPieces.CityTemplate(p_186189_2_, p_186189_0_.templatePosition, p_186189_3_, p_186189_4_);
    BlockPos blockpos = p_186189_0_.template.calculateConnectedPos(p_186189_0_.placeSettings, p_186189_1_, structureendcitypieces$citytemplate.placeSettings, BlockPos.ORIGIN);
    structureendcitypieces$citytemplate.offset(blockpos.getX(), blockpos.getY(), blockpos.getZ());
    return structureendcitypieces$citytemplate;
}
项目:Solar    文件:ObeliskDecorator.java   
@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
    random.setSeed(world.getSeed());
    long good = random.nextLong();
    long succ = random.nextLong();

    good *= x >> 3;
    succ *= z >> 3;
    random.setSeed(good * succ * world.getSeed());
    //Generate
    if(GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity > 0D
            && GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.rarity / 100D > random.nextDouble()) {
        List<AxisAlignedBB> occupied = Lists.newArrayList();
        for(int i = 0; i < GEN_CONFIG.MONOLITH_CONFIG.OBELISK_DECORATOR.size; i++) {
            BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
            int below = random.nextInt(7);
            if(top.getY() > below) {
                top = top.add(0, -below, 0);
            }
            Template obelisk = obelisks.next().load(world);
            Rotation rotation = Rotation.values()[random.nextInt(4)];
            Vector3 vec = Vector3.create(obelisk.getSize()).rotate(rotation);
            AxisAlignedBB obeliskBB = new AxisAlignedBB(top, vec.add(top).toBlockPos()).grow(1);
            if(occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
                PlacementSettings settings = new PlacementSettings();
                settings.setRotation(rotation);
                settings.setRandom(random);
                obelisk.addBlocksToWorld(world, top, settings);

                occupied.add(obeliskBB);
            }
        }
    }
}
项目:CustomWorldGen    文件:StructureEndCityPieces.java   
public CityTemplate(String pieceNameIn, BlockPos pos, Rotation rot, boolean p_i46634_4_)
{
    super(0);
    this.pieceName = pieceNameIn;
    this.rotation = rot;
    this.overwrite = p_i46634_4_;
    this.loadAndSetup(pos);
}
项目:CustomWorldGen    文件:StructureComponent.java   
public void setCoordBaseMode(@Nullable EnumFacing facing)
{
    this.coordBaseMode = facing;

    if (facing == null)
    {
        this.rotation = Rotation.NONE;
        this.mirror = Mirror.NONE;
    }
    else
    {
        switch (facing)
        {
            case SOUTH:
                this.mirror = Mirror.LEFT_RIGHT;
                this.rotation = Rotation.NONE;
                break;
            case WEST:
                this.mirror = Mirror.LEFT_RIGHT;
                this.rotation = Rotation.CLOCKWISE_90;
                break;
            case EAST:
                this.mirror = Mirror.NONE;
                this.rotation = Rotation.CLOCKWISE_90;
                break;
            default:
                this.mirror = Mirror.NONE;
                this.rotation = Rotation.NONE;
        }
    }
}
项目:CustomWorldGen    文件:BlockTripWire.java   
/**
 * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withRotation(IBlockState state, Rotation rot)
{
    switch (rot)
    {
        case CLOCKWISE_180:
            return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(EAST, state.getValue(WEST)).withProperty(SOUTH, state.getValue(NORTH)).withProperty(WEST, state.getValue(EAST));
        case COUNTERCLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(EAST)).withProperty(EAST, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(WEST)).withProperty(WEST, state.getValue(NORTH));
        case CLOCKWISE_90:
            return state.withProperty(NORTH, state.getValue(WEST)).withProperty(EAST, state.getValue(NORTH)).withProperty(SOUTH, state.getValue(EAST)).withProperty(WEST, state.getValue(SOUTH));
        default:
            return state;
    }
}
项目:Backmemed    文件:StructureEndCityPieces.java   
public CityTemplate(TemplateManager p_i47214_1_, String p_i47214_2_, BlockPos p_i47214_3_, Rotation p_i47214_4_, boolean p_i47214_5_)
{
    super(0);
    this.pieceName = p_i47214_2_;
    this.templatePosition = p_i47214_3_;
    this.rotation = p_i47214_4_;
    this.overwrite = p_i47214_5_;
    this.func_191085_a(p_i47214_1_);
}
项目:Backmemed    文件:StructureEndCityPieces.java   
protected void readStructureFromNBT(NBTTagCompound tagCompound, TemplateManager p_143011_2_)
{
    super.readStructureFromNBT(tagCompound, p_143011_2_);
    this.pieceName = tagCompound.getString("Template");
    this.rotation = Rotation.valueOf(tagCompound.getString("Rot"));
    this.overwrite = tagCompound.getBoolean("OW");
    this.func_191085_a(p_143011_2_);
}
项目:Backmemed    文件:StructureComponent.java   
public void setCoordBaseMode(@Nullable EnumFacing facing)
{
    this.coordBaseMode = facing;

    if (facing == null)
    {
        this.rotation = Rotation.NONE;
        this.mirror = Mirror.NONE;
    }
    else
    {
        switch (facing)
        {
            case SOUTH:
                this.mirror = Mirror.LEFT_RIGHT;
                this.rotation = Rotation.NONE;
                break;

            case WEST:
                this.mirror = Mirror.LEFT_RIGHT;
                this.rotation = Rotation.CLOCKWISE_90;
                break;

            case EAST:
                this.mirror = Mirror.NONE;
                this.rotation = Rotation.CLOCKWISE_90;
                break;

            default:
                this.mirror = Mirror.NONE;
                this.rotation = Rotation.NONE;
        }
    }
}
项目:Backmemed    文件:Template.java   
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch);
                worldIn.spawnEntityInWorld(entity);
            }
        }
    }
}
项目:Backmemed    文件:Template.java   
private static BlockPos transformedBlockPos(BlockPos pos, Mirror mirrorIn, Rotation rotationIn)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();
    boolean flag = true;

    switch (mirrorIn)
    {
        case LEFT_RIGHT:
            k = -k;
            break;

        case FRONT_BACK:
            i = -i;
            break;

        default:
            flag = false;
    }

    switch (rotationIn)
    {
        case COUNTERCLOCKWISE_90:
            return new BlockPos(k, j, -i);

        case CLOCKWISE_90:
            return new BlockPos(-k, j, i);

        case CLOCKWISE_180:
            return new BlockPos(-i, j, -k);

        default:
            return flag ? new BlockPos(i, j, k) : pos;
    }
}
项目:Backmemed    文件:Template.java   
private static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn)
{
    double d0 = vec.xCoord;
    double d1 = vec.yCoord;
    double d2 = vec.zCoord;
    boolean flag = true;

    switch (mirrorIn)
    {
        case LEFT_RIGHT:
            d2 = 1.0D - d2;
            break;

        case FRONT_BACK:
            d0 = 1.0D - d0;
            break;

        default:
            flag = false;
    }

    switch (rotationIn)
    {
        case COUNTERCLOCKWISE_90:
            return new Vec3d(d2, d1, 1.0D - d0);

        case CLOCKWISE_90:
            return new Vec3d(1.0D - d2, d1, d0);

        case CLOCKWISE_180:
            return new Vec3d(1.0D - d0, d1, 1.0D - d2);

        default:
            return flag ? new Vec3d(d0, d1, d2) : vec;
    }
}
项目:Backmemed    文件:Template.java   
public static BlockPos func_191157_a(BlockPos p_191157_0_, Mirror p_191157_1_, Rotation p_191157_2_, int p_191157_3_, int p_191157_4_)
{
    --p_191157_3_;
    --p_191157_4_;
    int i = p_191157_1_ == Mirror.FRONT_BACK ? p_191157_3_ : 0;
    int j = p_191157_1_ == Mirror.LEFT_RIGHT ? p_191157_4_ : 0;
    BlockPos blockpos = p_191157_0_;

    switch (p_191157_2_)
    {
        case COUNTERCLOCKWISE_90:
            blockpos = p_191157_0_.add(j, 0, p_191157_3_ - i);
            break;

        case CLOCKWISE_90:
            blockpos = p_191157_0_.add(p_191157_4_ - j, 0, i);
            break;

        case CLOCKWISE_180:
            blockpos = p_191157_0_.add(p_191157_3_ - i, 0, p_191157_4_ - j);
            break;

        case NONE:
            blockpos = p_191157_0_.add(i, 0, j);
    }

    return blockpos;
}
项目:CustomWorldGen    文件:TileEntitySkull.java   
public void rotate(Rotation p_189667_1_)
{
    if (this.worldObj != null && this.worldObj.getBlockState(this.getPos()).getValue(BlockSkull.FACING) == EnumFacing.UP)
    {
        this.skullRotation = p_189667_1_.rotate(this.skullRotation, 16);
    }
}
项目:Backmemed    文件:WoodlandMansionPieces.java   
public MansionTemplate(TemplateManager p_i47356_1_, String p_i47356_2_, BlockPos p_i47356_3_, Rotation p_i47356_4_, Mirror p_i47356_5_)
{
    super(0);
    this.field_191082_d = p_i47356_2_;
    this.templatePosition = p_i47356_3_;
    this.field_191083_e = p_i47356_4_;
    this.field_191084_f = p_i47356_5_;
    this.func_191081_a(p_i47356_1_);
}
项目:Backmemed    文件:WoodlandMansionPieces.java   
private void func_191124_c(List<WoodlandMansionPieces.MansionTemplate> p_191124_1_, WoodlandMansionPieces.PlacementData p_191124_2_)
{
    p_191124_2_.field_191139_b = p_191124_2_.field_191139_b.offset(p_191124_2_.field_191138_a.rotate(EnumFacing.SOUTH), -1);
    p_191124_1_.add(new WoodlandMansionPieces.MansionTemplate(this.field_191134_a, "wall_corner", p_191124_2_.field_191139_b, p_191124_2_.field_191138_a));
    p_191124_2_.field_191139_b = p_191124_2_.field_191139_b.offset(p_191124_2_.field_191138_a.rotate(EnumFacing.SOUTH), -7);
    p_191124_2_.field_191139_b = p_191124_2_.field_191139_b.offset(p_191124_2_.field_191138_a.rotate(EnumFacing.WEST), -6);
    p_191124_2_.field_191138_a = p_191124_2_.field_191138_a.add(Rotation.CLOCKWISE_90);
}
项目:Backmemed    文件:WoodlandMansionPieces.java   
private void func_191129_a(List<WoodlandMansionPieces.MansionTemplate> p_191129_1_, BlockPos p_191129_2_, Rotation p_191129_3_, EnumFacing p_191129_4_, WoodlandMansionPieces.RoomCollection p_191129_5_)
{
    Rotation rotation = Rotation.NONE;
    String s = p_191129_5_.func_191104_a(this.field_191135_b);

    if (p_191129_4_ != EnumFacing.EAST)
    {
        if (p_191129_4_ == EnumFacing.NORTH)
        {
            rotation = rotation.add(Rotation.COUNTERCLOCKWISE_90);
        }
        else if (p_191129_4_ == EnumFacing.WEST)
        {
            rotation = rotation.add(Rotation.CLOCKWISE_180);
        }
        else if (p_191129_4_ == EnumFacing.SOUTH)
        {
            rotation = rotation.add(Rotation.CLOCKWISE_90);
        }
        else
        {
            s = p_191129_5_.func_191099_b(this.field_191135_b);
        }
    }

    BlockPos blockpos = Template.func_191157_a(new BlockPos(1, 0, 0), Mirror.NONE, rotation, 7, 7);
    rotation = rotation.add(p_191129_3_);
    blockpos = blockpos.func_190942_a(p_191129_3_);
    BlockPos blockpos1 = p_191129_2_.add(blockpos.getX(), 0, blockpos.getZ());
    p_191129_1_.add(new WoodlandMansionPieces.MansionTemplate(this.field_191134_a, s, blockpos1, rotation));
}
项目:Backmemed    文件:WorldGenFossils.java   
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L);
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();
    Rotation[] arotation = Rotation.values();
    Rotation rotation = arotation[random.nextInt(arotation.length)];
    int i = random.nextInt(FOSSILS.length);
    TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
    Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]);
    Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]);
    ChunkPos chunkpos = new ChunkPos(position);
    StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
    PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random);
    BlockPos blockpos = template.transformedSize(rotation);
    int j = random.nextInt(16 - blockpos.getX());
    int k = random.nextInt(16 - blockpos.getZ());
    int l = 256;

    for (int i1 = 0; i1 < blockpos.getX(); ++i1)
    {
        for (int j1 = 0; j1 < blockpos.getX(); ++j1)
        {
            l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k));
        }
    }

    int k1 = Math.max(l - 15 - random.nextInt(10), 10);
    BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation);
    placementsettings.setIntegrity(0.9F);
    template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
    placementsettings.setIntegrity(0.1F);
    template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20);
    return true;
}
项目:CustomWorldGen    文件:StructureEndCityPieces.java   
public static void beginHouseTower(BlockPos p_186190_0_, Rotation p_186190_1_, List<StructureComponent> p_186190_2_, Random p_186190_3_)
{
    FAT_TOWER_GENERATOR.init();
    HOUSE_TOWER_GENERATOR.init();
    TOWER_BRIDGE_GENERATOR.init();
    TOWER_GENERATOR.init();
    StructureEndCityPieces.CityTemplate structureendcitypieces$citytemplate = func_189935_b(p_186190_2_, new StructureEndCityPieces.CityTemplate("base_floor", p_186190_0_, p_186190_1_, true));
    structureendcitypieces$citytemplate = func_189935_b(p_186190_2_, addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 0, -1), "second_floor", p_186190_1_, false));
    structureendcitypieces$citytemplate = func_189935_b(p_186190_2_, addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 4, -1), "third_floor", p_186190_1_, false));
    structureendcitypieces$citytemplate = func_189935_b(p_186190_2_, addPiece(structureendcitypieces$citytemplate, new BlockPos(-1, 8, -1), "third_roof", p_186190_1_, true));
    recursiveChildren(TOWER_GENERATOR, 1, structureendcitypieces$citytemplate, (BlockPos)null, p_186190_2_, p_186190_3_);
}