本文整理匯總了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);
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}