net.minecraft.util.math.BlockPos#west ( )源码实例Demo

下面列出了net.minecraft.util.math.BlockPos#west ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: the-hallow   文件: EatBreadcrumbsGoal.java
private BlockPos tweakToProperPos(BlockPos pos, BlockView blockView) {
	if (blockView.getBlockState(pos).getBlock() == this.targetBlock) {
		return pos;
	} else {
		BlockPos[] blockPoss = new BlockPos[]{pos.down(), pos.west(), pos.east(), pos.north(), pos.south(), pos.down().down()};
		BlockPos[] var4 = blockPoss;
		int var5 = blockPoss.length;
		
		for (int var6 = 0; var6 < var5; ++var6) {
			BlockPos blockPos2 = var4[var6];
			if (blockView.getBlockState(blockPos2).getBlock() == this.targetBlock) {
				return blockPos2;
			}
		}
		
		return null;
	}
}
 
@Override
public List<BlockPos> getOtherParts(BlockState state, BlockPos pos) {
    List<BlockPos> parts = new LinkedList<>();
    BlockPos rod = pos.up();
    BlockPos mid = rod.up();
    BlockPos front = mid.north();
    BlockPos back = mid.south();

    BlockPos right = mid.east();
    BlockPos left = mid.west();

    BlockPos frontLeft = front.east();
    BlockPos frontRight = front.west();
    BlockPos backLeft = back.east();
    BlockPos backRight = back.west();

    parts.add(rod);
    parts.add(mid);
    parts.add(front);
    parts.add(back);

    parts.add(right);
    parts.add(left);

    parts.add(frontLeft);
    parts.add(frontRight);
    parts.add(backLeft);
    parts.add(backRight);

    return parts;
}
 
源代码3 项目: seppuku   文件: HolesModule.java
private boolean isBlockValid(IBlockState blockState, BlockPos blockPos) {
    if (this.holes.contains(blockPos))
        return false;

    if (blockState.getBlock() != Blocks.AIR)
        return false;

    if (Minecraft.getMinecraft().player.getDistanceSq(blockPos) < 1)
        return false;

    if (Minecraft.getMinecraft().world.getBlockState(blockPos.up()).getBlock() != Blocks.AIR)
        return false;

    if (Minecraft.getMinecraft().world.getBlockState(blockPos.up(2)).getBlock() != Blocks.AIR) // ensure the area is tall enough for the player
        return false;

    final BlockPos[] touchingBlocks = new BlockPos[]{
            blockPos.north(), blockPos.south(), blockPos.east(), blockPos.west()
    };

    int validHorizontalBlocks = 0;
    for (BlockPos touching : touchingBlocks) {
        final IBlockState touchingState = Minecraft.getMinecraft().world.getBlockState(touching);
        if ((touchingState.getBlock() != Blocks.AIR) && touchingState.isFullBlock()) {
            validHorizontalBlocks++;
        }
    }

    if (validHorizontalBlocks < 4)
        return false;

    return true;
}
 
源代码4 项目: TofuCraftReload   文件: BlockRice.java
protected float getRiceGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
    float f = 1.0F;
    BlockPos blockpos = pos.down();

    for (int i = -1; i <= 1; ++i) {
        for (int j = -1; j <= 1; ++j) {
            float f1 = 0.0F;
            IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

            if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
                f1 = 1.0F;

                if (this.isWater(worldIn, blockpos.add(i, 0, j))) {
                    f1 = 3.0F;
                }
            }

            if (i != 0 || j != 0) {
                f1 /= 4.0F;
            }

            f += f1;
        }
    }

    BlockPos blockpos1 = pos.north();
    BlockPos blockpos2 = pos.south();
    BlockPos blockpos3 = pos.west();
    BlockPos blockpos4 = pos.east();
    boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
    boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();

    if (flag && flag1) {
        f /= 2.0F;
    } else {
        boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

        if (flag2) {
            f /= 2.0F;
        }
    }

    return f;
}
 
