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


Java BlockPos.getX方法代碼示例

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


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

示例1: onBlockHarvested

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
	if (worldIn.getTileEntity(pos) != null && worldIn.getTileEntity(pos).hasCapability(ExPCropCapability.cropCap, null))
	{
		IExPCrop crop = IExPCrop.of(worldIn.getTileEntity(pos));
		Pair<EnumActionResult, NonNullList<ItemStack>> ret = crop.onHarvest(player, worldIn, pos, state, EnumHand.MAIN_HAND, player.getHeldItemMainhand(), false);
		if (ret.getLeft() == EnumActionResult.SUCCESS)
		{
			for (ItemStack is : ret.getRight())
			{
				EntityItem drop = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, is.copy());
				worldIn.spawnEntity(drop);
			}
		}
	}
	
	super.onBlockHarvested(worldIn, pos, state, player);
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:20,代碼來源:BlockCrop.java

示例2: generate

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@Override
public boolean generate(World worldIn, Random rand, BlockPos posIn) {
	
	if (!(worldIn instanceof WorldServer)) {
		return false;
	}

	WorldServer world = (WorldServer) worldIn;

	if (world.provider.getDimension() != -1) {
		return false;
	}

	if (world.rand.nextInt(rarity) == 0) {
		int y = findPosY(world, posIn);
		if (y > 0) {
			BlockPos pos = new BlockPos(posIn.getX(), findPosY(world, posIn), posIn.getZ());
			generateMonument(world, pos, rand);
		}
		return true;
	}

	return false;

}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:26,代碼來源:InfernalMonumentGenerator.java

