Any mod can now add JSON Solderer recipes without requiring the API, by putting the JSONs in their assets directory in a "solderer_recipes" directory. Fixes #1356
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Made all IO blocks have a blacklist instead of a whitelist by default (raoulvdberge)
|
||||
- Made item storage disks and blocks capacity a power of two (1k now means 1024 items instead of 1000, etc) (raoulvdberge)
|
||||
- An empty blacklist now means: accept any item. An empty whitelist now means: don't accept any item (an empty whitelist USED to mean: accept any item) (raoulvdberge)
|
||||
- Any mod can now add JSON Solderer recipes without requiring the API, by putting the JSONs in their assets directory in a "solderer_recipes" directory (raoulvdberge)
|
||||
- Updated Russian translation (kellixon)
|
||||
|
||||
### 1.5.34
|
||||
|
@@ -206,17 +206,18 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
|
||||
public EnumFacing getDirection() {
|
||||
if (direction == null) {
|
||||
resetDirection();
|
||||
loadDirection();
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
// @todo: Move this data to the network node.
|
||||
public void resetDirection() {
|
||||
public void loadDirection() {
|
||||
EnumFacing direction = ((TileBase) world.getTileEntity(pos)).getDirection();
|
||||
|
||||
if (!direction.equals(this.direction)) {
|
||||
this.direction = direction;
|
||||
|
||||
onDirectionChanged();
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -12,6 +11,7 @@ import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -23,41 +23,39 @@ public class SoldererRecipeLoader {
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public static void load() {
|
||||
JsonContext context = new JsonContext(RS.ID);
|
||||
for (ModContainer container : Loader.instance().getActiveModList()) {
|
||||
JsonContext context = new JsonContext(container.getModId());
|
||||
|
||||
CraftingHelper.findFiles(Loader.instance().activeModContainer(), "assets/" + RS.ID + "/solderer_recipes", root -> {
|
||||
// @todo: Load the constants into to the context.
|
||||
CraftingHelper.findFiles(container, "assets/" + container.getModId() + "/solderer_recipes", root -> true, (root, file) -> {
|
||||
String relative = root.relativize(file).toString();
|
||||
|
||||
return true;
|
||||
}, (root, file) -> {
|
||||
String relative = root.relativize(file).toString();
|
||||
if (!"json".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
|
||||
ResourceLocation key = new ResourceLocation(container.getModId(), name);
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = Files.newBufferedReader(file);
|
||||
|
||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeFactory(key, JsonUtils.fromJson(GSON, reader, JsonObject.class)).create(context));
|
||||
} catch (JsonParseException e) {
|
||||
FMLLog.log.error("Parsing error while reading JSON solderer recipe {}", key);
|
||||
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
FMLLog.log.error("Couldn't read JSON solderer recipe {}", key);
|
||||
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
|
||||
if (!"json".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
|
||||
ResourceLocation key = new ResourceLocation(RS.ID, name);
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = Files.newBufferedReader(file);
|
||||
|
||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeFactory(key, JsonUtils.fromJson(GSON, reader, JsonObject.class)).create(context));
|
||||
} catch (JsonParseException e) {
|
||||
FMLLog.log.error("Parsing error while reading JSON solderer recipe {}", key, e);
|
||||
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
FMLLog.log.error("Couldn't read JSON solderer recipe {} from {}", key, file, e);
|
||||
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
|
||||
return true;
|
||||
}, false, false);
|
||||
}, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
public void setDirection(EnumFacing direction) {
|
||||
super.setDirection(direction);
|
||||
|
||||
getNode().resetDirection();
|
||||
getNode().loadDirection();
|
||||
}
|
||||
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
|
Reference in New Issue
Block a user