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


Java Monster类代码示例

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


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

示例1: onBlockBurnGlobal

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
  public void onBlockBurnGlobal(ChangeBlockEvent.Modify e){
Transaction<BlockSnapshot> b = e.getTransactions().get(0);
Region r = RedProtect.get().rm.getTopRegion(b.getOriginal().getLocation().get());
  	if (r != null){
  		return;
  	}
  	
  	if (e.getCause().first(Monster.class).isPresent()) {
          if (!RedProtect.get().cfgs.getGlobalFlag(b.getOriginal().getLocation().get().getExtent().getName(),"entity-block-damage")){
          	e.setCancelled(true);
          }
  	}
  	
if (b.getFinal().getState().getType().equals(BlockTypes.FIRE) && !RedProtect.get().cfgs.getGlobalFlag(b.getOriginal().getLocation().get().getExtent().getName(),"fire-block-damage")){
	e.setCancelled(true);
      }
  }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:19,代码来源:RPGlobalListener.java

示例2: onFrameAndBoatBrake

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onFrameAndBoatBrake(DamageEntityEvent e) {
	
	RedProtect.get().logger.debug("blocks","Is BlockListener - DamageEntityEvent event");
	Entity ent = e.getTargetEntity();
	Location<World> l = e.getTargetEntity().getLocation();
	    
	Region r = RedProtect.get().rm.getTopRegion(l);
	
	if (ent instanceof Hanging && e.getCause().first(Monster.class).isPresent()) {    		
		if (r != null && !r.canFire()){
			e.setCancelled(true);
    		return;
		}
    }   
	
	if (ent instanceof Boat && e.getCause().first(Player.class).isPresent()){
		Player p = e.getCause().first(Player.class).get();
		if (!r.canMinecart(p)){
			RPLang.sendMessage(p, "blocklistener.region.cantbreak");
			e.setCancelled(true);
        }
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPBlockListener.java

示例3: onEntitySpawn

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
  List<Entity> entities = event.getEntities();

  for (Entity entity : entities) {
    if (!isApplicable(entity)) {
      continue;
    }

    if (entity instanceof Lightning) {
      ((Lightning) entity).setEffect(true);
      continue;
    }

    if (entity instanceof Monster || (entity instanceof SkeletonHorse)) {
      event.setCancelled(true);
      return;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:21,代码来源:MainWorldWrapper.java

示例4: run

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Override
public void run(Living owner, Living attacker, DamageEntityEvent event) {
  notify(owner, Text.of(TextColors.YELLOW, "Your armor releases a burst of energy."));
  notify(owner, Text.of(TextColors.YELLOW, "You are healed by an ancient force."));

  final double attackDamage = event.getBaseDamage();
  EntityHealthUtil.heal(owner, attackDamage);

  getTargetEntities(owner).stream().filter(e -> e instanceof Living).forEach(e -> {
    if (e.equals(owner)) {
      return;
    }

    if (e.getType() == owner.getType()) {
      EntityHealthUtil.heal((Living) e, attackDamage);
      notify((Living) e, Text.of(TextColors.YELLOW, "You are healed by an ancient force."));
    } else if (!(owner instanceof Player) || e instanceof Monster) {
      e.setVelocity(new Vector3d(
          Probability.getRangedRandom(-1.5, 1.5),
          Probability.getRandom(2.5),
          Probability.getRangedRandom(-1.5, 1.5)
      ));
      e.offer(Keys.FIRE_TICKS, Probability.getRandom(20 * 60));
    }
  });
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:27,代码来源:PowerBurst.java

示例5: checkDungeonProgression

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
public void checkDungeonProgression() {
  Optional<DesmireDungeonRoom> optRoom = getCurrentlyOccupiedRoom();
  if (!optRoom.isPresent()) {
    return;
  }

  DesmireDungeonRoom room = optRoom.get();
  if (room != activeRoom) {
    activeRoom.lockDoors();
    activeRoom = room;
    activeRoom.summonCreatures();
    return;
  }

  int containedCount = getContained(room.getBoundingBox(), Monster.class).size();
  if (containedCount < 1) {
    activeRoom.unlockDoors();
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:DesmireDungeonInstance.java

示例6: onSpawn

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onSpawn(final SpawnEntityEvent event) {
    // Filter spawns
    event.filterEntities((Predicate<Entity>) entity -> {
        if (entity instanceof Monster) {
            return SafeGuard.getZoneManager().allows(spawnMonsterFlag, entity.getLocation());
        }

        return true;
    });
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:12,代码来源:SpawnEntityListener.java

示例7: onEntitySpawn

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onEntitySpawn(SpawnEntityEvent event)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	event.filterEntities(e -> !(e instanceof Monster) || DataHandler.getFlag("mobs", e.getLocation()));
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:10,代码来源:MobSpawningListener.java

示例8: onInteract

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractEntityEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Entity target = event.getTargetEntity();
	if (target instanceof Player || target instanceof Monster)
	{
		return;
	}
	if (target instanceof ItemFrame || target instanceof ArmorStand)
	{
		if (player.hasPermission("nations.admin.bypass.perm.build"))
		{
			return;
		}
		if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetEntity().getLocation()))
		{
			event.setCancelled(true);
			player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
		}
		return;
	}
	if (!DataHandler.getPerm("interact", player.getUniqueId(), event.getTargetEntity().getLocation()))
	{
		event.setCancelled(true);
		player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:36,代码来源:InteractPermListener.java

示例9: getNearbyMonsters

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
protected static Collection<Monster> getNearbyMonsters(Player player, int radius) {
	Collection<Entity> entities = getNearbyEntities(player, radius);
	Collection<Monster> monsters = new HashSet<Monster>();

	for (Entity en : entities) {
		if (en instanceof Monster) {
			monsters.add((Monster) en);
		}
	}
	return monsters;
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:12,代码来源:SpongeTargetUtils.java

示例10: WitherBlockBreak

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
 public void WitherBlockBreak(ChangeBlockEvent.Break event, @First Entity e) {    	    	
 	if (e instanceof Monster) {
 		BlockSnapshot b = event.getTransactions().get(0).getOriginal();
RedProtect.get().logger.debug("entity","RPEntityListener - Is EntityChangeBlockEvent event! Block "+b.getState().getType().getName());
Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());
         if (!cont.canWorldBreak(b)){        		        		
     		event.setCancelled(true);
     		return;
     	} 
         if (r != null && !r.canMobLoot()){
      	   event.setCancelled(true);
         }            
 	}
 }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:16,代码来源:RPEntityListener.java

示例11: onChunkUnload

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onChunkUnload(ChunkLoad e) {
	Optional<Entity> wOpt = e.getEntities().stream().findFirst();
	if (!wOpt.isPresent() || !RedProtect.get().cfgs.getGlobalFlag(wOpt.get().getWorld().getName(), "remove-entities-not-allowed-to-spawn")){
		return;
	}
	World w = wOpt.get().getWorld();
	List<Entity> ents = e.getEntities();
	for (Entity ent:ents){
		Region entr = RedProtect.get().rm.getTopRegion(ent.getLocation());
		if (entr != null){
			if (!entr.canSpawnMonsters() && ent instanceof Monster){
    			ent.remove();
    		}
		} else {
			if (ent instanceof Monster){
				if (!RedProtect.get().cfgs.getGlobalFlag(w.getName(), "spawn-monsters")){
					ent.remove();
				}    			   				
			}
			else if (!RedProtect.get().cfgs.getGlobalFlag(w.getName(), "spawn-passives")){
				if (ent.getCreator().isPresent()){
					return;
				}
				ent.remove();
			} 
		}    		
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:30,代码来源:RPWorldListener.java

示例12: onEntityConstruction

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的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

示例13: onEntitySpawn

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
  List<Entity> entities = event.getEntities();

  Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.class);
  for (Entity entity : entities) {
    if (!isApplicable(entity)) {
      continue;
    }

    if (entity instanceof Lightning) {
      ((Lightning) entity).setEffect(true);
      continue;
    }

    if (entity instanceof Egg && optBlockCause.isPresent()) {
      new ItemDropper(entity.getLocation()).dropStacks(
          Lists.newArrayList(newItemStack(ItemTypes.EGG)), SpawnTypes.DISPENSE
      );
      event.setCancelled(true);
      return;
    }

    if (entity instanceof Monster || (entity instanceof SkeletonHorse)) {
      event.setCancelled(true);
      return;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:30,代码来源:BuildWorldWrapper.java

示例14: countEntities

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Override
public int[] countEntities(Plot plot) {
    Location pos1 = plot.getBottomAbs();
    Location pos2 = plot.getTopAbs();
    World world = SpongeUtil.getWorld(pos1.getWorld());
    int bx = pos1.getX();
    int bz = pos1.getZ();
    int tx = pos2.getX();
    int tz = pos2.getZ();
    int[] count = new int[6];
    world.getEntities(entity -> {
        org.spongepowered.api.world.Location loc = entity.getLocation();
        int x = loc.getBlockX();
        if ((x >= bx) && (x <= tx)) {
            int z = loc.getBlockZ();
            if ((z >= bz) && (z <= tz)) {
                count[0]++;
                if (entity instanceof Living) {
                    count[3]++;
                    if (entity instanceof Animal) {
                        count[1]++;
                    } else if (entity instanceof Monster) {
                        count[2]++;
                    }
                } else {
                    count[4]++;
                }
            }
        }
        return false;
    });
    
    return count;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:35,代码来源:SpongeChunkManager.java

示例15: onMonsterDeath

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
public void onMonsterDeath(DestructEntityEvent.Death event, @Root Player player, @Getter("getTargetEntity") Monster monster) {
    Point.Builder p = newPoint("monster_death");
    addPlayer(p, player);
    EntityType type = monster.getType();
    p.tag("monster_type", type.getId());
    p.addField("monster_name", type.getName());
    addLocation(p, monster.getLocation());
    connection.write(p.build());
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:Stats.java


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