示例#1
0
 private void makeSwarm(PlayerInteractEvent e, EntityPlayer player, IBeeHousing tile) {
   if (tile.getBeekeepingLogic() != null
       && tile.getBeeInventory() != null
       && tile.getBeekeepingLogic().canDoBeeFX()) {
     IBee member = BeeManager.beeRoot.getMember(tile.getBeeInventory().getQueen());
     if (member != null) {
       SwarmBehavior behavior = getSwarmBehavior(player);
       if (behavior != null) {
         if (behavior.entity != null) {
           behavior.entity.setDead();
         }
         Controller controller = Nanomachines.getController(player);
         if (controller != null) {
           controller.changeBuffer(-10);
         }
         behavior.spawnNewEntity(
             e.x + 0.5,
             e.y + 0.5,
             e.z + 0.5,
             member.getGenome().getPrimary().getIconColour(0),
             member.getGenome().getTolerantFlyer());
         swingItem(player);
       }
     }
   }
 }
示例#2
0
  private SwarmBehavior getSwarmBehavior(EntityPlayer player) {
    Controller controller = Nanomachines.getController(player);
    if (controller != null) {
      Iterable<Behavior> behaviors = controller.getActiveBehaviors();
      for (Behavior behavior : behaviors) {
        if (behavior instanceof SwarmBehavior) {
          return (SwarmBehavior) behavior;
        }
      }
    }
    return null;

    /*SwarmBehavior behavior = behaviors.get(player.getCommandSenderName());
    if(behavior == null) {
    	behavior = new SwarmBehavior(player);
    	behavior.onEnable();
    	behaviors.put(player.getCommandSenderName(), behavior);
    }
    return behavior;*/
  }