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


Java MatterProperty类代码示例

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


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

示例1: onLiquidFlow

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
	if (e.getLocations().isEmpty()) return;
			
	Location<World> loc = e.getLocations().get(0);
	BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
	
	Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
	if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
		String name = "Water";
		BlockType type = snapshot.getState().getType();
		if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
			name = "Lava";
		db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:LiquidFlowListener.java

示例2: onWaterLavaFlow

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
@Listener
public void onWaterLavaFlow(ChangeBlockEvent.Place event)
{
    if (!this.module.getConfig().protectBlocksFromWaterLava)
    {
        return;
    }
    // do not allow change
    event.getTransactions().stream()
            .filter(trans -> trans.getFinal().getState().getType().getProperty(MatterProperty.class).get().getValue() == LIQUID)
            .forEach(trans -> {
                Location<World> location = trans.getOriginal().getLocation().get();
                if (manager.getLock(location) != null)
                {
                    trans.setCustom(trans.getOriginal()); // do not allow change
                }
            });
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:19,代码来源:LockerBlockListener.java

示例3: getLiquidBlockTypes

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
/**
 * Get a list of all LIQUID block types.
 *
 * @return List<BlockType>
 */
public static List<BlockType> getLiquidBlockTypes() {
    List<BlockType> liquids = new ArrayList<>();

    Collection<BlockType> types = Prism.getGame().getRegistry().getAllOf(BlockType.class);
    for (BlockType type : types) {
        Optional<MatterProperty> property = type.getProperty(MatterProperty.class);
        if (property.isPresent() && Objects.equals(property.get().getValue(), Matter.LIQUID)) {
            liquids.add(type);
        }
    }

    // @todo Sponge has not yet implemented the MatterProperties...
    liquids.add(BlockTypes.LAVA);
    liquids.add(BlockTypes.FLOWING_LAVA);
    liquids.add(BlockTypes.WATER);
    liquids.add(BlockTypes.FLOWING_WATER);

    return liquids;
}
 
开发者ID:prism,项目名称:Prism,代码行数:25,代码来源:BlockUtil.java

示例4: isTransparent

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
private static boolean isTransparent(BlockState blockstate, boolean waterIsTransparent) {
    if (blockstate.getType() == BlockTypes.SNOW_LAYER) {
        return false;
    }

    IBlockState iblockstate = (IBlockState)(Object) blockstate;
    Optional<MatterProperty> matterProperty = blockstate.getProperty(MatterProperty.class);
    if (!waterIsTransparent && matterProperty.isPresent() && matterProperty.get().getValue() == MatterProperty.Matter.LIQUID) {
        return false;
    }
    return !iblockstate.isOpaqueCube();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:13,代码来源:Visualization.java

示例5: hasLock

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
private boolean hasLock(Location<World> block, Direction direction, Set<Location<World>> locs, boolean extend, int iterations)
{
    iterations++;
    if (!locs.add(block) || iterations > 12) // Add Block to set - if not added or iterations > 12 stop
    {
        return false;
    }
    if (manager.getLock(block) != null) // Found Lock. Abort
    {
        return true;
    }

    if (block.getBlockType().getProperty(MatterProperty.class).get().getValue() != SOLID)
    {
        return false;
    }
    if (extend && hasLock(block.getRelative(direction), direction, locs, true, iterations))
    {
        return true;
    }
    if (block.getBlockType() == SLIME)
    {
        for (Direction dir : Direction.values())
        {
            if (dir.isCardinal() && hasLock(block.getRelative(dir), direction, locs, extend, iterations))
            {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:33,代码来源:LockerBlockListener.java

示例6: isSolidBlock

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
private boolean isSolidBlock(BlockState bs) {
    final Optional<MatterProperty> mp = bs.getProperty(MatterProperty.class);
    return mp.isPresent() && mp.get().getValue() == MatterProperty.Matter.SOLID;
}
 
开发者ID:ichorpowered,项目名称:latch,代码行数:5,代码来源:ChangeBlockListener.java

示例7: addClaimElements

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
private void addClaimElements(int height, Location<World> locality, GPPlayerData playerData) {
    this.initBlockVisualTypes(type);
    Location<World> lesser = this.claim.getLesserBoundaryCorner();
    Location<World> greater = this.claim.getGreaterBoundaryCorner();
    World world = lesser.getExtent();
    boolean liquidTransparent = locality.getBlock().getType().getProperty(MatterProperty.class).isPresent() ? false : true;

    this.smallx = lesser.getBlockX();
    this.smally = this.useCuboidVisual() ? lesser.getBlockY() : 0;
    this.smallz = lesser.getBlockZ();
    this.bigx = greater.getBlockX();
    this.bigy = this.useCuboidVisual() ? greater.getBlockY() : 0;
    this.bigz = greater.getBlockZ();
    this.minx = this.claim.cuboid ? this.smallx : locality.getBlockX() - 75;
    this.minz = this.claim.cuboid ? this.smallz : locality.getBlockZ() - 75;
    this.maxx = this.claim.cuboid ? this.bigx : locality.getBlockX() + 75;
    this.maxz = this.claim.cuboid ? this.bigz : locality.getBlockZ() + 75;

    // initialize visualization elements without Y values and real data
    // that will be added later for only the visualization elements within
    // visualization range

    if (this.smallx == this.bigx && this.smally == this.bigy && this.smallz == this.bigz) {
        BlockSnapshot blockClicked =
                snapshotBuilder.from(new Location<World>(world, this.smallx, this.smally, this.smallz)).blockState(this.cornerMaterial.getDefaultState()).build();
        elements.add(new Transaction<BlockSnapshot>(blockClicked.getLocation().get().createSnapshot(), blockClicked));
        return;
    }

    // check CUI support
    if (GriefPreventionPlugin.instance.worldEditProvider != null && playerData != null) {
        GriefPreventionPlugin.instance.worldEditProvider.hasCUISupport(playerData.getPlayerName());
        playerData.showVisualFillers = false;
        STEP = 0;
    }

    if (this.useCuboidVisual()) {
        this.addVisuals3D(claim, playerData);
    } else {
        this.addVisuals2D(claim, height, liquidTransparent);
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:43,代码来源:Visualization.java

示例8: matter

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
public static PropertyProviderCollection matter(MatterProperty.Matter constant) {
    final MatterProperty property = MATTER_PROPERTIES.get(constant);
    return PropertyProviderCollection.builder()
            .add(MatterProperty.class, new ConstantPropertyProvider<>(property))
            .build();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:PropertyProviders.java

示例9: isLiquid

import org.spongepowered.api.data.property.block.MatterProperty; //导入依赖的package包/类
@Override
public boolean isLiquid() {
    return getHandle().getBlockType().getProperty(MatterProperty.class).get().getValue() == LIQUID;
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PoreBlock.java


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