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


Java BlockState.getType方法代码示例

本文整理汇总了Java中org.spongepowered.api.block.BlockState.getType方法的典型用法代码示例。如果您正苦于以下问题:Java BlockState.getType方法的具体用法?Java BlockState.getType怎么用?Java BlockState.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.block.BlockState的用法示例。


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

示例1: checkPhysicalLobbySign

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Override
protected int checkPhysicalLobbySign(Location3D loc) {
    if (loc.getWorld().isPresent()) {
        Optional<World> world = Sponge.getGame().getServer().getWorld(loc.getWorld().get());

        if (world.isPresent()) {
            BlockState blockState = world.get().getBlock(LocationConverter.floor(loc));

            if (blockState.getType() == BlockTypes.STANDING_SIGN
                    || blockState.getType() == BlockTypes.WALL_SIGN) {
                return 0;
            } else {
                InfernoCore.logWarning("Found lobby sign with location not containing a sign block. Removing...");
                return 2;
            }
        } else {
            InfernoCore.logVerbose("Cannot load world \"" + loc.getWorld().get()
                    + "\" - not loading contained lobby sign");
            return 1;
        }
    } else {
        InfernoCore.logWarning("Found lobby sign in store with invalid location serial. Removing...");
        return 2;
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:26,代码来源:InfernoMinigame.java

示例2: getBlockSelectionBox

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Override
public Optional<AABB> getBlockSelectionBox(int x, int y, int z) {
    final BlockState block = getBlock(x, y, z);
    if (block.getType() == BlockTypes.AIR) {
        return Optional.empty();
    }
    final ObjectProvider<AABB> aabbObjectProvider = ((LanternBlockType) block.getType()).getBoundingBoxProvider();
    if (aabbObjectProvider == null) {
        return Optional.empty();
    }
    final AABB aabb;
    if (aabbObjectProvider instanceof ConstantObjectProvider || aabbObjectProvider instanceof CachedSimpleObjectProvider
            || aabbObjectProvider instanceof SimpleObjectProvider) {
        aabb = aabbObjectProvider.get(block, null, null);
    } else {
        aabb = aabbObjectProvider.get(block, new Location<>(this.world, x, y, z), null);
    }
    return aabb == null ? Optional.empty() : Optional.of(aabb.offset(x, y, z));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:LanternChunk.java

示例3: doubleChest

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
public static AABB doubleChest(BlockState blockState, @Nullable Location<World> location, @Nullable Direction face) {
    if (location != null) {
        for (Direction direction : Chest.DIRECTIONS) {
            if (blockState.getType() == location.getBlockRelative(direction).getBlock().getType()) {
                switch (direction) {
                    case NORTH:
                        return Chest.CONNECTED_NORTH;
                    case EAST:
                        return Chest.CONNECTED_EAST;
                    case SOUTH:
                        return Chest.CONNECTED_SOUTH;
                    case WEST:
                        return Chest.CONNECTED_WEST;
                    default:
                        throw new IllegalStateException();
                }
            }
        }
    }
    return Chest.DEFAULT;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:BoundingBoxes.java

示例4: onRemove

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Override
public void onRemove() {
	super.onRemove();
	Location<World> location = getConsumer().getEntity().getLocation();
	BlockState build = BlockState.builder().blockType(BlockTypes.AIR).build();

	for (Vector3i vector3i : vector3is) {
		BlockState block = location.getExtent().getBlock(vector3i);
		if (block.getType() == BlockTypes.WEB) {
			location.getExtent().setBlock(
					vector3i,
					build,
					BlockChangeFlag.NONE
			);
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:18,代码来源:WebEffect.java

示例5: onPlayerInteract

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onPlayerInteract(InteractBlockEvent event) {
    BlockState state = event.getTargetBlock().getState();
    if (state.getType() == BlockTypes.WALL_SIGN || state.getType() == BlockTypes.STANDING_SIGN) {
        Optional<Player> player = event.getCause().first(Player.class);
        if (!event.getTargetBlock().getLocation().isPresent() || !player.isPresent()) {
            return;
        }
        Location3D loc = WorldLocationConverter.of(event.getTargetBlock().getLocation().get());

        CommonCore.getMinigames().values().forEach(mg -> mg.getArenas().stream()
                .filter(arena -> arena.getLobbySignAt(loc).isPresent()).forEach(arena -> {
                    Optional<Boolean> sneaking = player.get().get(Keys.IS_SNEAKING);
                    if (event instanceof InteractBlockEvent.Primary
                            && sneaking.isPresent() && sneaking.get()
                            || !mg.getConfigValue(ConfigNode.REQUIRE_SNEAK_TO_DESTROY_LOBBY)) {
                        if (player.get().hasPermission(mg.getPlugin() + ".lobby.destroy")
                                || player.get().hasPermission(mg.getPlugin() + ".lobby.*")) {
                            arena.getLobbySignAt(loc).get().unregister();
                            player.get().sendMessage(Text.builder("Unregistered lobby sign")
                                    .color(TextColors.DARK_AQUA).build());
                            return;
                        }
                    }
                    mg.getEventBus().post(new CommonPlayerClickLobbySignEvent(
                            player.get().getUniqueId(),
                            arena.getLobbySignAt(loc).get(),
                            event instanceof InteractBlockEvent.Primary
                                    ? PlayerClickLobbySignEvent.ClickType.LEFT
                                    : PlayerClickLobbySignEvent.ClickType.RIGHT
                    ));
                })
        );
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:36,代码来源:LobbyListener.java

示例6: isTransparent

import org.spongepowered.api.block.BlockState; //导入方法依赖的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

示例7: hasSurfaceFluids

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
boolean hasSurfaceFluids() {
    Location<World> lesser = this.getLesserBoundaryCorner();
    Location<World> greater = this.getGreaterBoundaryCorner();

    // don't bother for very large claims, too expensive
    if (this.getClaimBlocks() > MAX_AREA) {
        return false;
    }

    int seaLevel = 0; // clean up all fluids in the end

    // respect sea level in normal worlds
    if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) {
        seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent());
    }

    for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) {
        for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) {
            for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) {
                // dodge the exclusion claim
                BlockState block = lesser.getExtent().getBlock(x, y, z);

                if (block.getType() == BlockTypes.WATER || block.getType() == BlockTypes.FLOWING_WATER
                        || block.getType() == BlockTypes.LAVA || block.getType() == BlockTypes.FLOWING_LAVA) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:33,代码来源:GPClaim.java

示例8: getBlockStateMeta

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
public static int getBlockStateMeta(BlockState state) {
    Integer meta = BLOCKSTATE_META_CACHE.get(state);
    if (meta == null) {
        Block mcBlock = (net.minecraft.block.Block) state.getType();
        meta = mcBlock.getMetaFromState((IBlockState) state);
        BLOCKSTATE_META_CACHE.put(state, meta);
    }
    return meta;
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:10,代码来源:BlockUtils.java

示例9: handleBrokenBlock

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
private void handleBrokenBlock() {
    final Location<World> location = new Location<>(this.player.getWorld(), this.diggingBlock);

    final CauseStack causeStack = CauseStack.current();
    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        frame.pushCause(this.player);

        // Add context
        frame.addContext(EventContextKeys.PLAYER, this.player);
        frame.addContext(ContextKeys.INTERACTION_LOCATION, location);
        frame.addContext(ContextKeys.BLOCK_LOCATION, location);

        final BehaviorContextImpl context = new BehaviorContextImpl(causeStack);

        final BlockState blockState = location.getBlock();
        final LanternBlockType blockType = (LanternBlockType) blockState.getType();
        if (context.process(blockType.getPipeline().pipeline(BreakBlockBehavior.class),
                (ctx, behavior) -> behavior.tryBreak(blockType.getPipeline(), ctx)).isSuccess()) {
            context.accept();

            this.diggingBlock = null;
            this.diggingBlockType = null;
        } else {
            context.revert();

            // TODO: Resend tile entity data, action data, ... ???
            this.player.sendBlockChange(this.diggingBlock, blockState);
        }
        if (this.lastBreakState != -1) {
            sendBreakUpdate(-1);
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:34,代码来源:PlayerInteractionHandler.java

示例10: onBlockChange

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Override
public void onBlockChange(int x, int y, int z, BlockState oldBlockState, BlockState newBlockState) {
    final long key = LanternChunk.key(x >> 4, z >> 4);
    final ObservedChunk observedChunk = this.observedChunks.get(key);
    if (observedChunk != null) {
        observedChunk.addBlockChange(() -> new Vector3i(x, y, z));
        if (oldBlockState.getType() != newBlockState.getType()) {
            observedChunk.removeBlockAction(new Vector3i(x, y, z));
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:ObservedChunkManager.java

示例11: getByBlock

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
static PortalState getByBlock(BlockState state) {
	BlockType type = state.getType();
	if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA) {
		return LAVA;
	}
	if (type == BlockTypes.WATER || type == BlockTypes.FLOWING_WATER) {
		return WATER;
	}
	return INITIALIZED;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:PortalEffect.java

示例12: findLeversAndFloodBlocks

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
private void findLeversAndFloodBlocks() {

    Vector3i min = flashMemoryRoom.getMinimumPoint();
    Vector3i max = flashMemoryRoom.getMaximumPoint();

    int minX = min.getX();
    int minZ = min.getZ();
    int minY = min.getY();
    int maxX = max.getX();
    int maxZ = max.getZ();
    int maxY = max.getY();

    for (int x = minX; x <= maxX; x++) {
      for (int z = minZ; z <= maxZ; z++) {
        for (int y = maxY; y >= minY; --y) {
          BlockState state = getRegion().getExtent().getBlock(x, y, z);
          if (state.getType() == BlockTypes.LEVER) {
            Location<World> loc = new Location<>(getRegion().getExtent(), x, y, z);
            loc.getExtent().setBlock(
                loc.getBlockPosition(),
                state.withTrait(BooleanTraits.LEVER_POWERED, false).orElse(state),
                Cause.source(SkreePlugin.container()).build()
            );

            leverBlocks.put(loc, !Probability.getChance(3));
            for (int i = y; i < maxY; i++) {
              BlockType type = getRegion().getExtent().getBlockType(x, i, z);
              if (type == BlockTypes.AIR) {
                floodBlocks.add(new Location<>(getRegion().getExtent(), x, i, z));
                break;
              }
            }
            break; // One lever a column only
          }
        }
      }
    }
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:39,代码来源:GoldRushInstance.java

示例13: BlockStateView

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
public BlockStateView(BlockState value) {
    super(value);

    this.type = value.getType();
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:6,代码来源:BlockStateView.java

示例14: plantTree

import org.spongepowered.api.block.BlockState; //导入方法依赖的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

示例15: getBlock

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Override
public BlockState getBlock() {
    final BlockState block = getLocation().getBlock();
    return block.getType() == BlockTypes.FURNACE || block.getType() == BlockTypes.LIT_FURNACE ? block :
            BlockTypes.FURNACE.getDefaultState();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:LanternFurnace.java


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