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


Java Location.getExtent方法代码示例

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


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

示例1: spawnItem

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
public void spawnItem(Location<World> location, ItemStackSnapshot snapshot, Object notifier) {
    World world = location.getExtent();
    Item rejectedItem = (Item) world.createEntity(EntityTypes.ITEM, location.getPosition());

    Cause cause = Cause.source(
            EntitySpawnCause.builder()
                    .entity(rejectedItem)
                    .type(SpawnTypes.PLUGIN)
                    .build()
            )
            .owner(CustomItemLibrary.getInstance().getPluginContainer())
            .notifier(notifier)
            .build();

    rejectedItem.offer(Keys.REPRESENTED_ITEM, snapshot);
    world.spawnEntity(rejectedItem, cause);
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:18,代码来源:Util.java

示例2: serialize

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public void serialize(TypeToken<?> typeToken, Location loc, ConfigurationNode value) throws ObjectMappingException {
    if(loc.getExtent() instanceof World){
        value.getNode("world").setValue(((World) loc.getExtent()).getName());
    }else{
        throw new ObjectMappingException("No world Extent");
    }

    value.getNode("x").setValue(loc.getX());
    value.getNode("y").setValue(loc.getY());
    value.getNode("z").setValue(loc.getZ());
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:LocationSerializer.java

示例3: putItemInWorld

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
static public void putItemInWorld(ItemStackSnapshot itemStackSnapshop, Location<World> spawnLocation) {
	Extent extent = spawnLocation.getExtent();
	Entity item = extent.createEntity(EntityTypes.ITEM, spawnLocation.getPosition());
	item.offer(Keys.REPRESENTED_ITEM, itemStackSnapshop);
	extent.spawnEntity(item, Cause.source(EntitySpawnCause.builder()
			.entity(item).type(SpawnTypes.PLUGIN).build()).build());

}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:9,代码来源:Shop.java

示例4: matches

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public boolean matches(ScriptEventData data) {
    Entity ent = entity.getInternal();
    Location<World> loc = ent.getLocation();
    World world = loc.getExtent();
    return D2SpongeEventHelper.checkEntityType(ent.getType(), data, this::error)
            && D2SpongeEventHelper.checkWorld(world, data, this::error)
            && D2SpongeEventHelper.checkCuboid((new LocationTag(loc)).getInternal(), data, this::error)
            && D2SpongeEventHelper.checkWeather(Utilities.getIdWithoutDefaultPrefix(
                    world.getWeather().getId()), data, this::error);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityMovesScriptEvent.java

示例5: matches

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public boolean matches(ScriptEvent.ScriptEventData data) {
    Entity ent = entity.getInternal();
    Location<World> loc = ent.getLocation();
    World world = loc.getExtent();
    return D2SpongeEventHelper.checkEntityType(ent.getType(), data, this::error)
            && D2SpongeEventHelper.checkWorld(world, data, this::error)
            && D2SpongeEventHelper.checkCuboid((new LocationTag(loc)).getInternal(), data, this::error)
            && D2SpongeEventHelper.checkWeather(Utilities.getIdWithoutDefaultPrefix(
                    world.getWeather().getId()), data, this::error);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntitySpawnsScriptEvent.java

示例6: matches

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public boolean matches(ScriptEventData data) {
    Entity ent = ((EntityTag) entities.getInternal().get(0)).getInternal();
    Location<World> loc = ent.getLocation();
    World world = loc.getExtent();
    return D2SpongeEventHelper.checkEntityType(ent.getType(), data, this::error, "type")
            && D2SpongeEventHelper.checkWorld(world, data, this::error)
            && D2SpongeEventHelper.checkCuboid(new LocationTag(loc).getInternal(), data, this::error)
            && D2SpongeEventHelper.checkWeather(Utilities.getIdWithoutDefaultPrefix(
                    world.getWeather().getId()), data, this::error);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:12,代码来源:EntityCollidesWithEntityScriptEvent.java

示例7: open

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
@Override
public void open(Player player, Manager manager) {
    PlayerOpenCrateEvent open_event = new PlayerOpenCrateEvent(player, manager);
    Sponge.getEventManager().post(open_event);
    if (open_event.isCancelled()) return;
    Location<World> location = player.getLocation();
    Vector3i position = player.getLocation().getBlockPosition();
    World world = location.getExtent();
    int loc_x = position.getX();
    int loc_y = position.getY();
    int loc_z = position.getZ();
    HashMap<Location<World>, BlockState> original_block_states = new HashMap<Location<World>, BlockState>();
    for (int x = -2; x <= 2; x++) {
        for (int y = -1; y <= 3; y++) {
            for (int z = -2; z <= 2; z++) {
                Location loc = new Location<World>(
                        world, loc_x + x, loc_y + y, loc_z + z);
                BlockState loc_state = loc.getBlock();
                original_block_states.put(loc, loc_state);
                location.setBlockType(BlockTypes.AIR, BlockChangeFlags.NONE);
            }
        }
    }
    for (int x = -2; x <= 2; x++) {
        for (int z = -2; z <= 2; z++) {
            new Location<World>(world, loc_x + x, loc_y - 1, loc_z + z).
                    setBlockType(floor_block_type, BlockChangeFlags.NONE);
            if (z == 2 || z == -2 || x == 2 || x == -2) {
                new Location<World>(world, loc_x + x, loc_y , loc_z + z).
                        setBlockType(fence_block_type, BlockChangeFlags.NONE);
            }
        }
    }
    HashSet<HologramsService.Hologram> holograms = new HashSet<HologramsService.Hologram>();
    Location<World> loc1 = new Location<World>(world, loc_x + 2, loc_y, loc_z);
    loc1.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.WEST).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc2 = new Location<World>(world, loc_x - 2, loc_y, loc_z);
    loc2.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.EAST).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc3 = new Location<World>(world, loc_x, loc_y, loc_z + 2);
    loc3.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.NORTH).
                    build(),
            BlockChangeFlags.NONE);
    Location<World> loc4 = new Location<World>(world, loc_x, loc_y, loc_z - 2);
    loc4.setBlock(BlockState.builder().
                    blockType(crate_block_type).
                    add(Keys.DIRECTION, Direction.SOUTH).
                    build(),
            BlockChangeFlags.NONE);
    Utils.tryCreateHologram(loc1, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc2, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc3, hologram).ifPresent(holograms::add);
    Utils.tryCreateHologram(loc4, hologram).ifPresent(holograms::add);
    getOpenSound().ifPresent(sound -> player.playSound(sound, player.getLocation().getPosition(), 1.));
    PLAYERS_OPENING_ANIMATION1.put(player, new Information(this, manager,
            new HashMap<Location<World>, Boolean>(){{
                put(loc1, false);
                put(loc2, false);
                put(loc3, false);
                put(loc4, false);
            }}, original_block_states, holograms));
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:72,代码来源:Animation1OpenManager.java

示例8: setHomeInternal

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
public void setHomeInternal(@Nullable Location<World> location) {
    home = location == null ? null : new Location<>(location.getExtent(), location.getPosition());
    TaskForwarder.sendUpdateClan(this);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:5,代码来源:ClanImpl.java

示例9: LocationTag

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
public LocationTag(Location<World> location) {
    this(location.getX(), location.getY(), location.getZ(), location.getExtent());
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:4,代码来源:LocationTag.java

示例10: setLoc

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
public void setLoc(Location<World> loc) {
	this.loc = new Location<World>(loc.getExtent(), loc.getBlockX()+0.5, loc.getY(), loc.getBlockZ()+0.5);
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:4,代码来源:NPCguard.java

示例11: placeBlock

import org.spongepowered.api.world.Location; //导入方法依赖的package包/类
/**
 * Constructs a custom block and places it in the world.
 *
 * @param block The block location
 * @param cause The cause
 * @return The wrapped block
 */
default T placeBlock(Block block, BlockChangeFlag flag, Cause cause) {
    Location<World> location = block.getLocation()
            .orElseThrow(() -> new IllegalStateException("Could not access the location of the provided block."));
    World world = location.getExtent();

    // Remove the previous custom block
    CustomItemLibrary.getInstance().getService().removeArmorStandsAt(block);

    location.setBlockType(CustomBlock.BLOCK_TYPE_CUSTOM, flag, cause);

    ArmorStand armorStand = createDummyArmorStand(block);
    Vector3d rotation = Vector3d.ZERO;

    if(isRotateHorizontally()) {
        Optional<Player> player = cause.first(Player.class);

        if(player.isPresent()) {
            Vector3d headRotation = player.get().getHeadRotation();
            double angle = Math.floorMod(180 + (int) Math.floor(headRotation.getY()), 360);
            angle += 45;
            angle = Math.floorMod((int) Math.floor(angle), 360);
            angle = (int) (angle / 90);
            angle = angle * 90;
            rotation = Vector3d.from(0, angle, 0);
        }
    }

    armorStand.offer(createDefaultCustomFeatureData());
    armorStand.offer(new CustomBlockData());
    armorStand.setRotation(rotation);

    world.spawnEntity(armorStand, cause);

    T result = customizeBlock(block, armorStand, cause);

    result.setModel(getDefaultModel());
    CustomItemLibrary.getInstance().getService().registerBlockAsLoaded(result);

    return result;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:48,代码来源:CustomBlockDefinition.java


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