类net.minecraft.util.Mirror源码实例Demo

下面列出了怎么用net.minecraft.util.Mirror的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: GregTech   文件: WorldGenAbandonedBase.java
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (ConfigHolder.abandonedBaseRarity == 0 ||
        world.getWorldType() == WorldType.FLAT ||
        world.provider.getDimensionType() != DimensionType.OVERWORLD ||
        !world.getWorldInfo().isMapFeaturesEnabled()) {
        return; //do not generate in flat worlds, or in non-surface worlds
    }
    BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8);

    if (random.nextInt(ConfigHolder.abandonedBaseRarity) == 0) {
        int variantNumber = random.nextInt(3);
        Rotation rotation = Rotation.values()[random.nextInt(Rotation.values().length)];
        ResourceLocation templateId = new ResourceLocation(GTValues.MODID, "abandoned_base/abandoned_base_1_" + variantNumber);
        Template template = TemplateManager.getBuiltinTemplate(world, templateId);
        BlockPos originPos = template.getZeroPositionWithTransform(randomPos, Mirror.NONE, rotation);
        originPos = TemplateManager.calculateAverageGroundLevel(world, originPos, template.getSize());
        template.addBlocksToWorld(world, originPos, new PlacementSettings().setRotation(rotation));
    }
}
 
源代码2 项目: litematica   文件: PositionUtils.java
public static float getMirroredYaw(float yaw, Mirror mirror)
{
    yaw = MathHelper.wrapDegrees(yaw);

    switch (mirror)
    {
        case LEFT_RIGHT:
            yaw = 180.0F - yaw;
            break;
        case FRONT_BACK:
            yaw = -yaw;
            break;
        default:
    }

    return yaw;
}
 
源代码3 项目: litematica   文件: SchematicPlacementManager.java
public void setSubRegionMirror(SchematicPlacement placement, String regionName, Mirror mirror, IMessageConsumer feedback)
{
    if (placement.isLocked())
    {
        feedback.addMessage(MessageType.ERROR, "litematica.message.placement.cant_modify_is_locked");
        return;
    }

    SubRegionPlacement subPlacement = placement.getRelativeSubRegionPlacement(regionName);

    if (subPlacement != null)
    {
        this.onPrePlacementChange(placement);
        placement.setSubRegionMirror(regionName, mirror);
        this.onPlacementRegionModified(placement);
    }
}
 
源代码4 项目: litematica   文件: SchematicPlacingUtils.java
public static void rotateEntity(Entity entity, double x, double y, double z, Rotation rotationCombined, Mirror mirrorMain, Mirror mirrorSub)
{
    float rotationYaw = entity.rotationYaw;

    if (mirrorMain != Mirror.NONE)          { rotationYaw = entity.getMirroredYaw(mirrorMain); }
    if (mirrorSub != Mirror.NONE)           { rotationYaw = entity.getMirroredYaw(mirrorSub); }
    if (rotationCombined != Rotation.NONE)  { rotationYaw += entity.rotationYaw - entity.getRotatedYaw(rotationCombined); }

    entity.setLocationAndAngles(x, y, z, rotationYaw, entity.rotationPitch);

    entity.prevRotationYaw = rotationYaw;
    entity.prevRotationPitch = entity.rotationPitch;

    if (entity instanceof EntityLivingBase)
    {
        EntityLivingBase livingBase = (EntityLivingBase) entity;
        livingBase.rotationYawHead = rotationYaw;
        livingBase.prevRotationYawHead = rotationYaw;
        livingBase.renderYawOffset = rotationYaw;
        livingBase.prevRenderYawOffset = rotationYaw;
    }
}
 
源代码5 项目: TofuCraftReload   文件: TofuCastlePiece.java
private TofuCastleTemplate(TemplateManager manager, BlockPos pos, Rotation rotation, Mirror mirror, String templateName) {
    super(0);
    this.templatePosition = pos;
    this.rotation = rotation;
    this.mirror = mirror;
    this.templateName = templateName;
    this.loadTemplate(manager);
}
 
源代码6 项目: TofuCraftReload   文件: TofuCastlePiece.java
@Override
protected void readStructureFromNBT(NBTTagCompound compound, TemplateManager manager) {
    super.readStructureFromNBT(compound, manager);
    this.isAleadyBossRoomGen = compound.getBoolean("BossRoom");
    this.templateName = compound.getString("Template");
    this.rotation = Rotation.valueOf(compound.getString("Rot"));
    this.mirror = Mirror.valueOf(compound.getString("Mi"));
    this.loadTemplate(manager);
}
 
