From a21d8534db89befa149d38a05e93c7641b1b039b Mon Sep 17 00:00:00 2001 From: Quarris Date: Tue, 28 Sep 2021 19:58:04 +0100 Subject: [PATCH] Added ability to define ports as structure parts rather than individual blocks. --- .../controllers/{all.json => basic.json} | 20 +-- .../masterful_machinery/controllers/mid.json | 106 +++++++++++++ .../MachineStructureRecipeCategory.java | 139 +++++++++++------- .../screen/PortBlockContainerScreen.java | 10 +- .../mods/mm/data/MachineStructureRecipe.java | 42 ++++-- .../structure/MachineStructureBlockPos.java | 20 ++- .../model/structure/MachineStructurePort.java | 31 ++++ .../MachineStructureRecipeKeyModel.java | 17 +-- .../MachineStructureRecipeLegendModel.java | 14 +- .../recipes/structures/test_tiered_fluid.json | 33 +++++ .../recipes/structures/test_variable_ios.json | 52 +++++++ .../data/mm/recipes/test_tiered_fluid.json | 24 +++ version.properties | 4 +- 13 files changed, 406 insertions(+), 106 deletions(-) rename demo_config/config/masterful_machinery/controllers/{all.json => basic.json} (87%) create mode 100644 demo_config/config/masterful_machinery/controllers/mid.json create mode 100644 src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructurePort.java create mode 100644 src/test/resources/data/mm/recipes/structures/test_tiered_fluid.json create mode 100644 src/test/resources/data/mm/recipes/structures/test_variable_ios.json create mode 100644 src/test/resources/data/mm/recipes/test_tiered_fluid.json diff --git a/demo_config/config/masterful_machinery/controllers/all.json b/demo_config/config/masterful_machinery/controllers/basic.json similarity index 87% rename from demo_config/config/masterful_machinery/controllers/all.json rename to demo_config/config/masterful_machinery/controllers/basic.json index 25f7851..f0501c9 100644 --- a/demo_config/config/masterful_machinery/controllers/all.json +++ b/demo_config/config/masterful_machinery/controllers/basic.json @@ -8,8 +8,8 @@ "name": "Item", "id": "simple", "data": { - "rows": 3, - "columns": 3 + "rows": 1, + "columns": 1 } }, { @@ -17,7 +17,7 @@ "name": "Energy", "id": "simple", "data": { - "capacity": 1000000000 + "capacity": 1000000 } }, { @@ -25,7 +25,7 @@ "name": "Fluid", "id": "simple", "data": { - "capacity": 10000 + "capacity": 5000 } }, { @@ -35,7 +35,7 @@ "data": { "criticalPressure": 7, "dangerPressure": 5, - "volume": 10000 + "volume": 7000 } }, { @@ -43,7 +43,7 @@ "name": "Mana", "id": "simple", "data": { - "capacity": 100000 + "capacity": 50000 } }, { @@ -51,7 +51,7 @@ "name": "Starlight", "id": "simple", "data": { - "capacity": 1000 + "capacity": 500 } }, { @@ -67,7 +67,7 @@ "name": "Gas", "id": "simple", "data": { - "capacity": 100000000 + "capacity": 100000 } }, { @@ -75,7 +75,7 @@ "name": "Slurry", "id": "simple", "data": { - "capacity": 100000000 + "capacity": 100000 } }, { @@ -83,7 +83,7 @@ "name": "Infuse", "id": "simple", "data": { - "capacity": 100000000 + "capacity": 100000 } }, { diff --git a/demo_config/config/masterful_machinery/controllers/mid.json b/demo_config/config/masterful_machinery/controllers/mid.json new file mode 100644 index 0000000..a0fffa5 --- /dev/null +++ b/demo_config/config/masterful_machinery/controllers/mid.json @@ -0,0 +1,106 @@ +{ + "controllerId": "mid", + "name": "Mid", + "ports": [ + { + "type": "masterfulmachinery:items", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Item", + "id": "intermediate", + "data": { + "rows": 3, + "columns": 3 + } + }, + { + "type": "masterfulmachinery:energy", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Energy", + "id": "intermediate", + "data": { + "capacity": 1000000000 + } + }, + { + "type": "masterfulmachinery:fluids", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Fluid", + "id": "intermediate", + "data": { + "capacity": 10000 + } + }, + { + "type": "masterfulmachinery:pncr_pressure", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Pressure", + "id": "intermediate", + "data": { + "criticalPressure": 7, + "dangerPressure": 5, + "volume": 10000 + } + }, + { + "type": "masterfulmachinery:botania_mana", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Mana", + "id": "intermediate", + "data": { + "capacity": 100000 + } + }, + { + "type": "masterfulmachinery:astral_starlight", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Starlight", + "id": "intermediate", + "data": { + "capacity": 1000 + } + }, + { + "type": "masterfulmachinery:create_rotation", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Rotation", + "id": "intermediate", + "data": { + "stress": 3 + } + }, + { + "type": "masterfulmachinery:mekanism_gas", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Gas", + "id": "intermediate", + "data": { + "capacity": 100000000 + } + }, + { + "type": "masterfulmachinery:mekanism_slurry", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Slurry", + "id": "intermediate", + "data": { + "capacity": 100000000 + } + }, + { + "type": "masterfulmachinery:mekanism_infuse", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Infuse", + "id": "intermediate", + "data": { + "capacity": 100000000 + } + }, + { + "type": "masterfulmachinery:weather", + "textureOverride": "minecraft:block/red_terracotta", + "name": "Weather", + "id": "intermediate", + "data": {} + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java index e8d4afa..ce96ecc 100644 --- a/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java +++ b/src/main/java/com/ticticboooom/mods/mm/client/jei/category/MachineStructureRecipeCategory.java @@ -3,9 +3,13 @@ package com.ticticboooom.mods.mm.client.jei.category; import com.mojang.blaze3d.matrix.MatrixStack; import com.ticticboooom.mods.mm.MM; import com.ticticboooom.mods.mm.block.ControllerBlock; +import com.ticticboooom.mods.mm.block.MachinePortBlock; import com.ticticboooom.mods.mm.client.util.GuiBlockRenderBuilder; import com.ticticboooom.mods.mm.data.MachineStructureRecipe; +import com.ticticboooom.mods.mm.data.model.structure.MachineStructureBlockPos; +import com.ticticboooom.mods.mm.data.model.structure.MachineStructurePort; import com.ticticboooom.mods.mm.data.model.structure.MachineStructureRecipeKeyModel; +import com.ticticboooom.mods.mm.helper.RLUtils; import com.ticticboooom.mods.mm.registration.MMLoader; import com.ticticboooom.mods.mm.registration.MMSetup; import mezz.jei.api.gui.IRecipeLayout; @@ -50,10 +54,11 @@ public class MachineStructureRecipeCategory implements IRecipeCategory tagIndexes = new HashMap<>(); - private Map tagIndexCounter = new HashMap<>(); private float scaleFactor = 1F; + private int tickTimer = 0; + private Map variantIndices = new HashMap<>(); + public MachineStructureRecipeCategory(IJeiHelpers helpers, ControllerBlock controller) { this.helpers = helpers; this.controller = controller; @@ -76,6 +81,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory parts = recipe.getModels().get(0); if (slicingActive) { parts = parts.stream().filter(x -> x.getPos().getY() == sliceY).collect(Collectors.toList()); } - //float sizeX = 162, sizeY = 121; - //float scaledSizeX = sizeX / scaleFactor, scaledSizeY = sizeY / scaleFactor; - float tx = 6.5f, ty = -5, tz = 10; + //float tx = 6.5f, ty = -5, tz = 10; + float tx = 0, ty = 0, tz = 10; + Vector3f prePos = new Vector3f(tx, ty, tz); + Vector3f offset = new Vector3f(centreX / 2, centerY / 2, centreZ / 2); - int i = 0; + // Render the block parts for (MachineStructureRecipeKeyModel part : parts) { - tagIndexes.putIfAbsent(i, 0); - tagIndexCounter.putIfAbsent(i, 0); - if (part.getBlock().isEmpty() && part.getTag().isEmpty()) { + variantIndices.putIfAbsent(part.getPos(), 0); + if (part.getBlock().isEmpty() && part.getTag().isEmpty() && part.getPort() == null) { continue; } @@ -184,65 +193,75 @@ public class MachineStructureRecipeCategory implements IRecipeCategory tag = BlockTags.getCollection().getTagByID(resourceLocation); - if (tag != null) { - Integer index = tagIndexes.get(i); + Integer index = this.variantIndices.get(part.getPos()); - Block block = tag.getAllElements().get((int) Math.floor(index / 50.0)); - index++; - if (index >= (tag.getAllElements().size()) * 50) { - index = 0; - } + Block block = tag.getAllElements().get(index); + if (this.tickTimer == 0) { + this.variantIndices.put(part.getPos(), (index+1) % tag.getAllElements().size()); + } - tagIndexes.put(i, index); - if (block != null) { - BlockState defaultState = block.getDefaultState(); - defaultState = with(defaultState, part.getProperties()); - new GuiBlockRenderBuilder(defaultState).at(bp) - .withPrePosition(new Vector3f(tx, ty, tz)) - .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) - .withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true)) - .withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor)) - .withOffset(new Vector3f(-0.5f, -0.5f, -0.5f)) - .finalize(matrixStack); + if (block != null) { + BlockState defaultState = block.getDefaultState(); + defaultState = with(defaultState, part.getProperties()); + renderBlock(defaultState, bp, prePos, offset, matrixStack); + } + } else if (part.getPort() != null) { + MachineStructurePort port = part.getPort(); + ArrayList> ports = port.isInput() ? MMLoader.IPORT_BLOCKS : MMLoader.OPORT_BLOCKS; + Integer index = this.variantIndices.get(part.getPos()); + String controllerId = port.getControllerId().get(index); + if (this.tickTimer == 0) { + this.variantIndices.put(part.getPos(), (index+1) % port.getControllerId().size()); + } + String type = port.getType(); + MachinePortBlock block = null; + for (RegistryObject regPortBlock : ports) { + MachinePortBlock portBlock = regPortBlock.get(); + if (portBlock.getPortTypeId().equals(RLUtils.toRL(type)) && portBlock.getControllerId().equals(controllerId)) { + block = portBlock; + break; } } + if (block != null) { + BlockState defaultState = block.getDefaultState(); + defaultState = with(defaultState, part.getProperties()); + renderBlock(defaultState, bp, prePos, offset, matrixStack); + } } } + // Render the controller block if (sliceY == 0) { ControllerBlock block = null; + MachineStructureBlockPos controllerPos = new MachineStructureBlockPos(0, 0, 0); + this.variantIndices.putIfAbsent(controllerPos, 0); + Integer index = this.variantIndices.get(controllerPos); + String controller = recipe.getControllerId().get(index); + if (this.tickTimer == 0) { + this.variantIndices.put(controllerPos, (index+1) % recipe.getControllerId().size()); + } for (RegistryObject reg : MMLoader.BLOCKS) { - if (recipe.getControllerId().contains(reg.get().getControllerId())) { + if (reg.get().getControllerId().equals(controller)) { block = reg.get(); } } if (block != null) { BlockState defaultState = block.getDefaultState().with(DirectionalBlock.FACING, Direction.NORTH); - new GuiBlockRenderBuilder(defaultState).at(new BlockPos(0, 0, 0)) - .withPrePosition(new Vector3f(tx, ty, tz)) - .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) - .withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true)) - .withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor)) - .withOffset(new Vector3f(-0.5f, -0.5f, -0.5f)) - .finalize(matrixStack); - + renderBlock(defaultState, new BlockPos(0, 0, 0), prePos, offset, matrixStack); } } - this.recipe = recipe; + // End tick xLastMousePosition = mouseX; yLastMousePosition = mouseY; getButton().draw(matrixStack, 144, 125); + if (++this.tickTimer % 40 == 0) { + this.tickTimer = 0; + } } @Override @@ -296,4 +315,14 @@ public class MachineStructureRecipeCategory implements IRecipeCategory { + private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/port_gui.png"); + private final PortBlockContainer container; public PortBlockContainerScreen(PortBlockContainer container, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) { @@ -17,18 +19,16 @@ public class PortBlockContainerScreen extends ContainerScreen { @@ -70,9 +63,9 @@ public class MachineStructureRecipe implements IRecipe { BlockPos rotatedPos1 = new BlockPos(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()).rotate(Rotation.CLOCKWISE_180); BlockPos rotatedPos2 = new BlockPos(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()).rotate(Rotation.COUNTERCLOCKWISE_90); - rotated.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos.getX(), rotatedPos.getY(), rotatedPos.getZ()), model.getTag(), model.getBlock(), model.getProperties())); - rotated1.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos1.getX(), rotatedPos1.getY(), rotatedPos1.getZ()), model.getTag(), model.getBlock(), model.getProperties())); - rotated2.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos2.getX(), rotatedPos2.getY(), rotatedPos2.getZ()), model.getTag(), model.getBlock(), model.getProperties())); + rotated.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos.getX(), rotatedPos.getY(), rotatedPos.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort())); + rotated1.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos1.getX(), rotatedPos1.getY(), rotatedPos1.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort())); + rotated2.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos2.getX(), rotatedPos2.getY(), rotatedPos2.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort())); } this.models = new ArrayList<>(); @@ -142,6 +135,18 @@ public class MachineStructureRecipe implements IRecipe { valid = tag.contains(blockState.getBlock()); } else if (!model.getBlock().equals("")) { valid = blockState.getBlock().getRegistryName().toString().equals(model.getBlock()); + } else if (model.getPort() != null) { + MachineStructurePort structurePort = model.getPort(); + TileEntity portBlockEntity = world.getTileEntity(pos); + if (portBlockEntity instanceof IMachinePortTile && blockState.getBlock() instanceof MachinePortBlock) { + IMachinePortTile portTile = (IMachinePortTile) portBlockEntity; + MachinePortBlock portBlock = ((MachinePortBlock) blockState.getBlock()); + if (portTile.isInput() == structurePort.isInput() && + portBlock.getPortTypeId().equals(RLUtils.toRL(structurePort.getType()))) { + List controllerIds = structurePort.getControllerId() != null ? structurePort.getControllerId() : this.controllerId; + valid = controllerIds.contains(portBlock.getControllerId()); + } + } } if (!valid) { @@ -228,7 +233,6 @@ public class MachineStructureRecipe implements IRecipe { List result = getResult(obj.getAsJsonObject("legend"), layout); - validateStructure(result, ids, id, rl); MM.LOG.debug("Added structure '{}' with id '{}'", rl, id); return new MachineStructureRecipe(result, ids, id, rl, name); @@ -262,7 +266,7 @@ public class MachineStructureRecipe implements IRecipe { } MachineStructureRecipeLegendModel machineStructureRecipeLegendModel = model.get(c); BlockPos pos = new BlockPos(x, y, z).subtract(new BlockPos(controllerPos)); - result.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(pos.getX(), pos.getY(), pos.getZ()), machineStructureRecipeLegendModel.getTag(), machineStructureRecipeLegendModel.getBlock(), machineStructureRecipeLegendModel.getProperties())); + result.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(pos.getX(), pos.getY(), pos.getZ()), machineStructureRecipeLegendModel.getTag(), machineStructureRecipeLegendModel.getBlock(), machineStructureRecipeLegendModel.getProperties(), machineStructureRecipeLegendModel.getPort())); } z++; } @@ -355,8 +359,14 @@ public class MachineStructureRecipe implements IRecipe { if (!RLUtils.isRL(model.getTag())) { throw new InvalidStructureDefinitionException("Block Tag: " + model.getBlock() + " is defined but not a valid block tag id (ResourceLocation)"); } + } else if (model.getPort() != null) { + if (!MMPorts.PORTS.containsKey(RLUtils.toRL(model.getPort().getType()))) { + throw new InvalidStructureDefinitionException("Port: " + model.getPort() + " is defined but not a valid port type id (ResourceLocation)"); + } else if (!controllerId.containsAll(model.getPort().getControllerId())) { + throw new InvalidStructureDefinitionException("Port: " + model.getPort() + " is defined but not a valid port controller id specified (ResourceLocation)"); + } } else { - throw new InvalidStructureDefinitionException("YUo must define at least 1 'block' or 'tag' per port within the 'data' object"); + throw new InvalidStructureDefinitionException("You must define at least 1 'block' or 'tag' per port within the 'data' object"); } } diff --git a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureBlockPos.java b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureBlockPos.java index f1cfc43..397573d 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureBlockPos.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureBlockPos.java @@ -3,9 +3,12 @@ package com.ticticboooom.mods.mm.data.model.structure; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; import lombok.Getter; import net.minecraft.util.math.vector.Vector3i; +import java.util.Objects; + @Getter @AllArgsConstructor public class MachineStructureBlockPos implements Comparable { @@ -22,7 +25,22 @@ public class MachineStructureBlockPos implements Comparable CODEC = RecordCodecBuilder.create(x -> x.group( + Codec.STRING.fieldOf("type").forGetter(z -> z.type), + Codec.BOOL.fieldOf("input").forGetter(z -> z.input), + Codec.either(Codec.STRING, Codec.list(Codec.STRING)).xmap( + either -> either.map(Collections::singletonList, Function.identity()), + ids -> ids.size() == 1 ? Either.left(ids.get(0)) : Either.right(ids) + ).optionalFieldOf("controllerId").forGetter(z -> Optional.ofNullable(z.controllerId)) + ).apply(x, (w, y, z) -> new MachineStructurePort(w, y, z.orElse(null)))); + + private final String type; + private final boolean input; + private final List controllerId; +} diff --git a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeKeyModel.java b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeKeyModel.java index e44fccf..b431e2c 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeKeyModel.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeKeyModel.java @@ -1,13 +1,10 @@ package com.ticticboooom.mods.mm.data.model.structure; import com.mojang.serialization.Codec; -import com.mojang.serialization.Keyable; -import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import lombok.AllArgsConstructor; import lombok.Getter; -import java.util.ArrayList; import java.util.Map; import java.util.Optional; @@ -15,14 +12,16 @@ import java.util.Optional; @AllArgsConstructor public class MachineStructureRecipeKeyModel { public static final Codec CODEC = RecordCodecBuilder.create(x -> x.group( - MachineStructureBlockPos.CODEC.fieldOf("pos").forGetter(z -> z.pos), - Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)), - Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)), - Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("nbt").forGetter(z -> Optional.ofNullable(z.properties)) - ).apply(x, (w0, w, y, z) -> new MachineStructureRecipeKeyModel(w0, w.orElse(""), y.orElse(""), z.orElse(null)))); - private MachineStructureBlockPos pos; + MachineStructureBlockPos.CODEC.fieldOf("pos").forGetter(z -> z.pos), + Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)), + Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)), + Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("nbt").forGetter(z -> Optional.ofNullable(z.properties)), + MachineStructurePort.CODEC.optionalFieldOf("port").forGetter(z -> Optional.ofNullable(z.port)) + ).apply(x, (w0, w, y, z, z0) -> new MachineStructureRecipeKeyModel(w0, w.orElse(""), y.orElse(""), z.orElse(null), z0.orElse(null)))); + private MachineStructureBlockPos pos; private final String tag; private final String block; private final Map properties; + private final MachineStructurePort port; } diff --git a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeLegendModel.java b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeLegendModel.java index a29a9d5..5144761 100644 --- a/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeLegendModel.java +++ b/src/main/java/com/ticticboooom/mods/mm/data/model/structure/MachineStructureRecipeLegendModel.java @@ -2,13 +2,10 @@ package com.ticticboooom.mods.mm.data.model.structure; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import com.ticticboooom.mods.mm.nbt.model.NBTModel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; -import net.minecraft.nbt.CompoundNBT; -import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -16,13 +13,14 @@ import java.util.Optional; @AllArgsConstructor public class MachineStructureRecipeLegendModel { public static final Codec CODEC = RecordCodecBuilder.create(x -> x.group( - Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)), - Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)), - Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("props").forGetter(z -> Optional.ofNullable(z.properties)) - ).apply(x, (w, y, z) -> new MachineStructureRecipeLegendModel(w.orElse(""), y.orElse(""), z.orElse(null)))); + Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)), + Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)), + Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("props").forGetter(z -> Optional.ofNullable(z.properties)), + MachineStructurePort.CODEC.optionalFieldOf("port").forGetter(z -> Optional.ofNullable(z.port)) + ).apply(x, (w, y, z, z0) -> new MachineStructureRecipeLegendModel(w.orElse(""), y.orElse(""), z.orElse(null), z0.orElse(null)))); private final String tag; private final String block; - @Setter private Map properties; + private final MachineStructurePort port; } diff --git a/src/test/resources/data/mm/recipes/structures/test_tiered_fluid.json b/src/test/resources/data/mm/recipes/structures/test_tiered_fluid.json new file mode 100644 index 0000000..569b0e4 --- /dev/null +++ b/src/test/resources/data/mm/recipes/structures/test_tiered_fluid.json @@ -0,0 +1,33 @@ +{ + "type": "masterfulmachinery:machine_structure", + "id": "test_tiered_fluids", + "controllerId": [ + "basic", + "mid" + ], + "name": "Test Tiered Fluids", + "layout": [ + [ + "1C2" + ] + ], + "legend": { + "1": { + "port": { + "type": "masterfulmachinery:fluids", + "input": true, + "controllerId": [ + "basic", + "mid" + ] + } + }, + "2": { + "port": { + "type": "masterfulmachinery:fluids", + "input": false, + "controllerId": "mid" + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/data/mm/recipes/structures/test_variable_ios.json b/src/test/resources/data/mm/recipes/structures/test_variable_ios.json new file mode 100644 index 0000000..c964f55 --- /dev/null +++ b/src/test/resources/data/mm/recipes/structures/test_variable_ios.json @@ -0,0 +1,52 @@ +{ + "type": "masterfulmachinery:machine_structure", + "id": "variable_io", + "controllerId": "basic", + "name": "Variable IO", + "layout": [ + [ + ")C)", + "*+*", + ")*)" + ], + [ + "),)", + "-./", + ")0)" + ], + [ + ")))", + ")1)", + ")))" + ] + ], + "legend": { + "0": { + "block": "masterfulmachinery:basic_simple_port_fluids_output" + }, + "1": { + "block": "masterfulmachinery:basic_simple_port_mekanism_gas_output" + }, + ")": { + "block": "minecraft:polished_blackstone" + }, + "*": { + "block": "masterfulmachinery:basic_simple_port_energy_output" + }, + "+": { + "block": "masterfulmachinery:basic_simple_port_items_output" + }, + ",": { + "block": "minecraft:glass" + }, + "-": { + "block": "masterfulmachinery:basic_simple_port_items_input" + }, + ".": { + "block": "minecraft:water" + }, + "/": { + "block": "masterfulmachinery:basic_simple_port_fluids_input" + } + } +} \ No newline at end of file diff --git a/src/test/resources/data/mm/recipes/test_tiered_fluid.json b/src/test/resources/data/mm/recipes/test_tiered_fluid.json new file mode 100644 index 0000000..ed75e42 --- /dev/null +++ b/src/test/resources/data/mm/recipes/test_tiered_fluid.json @@ -0,0 +1,24 @@ +{ + "type": "masterfulmachinery:machine_process", + "structureId": "test_tiered_fluid", + "controllerId": ["basic", "mid"], + "ticks": 20, + "inputs": [ + { + "type": "masterfulmachinery:fluids", + "data": { + "fluid": "minecraft:water", + "amount": 50 + } + } + ], + "outputs": [ + { + "type": "masterfulmachinery:fluids", + "data": { + "fluid": "minecraft:water", + "amount": 1 + } + } + ] +} \ No newline at end of file diff --git a/version.properties b/version.properties index adddb7a..b862fc5 100644 --- a/version.properties +++ b/version.properties @@ -1,2 +1,2 @@ -#Fri Sep 03 00:36:37 BST 2021 -VERSION_CODE=766 +#Tue Sep 28 18:52:49 BST 2021 +VERSION_CODE=785