Package de.kumpelblase2.remoteentities.entities

Examples of de.kumpelblase2.remoteentities.entities.RemoteEndermanEntity


  }
 
  @EventHandler
  public void onJoin(PlayerJoinEvent inEvent) throws Exception
  {
    RemoteEntity entity = npcManager.createNamedEntity(RemoteEntityType.Human, inEvent.getPlayer().getLocation(), "test");
    TamingFeature feature = new RemoteTamingFeature(entity);
    feature.tame(inEvent.getPlayer());
    entity.getFeatures().addFeature(feature);
    entity.getMind().addMovementDesire(new DesireFollowTamer(entity, 5, 15), entity.getMind().getHighestMovementPriority() + 1);
  }
View Full Code Here


  }

  @EventHandler
  public void onJoin(PlayerJoinEvent inEvent) throws Exception
  {
    RemoteEntity entity = npcManager.createNamedEntity(RemoteEntityType.Human, inEvent.getPlayer().getLocation(), "Lonely Trader");

    //First of all, we create the feature with a store title. In this case, I named the store 'custom store'.
    RemoteTradingFeature feature = new RemoteTradingFeature(entity, "Custom store");

    //Then I add an offer. This time, the trader will sell 1 paper and it costs 1 stone.
    feature.addOffer(new ItemStack(Material.PAPER), new ItemStack(Material.STONE));

    //We can also specify how often this offer can be used. In order to do that, we create a TraderOffer, where we can specify the usable amount.
    //This means that this offer can only be used twice. If player 1 buys it once and player 2 buys it also one time, it will be gone for player 3.
    feature.addOffer(new TradeOffer(new ItemStack(Material.FEATHER), new ItemStack(Material.STONE), 2));

    //We can also add lore to the item if we want to. Here, I add some text to make it a bit more interesting.
    ItemStack customItem = new ItemStack(Material.DIAMOND_SWORD);
    ItemMeta meta = customItem.getItemMeta();
    meta.setDisplayName("BACON MAKER");
    meta.setLore(new ArrayList<String>(Arrays.asList("GET THAT BACON!")));
    customItem.setItemMeta(meta);

    //And just like we did earlier, I add it to the feature.
    feature.addOffer(new TradeOffer(customItem, new ItemStack(Material.FEATHER), 1));

    //Lastly, don't forget to add the feature to the entity.
    entity.getFeatures().addFeature(feature);
  }
View Full Code Here

    context.withName(inData.name).asPushable(inData.pushable).asStationary(inData.stationary).withID(inData.id);
    context.withSpeed(inData.speed).withPathfindingRange(inData.pathfindingRange);
    if(inData.location != null)
      context.atLocation(inData.location.toBukkitLocation());

    RemoteEntity entity = context.create();
    for(DesireData data : inData.movementDesires)
    {
      DesireItem item = data.create(entity);
      entity.getMind().addMovementDesire(item.getDesire(), item.getPriority());
    }

    for(DesireData data : inData.actionDesires)
    {
      DesireItem item = data.create(entity);
      entity.getMind().addTargetingDesire(item.getDesire(), item.getPriority());
    }

    for(BehaviorData data : inData.behaviors)
    {
      entity.getMind().addBehaviour(data.create(entity));
    }
   
    for(FeatureData data : inData.features)
    {
      entity.getFeatures().addFeature(data.create(entity));
    }

    return entity;
  }
View Full Code Here

  }

  @Test
  public void testCreateNotNamed()
  {
    RemoteEntity created = new CreateEntityContext(this.m_entityManager).withType(RemoteEntityType.Pig).withFeatures(mock(InventoryFeature.class)).create();
    assertEquals("Created entity and saved entity should be equal", this.m_remoteEntity, created);
    verify(created.getFeatures(), times(1)).addFeature(any(InventoryFeature.class));
    verify(created, never()).setName(anyString());
    verify(created, never()).setSpeed(anyDouble());
    verify(created, times(1)).setStationary(eq(false));
    verify(created, times(1)).setPushable(eq(true));
  }
View Full Code Here

  }

  @Test
  public void testCreateNamed()
  {
    RemoteEntity created = new CreateEntityContext(this.m_entityManager).withType(RemoteEntityType.Human).withName("Test").create();
    assertEquals("Created entity and saved entity should be equal", this.m_remotePlayer, created);
    verify(created, never()).setSpeed(anyDouble());
    verify(created, times(1)).setStationary(eq(false));
    verify(created, times(1)).setPushable(eq(true));
  }
