當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockPos.getAllInBoxMutable方法代碼示例

本文整理匯總了Java中net.minecraft.util.math.BlockPos.getAllInBoxMutable方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.getAllInBoxMutable方法的具體用法?Java BlockPos.getAllInBoxMutable怎麽用?Java BlockPos.getAllInBoxMutable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.math.BlockPos的用法示例。


在下文中一共展示了BlockPos.getAllInBoxMutable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getVisibleFacings

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private Set<EnumFacing> getVisibleFacings(BlockPos pos)
{
    VisGraph visgraph = new VisGraph();
    BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
    Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);

    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15)))
    {
        if (chunk.getBlockState(blockpos$mutableblockpos).isOpaqueCube())
        {
            visgraph.setOpaqueCube(blockpos$mutableblockpos);
        }
    }

    return visgraph.getVisibleFacings(pos);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:RenderGlobal.java

示例2: getNearbyCornerBlocks

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private List<TileEntityStructure> getNearbyCornerBlocks(BlockPos p_184418_1_, BlockPos p_184418_2_)
{
    List<TileEntityStructure> list = Lists.<TileEntityStructure>newArrayList();

    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(p_184418_1_, p_184418_2_))
    {
        IBlockState iblockstate = this.worldObj.getBlockState(blockpos$mutableblockpos);

        if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK)
        {
            TileEntity tileentity = this.worldObj.getTileEntity(blockpos$mutableblockpos);

            if (tileentity != null && tileentity instanceof TileEntityStructure)
            {
                list.add((TileEntityStructure)tileentity);
            }
        }
    }

    return list;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:TileEntityStructure.java

示例3: getNearbyCornerBlocks

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private List<TileEntityStructure> getNearbyCornerBlocks(BlockPos p_184418_1_, BlockPos p_184418_2_)
{
    List<TileEntityStructure> list = Lists.<TileEntityStructure>newArrayList();

    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(p_184418_1_, p_184418_2_))
    {
        IBlockState iblockstate = this.world.getBlockState(blockpos$mutableblockpos);

        if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK)
        {
            TileEntity tileentity = this.world.getTileEntity(blockpos$mutableblockpos);

            if (tileentity != null && tileentity instanceof TileEntityStructure)
            {
                list.add((TileEntityStructure)tileentity);
            }
        }
    }

    return list;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:TileEntityStructure.java

示例4: getColorAtPos

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private static int getColorAtPos(IBlockAccess blockAccess, BlockPos pos, BiomeColorHelper.ColorResolver colorResolver)
{
    int i = 0;
    int j = 0;
    int k = 0;

    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-1, 0, -1), pos.add(1, 0, 1)))
    {
        int l = colorResolver.getColorAtPos(blockAccess.getBiome(blockpos$mutableblockpos), blockpos$mutableblockpos);
        i += (l & 16711680) >> 16;
        j += (l & 65280) >> 8;
        k += l & 255;
    }

    return (i / 9 & 255) << 16 | (j / 9 & 255) << 8 | k / 9 & 255;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:BiomeColorHelper.java

示例5: randomDisplayTick

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    super.randomDisplayTick(stateIn, worldIn, pos, rand);
    for (BlockPos pos1 : BlockPos.getAllInBoxMutable(pos.add(-2, 0, -2), pos.add(2, 0, 2))) {
        if (worldIn.getBlockState(pos1).getBlock() instanceof IGrowable && rand.nextBoolean() && rand.nextBoolean() && rand.nextBoolean()) {
            worldIn.spawnParticle(EnumParticleTypes.WATER_WAKE, pos1.getX() + rand.nextDouble(), pos1.getY(), pos1.getZ() + rand.nextDouble(), 0.0D, 0.0D, 0.0D);
        }
    }
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:11,代碼來源:HydratorBlock.java

示例6: hasWater

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private boolean hasWater(World worldIn, BlockPos pos)
{
    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4)))
    {
        if (worldIn.getBlockState(blockpos$mutableblockpos).getMaterial() == Material.WATER)
        {
            return true;
        }
    }

    return false;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:13,代碼來源:BlockFarmland.java