源代码5 项目: Sakura_mod   文件: BlockPepperCrop.java
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
	float f = 1.0F;
	BlockPos blockpos = pos.down();

	for (int i = -1; i <= 1; ++i) {
		for (int j = -1; j <= 1; ++j) {
			float f1 = 0.0F;
			IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

			if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j),
					net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
				f1 = 1.0F;

				if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) {
					f1 = 3.0F;
				}
			}

			if (i != 0 || j != 0) {
				f1 /= 4.0F;
			}

			f += f1;
		}
	}

	BlockPos blockpos1 = pos.north();
	BlockPos blockpos2 = pos.south();
	BlockPos blockpos3 = pos.west();
	BlockPos blockpos4 = pos.east();
	boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos4).getBlock();
	boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos2).getBlock();

	if (flag && flag1) {
		f /= 2.0F;
	} else {
		boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.south()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

		if (flag2) {
			f /= 2.0F;
		}
	}

	return f;
}
 
源代码6 项目: Sakura_mod   文件: BlockVanillaCrop.java
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
	float f = 1.0F;
	BlockPos blockpos = pos.down();

	for (int i = -1; i <= 1; ++i) {
		for (int j = -1; j <= 1; ++j) {
			float f1 = 0.0F;
			IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

			if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j),
					net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
				f1 = 1.0F;

				if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) {
					f1 = 3.0F;
				}
			}

			if (i != 0 || j != 0) {
				f1 /= 4.0F;
			}

			f += f1;
		}
	}

	BlockPos blockpos1 = pos.north();
	BlockPos blockpos2 = pos.south();
	BlockPos blockpos3 = pos.west();
	BlockPos blockpos4 = pos.east();
	boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos4).getBlock();
	boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos2).getBlock();

	if (flag && flag1) {
		f /= 2.0F;
	} else {
		boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.south()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

		if (flag2) {
			f /= 2.0F;
		}
	}

	return f;
}
 
源代码7 项目: Sakura_mod   文件: BlockRiceCrop.java
protected float getRiceGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
    float f = 1.0F;
    BlockPos blockpos = pos.down();

    for (int i = -1; i <= 1; ++i) {
        for (int j = -1; j <= 1; ++j) {
            float f1 = 0.0F;
            IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

            if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
                f1 = 1.0F;

                if (this.isWater(worldIn, blockpos.add(i, 0, j))) {
                    f1 = 3.0F;
                }
            }

            if (i != 0 || j != 0) {
                f1 /= 4.0F;
            }

            f += f1;
        }
    }

    BlockPos blockpos1 = pos.north();
    BlockPos blockpos2 = pos.south();
    BlockPos blockpos3 = pos.west();
    BlockPos blockpos4 = pos.east();
    boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
    boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();

    if (flag && flag1) {
        f /= 2.0F;
    } else {
        boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

        if (flag2) {
            f /= 2.0F;
        }
    }

    return f;
}
 
源代码8 项目: Sakura_mod   文件: BlockGrapeVine.java
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
	float f = 1.0F;
	BlockPos blockpos = pos.down();

	for (int i = -1; i <= 1; ++i) {
		for (int j = -1; j <= 1; ++j) {
			float f1 = 0.0F;
			IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

			if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j),
					net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
				f1 = 1.0F;

				if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) {
					f1 = 3.0F;
				}
			}

			if (i != 0 || j != 0) {
				f1 /= 4.0F;
			}

			f += f1;
		}
	}

	BlockPos blockpos1 = pos.north();
	BlockPos blockpos2 = pos.south();
	BlockPos blockpos3 = pos.west();
	BlockPos blockpos4 = pos.east();
	boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos4).getBlock();
	boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos2).getBlock();

	if (flag && flag1) {
		f /= 2.0F;
	} else {
		boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.south()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

		if (flag2) {
			f /= 2.0F;
		}
	}

	return f;
}
 
源代码9 项目: Sakura_mod   文件: BlockGrapeLeaves.java
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos) {
	float f = 1.0F;
	BlockPos blockpos = pos.down();

	for (int i = -1; i <= 1; ++i) {
		for (int j = -1; j <= 1; ++j) {
			float f1 = 0.0F;
			IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

			if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j),
					net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable) blockIn)) {
				f1 = 1.0F;

				if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j))) {
					f1 = 3.0F;
				}
			}

			if (i != 0 || j != 0) {
				f1 /= 4.0F;
			}

			f += f1;
		}
	}

	BlockPos blockpos1 = pos.north();
	BlockPos blockpos2 = pos.south();
	BlockPos blockpos3 = pos.west();
	BlockPos blockpos4 = pos.east();
	boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos4).getBlock();
	boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock()
			|| blockIn == worldIn.getBlockState(blockpos2).getBlock();

	if (flag && flag1) {
		f /= 2.0F;
	} else {
		boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.north()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos4.south()).getBlock()
				|| blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

		if (flag2) {
			f /= 2.0F;
		}
	}

	return f;
}
 
