Esempio n. 1
0
 public List<Entity> getEntities() {
   List<Entity> entities = new ArrayList<Entity>();
   for (Location<World> loc : POS2) {
     Location<World> pos2 = loc.getRelative(Direction.UP);
     for (Entity entity : loc.getExtent().getEntities()) {
       if (entity.getLocation().getBlockPosition().equals(pos2.getBlockPosition())) {
         entities.add(entity);
       }
     }
   }
   return entities;
 }
 @Override
 public List<? extends Entity> filterEntityLocations(Predicate<Location<World>> predicate) {
   if (((net.minecraftforge.event.world.ExplosionEvent.Detonate) (Object) this).isCancelable()) {
     Iterator<? extends Entity> iterator = this.getEntities().iterator();
     while (iterator.hasNext()) {
       Entity entity = iterator.next();
       Location<World> location = entity.getLocation();
       if (!predicate.apply(location)) {
         iterator.remove();
       }
     }
   }
   return this.getEntities();
 }
  public static SpawnEntityEvent callEntityJoinWorldEvent(Event event) {
    if (!(event instanceof SpawnEntityEvent)) {
      throw new IllegalArgumentException("Event is not a valiud SpawnEntityEvent.");
    }

    SpawnEntityEvent spongeEvent = (SpawnEntityEvent) event;
    Iterator<org.spongepowered.api.entity.Entity> iterator = spongeEvent.getEntities().iterator();
    while (iterator.hasNext()) {
      org.spongepowered.api.entity.Entity entity = iterator.next();
      EntityJoinWorldEvent forgeEvent =
          new EntityJoinWorldEvent(
              (net.minecraft.entity.Entity) entity,
              (net.minecraft.world.World) entity.getLocation().getExtent());

      ((IMixinEventBus) MinecraftForge.EVENT_BUS).post(forgeEvent, true);
      if (forgeEvent.isCanceled()) {
        iterator.remove();
      }
    }
    return spongeEvent;
  }