源代码7 项目: enderutilities   文件: TemplateEnderUtilities.java
public void placeBlockAtIndex(World world, int index, BlockPos posStart)
{
    if (index < this.blocks.size())
    {
        TemplateEnderUtilities.TemplateBlockInfo blockInfo = this.blocks.get(index);

        BlockPos pos = transformedBlockPos(this.placement, blockInfo.pos).add(posStart);
        IBlockState stateNew = blockInfo.blockState;

        if (this.replaceMode == ReplaceMode.EVERYTHING ||
            (this.replaceMode == ReplaceMode.WITH_NON_AIR && stateNew.getMaterial() != Material.AIR) || world.isAirBlock(pos))
        {
            Mirror mirror = this.placement.getMirror();
            Rotation rotation = this.placement.getRotation();
            stateNew = stateNew.withMirror(mirror).withRotation(rotation);

            boolean success = false;

            if (this.dropOldBlocks)
            {
                world.destroyBlock(pos, true);
            }
            /*
            else
            {
                // Replace the block temporarily so that the old TE gets cleared for sure
                BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 4);
            }
            */

            // Place the new block
            success = world.setBlockState(pos, stateNew, 2);

            if (success && blockInfo.tileEntityData != null)
            {
                TileUtils.createAndAddTileEntity(world, pos, blockInfo.tileEntityData, rotation, mirror);
            }
        }
    }
}
 
源代码8 项目: litematica   文件: PositionUtils.java
/**
 * Mirrors and then rotates the given position around the origin
 */
public static BlockPos getTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation)
{
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    boolean isMirrored = true;

    switch (mirror)
    {
        // LEFT_RIGHT is essentially NORTH_SOUTH
        case LEFT_RIGHT:
            z = -z;
            break;
        // FRONT_BACK is essentially EAST_WEST
        case FRONT_BACK:
            x = -x;
            break;
        default:
            isMirrored = false;
    }

    switch (rotation)
    {
        case CLOCKWISE_90:
            return new BlockPos(-z, y,  x);
        case COUNTERCLOCKWISE_90:
            return new BlockPos( z, y, -x);
        case CLOCKWISE_180:
            return new BlockPos(-x, y, -z);
        default:
            return isMirrored ? new BlockPos(x, y, z) : pos;
    }
}
 
源代码9 项目: litematica   文件: PositionUtils.java
public static Vec3d getTransformedPosition(Vec3d originalPos, Mirror mirror, Rotation rotation)
{
    double x = originalPos.x;
    double y = originalPos.y;
    double z = originalPos.z;
    boolean transformed = true;

    switch (mirror)
    {
        case LEFT_RIGHT:
            z = 1.0D - z;
            break;
        case FRONT_BACK:
            x = 1.0D - x;
            break;
        default:
            transformed = false;
    }

    switch (rotation)
    {
        case COUNTERCLOCKWISE_90:
            return new Vec3d(z, y, 1.0D - x);
        case CLOCKWISE_90:
            return new Vec3d(1.0D - z, y, x);
        case CLOCKWISE_180:
            return new Vec3d(1.0D - x, y, 1.0D - z);
        default:
            return transformed ? new Vec3d(x, y, z) : originalPos;
    }
}
 
源代码10 项目: litematica   文件: PositionUtils.java
public static String getMirrorName(Mirror mirror)
{
    switch (mirror)
    {
        case FRONT_BACK:    return "FRONT_BACK";
        case LEFT_RIGHT:    return "LEFT_RIGHT";
        case NONE:
        default:            return "NONE";
    }
}
 
源代码11 项目: litematica   文件: SchematicPlacementManager.java
public void setMirror(SchematicPlacement placement, Mirror mirror, IMessageConsumer feedback)
{
    if (placement.isLocked())
    {
        feedback.addMessage(MessageType.ERROR, "litematica.message.placement.cant_modify_is_locked");
        return;
    }

    if (placement.getMirror() != mirror)
    {
        this.onPrePlacementChange(placement);
        placement.setMirror(mirror);
        this.onPlacementModified(placement);
    }
}
 
源代码12 项目: litematica   文件: SubRegionPlacement.java
void resetToOriginalValues()
{
    this.pos = this.defaultPos;
    this.rotation = Rotation.NONE;
    this.mirror = Mirror.NONE;
    this.enabled = true;
    this.ignoreEntities = false;
}
 
源代码13 项目: litematica   文件: SubRegionPlacement.java
public boolean isRegionPlacementModified(BlockPos originalPosition)
{
    return this.isEnabled() == false ||
           this.ignoreEntities() ||
           this.getMirror() != Mirror.NONE ||
           this.getRotation() != Rotation.NONE ||
           this.getPos().equals(originalPosition) == false;
}
 
源代码14 项目: litematica   文件: SchematicPlacement.java
void setSubRegionMirror(String regionName, Mirror mirror)
{
    SubRegionPlacement subRegion = this.relativeSubRegionPlacements.get(regionName);

    if (subRegion != null)
    {
        subRegion.setMirror(mirror);
    }
}
 