源代码10 项目: Sakura_mod   文件: BlockChestnut.java
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
{
    float f = 1.0F;
    BlockPos blockpos = pos.down();

    for (int i = -1; i <= 1; ++i)
    {
        for (int j = -1; j <= 1; ++j)
        {
            float f1 = 0.0F;
            IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));

            if (iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, blockpos.add(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)blockIn))
            {
                f1 = 1.0F;

                if (iblockstate.getBlock().isFertile(worldIn, blockpos.add(i, 0, j)))
                {
                    f1 = 3.0F;
                }
            }

            if (i != 0 || j != 0)
            {
                f1 /= 4.0F;
            }

            f += f1;
        }
    }

    BlockPos blockpos1 = pos.north();
    BlockPos blockpos2 = pos.south();
    BlockPos blockpos3 = pos.west();
    BlockPos blockpos4 = pos.east();
    boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
    boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();

    if (flag && flag1)
    {
        f /= 2.0F;
    }
    else
    {
        boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();

        if (flag2)
        {
            f /= 2.0F;
        }
    }

    return f;
}
 
源代码11 项目: seppuku   文件: NoCrystalModule.java
@Listener
public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final FreeCamModule freeCam = (FreeCamModule) Seppuku.INSTANCE.getModuleManager().find(FreeCamModule.class);

        if(freeCam != null && freeCam.isEnabled()) {
            return;
        }

        final Vec3d pos = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
        final float playerSpeed = (float) MathUtil.getDistance(pos, mc.player.posX, mc.player.posY, mc.player.posZ);

        final BlockPos interpPos = new BlockPos(pos.x, pos.y, pos.z);

        final BlockPos north = interpPos.north();
        final BlockPos south = interpPos.south();
        final BlockPos east = interpPos.east();
        final BlockPos west = interpPos.west();

        final BlockPos northBelow = interpPos.north().down();
        final BlockPos southBelow = interpPos.south().down();
        final BlockPos eastBelow = interpPos.east().down();
        final BlockPos westBelow = interpPos.west().down();

        int lastSlot;
        final int slot = findStackHotbar(Blocks.OBSIDIAN);
        if (hasStack(Blocks.OBSIDIAN) || slot != -1) {
            if ((mc.player.onGround && playerSpeed <= 0.005f)
                    && (this.sneak.getValue() || (!mc.gameSettings.keyBindSneak.isKeyDown()))) {

                lastSlot = mc.player.inventory.currentItem;
                mc.player.inventory.currentItem = slot;
                mc.playerController.updateController();

                // Place supporting blocks
                if (valid(northBelow)) {
                    place(northBelow, EnumFacing.SOUTH);
                }
                if (valid(southBelow)) {
                    place(southBelow, EnumFacing.NORTH);
                }
                if (valid(eastBelow)) {
                    place(eastBelow, EnumFacing.WEST);
                }
                if (valid(westBelow)) {
                    place(westBelow, EnumFacing.EAST);
                }

                // Place protecting blocks
                if (valid(north)) {
                    place(north, EnumFacing.SOUTH);
                }
                if (valid(south)) {
                    place(south, EnumFacing.NORTH);
                }
                if (valid(east)) {
                    place(east, EnumFacing.WEST);
                }
                if (valid(west)) {
                    place(west, EnumFacing.EAST);
                }

                if (!slotEqualsBlock(lastSlot, Blocks.OBSIDIAN)) {
                    mc.player.inventory.currentItem = lastSlot;
                }
                mc.playerController.updateController();

                if (this.disable.getValue()) {
                    this.toggle();
                }
            }
        }
    }
}
 