示例3: randomDisplayTick

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    int i = ((Integer)stateIn.getValue(POWER)).intValue();

    if (i != 0)
    {
        double d0 = (double)pos.getX() + 0.5D + ((double)rand.nextFloat() - 0.5D) * 0.2D;
        double d1 = (double)((float)pos.getY() + 0.0625F);
        double d2 = (double)pos.getZ() + 0.5D + ((double)rand.nextFloat() - 0.5D) * 0.2D;
        float f = (float)i / 15.0F;
        float f1 = f * 0.6F + 0.4F;
        float f2 = Math.max(0.0F, f * f * 0.7F - 0.5F);
        float f3 = Math.max(0.0F, f * f * 0.6F - 0.7F);
        worldIn.spawnParticle(EnumParticleTypes.REDSTONE, d0, d1, d2, (double)f1, (double)f2, (double)f3, new int[0]);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:18,代碼來源:BlockRedstoneWire.java

示例4: findPossibleShelter

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@Nullable
private Vec3d findPossibleShelter()
{
    Random random = this.theCreature.getRNG();
    BlockPos blockpos = new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ);

    for (int i = 0; i < 10; ++i)
    {
        BlockPos blockpos1 = blockpos.add(random.nextInt(20) - 10, random.nextInt(6) - 3, random.nextInt(20) - 10);

        if (!this.theWorld.canSeeSky(blockpos1) && this.theCreature.getBlockPathWeight(blockpos1) < 0.0F)
        {
            return new Vec3d((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ());
        }
    }

    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:EntityAIFleeSun.java

示例5: Location

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
/** Creates a location from a world's spawn point */
public Location(WorldServer world)
{
    BlockPos spawn = world.getSpawnPoint();

    this.world = world;
    this.posX  = spawn.getX();
    this.posY  = spawn.getY();
    this.posZ  = spawn.getZ();
    this.pitch = 0;
    this.yaw   = 0;
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:13,代碼來源:Location.java

示例6: setMachineName

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public void setMachineName(BlockPos pos, String name) {
	String nameTag = "Name_"+pos.getX()+"_"+pos.getY()+"_"+pos.getZ();
	if (name == null || "".equals(name))
		this.db.removeTag(nameTag);
	else
		this.db.setString(nameTag, name);
	this.commit();
}
 
開發者ID:astronautlabs,項目名稱:rezolve,代碼行數:9,代碼來源:DatabaseServerEntity.java

示例7: findNewTarget

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
private void findNewTarget()
{
    if (this.currentPath == null || this.currentPath.isFinished())
    {
        int i = this.dragon.initPathPoints();
        BlockPos blockpos = this.dragon.worldObj.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION);
        EntityPlayer entityplayer = this.dragon.worldObj.getNearestAttackablePlayer(blockpos, 128.0D, 128.0D);
        int j;

        if (entityplayer != null)
        {
            Vec3d vec3d = (new Vec3d(entityplayer.posX, 0.0D, entityplayer.posZ)).normalize();
            j = this.dragon.getNearestPpIdx(-vec3d.xCoord * 40.0D, 105.0D, -vec3d.zCoord * 40.0D);
        }
        else
        {
            j = this.dragon.getNearestPpIdx(40.0D, (double)blockpos.getY(), 0.0D);
        }

        PathPoint pathpoint = new PathPoint(blockpos.getX(), blockpos.getY(), blockpos.getZ());
        this.currentPath = this.dragon.findPath(i, j, pathpoint);

        if (this.currentPath != null)
        {
            this.currentPath.incrementPathIndex();
        }
    }

    this.navigateToNextPathNode();

    if (this.currentPath != null && this.currentPath.isFinished())
    {
        this.dragon.getPhaseManager().setPhase(PhaseList.LANDING);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:36,代碼來源:PhaseLandingApproach.java

示例8: checkBlockLine

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
/**
 * Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
 * (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
 */
int checkBlockLine(BlockPos posOne, BlockPos posTwo)
{
    BlockPos blockpos = posTwo.add(-posOne.getX(), -posOne.getY(), -posOne.getZ());
    int i = this.getGreatestDistance(blockpos);
    float f = (float)blockpos.getX() / (float)i;
    float f1 = (float)blockpos.getY() / (float)i;
    float f2 = (float)blockpos.getZ() / (float)i;

    if (i == 0)
    {
        return -1;
    }
    else
    {
        for (int j = 0; j <= i; ++j)
        {
            BlockPos blockpos1 = posOne.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));

            if (!this.isReplaceable(world, blockpos1))
            {
                return j;
            }
        }

        return -1;
    }
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:32,代碼來源:BaseLargeTreeGenerator.java

示例9: randomDisplayTick

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
    for (int i = 0; i < 3; ++i)
    {
        int j = rand.nextInt(2) * 2 - 1;
        int k = rand.nextInt(2) * 2 - 1;
        double d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j;
        double d1 = (double)((float)pos.getY() + rand.nextFloat());
        double d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)k;
        double d3 = (double)(rand.nextFloat() * (float)j);
        double d4 = ((double)rand.nextFloat() - 0.5D) * 0.125D;
        double d5 = (double)(rand.nextFloat() * (float)k);
        worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:16,代碼來源:BlockEnderChest.java

示例10: 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

示例11: getSafeExitLocation

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
/**
 * Returns a safe BlockPos to disembark the bed
 */
@Nullable
public static BlockPos getSafeExitLocation(World worldIn, BlockPos pos, int tries)
{
    EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (int l = 0; l <= 1; ++l)
    {
        int i1 = i - enumfacing.getFrontOffsetX() * l - 1;
        int j1 = k - enumfacing.getFrontOffsetZ() * l - 1;
        int k1 = i1 + 2;
        int l1 = j1 + 2;

        for (int i2 = i1; i2 <= k1; ++i2)
        {
            for (int j2 = j1; j2 <= l1; ++j2)
            {
                BlockPos blockpos = new BlockPos(i2, j, j2);

                if (hasRoomForPlayer(worldIn, blockpos))
                {
                    if (tries <= 0)
                    {
                        return blockpos;
                    }

                    --tries;
                }
            }
        }
    }

    return null;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:40,代碼來源:BlockBed.java

示例12: canBlockSeeSky

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
public boolean canBlockSeeSky(BlockPos pos)
{
    if (pos.getY() >= this.getSeaLevel())
    {
        return this.canSeeSky(pos);
    }
    else
    {
        BlockPos blockpos = new BlockPos(pos.getX(), this.getSeaLevel(), pos.getZ());

        if (!this.canSeeSky(blockpos))
        {
            return false;
        }
        else
        {
            for (blockpos = blockpos.down(); blockpos.getY() > pos.getY(); blockpos = blockpos.down())
            {
                IBlockState iblockstate = this.getBlockState(blockpos);

                if (iblockstate.getBlock().getLightOpacity(iblockstate, this, blockpos) > 0 && !iblockstate.getMaterial().isLiquid())
                {
                    return false;
                }
            }

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

示例13: limb

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
void limb(BlockPos p_175937_1_, BlockPos p_175937_2_, Block p_175937_3_)
{
    BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
    int i = this.getGreatestDistance(blockpos);
    float f = (float)blockpos.getX() / (float)i;
    float f1 = (float)blockpos.getY() / (float)i;
    float f2 = (float)blockpos.getZ() / (float)i;

    for (int j = 0; j <= i; ++j)
    {
        BlockPos blockpos1 = p_175937_1_.add((double)(0.5F + (float)j * f), (double)(0.5F + (float)j * f1), (double)(0.5F + (float)j * f2));
        BlockLog.EnumAxis blocklog$enumaxis = this.getLogAxis(p_175937_1_, blockpos1);
        this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState().withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:16,代碼來源:WorldGenBigTree.java

示例14: triggerMixEffects

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
protected void triggerMixEffects(World worldIn, BlockPos pos)
{
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();
    worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

    for (int i = 0; i < 8; ++i)
    {
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:BlockLiquid.java

示例15: generate

import net.minecraft.util.math.BlockPos; //導入方法依賴的package包/類
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
	float f = rand.nextFloat() * (float)Math.PI;
       double d0 = (double)((float)(position.getX() + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
       double d1 = (double)((float)(position.getX() + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F);
       double d2 = (double)((float)(position.getZ() + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
       double d3 = (double)((float)(position.getZ() + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F);
       double d4 = (double)(position.getY() + rand.nextInt(3) - 2);
       double d5 = (double)(position.getY() + rand.nextInt(3) - 2);

       for (int i = 0; i < this.numberOfBlocks; ++i)
       {
           float f1 = (float)i / (float)this.numberOfBlocks;
           double d6 = d0 + (d1 - d0) * (double)f1;
           double d7 = d4 + (d5 - d4) * (double)f1;
           double d8 = d2 + (d3 - d2) * (double)f1;
           double d9 = rand.nextDouble() * (double)this.numberOfBlocks / 16.0D;
           double d10 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
           double d11 = (double)(MathHelper.sin((float)Math.PI * f1) + 1.0F) * d9 + 1.0D;
           int j = MathHelper.floor(d6 - d10 / 2.0D);
           int k = MathHelper.floor(d7 - d11 / 2.0D);
           int l = MathHelper.floor(d8 - d10 / 2.0D);
           int i1 = MathHelper.floor(d6 + d10 / 2.0D);
           int j1 = MathHelper.floor(d7 + d11 / 2.0D);
           int k1 = MathHelper.floor(d8 + d10 / 2.0D);

           for (int l1 = j; l1 <= i1; ++l1)
           {
               double d12 = ((double)l1 + 0.5D - d6) / (d10 / 2.0D);

               if (d12 * d12 < 1.0D)
               {
                   for (int i2 = k; i2 <= j1; ++i2)
                   {
                       double d13 = ((double)i2 + 0.5D - d7) / (d11 / 2.0D);

                       if (d12 * d12 + d13 * d13 < 1.0D)
                       {
                           for (int j2 = l; j2 <= k1; ++j2)
                           {
                               double d14 = ((double)j2 + 0.5D - d8) / (d10 / 2.0D);

                               if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D)
                               {
                                   BlockPos blockpos = new BlockPos(l1, i2, j2);

                                   IBlockState state = worldIn.getBlockState(blockpos);
                                   if(HarshenUtils.toArray(HarshenBlocks.HARSHEN_DIMENSIONAL_DIRT, HarshenBlocks.HARSHEN_DIMENSIONAL_ROCK).contains(worldIn.getBlockState(blockpos).getBlock()))
                                       worldIn.setBlockState(blockpos, this.state, 2);	


                               }
                           }
                       }
                   }
               }
           }
       }

       return true;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:62,代碼來源:PontusWorldGeneratorItiumOre.java


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