源代码15 项目: litematica   文件: SchematicUtils.java
public static IBlockState getUntransformedBlockState(IBlockState state, SchematicPlacement schematicPlacement, String subRegionName)
{
    SubRegionPlacement placement = schematicPlacement.getRelativeSubRegionPlacement(subRegionName);

    if (placement != null)
    {
        final Rotation rotationCombined = PositionUtils.getReverseRotation(schematicPlacement.getRotation().add(placement.getRotation()));
        final Mirror mirrorMain = schematicPlacement.getMirror();
        Mirror mirrorSub = placement.getMirror();

        if (mirrorSub != Mirror.NONE &&
            (schematicPlacement.getRotation() == Rotation.CLOCKWISE_90 ||
             schematicPlacement.getRotation() == Rotation.COUNTERCLOCKWISE_90))
        {
            mirrorSub = mirrorSub == Mirror.FRONT_BACK ? Mirror.LEFT_RIGHT : Mirror.FRONT_BACK;
        }

        if (rotationCombined != Rotation.NONE)
        {
            state = state.withRotation(rotationCombined);
        }

        if (mirrorSub != Mirror.NONE)
        {
            state = state.withMirror(mirrorSub);
        }

        if (mirrorMain != Mirror.NONE)
        {
            state = state.withMirror(mirrorMain);
        }
    }

    return state;
}
 
源代码16 项目: enderutilities   文件: PositionUtils.java
public static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn)
{
    double x = vec.x;
    double y = vec.y;
    double z = vec.z;
    boolean isMirrored = true;

    switch (mirrorIn)
    {
        case LEFT_RIGHT:
            z = 1.0D - z;
            break;
        case FRONT_BACK:
            x = 1.0D - x;
            break;
        default:
            isMirrored = false;
    }

    switch (rotationIn)
    {
        case COUNTERCLOCKWISE_90:
            return new Vec3d(z, y, 1.0D - x);
        case CLOCKWISE_90:
            return new Vec3d(1.0D - z, y, x);
        case CLOCKWISE_180:
            return new Vec3d(1.0D - x, y, 1.0D - z);
        default:
            return isMirrored ? new Vec3d(x, y, z) : vec;
    }
}
 
源代码17 项目: Cyberware   文件: BlockBeaconPost.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
	switch (mirrorIn)
	{
		case LEFT_RIGHT:
			return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH));
		case FRONT_BACK:
			return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST));
		default:
			return super.withMirror(state, mirrorIn);
	}
}
 
源代码18 项目: enderutilities   文件: ItemBuildersWand.java
private void setMirror(ItemStack stack, Mode mode, Mirror mirror)
{
    int sel = this.getSelectionIndex(stack);
    NBTTagCompound tag = this.getModeTag(stack, mode);
    tag.setByte("Mirror_" + sel, (byte)mirror.ordinal());
    tag.setBoolean("IsMirrored_" + sel, mirror != Mirror.NONE);
}
 
源代码19 项目: enderutilities   文件: ItemBuildersWand.java
public Mirror getMirror(ItemStack stack, Mode mode)
{
    int sel = this.getSelectionIndex(stack);
    NBTTagCompound tag = this.getModeTag(stack, mode);

    if (tag.getBoolean("IsMirrored_" + sel) && tag.hasKey("Mirror_" + sel, Constants.NBT.TAG_BYTE))
    {
        return Mirror.values()[tag.getByte("Mirror_" + sel) % Mirror.values().length];
    }

    return Mirror.NONE;
}
 
源代码20 项目: enderutilities   文件: ItemBuildersWand.java
private void moveEndPosition(ItemStack stack, EntityPlayer player, boolean reverse)
{
    EnumFacing direction = EntityUtils.getClosestLookingDirection(player);
    Mode mode = Mode.getMode(stack);
    BlockPosEU posStart = mode == Mode.CUBE || mode == Mode.WALLS ?
            this.getPosition(stack, mode, POS_START) : this.getPerTemplateAreaCorner(stack, mode, POS_START);
    BlockPosEU posEnd = this.getPosition(stack, mode, POS_END);

    if (posEnd == null)
    {
        posEnd = posStart;
    }

    if (posStart != null && posEnd != null)
    {
        int v = reverse ? 1 : -1;
        posEnd = posEnd.add(direction.getXOffset() * v, direction.getYOffset() * v, direction.getZOffset() * v);

        if (mode == Mode.WALLS || mode == Mode.CUBE)
        {
            this.setPosition(posEnd, false, stack, player);
        }
        else
        {
            this.setPerTemplateAreaCorner(posEnd, mode, false, stack, player);
            this.setAreaFacing(stack, mode, PositionUtils.getFacingFromPositions(posStart, posEnd));
            this.setMirror(stack, mode, Mirror.NONE);
        }
    }
}
 