View Full Code Here

  InteractBehavior m_behavior2;

  @Before
  public void setup()
  {
    RemoteEntity entity = mock(RemoteEntity.class);
    when(entity.getHandle()).thenReturn(mock(EntityInsentient.class));
    this.m_mind = spy(new Mind(entity));
    when(this.m_behavior.getName()).thenReturn("Interact");
    when(this.m_behavior2.getName()).thenReturn("Interact");
  }
View Full Code Here

   * @throws NoNameException  When no name is specified while trying to spawn a named entity
   * @throws InternalError    When an error occurred during creation process
   */
  public RemoteEntity create()
  {
    RemoteEntity created;

    if(this.m_type == null)
      throw new NoTypeException();

    this.m_id = this.m_manager.getNextFreeID(this.m_id);

    if(this.m_type.isNamed())
    {
      if(this.m_name == null)
        throw new NoNameException("Tried to spawn a named entity without name");

      created = this.m_manager.createNamedEntity(this.m_type, this.m_id, this.m_name);
    }
    else
      created = this.m_manager.createEntity(this.m_type, this.m_id);

    if(created == null)
      throw new InternalError("Was not able to create entity with given type and id. Type was " + this.m_type + " and id " + this.m_id);

    for(Feature feature : this.m_features)
    {
      created.getFeatures().addFeature(feature);
    }

    for(Behavior behavior : this.m_behaviors)
    {
      created.getMind().addBehaviour(behavior);
    }

    for(DesireItem desire : this.m_movementDesires)
    {
      created.getMind().addMovementDesire(desire.getDesire(), desire.getPriority());
    }

    for(DesireItem desire : this.m_actionDesires)
    {
      created.getMind().addTargetingDesire(desire.getDesire(), desire.getPriority());
    }

    created.setStationary(this.m_stationary);
    created.setPushable(this.m_pushable);
    if(this.m_speed != -1)
      created.setSpeed(this.m_speed);

    if(this.m_location != null)
      created.spawn(this.m_location);

    if(this.m_maxHealth != -1 && created.getBukkitEntity() != null)
      created.getBukkitEntity().setMaxHealth(this.m_maxHealth);

    if(this.m_pathfindingRange != -1)
      created.setPathfindingRange(this.m_pathfindingRange);

    return created;
  }
View Full Code Here

    PathResult result = this.find(this.m_entity.getBukkitEntity().getLocation(), inTo);
    if(result != PathResult.SUCCESS)
      return false;

    RemoteAsyncPathFindEvent event = new RemoteAsyncPathFindEvent(this.m_entity, this.getLastPath());
    Bukkit.getPluginManager().callEvent(event);
    this.m_currentPath = event.getPath();
    NMSUtil.getNavigation(this.m_entity.getHandle()).a(this.m_currentPath.toNMSPath(), this.m_entity.getSpeed());
    return true;
  }
View Full Code Here

    PathResult result = this.find(this.m_entity.getBukkitEntity().getLocation(), inTo);
    if(result != PathResult.SUCCESS)
      return false;

    RemoteAsyncPathFindEvent event = new RemoteAsyncPathFindEvent(this.m_entity, this.getLastPath());
    Bukkit.getPluginManager().callEvent(event);
    this.m_currentPath = event.getPath();
    NMSUtil.getNavigation(this.m_entity.getHandle()).a(this.m_currentPath.toNMSPath(), inSpeed);
    return true;
  }
View Full Code Here

      @Override
      public void onPathfindEnd(Pathfinder inFinder, PathResult inResult)
      {
        if(inResult == PathResult.SUCCESS)
        {
          RemoteAsyncPathFindEvent event = new RemoteAsyncPathFindEvent(Pathfinder.this.m_entity, inFinder.getLastPath(), true);
          Bukkit.getPluginManager().callEvent(event);
          if(event.isCancelled())
            return;

          Pathfinder.this.m_currentPath = event.getPath();
          NMSUtil.getNavigation(Pathfinder.this.m_entity.getHandle()).a(Pathfinder.this.m_currentPath.toNMSPath(), Pathfinder.this.m_entity.getSpeed());
        }
      }
    });
    return true;
View Full Code Here

TOP

Related Classes of de.kumpelblase2.remoteentities.entities.RemoteEndermanEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.