本文整理汇总了Java中org.spongepowered.api.data.property.block.PassableProperty类的典型用法代码示例。如果您正苦于以下问题:Java PassableProperty类的具体用法?Java PassableProperty怎么用?Java PassableProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PassableProperty类属于org.spongepowered.api.data.property.block包,在下文中一共展示了PassableProperty类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: groundEntity
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private static Handler groundEntity()
{
return mount -> {
double speed = mount.currentSpeed();
Vector3d rotation = mount.player.getHeadRotation();
Vector3d velocity = rotationToVelocity(mount.player.getRotation(), speed, 0).add(0, mount.vehicle.getVelocity().getY(), 0);
Vector3d ahead = direction(rotation).mul(1, 0, 1);
Optional<PassableProperty> passable = mount.vehicle.getLocation().add(ahead).getProperty(PassableProperty.class);
if (!passable.map(AbstractProperty::getValue).orElse(true) && canJump(mount.vehicle))
{
velocity = velocity.add(0, 0.15 + (speed * 0.15), 0);
}
mount.vehicle.setVelocity(velocity);
mount.vehicle.setRotation(rotation);
};
}
开发者ID:dags-,项目名称:Mounts,代码行数:19,代码来源:Mount.java
示例2: canJump
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private static boolean canJump(Living mount)
{
return mount.isOnGround() || !mount.getLocation()
.getRelative(Direction.DOWN)
.getRelative(Direction.DOWN)
.getProperty(PassableProperty.class)
.map(AbstractProperty::getValue)
.orElse(false);
}
开发者ID:dags-,项目名称:Mounts,代码行数:10,代码来源:Mount.java
示例3: plantTree
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private void plantTree(ExplosionEvent.Pre event) {
Location explosionLocation = event.getExplosion().getLocation();
int x = (int) explosionLocation.getX();
int y = (int) explosionLocation.getY();
int z = (int) explosionLocation.getZ();
//Evaluating the tree type, based on biome
World world = event.getTargetWorld();
BiomeType biome = world.getBiome(x, z);
BiomeGenerationSettings biomeSettings = world.getWorldGenerator().getBiomeSettings(biome);
List<Forest> forestPopulators = biomeSettings.getPopulators(Forest.class);
PopulatorObject populator;
try {
//There may be multiple tree types in one Biome. Get one per weighted random
populator = forestPopulators.isEmpty() ? fallbackTreePopulator : forestPopulators.get(0).getTypes().get(random).get(0);
} catch (Exception e) {
populator = fallbackTreePopulator;
}
//if the explosion happened on level 0, set it to 1, so we can place a dirt block below
if (y == 0) {
y = 1;
}
Vector3i pos = new Vector3i(x, y, z);
Vector3i below = new Vector3i(x, y - 1, z);
Cause genericCause = Cause.of(NamedCause.owner(container));
//set Dirt block below if possible (Trees cannot be placed without)
BlockState blockBelow = world.containsBlock(below) ? world.getBlock(below) : null;
if (blockBelow != null) {
BlockState blockState = BlockState.builder().blockType(BlockTypes.DIRT).build();
world.setBlock(below, blockState, genericCause);
}
//Remove Grass, redstone, etc.
BlockState blockOnPosition = world.getBlock(pos);
Optional<PassableProperty> passableProperty_Op = blockOnPosition.getProperty(PassableProperty.class);
boolean blockPassable = passableProperty_Op.isPresent() && passableProperty_Op.get().getValue();
boolean passableBlockRemoved = false;
if (blockPassable) {
world.setBlock(pos, BlockState.builder().blockType(BlockTypes.AIR).build(), BlockChangeFlag.NEIGHBOR, genericCause);
passableBlockRemoved = true;
}
boolean treePlaced = false;
//is the tree placeable?
if (populator.canPlaceAt(world, x, y, z)) {
//Place the tree
populator.placeObject(world, random, x, y, z);
treePlaced = true;
} else if (passableBlockRemoved) {
//Reset passable Block
world.setBlock(pos, blockOnPosition, genericCause);
}
//Replace block below with original Block (unless the tree was placed in mid-air or water)
if (blockBelow != null && !(treePlaced && (blockBelow.getType() == BlockTypes.AIR ||
blockBelow.getType() == BlockTypes.WATER ||
blockBelow.getType() == BlockTypes.FLOWING_WATER))) {
world.setBlock(below, blockBelow, genericCause);
}
}
开发者ID:Felfio,项目名称:treepers-sponge,代码行数:71,代码来源:Treepers.java
示例4: passable
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
public static PropertyProviderCollection passable(boolean constant) {
final PassableProperty property = constant ? PASSABLE_PROPERTY_TRUE : PASSABLE_PROPERTY_FALSE;
return PropertyProviderCollection.builder()
.add(PassableProperty.class, new ConstantPropertyProvider<>(property))
.build();
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:PropertyProviders.java
示例5: execute
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
if (src instanceof Player)
{
Player player = (Player) src;
BlockRay<World> playerBlockRay = BlockRay.from(player).blockLimit(350).build();
BlockRayHit<World> finalHitRay = null;
while (playerBlockRay.hasNext())
{
BlockRayHit<World> currentHitRay = playerBlockRay.next();
if (!player.getWorld().getBlockType(currentHitRay.getBlockPosition()).equals(BlockTypes.AIR))
{
finalHitRay = currentHitRay;
break;
}
}
if (finalHitRay == null)
{
player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Could not find the block you're looking at within range!"));
}
else
{
boolean safely = false;
// If not passable, then it is a solid block
if (!finalHitRay.getLocation().getProperty(PassableProperty.class).get().getValue())
{
safely = player.setLocationSafely(finalHitRay.getLocation().add(0, 1, 0));
}
else
{
// If the block below this is tall grass or a tall flower, then teleport down to that
if (finalHitRay.getLocation().getRelative(Direction.DOWN).getProperty(PassableProperty.class).get().getValue())
{
safely = player.setLocationSafely(finalHitRay.getLocation().sub(0, 1, 0));
}
else
{
// If not then we found our location
safely = player.setLocationSafely(finalHitRay.getLocation());
}
}
if (safely)
{
player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Jumped to the block you were looking at."));
}
else
{
player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Couldn't safely put you where you are looking."));
}
}
}
else
{
src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /jump!"));
}
return CommandResult.success();
}
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:64,代码来源:JumpExecutor.java
示例6: isPassable
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private boolean isPassable(BlockType blockType) {
Optional<PassableProperty> optProp = blockType.getProperty(PassableProperty.class);
return optProp.map(AbstractProperty::getValue).orElse(false);
}
开发者ID:Skelril,项目名称:Skree,代码行数:5,代码来源:FearBomb.java
示例7: isSafePassableBlock
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private static boolean isSafePassableBlock(BlockType blockType) {
boolean isPassable = blockType.getProperty(PassableProperty.class).orElse(new PassableProperty(false)).getValue();
return isPassable && !isBlacklistedBlock(blockType);
}
开发者ID:Skelril,项目名称:Skree,代码行数:6,代码来源:SafeTeleportHelper.java
示例8: isPassable
import org.spongepowered.api.data.property.block.PassableProperty; //导入依赖的package包/类
private static boolean isPassable(World w, Double x, int y, Double z) {
Optional<PassableProperty> prop = new Location<>(w, x, y, z).getBlock().getProperty(PassableProperty.class);
return prop.map(AbstractProperty::getValue).orElse(false);
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:5,代码来源:LocationUtil.java
注:本文中的org.spongepowered.api.data.property.block.PassableProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论