Java 类net.minecraft.util.math.BlockPos.MutableBlockPos 实例源码

项目:Structure    文件:StructureDefinitionBuilder.java   
/**
 * 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);
    }
}
项目:Structure    文件:StructureDefinitionBuilder.java   
/**
 * 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);
    }
}
项目:Structure    文件:TransformLAG.java   
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
    );
}
项目:Structure    文件:StructureBlock.java   
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);
            }
        }
    }
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/**
 * 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();
                }
            };
        }
    };

}
项目:enderutilities    文件:PositionUtils.java   
/**
 * 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;
}
项目:BetterChests    文件:TreeHandler.java   
@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;
}
项目:Bewitchment    文件:BlockMoonbell.java   
@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);
            }
        }
    }
}
项目:Bewitchment    文件:BlockMoonbell.java   
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;
        }
    }
}
项目:VoidUtils    文件:TileEntityQuarry.java   
@Override
public void readFromNBT(NBTTagCompound nbt)
{
    super.readFromNBT(nbt);
    if (nbt.hasKey("current"))
        this.current = new MutableBlockPos(BlockPos.fromLong(nbt.getLong("current")));
}
项目:Structure    文件:StructureDefinitionBuilder.java   
/**
 * 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);
}
项目:Structure    文件:StructureIterable.java   
@Override
public MutableBlockPos next()
{
    if (!hasNext())
    {
        throw new NoSuchElementException();
    }

    pos.setPos(rowNo, layerNo, depthNo);

    shiftReadHead();

    return pos;
}
项目:Structure    文件:BlockPosUtil.java   
public static MutableBlockPos mutOffset(MutableBlockPos pos, EnumFacing facing)
{
    return pos.setPos(
            facing.getFrontOffsetX() + pos.getX(),
            facing.getFrontOffsetY() + pos.getY(),
            facing.getFrontOffsetZ() + pos.getZ()
    );
}
项目:Structure    文件:StructureBlock.java   
@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
}
项目:Structure    文件:StructureBlock.java   
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());
            }
        }
    }
}
项目:Structure    文件:StructureDefinition.java   
public Iterable<MutableBlockPos> getStructureItr()
{
    return new Iterable<MutableBlockPos>()
    {
        @Override
        public Iterator<MutableBlockPos> iterator()
        {
            return new StructureIterable(
                    -masterPosition.getX(),                -masterPosition.getY(),                   -masterPosition.getZ(),
                    blocks.length - masterPosition.getX(), blocks[0].length - masterPosition.getY(), blocks[0][0].length - masterPosition.getZ());
        }
    };
}
项目:Toms-Mod    文件:TomsModUtils.java   
public static List<BlockChecker> getLayers(Object[][] config, final Map<Character, MultiblockBlockChecker> materialMap, final World world, final EnumFacing facing, final BlockPos pos) {
    List<BlockChecker> list = new ArrayList<>();
    final MutableBlockPos corner = new MutableBlockPos(pos);
    for (int l = 1;l < config.length;l++) {
        final int m = l - 1;
        Object[] objA = config[l];
        for (int k = 0;k < objA.length;k++) {
            Object o = objA[k];
            final int n = k;
            char[] cA = o.toString().toCharArray();
            for (int i = 0;i < cA.length;i++) {
                final int j = i;
                final char c = cA[i];
                if (c == '@') {
                    corner.setPos(pos.offset(facing.rotateY(), -i).offset(facing, -k).offset(EnumFacing.DOWN, l - 1));
                } else if (c == ' ') {
                    list.add(new BlockChecker(doRun -> AIR.apply(new WorldPos(world, corner.offset(facing.rotateY(), j).offset(facing, n).offset(EnumFacing.UP, m), pos, 0, 0)), 1, c, () -> corner.offset(facing.rotateY(), j).offset(facing, n).offset(EnumFacing.UP, m), m));
                } else if (c == '*') {
                    list.add(new BlockChecker(a -> 2, 2, c, () -> corner.offset(facing.rotateY(), j).offset(facing, n).offset(EnumFacing.UP, m), m));
                } else {
                    list.add(new BlockChecker(doRun -> {
                        MultiblockBlockChecker predicate = materialMap.get(c);
                        if (predicate == null)
                            predicate = AIR;
                        return predicate.apply(new WorldPos(world, corner.offset(facing.rotateY(), j).offset(facing, n).offset(EnumFacing.UP, m), pos, doRun, m));
                    }, 0, c, () -> corner.offset(facing.rotateY(), j).offset(facing, n).offset(EnumFacing.UP, m), m));
                }
            }
        }
    }
    return list;
}
项目:Hard-Science    文件:TerrainState.java   
/** 
 * Pass in pos with Y of flow block for which we are getting data.
 * Returns relative flow height based on blocks 2 above through 2 down.
 * Gets called frequently, thus the use of mutable pos.
 */
