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


Java BlockPos类代码示例

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


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

示例1: findItemOnGroundOrInChest

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
@Override
public boolean findItemOnGroundOrInChest(Predicate<ItemStack> matcher, int maxAmount, String message, String... parameters) {
    List<BlockPos> meeCreepChests = findMeeCreepChests(worker.getSearchBox());
    if (meeCreepChests.isEmpty()) {
        if (!findItemOnGround(worker.getSearchBox(), matcher, this::pickup)) {
            if (!findInventoryContainingMost(worker.getSearchBox(), matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
                showMessage(message, parameters);
                return false;
            }
        }
    } else {
        if (!findInventoryContainingMost(meeCreepChests, matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
            showMessage(message, parameters);
            return false;
        }
    }
    return true;
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:19,代码来源:WorkerHelper.java

示例2: getItem

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

    if (tileentityflowerpot != null)
    {
        ItemStack itemstack = tileentityflowerpot.getFlowerItemStack();

        if (itemstack != null)
        {
            return itemstack;
        }
    }

    return new ItemStack(Items.FLOWER_POT);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:BlockFlowerPot.java

示例3: neighborChanged

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);

    if (enumfacing$axis == EnumFacing.Axis.X)
    {
        BlockPortal.Size blockportal$size = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.X);

        if (!blockportal$size.isValid() || blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
    else if (enumfacing$axis == EnumFacing.Axis.Z)
    {
        BlockPortal.Size blockportal$size1 = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.Z);

        if (!blockportal$size1.isValid() || blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:BlockPortal.java

示例4: getPossibleCreatures

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
	if (pos==null) return ImmutableList.of();
	
	if (creatureType == EnumCreatureType.MONSTER) {
           //if (this.genNetherBridge.isInsideStructure(pos)) {
           //    return this.genNetherBridge.getSpawnList();
           //}

           if (this.genNetherBridge.isPositionInStructure(this.world, pos) && this.world.getBlockState(pos.down()).getBlock() == Blocks.NETHER_BRICK) {
               return this.genNetherBridge.getSpawnList();
           }
           
           return Biomes.HELL.getSpawnableList(EnumCreatureType.MONSTER); //TODO: Replace with actual-biome lists.
	}
	return ImmutableList.of();

	//Biome biome = this.world.getBiome(pos);
	//return biome.getSpawnableList(creatureType);
}
 
开发者ID:elytra,项目名称:ThermionicsWorld,代码行数:20,代码来源:ChunkProviderNeo.java

示例5: moveMinecartOnRail

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
/**
 * Moved to allow overrides.
 * This code handles minecart movement and speed capping when on a rail.
 */
public void moveMinecartOnRail(BlockPos pos)
{
    double mX = this.motionX;
    double mZ = this.motionZ;

    if (this.isBeingRidden())
    {
        mX *= 0.75D;
        mZ *= 0.75D;
    }

    double max = this.getMaxSpeed();
    mX = MathHelper.clamp_double(mX, -max, max);
    mZ = MathHelper.clamp_double(mZ, -max, max);
    this.moveEntity(mX, 0.0D, mZ);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:EntityMinecart.java

示例6: dispense

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playEvent(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
            {
                tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BlockDispenser.java

示例7: updateTick

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (this.getAge(state) >= getMaxAge())
		return;
	
	int friends = 0;
	
	Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
	Iterator it = getBox.iterator();
	while (it.hasNext()) {
		BlockPos looppos = (BlockPos)it.next();
		Block loopblock = world.getBlockState(looppos).getBlock();
		if (loopblock != null && !world.isAirBlock(looppos) && loopblock == UCBlocks.cropWafflonia) {
			if (!world.isRemote)
				friends++;
		}
	}
	if ((friends != 0 && friends % 4 != 0) || friends == 0)
		return;
	
	super.updateTick(world, pos, state, rand);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:24,代码来源:Wafflonia.java

示例8: 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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:WorldGenVines.java

示例9: xDominant

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
private List<BlockPos> xDominant(BlockPos start, BlockPos end) {
    int x = start.getX();
    int y = start.getY();
    int z = start.getZ();
    
    int yd = ay - (ax >> 1);
    int zd = az - (ax >> 1);
    
    List<BlockPos> posLt = new ArrayList<>();
    do {
        posLt.add(new BlockPos(x, y, z));
        if(yd >= 0) {
            y += sy;
            yd -= ax;
        }
        if(zd >= 0) {
            z += sz;
            zd -= ax;                    
        }
        x += sx;
        yd += ay;
        zd += az;
    } while(x != end.getX());
    return posLt;
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:26,代码来源:LinePts.java

示例10: computeEnergyCost

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
private int computeEnergyCost(EntityPlayer player, int blockDim, BlockPos pos)
  {
  	// check fuel type
  	if (UniversalRemoteConfiguration.fuel.fuelType.equals(UniversalRemoteConfiguration.FuelType.Energy.toString()) &&
  			UniversalRemoteConfiguration.fuel.energy.energyCapacity > 0)
{

	if (player.dimension == blockDim) {

		return Math.min(UniversalRemoteConfiguration.fuel.energy.energyCostMax, (int)(Math.sqrt(player.getDistanceSq(pos)) * UniversalRemoteConfiguration.fuel.energy.energyCostPerBlock));

	} else {

		return UniversalRemoteConfiguration.fuel.energy.energyCostMax;

	}

} else {
	return 0;
}
  }
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:22,代码来源:ItemUniversalRemote.java

示例11: generateTree

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
@Override
public boolean generateTree(World worldIn, Random rand, BlockPos pos) {
	filler.leaf = leaf;
	// Check light levels
	if(worldIn.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = rand.nextInt(heightVar) + height;
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(worldIn,pos.add(0,h,0))){
			return false;
		}
	}
	// Place central trunk
	for(int y = 0; y<h; y++){
		fill(worldIn, pos.add(0, y, 0));
	}
	filler.fillLeaves(worldIn, pos.add(0,h-1,0), rand);
	
	return false;
}
 
开发者ID:trigg,项目名称:Firma,代码行数:23,代码来源:TreeGeneric.java

示例12: onBlockActivated

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityEnchantmentTable)
        {
            playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
        }

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

示例13: growLeavesLayerStrict

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(World worldIn, BlockPos layerCenter, int width)
{
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j)
    {
        for (int k = -width; k <= width + 1; ++k)
        {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
            {
                BlockPos blockpos = layerCenter.add(j, 0, k);
                IBlockState state = worldIn.getBlockState(blockpos);

                if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos))
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:28,代码来源:WorldGenHugeTrees.java

示例14: neighborChanged

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
	BlockPos I = pos.add(-1, 0, -1);
	BlockPos F = pos.add(1, 1, 1);
	for (BlockPos blockPos : BlockPos.getAllInBox(I, F)) {
		Block block = worldIn.getBlockState(blockPos).getBlock();
		if (block != this && block != Blocks.WATER && block != Blocks.FLOWING_WATER) {
			checkAndDropBlock(worldIn, pos, state);
			break;
		}
	}
	if (!canBlockStay(worldIn, pos, state) || !canSustainBush(worldIn.getBlockState(pos.down()))) {
		checkAndDropBlock(worldIn, pos, state);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:16,代码来源:CropKelp.java

示例15: onNeighborChange

import net.minecraft.util.math.BlockPos; //导入依赖的package包/类
@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
{
	super.onNeighborChange(world, pos, neighbor);
	if (world instanceof World)
	{
		World w = (World) world;
		if (this.canFall(w, world.getBlockState(pos), pos, neighbor))
		{
			w.setBlockState(pos, ExPBlocks.soil.getDefaultState().withProperty(DIRT_CLASS, world.getBlockState(pos).getValue(DIRT_CLASS)));
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:14,代码来源:BlockFarmland.java


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