示例7: generate

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(position.add(-1, -2, -1), position.add(1, 2, 1)))
    {
        boolean flag = blockpos$mutableblockpos.getX() == position.getX();
        boolean flag1 = blockpos$mutableblockpos.getY() == position.getY();
        boolean flag2 = blockpos$mutableblockpos.getZ() == position.getZ();
        boolean flag3 = Math.abs(blockpos$mutableblockpos.getY() - position.getY()) == 2;

        if (flag && flag1 && flag2)
        {
            this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.END_GATEWAY.getDefaultState());
        }
        else if (flag1)
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
        }
        else if (flag3 && flag && flag2)
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
        }
        else if ((flag || flag2) && !flag3)
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
        }
        else
        {
            this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
        }
    }

    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:34,代碼來源:WorldGenEndGateway.java

示例8: updateTick

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if (rand.nextInt(25) == 0) {
		int i = 5;

		for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4))) {
			if (worldIn.getBlockState(blockpos).getBlock() == this) {
				--i;

				if (i <= 0) {
					return;
				}
			}
		}

		BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);

		for (int k = 0; k < 4; ++k) {
			if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState())) {
				pos = blockpos1;
			}

			blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
		}

		if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState())) {
			worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:31,代碼來源:BlockTorchwood.java

示例9: getGrassColour

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public static int getGrassColour(World world, Biome biome, BlockPos pos) {
    int rad = 6;
    int divisor = (rad*2 + 1);
    divisor *= divisor;

    int r = 0;
    int g = 0;
    int b = 0;

    Map<Biome, Integer> biomeColours = new HashMap<>();
    Biome ib;
    int col,x,z;

    for (BlockPos.MutableBlockPos ipos : BlockPos.getAllInBoxMutable(pos.add(-rad, 0, -rad), pos.add(rad, 0, rad)))
    {
        ib = grassCache.getUnchecked(new GrassCacheKey(world, ipos));

        if (biomeColours.containsKey(ib)) {
            col = biomeColours.get(ib);
        } else {
            col = ib.getGrassColorAtPos(pos);
            biomeColours.put(ib, col);
        }

        r += (col & 0xFF0000) >> 16;
        g += (col & 0x00FF00) >> 8;
        b += (col & 0x0000FF);
    }

    return (r / divisor & 255) << 16 | (g / divisor & 255) << 8 | b / divisor & 255;
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:32,代碼來源:GrassColours.java

示例10: noteBlockPlayEvent

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@SubscribeEvent
public void noteBlockPlayEvent(NoteBlockEvent.Play event) {
	
	if (event.getWorld().isRemote)
		return;
	
	BlockPos epos = event.getPos();
	int range = 10;
	for (BlockPos pos : BlockPos.getAllInBoxMutable(epos.add(-range, -2, -range), epos.add(range, 2, range))) {
		TileEntity te = event.getWorld().getTileEntity(pos);
		if (te != null && te instanceof TileMusicaPlant) {
			TileMusicaPlant plant = (TileMusicaPlant)te;
			if (plant.getBeats().size() > 0)
			{
				for (int i = 0; i < plant.getBeats().size(); i++) {
					Beat beat = plant.getBeats().get(i);
					if (beat.beatMatches(new Beat(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime()))) {
						plant.setNewBeatTime(i, event.getWorld().getTotalWorldTime());
						return;
					}
				}
			}
			if (plant.canAddNote())
				plant.setNote(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime());
		}
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:28,代碼來源:UCEventHandlerServer.java

示例11: updateTick

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (rand.nextInt(25) == 0)
    {
        int i = 5;
        int j = 4;

        for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4)))
        {
            if (worldIn.getBlockState(blockpos).getBlock() == this)
            {
                --i;

                if (i <= 0)
                {
                    return;
                }
            }
        }

        BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);

        for (int k = 0; k < 4; ++k)
        {
            if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
            {
                pos = blockpos1;
            }

            blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
        }

        if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
        {
            worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:39,代碼來源:BlockMushroom.java

示例12: freezeNearby

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
    if (living.onGround)
    {
        float f = (float)Math.min(16, 2 + level);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
        {
            if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
            {
                blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                if (iblockstate.getMaterial() == Material.AIR)
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                    if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.canBlockBePlaced(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null, (ItemStack)null))
                    {
                        worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
                        worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getRandomIntegerInRange(living.getRNG(), 60, 120));
                    }
                }
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:29,代碼來源:EnchantmentFrostWalker.java

示例13: freezeNearby

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
{
    if (living.onGround)
    {
        float f = (float)Math.min(16, 2 + level);
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
        {
            if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
            {
                blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                if (iblockstate.getMaterial() == Material.AIR)
                {
                    IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                    if (iblockstate1.getMaterial() == Material.WATER && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.func_190527_a(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
                    {
                        worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
                        worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getInt(living.getRNG(), 60, 120));
                    }
                }
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:29,代碼來源:EnchantmentFrostWalker.java

示例14: takeBlocksFromWorld

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
/**
 * takes blocks from the world and puts the data them into this template
 */
public void takeBlocksFromWorld(World worldIn, BlockPos startPos, BlockPos endPos, boolean takeEntities, @Nullable Block toIgnore)
{
    if (endPos.getX() >= 1 && endPos.getY() >= 1 && endPos.getZ() >= 1)
    {
        BlockPos blockpos = startPos.add(endPos).add(-1, -1, -1);
        List<Template.BlockInfo> list = Lists.<Template.BlockInfo>newArrayList();
        List<Template.BlockInfo> list1 = Lists.<Template.BlockInfo>newArrayList();
        List<Template.BlockInfo> list2 = Lists.<Template.BlockInfo>newArrayList();
        BlockPos blockpos1 = new BlockPos(Math.min(startPos.getX(), blockpos.getX()), Math.min(startPos.getY(), blockpos.getY()), Math.min(startPos.getZ(), blockpos.getZ()));
        BlockPos blockpos2 = new BlockPos(Math.max(startPos.getX(), blockpos.getX()), Math.max(startPos.getY(), blockpos.getY()), Math.max(startPos.getZ(), blockpos.getZ()));
        this.size = endPos;

        for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos1, blockpos2))
        {
            BlockPos blockpos3 = blockpos$mutableblockpos.subtract(blockpos1);
            IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

            if (toIgnore == null || toIgnore != iblockstate.getBlock())
            {
                TileEntity tileentity = worldIn.getTileEntity(blockpos$mutableblockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound.removeTag("x");
                    nbttagcompound.removeTag("y");
                    nbttagcompound.removeTag("z");
                    list1.add(new Template.BlockInfo(blockpos3, iblockstate, nbttagcompound));
                }
                else if (!iblockstate.isFullBlock() && !iblockstate.isFullCube())
                {
                    list2.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
                }
                else
                {
                    list.add(new Template.BlockInfo(blockpos3, iblockstate, (NBTTagCompound)null));
                }
            }
        }

        this.blocks.clear();
        this.blocks.addAll(list);
        this.blocks.addAll(list1);
        this.blocks.addAll(list2);

        if (takeEntities)
        {
            this.takeEntitiesFromWorld(worldIn, blockpos1, blockpos2.add(1, 1, 1));
        }
        else
        {
            this.entities.clear();
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:59,代碼來源:Template.java

示例15: generate

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(new BlockPos(position.getX() - 4, position.getY() - 1, position.getZ() - 4), new BlockPos(position.getX() + 4, position.getY() + 32, position.getZ() + 4)))
    {
        double d0 = blockpos$mutableblockpos.getDistance(position.getX(), blockpos$mutableblockpos.getY(), position.getZ());

        if (d0 <= 3.5D)
        {
            if (blockpos$mutableblockpos.getY() < position.getY())
            {
                if (d0 <= 2.5D)
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
                }
                else if (blockpos$mutableblockpos.getY() < position.getY())
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.END_STONE.getDefaultState());
                }
            }
            else if (blockpos$mutableblockpos.getY() > position.getY())
            {
                this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
            }
            else if (d0 > 2.5D)
            {
                this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.BEDROCK.getDefaultState());
            }
            else if (this.activePortal)
            {
                this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.END_PORTAL.getDefaultState());
            }
            else
            {
                this.setBlockAndNotifyAdequately(worldIn, new BlockPos(blockpos$mutableblockpos), Blocks.AIR.getDefaultState());
            }
        }
    }

    for (int i = 0; i < 4; ++i)
    {
        this.setBlockAndNotifyAdequately(worldIn, position.up(i), Blocks.BEDROCK.getDefaultState());
    }

    BlockPos blockpos = position.up(2);

    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        this.setBlockAndNotifyAdequately(worldIn, blockpos.offset(enumfacing), Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, enumfacing));
    }

    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:53,代碼來源:WorldGenEndPodium.java


注:本文中的net.minecraft.util.math.BlockPos.getAllInBoxMutable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。