源代码12 项目: Wurst7   文件: PathFinder.java
private ArrayList<PathPos> getNeighbors(PathPos pos)
{
	ArrayList<PathPos> neighbors = new ArrayList<>();
	
	// abort if too far away
	if(Math.abs(start.getX() - pos.getX()) > 256
		|| Math.abs(start.getZ() - pos.getZ()) > 256)
		return neighbors;
	
	// get all neighbors
	BlockPos north = pos.north();
	BlockPos east = pos.east();
	BlockPos south = pos.south();
	BlockPos west = pos.west();
	
	BlockPos northEast = north.east();
	BlockPos southEast = south.east();
	BlockPos southWest = south.west();
	BlockPos northWest = north.west();
	
	BlockPos up = pos.up();
	BlockPos down = pos.down();
	
	// flying
	boolean flying = canFlyAt(pos);
	// walking
	boolean onGround = canBeSolid(down);
	
	// player can move sideways if flying, standing on the ground, jumping,
	// or inside of a block that allows sideways movement (ladders, webs,
	// etc.)
	if(flying || onGround || pos.isJumping()
		|| canMoveSidewaysInMidairAt(pos) || canClimbUpAt(pos.down()))
	{
		// north
		if(checkHorizontalMovement(pos, north))
			neighbors.add(new PathPos(north));
		
		// east
		if(checkHorizontalMovement(pos, east))
			neighbors.add(new PathPos(east));
		
		// south
		if(checkHorizontalMovement(pos, south))
			neighbors.add(new PathPos(south));
		
		// west
		if(checkHorizontalMovement(pos, west))
			neighbors.add(new PathPos(west));
		
		// north-east
		if(checkDiagonalMovement(pos, Direction.NORTH, Direction.EAST))
			neighbors.add(new PathPos(northEast));
		
		// south-east
		if(checkDiagonalMovement(pos, Direction.SOUTH, Direction.EAST))
			neighbors.add(new PathPos(southEast));
		
		// south-west
		if(checkDiagonalMovement(pos, Direction.SOUTH, Direction.WEST))
			neighbors.add(new PathPos(southWest));
		
		// north-west
		if(checkDiagonalMovement(pos, Direction.NORTH, Direction.WEST))
			neighbors.add(new PathPos(northWest));
	}
	
	// up
	if(pos.getY() < 256 && canGoThrough(up.up())
		&& (flying || onGround || canClimbUpAt(pos))
		&& (flying || canClimbUpAt(pos) || goal.equals(up)
			|| canSafelyStandOn(north) || canSafelyStandOn(east)
			|| canSafelyStandOn(south) || canSafelyStandOn(west))
		&& (divingAllowed || BlockUtils.getState(up.up())
			.getMaterial() != Material.WATER))
		neighbors.add(new PathPos(up, onGround));
	
	// down
	if(pos.getY() > 0 && canGoThrough(down) && canGoAbove(down.down())
		&& (flying || canFallBelow(pos)) && (divingAllowed
			|| BlockUtils.getState(pos).getMaterial() != Material.WATER))
		neighbors.add(new PathPos(down));
	
	return neighbors;
}
 
源代码13 项目: TFC2   文件: TeleporterPaths.java
@Override
public boolean placeInExistingPortal(Entity entityIn, float rotationYaw)
{
	boolean flag = true;
	int playerX = MathHelper.floor(entityIn.posX);
	int playerZ = MathHelper.floor(entityIn.posZ);
	boolean shouldAddPortalPosition = true;
	boolean foundPortal = false;
	BlockPos object = new BlockPos(entityIn);
	long k = ChunkPos.asLong(playerX, playerZ);

	IslandMap islandMap = Core.getMapForWorld(worldServerInstance, entityIn.getPosition());
	Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096));
	//Check if we already have a portal position cached here
	if (this.destinationCoordinateCache.containsKey(k))
	{
		Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.get(k);
		object = portalposition;
		portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
		shouldAddPortalPosition = false;
	}
	else //If not then we do a simple search for the closest portal block
	{
		object = this.findPortal(new BlockPos(entityIn));
	}

	//If we found a portal location then we need to move the player to it
	if (object != null)
	{
		if (shouldAddPortalPosition)
		{
			this.destinationCoordinateCache.put(k, new Teleporter.PortalPosition((BlockPos)object, this.worldServerInstance.getTotalWorldTime()));
			//this.destinationCoordinateKeys.add(Long.valueOf(k));
		}

		EnumFacing enumfacing = null;
		BlockPos pos = object;
		PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal);

		if(this.checkRoomForPlayer(pos.north()))
			pos = pos.north();
		else if(this.checkRoomForPlayer(pos.south()))
			pos = pos.south();
		else if(this.checkRoomForPlayer(pos.east()))
			pos = pos.east();
		else if(this.checkRoomForPlayer(pos.west()))
			pos = pos.west();

		entityIn.setLocationAndAngles(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, rotationYaw, entityIn.rotationPitch);
		return true;
	}
	else
	{
		return false;
	}
}