public static int getFlowHeight(IBlockAccess world, MutableBlockPos pos)
{
    pos.setY(pos.getY() + 2);;
    IBlockState state = world.getBlockState(pos);
    int h = TerrainBlock.getFlowHeightFromState(state);
    if(h > 0) return 2 * BLOCK_LEVELS_INT + h;

    pos.setY(pos.getY() - 1);
    state = world.getBlockState(pos);
    h = TerrainBlock.getFlowHeightFromState(state);
    if(h > 0) return BLOCK_LEVELS_INT + h;

    pos.setY(pos.getY() - 1);
    state = world.getBlockState(pos);
    h = TerrainBlock.getFlowHeightFromState(state);
    if(h > 0) return h;

    pos.setY(pos.getY() - 1);
    state = world.getBlockState(pos);
    h = TerrainBlock.getFlowHeightFromState(state);
    if(h > 0) return -BLOCK_LEVELS_INT + h;

    pos.setY(pos.getY() - 1);
    state = world.getBlockState(pos);
    h = TerrainBlock.getFlowHeightFromState(state);
    if(h > 0) return -2 * BLOCK_LEVELS_INT + h;

    return NO_BLOCK;
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/** convenience method - returns set of all block positions in AABB defined by inputs, inclusive */
public static Set<BlockPos> positionsInRegion(BlockPos from, BlockPos to)
{
    CubicBlockRegion temp = new CubicBlockRegion(from, to, false);
    ImmutableSet.Builder<BlockPos> builder = ImmutableSet.builder();

    for(BlockPos.MutableBlockPos pos : temp.allPositions())
    {
        builder.add(pos.toImmutable());
    }
    return builder.build();
}
项目:enderutilities    文件:ItemBuildersWand.java   
private Area3D(NBTTagCompound tag)
{
    this.pos = new MutableBlockPos(0, 0, 0);
    this.neg = new MutableBlockPos(0, 0, 0);

    this.readFromNBT(tag);
}
项目:enderutilities    文件:ItemBuildersWand.java   
private MutableBlockPos clampBounds(MutableBlockPos bounds)
{
    int x = MathHelper.clamp(bounds.getX(), 0, this.maxSize);
    int y = MathHelper.clamp(bounds.getY(), 0, this.maxSize);
    int z = MathHelper.clamp(bounds.getZ(), 0, this.maxSize);

    return bounds.setPos(x, y, z);
}
项目:enderutilities    文件:ItemBuildersWand.java   
private void setFromPacked(MutableBlockPos bounds, int packed)
{
    int x = MathHelper.clamp((packed >> 16) & 0xFF, 0, this.maxSize);
    int y = MathHelper.clamp((packed >>  8) & 0xFF, 0, this.maxSize);
    int z = MathHelper.clamp(packed         & 0xFF, 0, this.maxSize);

    bounds.setPos(x, y, z);
}
项目:BetterChests    文件:PumpkinBlockHandler.java   
@Override
public boolean canHandlePlant(Collection<ItemStack> items, World world, BlockPos pos, IBlockState state) {
    if (!WorldUtil.isBlockAir(world, pos)) {
        return false;
    }
    MutableBlockPos mut = new MutableBlockPos();
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        mut.setPos(pos).move(facing);
        IBlockState other = world.getBlockState(mut);
        if (other.getBlock() == Blocks.MELON_STEM || other.getBlock() == Blocks.PUMPKIN_STEM) {
            return  true;
        }
    }
    return false;
}
项目:BetterChests    文件:ReedHandler.java   
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
    MutableBlockPos mut = new MutableBlockPos(pos);
    while (world.getBlockState(mut).getBlock() == state.getBlock()) {
        mut.move(EnumFacing.UP);
    }
    mut.move(EnumFacing.DOWN);
    if (mut.getY() != pos.getY()) {
        PlantHarvestHelper.breakBlockHandleDrop(world, mut, state, chest);
        return true;
    }
    return false;
}
项目:Structure    文件:StructureBlockItem.java   
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState)
{
    final StructureBlock block = (StructureBlock) this.block;

    if (player == null)
    {
        return false;
    }

    final EnumFacing orientation = EnumFacing.getHorizontal(MathHelper.floor_double(player.rotationYaw * 4.0f / 360.0f + 0.5) & 3);
    final boolean mirror = block.canMirror() && player.isSneaking();

    newState = newState.withProperty(BlockHorizontal.FACING, orientation);

    if (block.canMirror())
    {
        newState = newState.withProperty(StructureBlock.MIRROR, mirror);
    }

    //find master block location
    final BlockPos hSize = block.getPattern().getHalfBlockBounds();
    final BlockPos ml = block.getPattern().getMasterLocation();

    BlockPos origin
            = localToGlobal(
            -hSize.getX() + ml.getX(), ml.getY(), -hSize.getZ() + ml.getZ(),
            pos.getX(), pos.getY(), pos.getZ(),
            orientation, mirror, block.getPattern().getBlockBounds());

    //check block locations
    for (final MutableBlockPos local : block.getPattern().getStructureItr())
    {
        if (!block.getPattern().hasBlockAt(local))
        {
            continue;
        }

        mutLocalToGlobal(local, origin, orientation, mirror, block.getPattern().getBlockBounds());

        if (!world.getBlockState(local).getBlock().isReplaceable(world, local))
        {
            return false;
        }
    }

    world.setBlockState(origin, newState, 0x2);
    block.onBlockPlacedBy(world, origin, newState, player, stack);

    return true;
}
项目:Structure    文件:StructureFormTool.java   
@Override
public SearchResult call() throws Exception
{
    final StructureDefinition sd = ssBlock.getPattern();
    final BlockPos tl = sd.getToolFormLocation();

    nextOrientation:
    for (final EnumFacing o: orientationOrder)
    {
        nextMirror:
        for (final boolean mirror : mirrorOrder)
        {
            final BlockPos origin =
                    localToGlobal(
                            -tl.getX(), -tl.getY(), -tl.getZ(),
                            pos.getX(), pos.getY(), pos.getZ(),
                            o, mirror, sd.getBlockBounds()
                    );

            for (final MutableBlockPos local : sd.getStructureItr())
            {
                final IPartBlockState pb = sd.getBlock(local);
                final IBlockState b = pb.getBlockState();

                //alter local coord var and changes it to world coord.
                mutLocalToGlobal(local, origin, o, mirror, sd.getBlockBounds());

                final IBlockState ncwb = world.getBlockState(local);

                final IBlockState wb = ncwb.getActualState(world, local);

                if (b != null && (b.getBlock() != wb.getBlock() || !doBlockStatesMatch(pb, localToGlobal(b, o, mirror), wb)))
                {
                    if (mirrorOrder.length <= 1) //is last mirror
                    {
                        continue nextOrientation;
                    }
                    else
                    {
                        if (mirror == mirrorOrder[1])
                        {
                            continue nextOrientation;
                        } else {
                            continue nextMirror;
                        }
                    }
                }
            }

            //found match, eeek!
            final SearchResult result = new SearchResult();

            result.block = ssBlock;
            result.origin = origin;
            result.orientation = o;
            result.mirror = mirror;

            return result;
        }
    }

    //no matches for this structure
    return null;
}
项目:Structure    文件:StructureDefinitionBuilder.java   
/**
 * Configures the location of the blocks.
 * M => Master block location. Specify only once
 * - => Block position
 *   => No block
 *
 * @param shift translation of S(C).origin to S(F).origin
 * @param layer
 */
