本文整理汇总了Java中net.minecraft.util.math.BlockPos.up方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPos.up方法的具体用法?Java BlockPos.up怎么用?Java BlockPos.up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.BlockPos
的用法示例。
在下文中一共展示了BlockPos.up方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
BlockPos cur = NeoHellGenerators.findSurface(worldIn, position);
if (cur==null) return false;
cur = cur.up(4); //punch through a certain amount of incline, too.
ArrayList<BlockPos> buffer = new ArrayList<BlockPos>();
//int depth = 20 + rand.nextInt(20);
for(int i=0; i<30; i++) {
float radius = 3f + rand.nextFloat()*4;
NeoHellGenerators.cylinderAround(cur, radius, buffer);
cur = cur.down();
}
for(BlockPos pos : buffer) {
if (pos.getY()<ChunkProviderNeo.SEA_LEVEL) {
worldIn.setBlockState(pos, TWBlocks.FLUID_PAIN.getDefaultState());
} else {
worldIn.setBlockToAir(pos); //TODO: randomy spawn sulfurgas pockets
}
}
return true;
}
示例2: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (; position.getY() < 128; position = position.up())
{
if (worldIn.isAirBlock(position))
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings())
{
if (Blocks.VINE.canPlaceBlockOnSide(worldIn, position, enumfacing))
{
IBlockState iblockstate = Blocks.VINE.getDefaultState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == EnumFacing.WEST));
worldIn.setBlockState(position, iblockstate, 2);
break;
}
}
}
else
{
position = position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4));
}
}
return true;
}
示例3: adjustPosToNearbyEntity
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
protected BlockPos adjustPosToNearbyEntity(BlockPos pos)
{
BlockPos blockpos = this.getPrecipitationHeight(pos);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.getX(), this.getHeight(), blockpos.getZ()))).expandXyz(3.0D);
List<EntityLivingBase> list = this.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new Predicate<EntityLivingBase>()
{
public boolean apply(@Nullable EntityLivingBase p_apply_1_)
{
return p_apply_1_ != null && p_apply_1_.isEntityAlive() && WorldServer.this.canSeeSky(p_apply_1_.getPosition());
}
});
if (!list.isEmpty())
{
return ((EntityLivingBase)list.get(this.rand.nextInt(list.size()))).getPosition();
}
else
{
if (blockpos.getY() == -1)
{
blockpos = blockpos.up(2);
}
return blockpos;
}
}
示例4: placePodzolAt
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private void placePodzolAt(World worldIn, BlockPos pos)
{
for (int i = 2; i >= -3; --i)
{
BlockPos blockpos = pos.up(i);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (block.canSustainPlant(iblockstate, worldIn, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.SAPLING)))
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, PODZOL);
break;
}
if (iblockstate.getMaterial() != Material.AIR && i < 0)
{
break;
}
}
}
示例5: func_191378_a
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private static BlockPos func_191378_a(BlockPos p_191378_0_, EntityCreature p_191378_1_)
{
if (!p_191378_1_.world.getBlockState(p_191378_0_).getMaterial().isSolid())
{
return p_191378_0_;
}
else
{
BlockPos blockpos;
for (blockpos = p_191378_0_.up(); blockpos.getY() < p_191378_1_.world.getHeight() && p_191378_1_.world.getBlockState(blockpos).getMaterial().isSolid(); blockpos = blockpos.up())
{
;
}
return blockpos;
}
}
示例6: findSuitableSpot
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* Find the nearest suitable spot to stand on at this x,z
* Or null if there is no suitable position
*/
private BlockPos findSuitableSpot(BlockPos pos) {
if (isStandable(pos)) {
return pos;
}
if (isStandable(pos.down())) {
return pos.down();
}
if (isStandable(pos.up())) {
return pos.up();
}
if (isStandable(pos.down(2))) {
return pos.down(2);
}
return null;
}
示例7: trunkGenOliveImpl
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public static int trunkGenOliveImpl(Pair<ITreeGenerator, BlockPos> p)
{
BlockPos initialPos = p.getRight();
TreeGenerator gen = (TreeGenerator)p.getKey();
int heightToGenerate = 5 + gen.worldGen.rand.nextInt(4);
int h = heightToGenerate + 1;
while (h-- > 0)
{
BlockPos pos = initialPos.up(h);
gen.worldGen.setBlockState(pos, gen.wood, 2);
gen.worldGen.setBlockState(pos.west(), gen.wood, 2);
gen.worldGen.setBlockState(pos.south(), gen.wood, 2);
gen.worldGen.setBlockState(pos.south().west(), gen.wood, 2);
}
return heightToGenerate;
}
示例8: generateTrunk
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
protected void generateTrunk(World world, BlockPos start, int height) {
//Create the trunk from the bottom up, using < to ensure it is covered with one layer of leaves
for (int layer = 0; layer < height; ++layer) {
BlockPos blockpos2 = start.up(layer);
if (this.replace.matches(world, blockpos2)) {
this.setBlockAndNotifyAdequately(world, start.up(layer), this.log);
}
}
}
示例9: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean generate(World worldIn, Random rand, BlockPos position)
{
IBlockState toSet = ExPBlocks.berryBushes[this.stateToPlace.ordinal()].getDefaultState().withProperty(ExPBlockProperties.BERRY_BUSH_TYPE, EnumBerry.values()[rand.nextInt(EnumBerry.values().length)]);
BlockPos offset = position.add(rand.nextInt(4) - rand.nextInt(4), 5, rand.nextInt(4) - rand.nextInt(4));
while (!worldIn.getBlockState(offset).getBlock().isAssociatedBlock(Blocks.GRASS) && offset.getY() > 96)
{
offset = offset.down();
}
if (worldIn.getBlockState(offset).getBlock().isAssociatedBlock(Blocks.GRASS))
{
BlockPos at = offset.up();
IBlockState current = worldIn.getBlockState(at);
if (current.getMaterial() != Material.WATER && (current.getBlock().isAir(current, worldIn, at) || current.getBlock().isReplaceable(worldIn, at)))
{
worldIn.setBlockState(at, toSet, 2);
if (rand.nextBoolean())
{
worldIn.setBlockState(at.up(), toSet, 2);
if (rand.nextDouble() < 0.1)
{
worldIn.setBlockState(at.up().up(), toSet, 2);
}
}
return true;
}
}
return false;
}
示例10: getBlockToDig
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
private BlockPos getBlockToDig(BlockPos p, EnumFacing facing, int blockidx) {
switch (blockidx) {
case 0: return p.up(1).offset(facing.rotateY());
case 1: return p.up(1);
case 2: return p.up(1).offset(facing.rotateYCCW());
case 3: return p.offset(facing.rotateY());
case 4: return p;
case 5: return p.offset(facing.rotateYCCW());
case 6: return p.down(1).offset(facing.rotateYCCW());
case 7: return p.down(1);
case 8: return p.down(1).offset(facing.rotateY());
}
return p;
}
示例11: clearCurrentPositionBlocksUpwards
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* Deletes all continuous blocks from selected position upwards. Stops at hitting air.
*/
protected void clearCurrentPositionBlocksUpwards(World worldIn, int x, int y, int z, StructureBoundingBox structurebb)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (structurebb.isVecInside(blockpos))
{
while (!worldIn.isAirBlock(blockpos) && blockpos.getY() < 255)
{
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 2);
blockpos = blockpos.up();
}
}
}
示例12: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
@Override
public boolean generate(World world, Random rand, BlockPos position) {
BlockPos pos = NeoHellGenerators.findSurface(world, position);
if (pos==null) {
//System.out.println("Failed to generate at "+position);
return false;
} else {
//System.out.println("Generating at "+pos);
}
int height = rand.nextInt(4) + 7;
IBlockState trunkState = Blocks.BONE_BLOCK.getDefaultState().withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
//EnumFacing.Axis axis = rand.nextBoolean() ? EnumFacing.Axis.X : EnumFacing.Axis.Z;
EnumAxis axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
BlockPos section = pos;
for(int y=0; y<height; y++) {
world.setBlockState(section, trunkState);
if (y>3 && y%2==0) {
axis = rand.nextBoolean() ? EnumAxis.X : EnumAxis.Z;
BlockPos arm = section;
int width = (height-y) / 2;
for(int i=0; i<width; i++) {
arm = arm.add(axis.xofs, axis.yofs, axis.zofs);
world.setBlockState(arm, axis==EnumAxis.X ?
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
}
arm = section;
for(int i=0; i<width; i++) {
arm = arm.add(-axis.xofs, -axis.yofs, -axis.zofs);
world.setBlockState(arm, axis==EnumAxis.X ?
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X) :
trunkState.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z));
}
}
section = section.up();
}
return true;
}
示例13: generate
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES) && position.getY() > 0; iblockstate = worldIn.getBlockState(position))
{
position = position.down();
}
Block block = worldIn.getBlockState(position).getBlock();
if (block == Blocks.DIRT || block == Blocks.GRASS)
{
position = position.up();
this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
for (int i = position.getY(); i <= position.getY() + 2; ++i)
{
int j = i - position.getY();
int k = 2 - j;
for (int l = position.getX() - k; l <= position.getX() + k; ++l)
{
int i1 = l - position.getX();
for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
{
int k1 = j1 - position.getZ();
if (Math.abs(i1) != k || Math.abs(k1) != k || rand.nextInt(2) != 0)
{
BlockPos blockpos = new BlockPos(l, i, j1);
Material material = worldIn.getBlockState(blockpos).getMaterial();
if (material == Material.AIR || material == Material.LEAVES)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
}
}
}
}
}
}
return true;
}
示例14: onItemRightClick
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
RayTraceResult raytraceresult = this.rayTrace(itemStackIn, worldIn, true);
if (raytraceresult == null)
{
return new ActionResult(EnumActionResult.PASS, itemstack);
}
else
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK)
{
BlockPos blockpos = raytraceresult.getBlockPos();
if (!itemStackIn.isBlockModifiable(worldIn, blockpos) || !worldIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemstack))
{
return new ActionResult(EnumActionResult.FAIL, itemstack);
}
BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = itemStackIn.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.WATER && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && itemStackIn.isAirBlock(blockpos1))
{
itemStackIn.setBlockState(blockpos1, Blocks.WATERLILY.getDefaultState(), 11);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
worldIn.addStat(StatList.getObjectUseStats(this));
itemStackIn.playSound(worldIn, blockpos, SoundEvents.BLOCK_WATERLILY_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
}
return new ActionResult(EnumActionResult.FAIL, itemstack);
}
}
示例15: onItemUse
import net.minecraft.util.math.BlockPos; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
if (playerIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else if (hand != EnumFacing.UP)
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(playerIn, worldIn);
if (!flag)
{
worldIn = worldIn.up();
}
int i = MathHelper.floor((double)(stack.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
EnumFacing enumfacing = EnumFacing.getHorizontal(i);
BlockPos blockpos = worldIn.offset(enumfacing);
ItemStack itemstack = stack.getHeldItem(pos);
if (stack.canPlayerEdit(worldIn, hand, itemstack) && stack.canPlayerEdit(blockpos, hand, itemstack))
{
IBlockState iblockstate1 = playerIn.getBlockState(blockpos);
boolean flag1 = iblockstate1.getBlock().isReplaceable(playerIn, blockpos);
boolean flag2 = flag || playerIn.isAirBlock(worldIn);
boolean flag3 = flag1 || playerIn.isAirBlock(blockpos);
if (flag2 && flag3 && playerIn.getBlockState(worldIn.down()).isFullyOpaque() && playerIn.getBlockState(blockpos.down()).isFullyOpaque())
{
IBlockState iblockstate2 = Blocks.BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
playerIn.setBlockState(worldIn, iblockstate2, 10);
playerIn.setBlockState(blockpos, iblockstate2.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD), 10);
playerIn.notifyNeighborsRespectDebug(worldIn, block, false);
playerIn.notifyNeighborsRespectDebug(blockpos, iblockstate1.getBlock(), false);
SoundType soundtype = iblockstate2.getBlock().getSoundType();
playerIn.playSound((EntityPlayer)null, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
itemstack.func_190918_g(1);
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
else
{
return EnumActionResult.FAIL;
}
}
}