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:
raoulvdberge
2018-06-03 10:59:11 +02:00
parent daf7641496
commit 22ac7b6718
4 changed files with 37 additions and 37 deletions

View File

@@ -18,6 +18,7 @@
- Made all IO blocks have a blacklist instead of a whitelist by default (raoulvdberge) - 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) - 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) - 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) - Updated Russian translation (kellixon)
### 1.5.34 ### 1.5.34

View File

@@ -206,17 +206,18 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
public EnumFacing getDirection() { public EnumFacing getDirection() {
if (direction == null) { if (direction == null) {
resetDirection(); loadDirection();
} }
return direction; return direction;
} }
// @todo: Move this data to the network node. public void loadDirection() {
public void resetDirection() {
EnumFacing direction = ((TileBase) world.getTileEntity(pos)).getDirection(); EnumFacing direction = ((TileBase) world.getTileEntity(pos)).getDirection();
if (!direction.equals(this.direction)) { if (!direction.equals(this.direction)) {
this.direction = direction; this.direction = direction;
onDirectionChanged(); onDirectionChanged();
} }
} }

View File

@@ -4,7 +4,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.util.JsonUtils; import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -12,6 +11,7 @@ import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.JsonContext; import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@@ -23,13 +23,10 @@ public class SoldererRecipeLoader {
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
public static void load() { 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 -> { CraftingHelper.findFiles(container, "assets/" + container.getModId() + "/solderer_recipes", root -> true, (root, file) -> {
// @todo: Load the constants into to the context.
return true;
}, (root, file) -> {
String relative = root.relativize(file).toString(); String relative = root.relativize(file).toString();
if (!"json".equals(FilenameUtils.getExtension(file.toString()))) { if (!"json".equals(FilenameUtils.getExtension(file.toString()))) {
@@ -37,7 +34,7 @@ public class SoldererRecipeLoader {
} }
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/"); String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
ResourceLocation key = new ResourceLocation(RS.ID, name); ResourceLocation key = new ResourceLocation(container.getModId(), name);
BufferedReader reader = null; BufferedReader reader = null;
@@ -46,11 +43,11 @@ public class SoldererRecipeLoader {
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeFactory(key, JsonUtils.fromJson(GSON, reader, JsonObject.class)).create(context)); API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeFactory(key, JsonUtils.fromJson(GSON, reader, JsonObject.class)).create(context));
} catch (JsonParseException e) { } catch (JsonParseException e) {
FMLLog.log.error("Parsing error while reading JSON solderer recipe {}", key, e); FMLLog.log.error("Parsing error while reading JSON solderer recipe {}", key);
return false; return false;
} catch (IOException e) { } catch (IOException e) {
FMLLog.log.error("Couldn't read JSON solderer recipe {} from {}", key, file, e); FMLLog.log.error("Couldn't read JSON solderer recipe {}", key);
return false; return false;
} finally { } finally {
@@ -60,4 +57,5 @@ public class SoldererRecipeLoader {
return true; return true;
}, false, false); }, false, false);
} }
}
} }

View File

@@ -53,7 +53,7 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
public void setDirection(EnumFacing direction) { public void setDirection(EnumFacing direction) {
super.setDirection(direction); super.setDirection(direction);
getNode().resetDirection(); getNode().loadDirection();
} }
public NBTTagCompound writeUpdate(NBTTagCompound tag) { public NBTTagCompound writeUpdate(NBTTagCompound tag) {