public void setConfiguration(BlockPos shift, String[]... layer)
{
    final int xsz = layer[0][0].length();
    final int ysz = layer.length;
    final int zsz = layer[0].length;

    sbLayoutSize = BlockPosUtil.of(xsz, ysz, zsz);
    sbLayout = new BitSet(xsz * ysz * zsz);

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

        switch (c)
        {
            case 'M': // Master block location
                if (masterPosition == null)
                {
                    masterPosition = BlockPosUtil.of(
                            local.getX() + shift.getX(),
                            local.getY() + shift.getY(),
                            local.getZ() + shift.getZ()
                    );
                } else
                {
                    throw new StructureDefinitionError("setConfiguration.Master position defined more then once.");
                }

            case ' ':
            case '-':
                sbLayout.set(
                        local.getX() + local.getZ() * xsz + local.getY() *zsz*xsz,
                        c != ' ');
                break;
            default:
            {
                throw new StructureDefinitionError("setConfiguration.Unknown char '" + c + '\'');
            }
        }
    }

    if (masterPosition == null)
    {
        throw new StructureDefinitionError("setConfiguration.Master position not defined");
    }
}
项目:Structure    文件:BlockPosUtil.java   
public static void mutSetX(MutableBlockPos pos, int x)
{
    pos.setPos(x, pos.getY(), pos.getZ());
}
项目:Structure    文件:BlockPosUtil.java   
public static void mutSetY(MutableBlockPos pos, int y)
{
    pos.setPos(pos.getX(), y, pos.getZ());
}
项目:Structure    文件:BlockPosUtil.java   
public static void mutSetZ(MutableBlockPos pos, int z)
{
    pos.setPos(pos.getX(), pos.getY(), z);
}
项目:Structure    文件:BlockPosUtil.java   
public static MutableBlockPos newMutBlockPos(BlockPos pos)
{
    return new MutableBlockPos().setPos(pos.getX(), pos.getY(), pos.getZ());
}
项目:Structure    文件:StructureBlock.java   
public void formStructure(World world, BlockPos origin, IBlockState state, int flag)
{
    final EnumFacing orientation = state.getValue(BlockHorizontal.FACING);
    final boolean mirror = getMirror(state);
    IBlockState shapeState = shapeBlock
            .getDefaultState()
            .withProperty(BlockHorizontal.FACING, orientation);

    if (canMirror)
    {
        shapeState = shapeState.withProperty(MIRROR, mirror);
    }

    for (final MutableBlockPos local : getPattern().getStructureItr())
    {
        if (!getPattern().hasBlockAt(local))
        {
            continue;
        }

        final BlockPos blockCoord = bindLocalToGlobal(origin, local, orientation, mirror, getPattern().getBlockBounds());

        world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL,
                blockCoord.getX() + 0.5f,
                blockCoord.getY() + 0.5f,
                blockCoord.getZ() + 0.5f, (-0.5 + Math.random()) * 0.25f, 0.05f, (-0.5 + Math.random()) * 0.2f);

        if (!local.equals(BlockPos.ORIGIN))
        {
            world.setBlockState(blockCoord, shapeState, flag);
        }

        final IStructureTE ssBlock = (IStructureTE) world.getTileEntity(blockCoord);

        if (ssBlock != null)
        {
            ssBlock.configureBlock(new BlockPos(local), regHash);
        } else
        {
            world.setBlockToAir(blockCoord);
            return;
        }
    }
}
项目:Structure    文件:StructurePacket.java   
@Override
public IMessage onMessage(StructurePacket msg, MessageContext ctx)
{
    final World world = Minecraft.getMinecraft().theWorld;
    final StructureBlock block = StructureRegistry.getStructureBlock(msg.structureHash);

    if (block == null)
    {
        return null;
    }

    int particleCount = 0;
    final float sAjt = 0.05f;
    final EnumFacing orientation = EnumFacing.VALUES[msg.orientationAndMirror & orientationMask];
    final boolean mirror = (msg.orientationAndMirror & flagMirrored) != 0;

    if (msg.sc == StructurePacketOption.BUILD)
    {
         IBlockState state = block.getDefaultState()
                .withProperty(BlockHorizontal.FACING, orientation);

        if (block.canMirror())
            state = state.withProperty(StructureBlock.MIRROR, mirror);

        world.setBlockState(msg.pos, state, 0x2);
        block.formStructure(world, msg.pos, state, 0x2);
        updateExternalNeighbours(world, msg.pos, block.getPattern(), orientation, mirror, true);

        return null;
    }

    for (final MutableBlockPos local : block.getPattern().getStructureItr())
    {
        final BlockPos coord = bindLocalToGlobal(
                msg.pos, local,
                orientation, mirror,
                block.getPattern().getBlockBounds()
        );

        //outward Vector
        float xSpeed = 0.0f;
        float ySpeed = 0.0f;
        float zSpeed = 0.0f;

        for (EnumFacing d :EnumFacing.VALUES)
        {
            if (!block.getPattern().hasBlockAt(local, d))
            {
                d = localToGlobal(d, orientation, mirror);

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

        switch (msg.sc)
        {
            case BOOM_PARTICLE:
                if (particleCount++ % 9 != 0)
                {
                    world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, coord.getX(), coord.getY(), coord.getZ(), xSpeed * sAjt, ySpeed * sAjt, zSpeed * sAjt);
                }
        }
    }

    return null;
}
项目:Aether-Legacy    文件:AetherBiomeDecorator.java   
@Override
  protected void genDecorations(Biome biomeGenBaseIn, World worldIn, Random random)
  {
    if (this.shouldSpawn(37))
    {
        this.crystal_island.generate(this.world, this.rand, this.chunkPos.add(this.nextInt(16) + 8, this.nextInt(64) + 32, this.nextInt(16) + 8));
    }

    if (this.shouldSpawn(3))
    {
        this.spawnOre(BlocksAether.aether_dirt.getDefaultState(), 32, 20, 128);
    }

if (this.shouldSpawn(2))
{
    this.getTree().generate(this.world, this.rand, this.world.getHeight(this.chunkPos.add(this.nextInt(16) + 8, 0, this.nextInt(16) + 8)));
}

if (this.shouldSpawn(1))
{
    this.skyroot_tree.generate(this.world, this.rand, this.world.getHeight(this.chunkPos.add(this.nextInt(16), 0, this.nextInt(16))));
}

if (AetherConfig.shouldLoadHolidayContent())
{
    if (this.shouldSpawn(15))
    {
        this.holiday_tree.generate(this.world, this.rand, this.world.getHeight(this.chunkPos.add(this.nextInt(16) + 8, 0, this.nextInt(16) + 8)));
    }
}

    this.generateFoilage(BlocksAether.white_flower.getDefaultState());
    this.generateFoilage(BlocksAether.purple_flower.getDefaultState());

    this.spawnOre(BlocksAether.icestone.getDefaultState(), 16, 10, 128);
    this.spawnOre(BlocksAether.ambrosium_ore.getDefaultState(), 16, 15, 128);
    this.spawnOre(BlocksAether.zanite_ore.getDefaultState(), 8, 15, 64);
    this.spawnOre(BlocksAether.gravitite_ore.getDefaultState(), 6, 8, 32);

    this.generateClouds(EnumCloudType.Golden, 4, false, 50, this.nextInt(64) + 96);
    this.generateClouds(EnumCloudType.Blue, 8, false, 26, this.nextInt(64) + 32);
    this.generateClouds(EnumCloudType.Cold, 16, false, 14, this.nextInt(64) + 64);
    this.generateClouds(EnumCloudType.Cold, 64, true, 50, 0);

MutableBlockPos mutedPos = new MutableBlockPos();

if (this.shouldSpawn(10))
{
    for (int x = this.chunkPos.getX(); x < this.chunkPos.getX() + 16; x++)
    {
        for (int z = this.chunkPos.getZ(); z < this.chunkPos.getZ() + 16; z++)
        {
            for (int n = 0; n < 48; n++)
            {
                mutedPos.setPos(x, n, z);
                if (this.world.getBlockState(mutedPos).getBlock() == Blocks.AIR && this.world.getBlockState(mutedPos.setPos(x, n + 1, z)).getBlock() == BlocksAether.aether_grass && this.world.getBlockState(mutedPos.setPos(x, n + 2, z)).getBlock() == Blocks.AIR)
                {
                    new AetherGenQuicksoil().generate(this.world, this.rand, mutedPos);
                    mutedPos.setPos(x, n + 128, z);
                }
            }
        }
    }
}

this.generateFoilage(BlocksAether.berry_bush.getDefaultState());
  }
项目:Hard-Science    文件:SingleBlockRegion.java   
@Override
public Iterable<MutableBlockPos> surfacePositions()
{
    return BlockPos.getAllInBoxMutable(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ());
}
项目:Hard-Science    文件:SingleBlockRegion.java   
@Override
public Iterable<MutableBlockPos> adjacentPositions()
{
    return CubicBlockRegion.getAllOnBoxSurfaceMutable(pos.getX() - 1, pos.getY() - 1, pos.getZ() - 1, pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/** All positions contained in the region, including interior positions if it is hollow */
public Iterable<MutableBlockPos> allPositions()
{
    return BlockPos.getAllInBoxMutable(this.minX, this.minY, this.minZ, this.maxX - 1, this.maxY - 1, this.maxZ - 1);
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/** All positions on the surface of the region. Will be same as {@link #allPositions()} if region is not at least 3x3x3 */
public Iterable<MutableBlockPos> surfacePositions()
{
    return getAllOnBoxSurfaceMutable(this.minX, this.minY, this.minZ, this.maxX - 1, this.maxY - 1, this.maxZ - 1);
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/** Positions that belong the region, excluding interior positions if hollow, but not excluding any excluded positions. */
public Iterable<MutableBlockPos> positions()
{
    return isHollow ? surfacePositions() : allPositions();
}
项目:Hard-Science    文件:CubicBlockRegion.java   
/** All positions on the surface of the region. Will be same as {@link #allPositions()} if region is not at least 3x3x3 */
public Iterable<MutableBlockPos> adjacentPositions()
{
    return getAllOnBoxSurfaceMutable(this.minX - 1, this.minY - 1, this.minZ - 1, this.maxX, this.maxY, this.maxZ);
}