• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ConstructEntityEvent类的典型用法和代码示例

java 1次浏览

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

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

示例1: onMobSpawn

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
@Listener
public void onMobSpawn(ConstructEntityEvent.Pre event, @Root Entity entity) {
    if (entity instanceof Living) {
        Optional<Chunk> chunk = entity.getWorld().getChunk(entity.getLocation().getChunkPosition());
        chunk.ifPresent(chunk1 -> {
            if (chunk1.getEntities().size() >= plugin.getMobLimitPerChunk()) {
                event.setCancelled(true);
            }
        });
    }
}
 

开发者ID:Time6628,
项目名称:CatClearLag,
代码行数:12,
代码来源:MobEventHandler.java

示例2: createEntity

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
public Entity createEntity(EntityType type, Vector3d position, Consumer<Entity> entityConsumer) {
    checkNotNull(position, "position");
    final LanternEntityType entityType = (LanternEntityType) checkNotNull(type, "type");
    final LanternEntity entity = (LanternEntity) entityType.getEntityConstructor().apply(UUID.randomUUID());
    entity.setPositionAndWorld(this, position);
    entityConsumer.accept(entity);
    final CauseStack causeStack = CauseStack.current();
    // Only throw the post event, the pre event will
    // only be called in specific cases.
    final ConstructEntityEvent.Post event = SpongeEventFactory.createConstructEntityEventPost(
            causeStack.getCurrentCause(), entity, type, entity.getTransform());
    Sponge.getEventManager().post(event);
    return entity;
}
 

开发者ID:LanternPowered,
项目名称:LanternServer,
代码行数:15,
代码来源:LanternWorld.java

示例3: handlePreEntitySpawning

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
private static List<Entity> handlePreEntitySpawning(CauseStack causeStack, Iterable<EntitySpawningEntry> entries) {
    final List<Entity> entities = new ArrayList<>();
    for (EntitySpawningEntry entry : entries) {
        // Call the pre construction event
        final ConstructEntityEvent.Pre preConstructEvent = SpongeEventFactory.createConstructEntityEventPre(
                causeStack.getCurrentCause(), entry.entityType, entry.transform);
        Sponge.getEventManager().post(preConstructEvent);
        if (!preConstructEvent.isCancelled()) {
            // Calls the post construction event
            entities.add(((LanternWorld) entry.transform.getExtent())
                    .createEntity(entry.entityType, entry.transform.getPosition(), entry.entityConsumer));
        }
    }
    return entities;
}
 

开发者ID:LanternPowered,
项目名称:LanternServer,
代码行数:16,
代码来源:LanternWorld.java

示例4: onEntityConstruction

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
@Listener
public void onEntityConstruction(ConstructEntityEvent.Pre event) {
  if (!isApplicable(event.getTransform().getExtent())) {
    return;
  }

  if (Monster.class.isAssignableFrom(event.getTargetType().getEntityClass())) {
    event.setCancelled(true);
  }
}
 

开发者ID:Skelril,
项目名称:Skree,
代码行数:11,
代码来源:MainWorldWrapper.java

示例5: onVehiclePlace

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
@Listener
public void onVehiclePlace(ConstructEntityEvent.Post event)
{
    if (event.getTargetEntity() instanceof Boat)
    {
        System.out.println("place");
        event.getTargetEntity().offer(new UnbreakableData(true));
    }
}
 

开发者ID:CubeEngine,
项目名称:modules-extra,
代码行数:10,
代码来源:Unbreakableboat.java

示例6: spawnEntity

点赞 2

import org.spongepowered.api.event.entity.ConstructEntityEvent; //导入依赖的package包/类
@Listener(order = Order.POST)
@Exclude({ConstructEntityEvent.class, DropItemEvent.Pre.class})
public void spawnEntity(Event event, @Root Cause cause)
        throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (!(cause.root() instanceof Player)) {
        return;
    }

    Player player = (Player) cause.root();

    if (event instanceof SpawnEntityEvent) {
        if (((SpawnEntityEvent) event).getEntities().isEmpty()) {
            return;
        }

        Entity entity = ((SpawnEntityEvent) event).getEntities().get(0);

        if (entity.getType().equals(EntityTypes.FISHING_HOOK)) {
            // Ignore fishing hooks - handled by FishingEvent
            return;
        }

        if (event instanceof DropItemEvent.Dispense) {
            int quantityDropped = 0;
            try {
                quantityDropped = ((Item) entity).item().get().getQuantity();
            } catch (IndexOutOfBoundsException err) {
                // suppress IndexOutOfBoundsException error and bail
                // this fixes an "impossible" issue #27
            }

            if (quantityDropped == 0) {
                return;
            }

            processEvent(event, player, quantityDropped);
        }
    } else {
        processEvent(event, player);
    }
}
 

开发者ID:BadgeUp,
项目名称:badgeup-sponge-client,
代码行数:42,
代码来源:GeneralEventListener.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)