Fix UU matter recipes.

Adds a PaddedShapedRecipe to RebornCore
This commit is contained in:
modmuss50 2021-06-02 21:25:15 +01:00
parent 315891885d
commit dc216b974d
39 changed files with 233 additions and 261 deletions

View file

@ -1 +1,5 @@
group = 'RebornCore'
minecraft {
accessWidener = file("src/main/resources/reborncore.accesswidener")
}

View file

@ -45,6 +45,7 @@ import reborncore.common.misc.RebornCoreTags;
import reborncore.common.multiblock.MultiblockRegistry;
import reborncore.common.network.ServerBoundPackets;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.recipes.PaddedShapedRecipe;
import reborncore.common.util.CalenderUtils;
import reborncore.common.util.GenericWrenchHelper;
@ -107,6 +108,7 @@ public class RebornCore implements ModInitializer {
RebornCoreCommands.setup();
RebornCoreTags.WATER_EXPLOSION_ITEM.toString();
PaddedShapedRecipe.PADDED.toString();
/* register UnloadHandler */
ServerBlockEntityEvents.BLOCK_ENTITY_UNLOAD.register((blockEntity, world) -> {

View file

@ -0,0 +1,62 @@
/*
* This file is part of RebornCore, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 TeamReborn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package reborncore.common.recipes;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry;
import java.util.Map;
public class PaddedShapedRecipe extends ShapedRecipe {
public static final Identifier ID = new Identifier("reborncore", "padded");
public static final RecipeSerializer<ShapedRecipe> PADDED = Registry.register(Registry.RECIPE_SERIALIZER, ID, new Serializer());
public PaddedShapedRecipe(Identifier id, String group, int width, int height, DefaultedList<Ingredient> input, ItemStack output) {
super(id, group, width, height, input, output);
}
private static class Serializer extends ShapedRecipe.Serializer {
@Override
public PaddedShapedRecipe read(Identifier identifier, JsonObject jsonObject) {
String group = JsonHelper.getString(jsonObject, "group", "");
Map<String, Ingredient> map = readSymbols(JsonHelper.getObject(jsonObject, "key"));
String[] strings = getPattern(JsonHelper.getArray(jsonObject, "pattern"));
int width = strings[0].length();
int height = strings.length;
DefaultedList<Ingredient> ingredients = createPatternMatrix(strings, map, width, height);
ItemStack output = outputFromJson(JsonHelper.getObject(jsonObject, "result"));
return new PaddedShapedRecipe(identifier, group, width, height, ingredients, output);
}
}
}

View file

@ -46,5 +46,6 @@
],
"custom": {
"modmenu:api": true
}
},
"accessWidener": "reborncore.accesswidener"
}

View file

@ -0,0 +1,5 @@
accessWidener v1 named
accessible method net/minecraft/recipe/ShapedRecipe readSymbols (Lcom/google/gson/JsonObject;)Ljava/util/Map;
accessible method net/minecraft/recipe/ShapedRecipe getPattern (Lcom/google/gson/JsonArray;)[Ljava/lang/String;
accessible method net/minecraft/recipe/ShapedRecipe createPatternMatrix ([Ljava/lang/String;Ljava/util/Map;II)Lnet/minecraft/util/collection/DefaultedList;

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UXX",
"XXX"
"U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"UXX",
"XXX"
" ",
"U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XXU",
"XXX"
"U ",
" U",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UUX",
"XUX"
"UU ",
" U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXU",
"XXX",
"XXX"
" U",
" ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XUX",
"XXX"
"U ",
" U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XXX",
"UXX"
"U ",
" ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XXX",
"XUX"
"U ",
" ",
" U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XUX",
" U ",
"UUU",
"UUX"
"UU "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UXU",
"UXX"
"U U",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"XXX",
"XXX"
" ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"UXX",
"UXX"
"U ",
"U ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XXX",
"XXU"
"U ",
" ",
" U"
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUX",
"XXX",
"XXX"
"UU ",
" ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
" ",
"UUU",
"XXX"
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"XXX",
"UXX"
" ",
" ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"XUX",
"XXU"
"U ",
" U ",
" U"
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUX",
"UXX",
"XXX"
"UU ",
"U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UUX",
"UXX"
"UU ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXU",
"XXX",
"XXX"
"U U",
" ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UXX",
"UXX",
"XXX"
"U ",
"U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"UXX",
"UXX"
" ",
"U ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XUX",
"XXU",
"XXX"
" U ",
" U",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XUX",
"XXX",
"XXX"
" U ",
" ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"XUX",
"XXX"
" U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UUX",
"XXX"
"UU ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"XXX",
"UXU"
" ",
" ",
"U U"
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"XXX",
"XUX"
" ",
" ",
" U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"XUX",
"XXX"
" ",
" U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XUX",
"XXX",
"UXX"
" U ",
" ",
"U "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XXX",
"XUX",
"XXU"
" ",
" U ",
" U"
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UXU",
"XXX"
"U U",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"UUU",
"UUU",
"XXX"
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {

View file

@ -1,16 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"type": "reborncore:padded",
"pattern": [
"XUX",
"XUX",
"XXX"
" U ",
" U ",
" "
],
"key": {
"U": {
"item": "techreborn:uu_matter"
},
"X": {
"item": "minecraft:air"
}
},
"result": {