From a8919dcd95f874436647447cfb432e64b70be119 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Fri, 16 Apr 2021 15:04:28 -0700 Subject: [PATCH] Fixes * Handle NBTByte Arrays * Update height for OC handlers --- build.properties | 2 +- resources/assets/nei/csv/handlers.csv | 6 +++--- src/codechicken/nei/util/NBTJson.java | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build.properties b/build.properties index 4bcd4595..2f134c94 100644 --- a/build.properties +++ b/build.properties @@ -2,4 +2,4 @@ mc_version=1.7.10 forge_version=10.13.4.1614-1.7.10 ccl_version=1.1.3.138 ccc_version=1.0.7.+ -mod_version=2.1.1-GTNH +mod_version=2.1.2-GTNH diff --git a/resources/assets/nei/csv/handlers.csv b/resources/assets/nei/csv/handlers.csv index 0aeca190..2eb4f707 100644 --- a/resources/assets/nei/csv/handlers.csv +++ b/resources/assets/nei/csv/handlers.csv @@ -204,8 +204,8 @@ gtPlusPlus.nei.DecayableRecipeHandler,GT++,miscutils:dustRadium226,,miscutils,TR gtPlusPlus.nei.GT_NEI_FlotationCell,GT++,gregtech:gt.blockmachines:31028,,miscutils,TRUE,,,120,,2,,,,,, gtPlusPlus.nei.GT_NEI_FluidReactor,GT++,gregtech:gt.blockmachines:998,,miscutils,TRUE,,,120,,2,,,,,, gtPlusPlus.nei.GT_NEI_MillingMachine,GT++,gregtech:gt.blockmachines:31027,,miscutils,TRUE,,,120,,2,,,,,, -li.cil.oc.integration.nei.CallbackDocHandler,OpenComputers,OpenComputers:item:98,,OpenComputers,TRUE,,,,,,,,,,, -li.cil.oc.integration.nei.ManualUsageHandler,OpenComputers,OpenComputers:item:98,,OpenComputers,TRUE,,,,,,,,,,, +li.cil.oc.integration.nei.CallbackDocHandler,OpenComputers,OpenComputers:item:98,,OpenComputers,TRUE,,,120,,2,,,,,, +li.cil.oc.integration.nei.ManualUsageHandler,OpenComputers,OpenComputers:item:98,,OpenComputers,TRUE,,,120,,2,,,,,, tonius.neiintegration.mods.harvestcraft.RecipeHandlerApiary,Pam's Harvestcraft,harvestcraft:apiary,,harvestcraft,TRUE,,,70,,5,,,,,,There's only 1 though tonius.neiintegration.mods.harvestcraft.RecipeHandlerChurn,Pam's Harvestcraft,harvestcraft:churn,,harvestcraft,TRUE,,,65,,5,,,,,,Same as above tonius.neiintegration.mods.harvestcraft.RecipeHandlerOven,Pam's Harvestcraft,harvestcraft:oven,,harvestcraft,TRUE,,,65,,5,,,,,, @@ -352,7 +352,7 @@ vazkii.botania.client.integration.nei.recipe.RecipeHandlerRunicAltar,Botania,Bot vazkii.botania.client.integration.nei.recipe.RecipeHandlerManaPool,Botania,Botania:pool,,Botania,TRUE,,,90,137,4,,,,,, vazkii.botania.client.integration.nei.recipe.RecipeHandlerElvenTrade,Botania,Botania:alfheimPortal,,Botania,TRUE,,,90,130,4,,,,,, vazkii.botania.client.integration.nei.recipe.RecipeHandlerBrewery,Botania,Botania:brewery,,Botania,TRUE,,,,,4,,,,,, -vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy,Botania,Botania:specialFlower,"{type: ""puredaisy""}",Botania,TRUE,,,,,4,,,,,, +vazkii.botania.client.integration.nei.recipe.RecipeHandlerPureDaisy,Botania,Botania:specialFlower,"{""type"": ""puredaisy""}",Botania,TRUE,,,,,4,,,,,, vazkii.botania.client.integration.nei.recipe.RecipeHandlerLexicaBotania,Botania,Botania:lexicon,,Botania,TRUE,,,,,,,,,,, com.jaquadro.minecraft.storagedrawers.integration.notenoughitems.UpgradeItemRecipeHandler,Storage Drawers,minecraft:crafting_table,,StorageDrawers,TRUE,,,65,166,5,,,,,, ieArcFurnace,Immersive Engineering,ImmersiveEngineering:graphiteElectrode,,ImmersiveEngineering,TRUE,,,65,166,5,,,,,, diff --git a/src/codechicken/nei/util/NBTJson.java b/src/codechicken/nei/util/NBTJson.java index 6c47cbd8..c3e407fd 100644 --- a/src/codechicken/nei/util/NBTJson.java +++ b/src/codechicken/nei/util/NBTJson.java @@ -9,6 +9,7 @@ import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.NBTTagFloat; @@ -19,11 +20,13 @@ import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.NBTTagString; +import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.IntStream; public class NBTJson { private static final Pattern numberPattern = Pattern.compile("^([-+]?[\\d]+\\.?[0-9]*)([bBsSlLfFdD]?)$"); @@ -65,6 +68,13 @@ public class NBTJson { arr.add(new JsonPrimitive(i)); } return arr; + } else if (nbt instanceof NBTTagByteArray) { + // Byte Array + JsonArray arr = new JsonArray(); + for(int i : ((NBTTagByteArray) nbt).func_150292_c()) { + arr.add(new JsonPrimitive(i)); + } + return arr; } else { throw new IllegalArgumentException("Unsupported NBT Tag: " + NBTBase.NBTTypes[nbt.getId()] + " - " + nbt); } @@ -119,6 +129,8 @@ public class NBTJson { if (nbtList.stream().allMatch(n -> n instanceof NBTTagInt)) { return new NBTTagIntArray(nbtList.stream().mapToInt(i -> ((NBTTagInt)i).func_150287_d() ).toArray()); + } else if (nbtList.stream().allMatch(n -> n instanceof NBTTagByte)) { + return new NBTTagByteArray(toByteArray(nbtList.stream().mapToInt(i -> ((NBTTagInt)i).func_150287_d() ))); } else { NBTTagList nbtTagList = new NBTTagList(); nbtList.forEach(nbtTagList::appendTag); @@ -138,5 +150,9 @@ public class NBTJson { throw new IllegalArgumentException("Unhandled element " + jsonElement); } + public static byte[] toByteArray(IntStream stream) { + return stream.collect(ByteArrayOutputStream::new, (baos, i) -> baos.write((byte) i), (baos1, baos2) -> baos1.write(baos2.toByteArray(), 0, baos2.size())) + .toByteArray(); + } }