@SuppressWarnings("unchecked")
  @Override
  public boolean openTradeWindow(String name, List<ItemStack[]> recipes, Player player) {
    try {
      EntityVillager villager = new EntityVillager(((CraftPlayer) player).getHandle().world, 0);
      if (name != null && !name.isEmpty()) {
        villager.setCustomName(name);
      }

      Field recipeListField = EntityVillager.class.getDeclaredField("bu");
      recipeListField.setAccessible(true);
      MerchantRecipeList recipeList = (MerchantRecipeList) recipeListField.get(villager);
      if (recipeList == null) {
        recipeList = new MerchantRecipeList();
        recipeListField.set(villager, recipeList);
      }
      recipeList.clear();
      for (ItemStack[] recipe : recipes) {
        recipeList.add(createMerchantRecipe(recipe[0], recipe[1], recipe[2]));
      }

      villager.a(((CraftPlayer) player).getHandle());

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
コード例 #2
0
  @Override
  public void collide(Entity inEntity) {
    if (this.getRemoteEntity() == null) {
      super.collide(inEntity);
      return;
    }

    if (((RemoteBaseEntity) this.m_remoteEntity).onCollide(inEntity.getBukkitEntity()))
      super.collide(inEntity);
  }
コード例 #3
0
  @Override
  public void g(double x, double y, double z) {
    if (this.m_remoteEntity == null) {
      super.g(x, y, z);
      return;
    }

    Vector vector = ((RemoteBaseEntity) this.m_remoteEntity).onPush(x, y, z);
    if (vector != null) super.g(vector.getX(), vector.getY(), vector.getZ());
  }
コード例 #4
0
  @Override
  public void e(float inXMotion, float inZMotion) {
    float[] motion = new float[] {inXMotion, inZMotion, 0};
    if (this.m_remoteEntity.getMind().hasBehaviour("Ride"))
      ((RideBehavior) this.m_remoteEntity.getMind().getBehaviour("Ride")).ride(motion);

    super.e(motion[0], motion[1]);
    this.motY = motion[2];
  }
コード例 #5
0
  @Override
  public void move(double d0, double d1, double d2) {
    if (this.m_remoteEntity != null && this.m_remoteEntity.isStationary()) return;

    super.move(d0, d1, d2);
  }
コード例 #6
0
 @Override
 public void l_() {
   super.l_();
   if (this.getRemoteEntity() != null) this.getRemoteEntity().getMind().tick();
 }
コード例 #7
0
 @Override
 public void die(DamageSource damagesource) {
   ((RemoteBaseEntity) this.m_remoteEntity).onDeath();
   super.die(damagesource);
 }