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


Java BlockPos.getY方法代码示例

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


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

示例1: updateTick

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (world.getLightFromNeighbors(pos.up()) >= 9) {
		if ((this.getAge(state) + 1) >= getMaxAge())
		{
			EntityItem ei = new EntityItem(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, UCItems.generic.createStack(EnumItems.PLUM));
			if (!world.isRemote)
				world.spawnEntityInWorld(ei);
			UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX(), pos.getY(), pos.getZ(), 4));
			world.setBlockState(pos, withAge(0), 2);
			return;
		}
	}
	super.updateTick(world, pos, state, rand);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:17,代码来源:Dirigible.java

示例2: transformBedrock

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private void transformBedrock(World world, BlockPos pos) {
	
	Iterable<BlockPos> poslist = BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, 0, range));
	Iterator posit = poslist.iterator();
	while (posit.hasNext()) {
		BlockPos looppos = (BlockPos)posit.next();
		if (!world.isAirBlock(looppos) && world.getBlockState(looppos).getBlock() == Blocks.BEDROCK) {
			if (looppos.getY() <= 1) continue;
			if (world.rand.nextBoolean()) {
				world.setBlockState(looppos, UCBlocks.darkBlock.getDefaultState(), 2);
				UCPacketHandler.sendToNearbyPlayers(world, looppos, new PacketUCEffect(EnumParticleTypes.CLOUD, looppos.getX(), looppos.getY(), looppos.getZ(), 6));
				return;
			}
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:17,代码来源:Petramia.java

示例3: moveTowards

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public void moveTowards(BlockPos pos)
{
    double d0 = (double)pos.getX();
    int i = pos.getY();
    double d1 = (double)pos.getZ();
    double d2 = d0 - this.posX;
    double d3 = d1 - this.posZ;
    float f = MathHelper.sqrt(d2 * d2 + d3 * d3);

    if (f > 12.0F)
    {
        this.targetX = this.posX + d2 / (double)f * 12.0D;
        this.targetZ = this.posZ + d3 / (double)f * 12.0D;
        this.targetY = this.posY + 8.0D;
    }
    else
    {
        this.targetX = d0;
        this.targetY = (double)i;
        this.targetZ = d1;
    }

    this.despawnTimer = 0;
    this.shatterOrDrop = this.rand.nextInt(5) > 0;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:EntityEnderEye.java

示例4: getAdjacentStorage

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static ArrayList<IEnergyStorage> getAdjacentStorage(World world, BlockPos pos) {
	ArrayList<IEnergyStorage> consumers = new ArrayList<>();
	
	if (pos.getY()<255) {
		IEnergyStorage up = getStorage(world,pos.up(),EnumFacing.DOWN);
		if (up.canReceive()) consumers.add(up);
	}
	
	if (pos.getY()>0) {
		IEnergyStorage down = getStorage(world, pos.down(), EnumFacing.UP);
		if (down.canReceive()) consumers.add(down);
	}
	
	IEnergyStorage north = getStorage(world, pos.north(), EnumFacing.SOUTH);
	if (north.canReceive()) consumers.add(north);
	IEnergyStorage south = getStorage(world, pos.south(), EnumFacing.NORTH);
	if (south.canReceive()) consumers.add(south);
	IEnergyStorage east = getStorage(world, pos.east(), EnumFacing.WEST);
	if (east.canReceive()) consumers.add(east);
	IEnergyStorage west = getStorage(world, pos.west(), EnumFacing.EAST);
	if (west.canReceive()) consumers.add(west);
	
	return consumers;
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:25,代码来源:RFTransport.java

示例5: getBlockState

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public IBlockState getBlockState(BlockPos pos)
{
    if (pos.getY() >= 0 && pos.getY() < 256)
    {
        int i = (pos.getX() >> 4) - this.chunkX;
        int j = (pos.getZ() >> 4) - this.chunkZ;

        if (i >= 0 && i < this.chunkArray.length && j >= 0 && j < this.chunkArray[i].length)
        {
            Chunk chunk = this.chunkArray[i][j];

            if (chunk != null)
            {
                return chunk.getBlockState(pos);
            }
        }
    }

    return Blocks.AIR.getDefaultState();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:ChunkCache.java

示例6: getBottomBlockAir

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static BlockPos getBottomBlockAir(World world, BlockPos pos)
{
	Chunk chunk = world.getChunkFromBlockCoords(pos);
       BlockPos blockpos;
       BlockPos blockpos1;

       for (blockpos = new BlockPos(pos.getX(), 0, pos.getZ()); blockpos.getY() < world.getActualHeight()- 1; blockpos = blockpos1)
       {
           blockpos1 = blockpos.up();
           IBlockState state = chunk.getBlockState(blockpos1);
           if ((state.getBlock() instanceof BlockLiquid || world.isAirBlock(blockpos1)) &&
           		chunk.getBlockState(blockpos1.up()) instanceof BlockLiquid || world.isAirBlock(blockpos1.up()))
           {
               break;
           }
       }
       return blockpos.up(2);		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:HarshenUtils.java

示例7: findRandomSpawnPos

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable
private Vec3d findRandomSpawnPos(BlockPos pos)
{
    for (int i = 0; i < 10; ++i)
    {
        BlockPos blockpos = pos.add(this.worldObj.rand.nextInt(16) - 8, this.worldObj.rand.nextInt(6) - 3, this.worldObj.rand.nextInt(16) - 8);

        if (this.theVillage.isBlockPosWithinSqVillageRadius(blockpos) && WorldEntitySpawner.canCreatureTypeSpawnAtLocation(EntityLiving.SpawnPlacementType.ON_GROUND, this.worldObj, blockpos))
        {
            return new Vec3d((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
        }
    }

    return null;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:VillageSiege.java

示例8: rayTraceAABB

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable
public static RayTraceResult rayTraceAABB(AxisAlignedBB box, BlockPos pos, Vec3d start, Vec3d end) {
	double x = pos.getX();
	double y = pos.getY();
	double z = pos.getZ();
	Vec3d a = start.subtract(x, y, z);
	Vec3d b = end.subtract(x, y, z);
	RayTraceResult result = box.calculateIntercept(a, b);
	if(result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
		return result;
	}
	return null;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:14,代码来源:RayTraceHelper.java

示例9: generate

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (int i = 0; i < 64; ++i)
    {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));

        if (worldIn.isAirBlock(blockpos) && (!worldIn.provider.getHasNoSky() || blockpos.getY() < 255) && this.block.canBlockStay(worldIn, blockpos, this.block.getDefaultState()))
        {
            worldIn.setBlockState(blockpos, this.block.getDefaultState(), 2);
        }
    }

    return true;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:WorldGenBush.java

示例10: spawnAsEntity

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
 * Spawns the given ItemStack as an EntityItem into the World at the given position
 */
public static void spawnAsEntity(World worldIn, BlockPos pos, ItemStack stack)
{
    if (!worldIn.isRemote && !stack.func_190926_b() && worldIn.getGameRules().getBoolean("doTileDrops"))
    {
        float f = 0.5F;
        double d0 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        double d1 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        double d2 = (double)(worldIn.rand.nextFloat() * 0.5F) + 0.25D;
        EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, stack);
        entityitem.setDefaultPickupDelay();
        worldIn.spawnEntityInWorld(entityitem);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:Block.java

示例11: dropRecord

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private void dropRecord(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox)tileentity;
            ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();

            if (itemstack != null)
            {
                worldIn.playEvent(1010, pos, 0);
                worldIn.playRecord(pos, (SoundEvent)null);
                blockjukebox$tileentityjukebox.setRecord((ItemStack)null);
                float f = 0.7F;
                double d0 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D;
                double d1 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.06000000238418579D + 0.6D;
                double d2 = (double)(worldIn.rand.nextFloat() * 0.7F) + 0.15000000596046448D;
                ItemStack itemstack1 = itemstack.copy();
                EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, itemstack1);
                entityitem.setDefaultPickupDelay();
                worldIn.spawnEntityInWorld(entityitem);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:BlockJukebox.java

示例12: FakePlayerUC

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public FakePlayerUC(World world, BlockPos pos, GameProfile profile) {
	
	super(FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(world.provider.getDimension()), profile);
	posX = pos.getX() + 0.5;
	posY = pos.getY() + 0.5;
	posZ = pos.getZ() + 0.5;
	this.connection = new FakeNetHandlerPlayServer(this);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:9,代码来源:FakePlayerUC.java

示例13: isSideSolid

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default)
{
    int x = (pos.getX() >> 4) - this.chunkX;
    int z = (pos.getZ() >> 4) - this.chunkZ;
    if (pos.getY() < 0 || pos.getY() >= 256) return _default;
    if (x < 0 || x >= chunkArray.length || z < 0 || z >= chunkArray[x].length) return _default;
    if (chunkArray[x][z] == null) return _default;

    IBlockState state = getBlockState(pos);
    return state.getBlock().isSideSolid(state, this, pos, side);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:ChunkCache.java

示例14: generateTopLeaves

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
protected void generateTopLeaves(World world, BlockPos genPos, BlockPos branchPos, int treeHeight, int leavesBase, Random rand, boolean alternate,
        int maxLeavesLength, boolean irregular, boolean inverted, IBlockState leaves) {
    boolean alt = false;
    float percent;
    int leavesLength;

    if (leavesBase > branchPos.getY()) {
        return;
    }

    generateBranchLeaves(world, branchPos, rand, true, 1, leaves);

    while (branchPos.getY() > leavesBase) {
        branchPos = branchPos.add(0, -1, 0);

        percent = ((branchPos.getY() - leavesBase) / (float) (genPos.getY() + treeHeight - leavesBase));

        if (!inverted) {
            percent = 1 - percent;
        }

        leavesLength = MathHelper.ceil(maxLeavesLength * percent);

        if (leavesLength > maxLeavesLength) {
            leavesLength = maxLeavesLength;
        }

        if (alt || !alternate || (irregular && rand.nextInt(5) == 0)) {
            generateBranchLeaves(world, branchPos, rand, false, leavesLength, irregular, leaves);
        }

        alt = !alt;
    }
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:35,代码来源:WorldGenAbstractGenesisTree.java

示例15: getPathToPos

import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Nullable
@Override
public Path getPathToPos(BlockPos pos) {
    telPos = pos;
    if (forceTeleport) {
        teleportCounter = 0;
        return null;
    }
    if (!pathfindingEntity.isBlockValidPathfindBlock(pos) || pathfindingEntity.getDistanceSqToCenter(pos) < 0.3)
        return null;

    pathfindingEntity.setStandby(false);
    teleportCounter = -1;
    Path path = super.getPathToPos(pos);
    
    //Only paths that actually end up where we want to are valid, not just halfway.
    if(path != null){
        PathPoint lastPoint = path.getFinalPathPoint();
        if(lastPoint != null && (lastPoint.x != pos.getX() || lastPoint.y != pos.getY() || lastPoint.z != pos.getZ())){
            path = null;
        }
    }
    
    if (path == null) {
        teleportCounter = 0;
    }

    return path;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:30,代码来源:EntityPathNavigateDrone.java


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