@Override
 public ItemStack getRecipeOutput() {
   Optional<Item> nominalOutput = recipe.getNominalOutput();
   if (nominalOutput.isPresent()) {
     return Game.natives().toNative(nominalOutput.get());
   }
   return null;
 }
 @Override
 public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
   Optional<Item> craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventoryCrafting));
   if (craftingResult.isPresent()) {
     return Game.natives().toNative(craftingResult.get());
   } else {
     return null;
   }
 }
Beispiel #3
0
 @Override
 public boolean setBlock(Vector3D position, BlockFactory blockFactory, Object... args) {
   // TODO: Implement object arguments
   net.minecraft.block.Block mcBlock = Game.natives().toNative(blockFactory.getDummy());
   return world()
       .setBlock(
           (int) position.getX(),
           (int) position.getY(),
           (int) position.getZ(),
           mcBlock != null ? mcBlock : Blocks.air);
 }
Beispiel #4
0
 @Override
 public Optional<Block> getBlock(Vector3D position) {
   net.minecraft.block.Block mcBlock =
       access.getBlock((int) position.getX(), (int) position.getY(), (int) position.getZ());
   if (mcBlock == null || mcBlock == Blocks.air) {
     return Optional.of(Game.blocks().getAirBlock());
   } else if (mcBlock instanceof FWBlock) {
     return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position));
   } else {
     return Optional.of(new BWBlock(mcBlock, this, position));
   }
 }
Beispiel #5
0
 @Override
 public Entity addEntity(Vector3D position, Item item) {
   EntityItem entityItem =
       new EntityItem(
           world(),
           position.getX(),
           position.getY(),
           position.getZ(),
           Game.natives().toNative(item));
   world().spawnEntityInWorld(entityItem);
   return new BWEntity(entityItem);
 }
Beispiel #6
0
  @Override
  public void load() {
    super.load();

    TopologicalSort.DirectedGraph<Mod> modGraph = new TopologicalSort.DirectedGraph<>();

    mods.keySet().forEach(modGraph::addNode);

    // Create directed graph edges.
    mods.keySet()
        .forEach(
            mod -> {
              Map<String, String> depMap = dependencyToMap(mod.dependencies());
              depMap.forEach(
                  (id, version) -> {
                    Optional<Mod> dependent =
                        mods.keySet().stream().filter(m2 -> m2.id().equals(id)).findFirst();

                    // TODO: Compare version requirements.
                    if (dependent.isPresent()) {
                      modGraph.addEdge(dependent.get(), mod);
                    }
                  });

              // Priority check
              mods.keySet()
                  .forEach(
                      compareMod -> {
                        if (mod.priority() < compareMod.priority()) {
                          modGraph.addEdge(compareMod, mod);
                        }
                      });
            });

    orderedMods.clear();

    TopologicalSort.topologicalSort(modGraph)
        .stream()
        .map(mods::get)
        .filter(mod -> mod instanceof Loadable)
        .map(mod -> (Loadable) mod)
        .forEachOrdered(orderedMods::add);

    Game.logger().info("NOVA mods loaded: " + mods.size());
  }
Beispiel #7
0
 @Override
 public Set<Entity> getEntities(Cuboid bound) {
   return (Set)
       world()
           .getEntitiesWithinAABB(
               Entity.class,
               AxisAlignedBB.getBoundingBox(
                   bound.min.getX(),
                   bound.min.getY(),
                   bound.min.getZ(),
                   bound.max.getX(),
                   bound.max.getY(),
                   bound.max.getZ()))
           .stream()
           .map(
               mcEnt ->
                   Game.natives()
                       .getNative(Entity.class, net.minecraft.entity.Entity.class)
                       .toNova((net.minecraft.entity.Entity) mcEnt))
           .collect(Collectors.toSet());
 }
 public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) {
   super(((Item) Game.natives().toNova(itemStack)).getID());
 }
Beispiel #9
0
 @Override
 public Optional<Entity> getEntity(String uniqueID) {
   return Optional.ofNullable(
       Game.natives().toNova(world().getEntityByID(Integer.parseInt(uniqueID))));
 }