• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Monster类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: onMove

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Listener
public void onMove(final DisplaceEntityEvent.Move event) {
    if (event.getTargetEntity() instanceof Monster && !SafeGuard.getZoneManager().allows(spawnMonsterFlag, event.getTargetEntity().getLocation())) {
        event.getTargetEntity().remove();
    }
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:7,代码来源:MoveEntityListener.java


示例17: getTargetMonster

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
protected static Monster getTargetMonster(Player player, int range) {
	return SpongeTargetUtils.<Monster> getTarget(player, range, getNearbyMonsters(player, range));
}
 
开发者ID:mcardy,项目名称:Zephyr,代码行数:4,代码来源:SpongeTargetUtils.java


示例18: 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) {
    Location<World> loc = entity.getLocation();
    Optional<Integer> optLevel = getLevel(loc);

    if (!optLevel.isPresent()) {
      continue;
    }
    int level = optLevel.get();

    if (entity instanceof Egg && optBlockCause.isPresent()) {
      PrimedTNT explosive = (PrimedTNT) entity.getLocation().getExtent().createEntity(
          EntityTypes.PRIMED_TNT,
          entity.getLocation().getPosition()
      );

      explosive.setVelocity(entity.getVelocity());
      explosive.offer(Keys.FUSE_DURATION, 20 * 4);

      // TODO used to have a 1/4 chance of creating fire
      entity.getLocation().getExtent().spawnEntity(
          explosive, Cause.source(SpawnCause.builder().type(SpawnTypes.DISPENSE).build()).build()
      );

      event.setCancelled(true);
      return;
    }

    if (level > 1) {
      // TODO move damage modification
      if (entity instanceof Monster) {
        HealthData healthData = ((Monster) entity).getHealthData();
        double curMax = healthData.maxHealth().get();

        if (curMax <= 80) { // TODO do this a better way, but for now it prevents super mobs

          double newMax = curMax * getHealthMod(level);

          healthData.set(Keys.MAX_HEALTH, newMax);
          healthData.set(Keys.HEALTH, newMax);

          entity.offer(healthData);
        }

        // Wandering Bosses
        Collection<String> wanderers = wanderingMobManager.getSupportedWanderersOfType(entity.getType());
        for (String wanderer : wanderers) {
          if (wanderingMobManager.chanceBind(wanderer, level, entity)) {
            break;
          }
        }
      }
    }

    Optional<Value<Integer>> optExplosiveRadius = Optional.empty();
    // Optional<Value<Integer>> optExplosiveRadius = event.getEntity().getValue(Keys.EXPLOSIVE_RADIUS);

    if (optExplosiveRadius.isPresent()) {
      Value<Integer> explosiveRadius = optExplosiveRadius.get();
      int min = explosiveRadius.get();

      entity.offer(
          Keys.EXPLOSION_RADIUS,
          Optional.of(MathExt.bound((min + level) / 2, min, entity instanceof Fireball ? 4 : 9))
      );
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:73,代码来源:WildernessWorldWrapper.java


示例19: runCharlotte

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
private void runCharlotte() {
  Living boss = getBoss(FreakyFourBoss.CHARLOTTE).get();
  for (int i = Probability.getRandom(10); i > 0; --i) {
    spawnCharlotteMinion(boss.getLocation().getPosition());
  }

  ZoneBoundingBox charlotteRG = regions.get(FreakyFourBoss.CHARLOTTE);
  switch (Probability.getRandom(3)) {
    case 1:
      createWall(
          charlotteRG,
          type -> type == BlockTypes.AIR,
          type -> type == BlockTypes.WEB,
          BlockTypes.AIR,
          BlockTypes.WEB,
          1,
          config.charlotteFloorWeb
      );
      break;
    case 2:
      if (boss instanceof Monster) {
        Optional<Entity> optTarget = ((Monster) boss).getTarget();
        if (optTarget.isPresent() && contains(optTarget.get())) {
          Entity target = optTarget.get();
          ZoneBoundingBox targetArea = new ZoneBoundingBox(
              target.getLocation().getPosition().sub(1, 1, 1).toInt(),
              new Vector3i(3, 3, 3)
          );

          targetArea.forAll(pt -> {
            if (getRegion().getExtent().getBlockType(pt) == BlockTypes.AIR) {
              getRegion().getExtent().setBlockType(
                  pt,
                  BlockTypes.WEB,
                  Cause.source(SkreePlugin.container()).build()
              );
            }
          });
        }
        break;
      }
    case 3:
      charlotteRG.forAll(pt -> {
        if (!Probability.getChance(config.charlotteWebSpider)) {
          return;
        }
        if (getRegion().getExtent().getBlockType(pt) == BlockTypes.WEB) {
          getRegion().getExtent().setBlockType(
              pt,
              BlockTypes.AIR,
              Cause.source(SkreePlugin.container()).build()
          );
          spawnCharlotteMinion(pt.toDouble().add(.5, 0, .5));
        }
      });
      break;
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:59,代码来源:FreakyFourInstance.java


示例20: remove

import org.spongepowered.api.entity.living.monster.Monster; //导入依赖的package包/类
@Override
public void remove() {
  remove(Monster.class, Animal.class, ExperienceOrb.class, Item.class, Arrow.class);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:5,代码来源:TheButcherShopInstance.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultiCollector类代码示例发布时间:2022-05-22
下一篇:
Java WithAnonymousUser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap