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


Java MutableBlockPos类代码示例

本文整理汇总了Java中net.minecraft.util.math.BlockPos.MutableBlockPos的典型用法代码示例。如果您正苦于以下问题:Java MutableBlockPos类的具体用法?Java MutableBlockPos怎么用?Java MutableBlockPos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: assignConstructionBlocks

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
 * builds the block array using the representation map and the layout(String[]...)
 * String = x-line
 * String[] = z-line
 * String[]... = y-line
 * @param layer the layout of the blocks.
 * @exception NullPointerException the layout is missing a map
 */
public void assignConstructionBlocks(String[]... layer)
{
    final int xsz = layer[0][0].length();
    final int ysz = layer.length;
    final int zsz = layer[0].length;

    conBlocks = new IBlockState[xsz][ysz][zsz];

    for (final MutableBlockPos local : BlockPos.getAllInBoxMutable(BlockPos.ORIGIN, new BlockPos(xsz-1, ysz-1, zsz-1)))
    {
        final char c = layer[local.getY()][local.getZ()].charAt(local.getX());

        if (!conDef.containsKey(c) && c != '-')
        {
            throw new StructureDefinitionError("Map missing '" + c + "' @" + local);
        }

        conBlocks[local.getX()][local.getY()][local.getZ()] = c == '-' ? null : conDef.get(c);
    }
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:29,代码来源:StructureDefinitionBuilder.java

示例2: assignConstructionStateBlocks

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
 * builds the state array using the representation map and the layout(String[]...)
 * String = x-line
 * String[] = z-line
 * String[]... = y-line
 * @param layer the layout of the states.
 * @exception NullPointerException the layout is missing a map
 */
public void assignConstructionStateBlocks(String[]... layer)
{
    final int xsz = layer[0][0].length();
    final int ysz = layer.length;
    final int zsz = layer[0].length;

    state = new String[xsz][ysz][zsz];

    for (final MutableBlockPos local : BlockPos.getAllInBoxMutable(BlockPos.ORIGIN, new BlockPos(xsz-1, ysz-1, zsz-1)))
    {
        final char c = layer[local.getY()][local.getZ()].charAt(local.getX());

        if (!repState.containsKey(c) && c != ' ')
        {
            throw new StructureDefinitionError("Map missing '" + c + "' @" + local);
        }

        state[local.getX()][local.getY()][local.getZ()] = repState.get(c);
    }
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:29,代码来源:StructureDefinitionBuilder.java

示例3: mutLocalToGlobal

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static void mutLocalToGlobal(MutableBlockPos local,
                                        BlockPos global,
                                        EnumFacing orientation, boolean ismirrored,
                                        BlockPos strucSize)
{
    final int rotIndex = orientation.ordinal()-2;

    if (rotIndex < 0 || rotIndex > 3) return; //should not happen. who screwed up

    if (ismirrored)
    {
        mutSetX(local, local.getX() * -1);
        if (strucSize.getX() % 2 == 0) mutSetX(local, 1 + local.getX());
    }

    final int rx = rotationMatrix[rotIndex][0][0] * local.getX() + rotationMatrix[rotIndex][0][1] * local.getZ();
    final int rz = rotationMatrix[rotIndex][1][0] * local.getX() + rotationMatrix[rotIndex][1][1] * local.getZ();

    local.setPos(
            global.getX() + rx,
            global.getY() + local.getY(),
            global.getZ() + rz
    );
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:25,代码来源:TransformLAG.java

示例4: breakStructure

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public void breakStructure(World world, BlockPos origin, EnumFacing orientation, boolean mirror, boolean isCreative, boolean isSneaking)
{
    for (final MutableBlockPos local : getPattern().getStructureItr())
    {
        if (getPattern().hasBlockAt(local))
        {
            final IBlockState block = getPattern().getBlock(local).getBlockState();
            mutLocalToGlobal(local, origin, orientation, mirror, getPattern().getBlockBounds());
            final IBlockState worldBlock = world.getBlockState(local);

            if (worldBlock.getBlock() instanceof StructureBlock || worldBlock.getBlock() instanceof StructureShapeBlock)
            {
                world.removeTileEntity(local);

                world.setBlockState(new BlockPos(local), (isCreative && !isSneaking) ?
                        Blocks.AIR.getDefaultState() :
                        localToGlobal(block, orientation, mirror)
                        , 0x2);
            }
        }
    }
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:23,代码来源:StructureBlock.java

示例5: includedPositions

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
 * All positions included in the region. Excludes interior positions if hollow, and excludes any excluded positions.
 */
public Iterable<MutableBlockPos> includedPositions()
{
    return new Iterable<BlockPos.MutableBlockPos>()
    {
        public Iterator<BlockPos.MutableBlockPos> iterator()
        {
            return new AbstractIterator<BlockPos.MutableBlockPos>()
            {
                Iterator<BlockPos.MutableBlockPos> wrapped = positions().iterator();
                
                protected BlockPos.MutableBlockPos computeNext()
                {
                    while(wrapped.hasNext())
                    {
                        BlockPos.MutableBlockPos result = wrapped.next();
                        if(exclusions == null || !exclusions.contains(result)) return result;
                    }
                    return (BlockPos.MutableBlockPos)this.endOfData();
                }
            };
        }
    };
    
}
 
开发者ID:grondag,项目名称:Hard-Science,代码行数:28,代码来源:CubicBlockRegion.java

示例6: getOffsetPosition

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
 * Returns the MutableBlockPos <b>pos</b> with a position set to <b>posReference</b> offset by <b>amount</b> in the direction <b>side</b>.
 */
public static MutableBlockPos getOffsetPosition(MutableBlockPos pos, BlockPos posReference, EnumFacing side, int amount)
{
    switch (side)
    {
        case NORTH:
            pos.setPos(posReference.getX(), posReference.getY(), posReference.getZ() - amount);
        case SOUTH:
            pos.setPos(posReference.getX(), posReference.getY(), posReference.getZ() + amount);
        case EAST:
            pos.setPos(posReference.getX() + amount, posReference.getY(), posReference.getZ());
        case WEST:
            pos.setPos(posReference.getX() - amount, posReference.getY(), posReference.getZ());
        case UP:
            pos.setPos(posReference.getX(), posReference.getY() + amount, posReference.getZ());
        case DOWN:
            pos.setPos(posReference.getX(), posReference.getY() - amount, posReference.getZ());
    }

    return pos;
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:24,代码来源:PositionUtils.java

示例7: handleHarvest

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
	MutableBlockPos start = new MutableBlockPos(pos);
	while (canBreak(world, start)) {
		start.move(EnumFacing.UP);
	}
	start.move(EnumFacing.DOWN);

	if (start.getY() >= pos.getY()) {
		BlockPos target = search(world, pos);
		IBlockState targetState = world.getBlockState(target);
		targetState.getBlock().breakBlock(world, pos, state);
		PlantHarvestHelper.breakBlockHandleDrop(world, target, targetState, chest);
		return true;
	}
	return false;
}
 
开发者ID:Aroma1997,项目名称:BetterChests,代码行数:18,代码来源:TreeHandler.java

示例8: spawnFlowers

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@SubscribeEvent
public void spawnFlowers(PlayerTickEvent evt) {
	if (evt.side == Side.SERVER && evt.phase == Phase.START) {
		World w = evt.player.world;
		if (w.getTotalWorldTime() % 20 == 0 && validBiomesMoonBell.contains(w.getBiome(evt.player.getPosition()))) {
			Random r = evt.player.getRNG();
			if (w.provider.getDimension() == 0 && w.provider.getMoonPhase(w.getWorldTime()) == 4 && !w.isDaytime() && evt.player.getRNG().nextDouble() < 0.2) {
				int dx = (r.nextInt(7) - 3) * 10;
				int dz = (r.nextInt(7) - 3) * 10;
				MutableBlockPos pos = new MutableBlockPos(evt.player.getPosition().add(dx, 0, dz));
				tryAndSpawn(w, pos);
			}
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:16,代码来源:BlockMoonbell.java

示例9: tryAndSpawn

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
private void tryAndSpawn(World w, MutableBlockPos p) {
	int oy = p.getY();
	for (int dy = -5; dy <= 5; dy++) {
		p.setY(oy + dy);
		if ((w.isAirBlock(p) || w.getBlockState(p).getBlock().isReplaceable(w, p)) && w.getBlockState(p.down()).getBlock() == Blocks.DIRT) {
			w.setBlockState(p, this.getDefaultState().withProperty(placed, false), 3);
			return;
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:11,代码来源:BlockMoonbell.java

示例10: readFromNBT

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound nbt)
{
    super.readFromNBT(nbt);
    if (nbt.hasKey("current"))
        this.current = new MutableBlockPos(BlockPos.fromLong(nbt.getLong("current")));
}
 
开发者ID:LexManos,项目名称:VoidUtils,代码行数:8,代码来源:TileEntityQuarry.java

示例11: getBlockState

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
/**
 * Gets the clean error checked block state
 * @param local local coords of the block within the map
 * @return block state
 */
private IPartBlockState getBlockState(MutableBlockPos local)
{
    final IBlockState block = conBlocks[local.getX()][local.getY()][local.getZ()];

    if (block == null) return PartBlockState.of();
    if (state == null) return PartBlockState.of(block);

    final String blockState = state[local.getX()][local.getY()][local.getZ()];

    if (blockState == null) return PartBlockState.of(block);

    return PartBlockState.of(block, blockState);
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:19,代码来源:StructureDefinitionBuilder.java

示例12: next

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
public MutableBlockPos next()
{
    if (!hasNext())
    {
        throw new NoSuchElementException();
    }

    pos.setPos(rowNo, layerNo, depthNo);

    shiftReadHead();

    return pos;
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:15,代码来源:StructureIterable.java

示例13: mutOffset

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static MutableBlockPos mutOffset(MutableBlockPos pos, EnumFacing facing)
{
    return pos.setPos(
            facing.getFrontOffsetX() + pos.getX(),
            facing.getFrontOffsetY() + pos.getY(),
            facing.getFrontOffsetZ() + pos.getZ()
    );
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:9,代码来源:BlockPosUtil.java

示例14: addDestroyEffects

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager)
{
    final float scaleVec = 0.05f;
    final TileEntity ute = world.getTileEntity(pos);

    if (ute instanceof StructureTE)
    {
        final StructureTE te = (StructureTE) ute;

        for (MutableBlockPos local : getPattern().getStructureItr())
        {
            //outward Vector
            float xSpeed = 0.0f;
            float ySpeed = 0.0f;
            float zSpeed = 0.0f;

            for (EnumFacing d : EnumFacing.VALUES)
            {
                if (!getPattern().hasBlockAt(local, d))
                {
                    d = localToGlobal(d, te.getOrientation(), te.getMirror());

                    xSpeed += d.getFrontOffsetX();
                    ySpeed += d.getFrontOffsetY();
                    zSpeed += d.getFrontOffsetZ();
                }
            }

            mutLocalToGlobal(local, pos, te.getOrientation(), te.getMirror(), getPattern().getBlockBounds());

            spawnBreakParticle(world, te, local, xSpeed * scaleVec, ySpeed * scaleVec, zSpeed * scaleVec);
        }
    }

    return true; //No Destroy Effects
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:39,代码来源:StructureBlock.java

示例15: updateExternalNeighbours

import net.minecraft.util.math.BlockPos.MutableBlockPos; //导入依赖的package包/类
public static void updateExternalNeighbours(World world, BlockPos origin, StructureDefinition sd, EnumFacing orientation, boolean mirror, boolean notifyBlocks)
{
    for (final MutableBlockPos local : sd.getStructureItr())
    {
        for (EnumFacing d : EnumFacing.VALUES)
        {
            if (!sd.hasBlockAt(local, d))
            {
                final IBlockState updatedBlock = sd.getBlock(local).getBlockState();

                if (updatedBlock == null)
                {
                    continue;
                }

                final MutableBlockPos mutLocal = BlockPosUtil.newMutBlockPos(local);
                BlockPosUtil.mutOffset(mutLocal, d);

                mutLocalToGlobal(
                        mutLocal,
                        origin,
                        orientation, mirror,
                        sd.getBlockBounds()
                );

                world.notifyNeighborsOfStateChange(mutLocal, updatedBlock.getBlock());
            }
        }
    }
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:31,代码来源:StructureBlock.java


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