源代码21 项目: enderutilities   文件: ItemBuildersWand.java
private void moveAreaImmediate(ItemStack stack, World world, EntityPlayer player, BlockPos posSrc1, BlockPos posSrc2, BlockPos posDst1,
        Mirror mirror, Rotation rotation)
{
    PlacementSettings placement = new PlacementSettings();
    placement.setMirror(mirror);
    placement.setRotation(rotation);
    placement.setIgnoreEntities(false);
    placement.setReplacedBlock(Blocks.BARRIER); // meh

    ReplaceMode replace = WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.MOVE_DST) ? ReplaceMode.EVERYTHING : ReplaceMode.NOTHING;
    TemplateEnderUtilities template = new TemplateEnderUtilities(placement, replace);
    template.takeBlocksFromWorld(world, posSrc1, posSrc2.subtract(posSrc1), true, false);
    this.deleteArea(stack, world, player, posSrc1, posSrc2, true);
    template.addBlocksToWorld(world, posDst1);
}
 
源代码22 项目: enderutilities   文件: TaskMoveArea.java
public TaskMoveArea(int dimension, BlockPos posSrcStart, BlockPos posSrcEnd, BlockPos posDstStart,
        Rotation rotationDst, Mirror mirrorDst, UUID wandUUID, int blocksPerTick)
{
    this.posSrcStart = posSrcStart;
    this.posDstStart = posDstStart;
    this.rotation = rotationDst;
    this.mirror = mirrorDst;
    this.wandUUID = wandUUID;
    this.dimension = dimension;
    this.blocksPerTick = blocksPerTick;
    this.boxRelative = new BlockPosBox(BlockPos.ORIGIN, posSrcEnd.subtract(posSrcStart));
    this.boxSource = new BlockPosBox(posSrcStart, posSrcEnd);
    this.handledPositions = new HashSet<BlockPos>();
}
 
源代码23 项目: enderutilities   文件: PositionUtils.java
/**
 * Mirrors and then rotates the given position around the origin
 */
public static BlockPos getTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation)
{
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    boolean isMirrored = true;

    switch (mirror)
    {
        // LEFT_RIGHT is essentially NORTH_SOUTH
        case LEFT_RIGHT:
            z = -z;
            break;
        // FRONT_BACK is essentially EAST_WEST
        case FRONT_BACK:
            x = -x;
            break;
        default:
            isMirrored = false;
    }

    switch (rotation)
    {
        case CLOCKWISE_90:
            return new BlockPos(-z, y,  x);
        case COUNTERCLOCKWISE_90:
            return new BlockPos( z, y, -x);
        case CLOCKWISE_180:
            return new BlockPos(-x, y, -z);
        default:
            return isMirrored ? new BlockPos(x, y, z) : pos;
    }
}
 
源代码24 项目: enderutilities   文件: PositionUtils.java
/**
 * Mirrors and then rotates the given position around the origin
 */
public static BlockPosEU getTransformedBlockPos(BlockPosEU pos, Mirror mirror, Rotation rotation)
{
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    boolean isMirrored = true;

    switch (mirror)
    {
        // LEFT_RIGHT is essentially NORTH_SOUTH
        case LEFT_RIGHT:
            z = -z;
            break;
        // FRONT_BACK is essentially EAST_WEST
        case FRONT_BACK:
            x = -x;
            break;
        default:
            isMirrored = false;
    }

    switch (rotation)
    {
        case CLOCKWISE_90:
            return new BlockPosEU(-z, y,  x, pos.getDimension(), pos.getFacing());
        case COUNTERCLOCKWISE_90:
            return new BlockPosEU( z, y, -x, pos.getDimension(), pos.getFacing());
        case CLOCKWISE_180:
            return new BlockPosEU(-x, y, -z, pos.getDimension(), pos.getFacing());
        default:
            return isMirrored ? new BlockPosEU(x, y, z, pos.getDimension(), pos.getFacing()) : pos;
    }
}
 
源代码25 项目: TofuCraftReload   文件: BlockAdvancedAggregator.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
 
源代码26 项目: TofuCraftReload   文件: BlockAggregator.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
 
源代码27 项目: TofuCraftReload   文件: BlockTFCrasher.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
 
源代码28 项目: TofuCraftReload   文件: BlockTFCompressor.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
}
 
源代码29 项目: Sakura_mod   文件: BlockBarrelDistillation.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation(state.getValue(FACING)));
}
 
源代码30 项目: Sakura_mod   文件: BlockBarrel.java
/**
 * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
 * blockstate.
 */
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
    return state.withRotation(mirrorIn.toRotation(state.getValue(FACING)));
}
 
 类所在包
 类方法
 同包方法