Fixed input ports with perTick set to true, now need to be validated for the recipe to go ahead. This used to cause inputs to consume resources even if the recipe wasn't able to process

This commit is contained in:
Quarris
2022-06-06 12:48:58 +01:00
parent 39e0d063f8
commit f3bf09faa0
8 changed files with 78 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
version = '1.16.5-0.1.61-hf-B' + getVersionNumber()
version = '1.16.5-0.1.62-B' + getVersionNumber()
group = 'com.ticticboooom.mods.mm' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'MasterfulMachinery'
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
@@ -177,7 +177,7 @@ dependencies {
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
compileOnly 'org.projectlombok:lombok:1.18.18'
annotationProcessor 'org.projectlombok:lombok:1.18.18'
minecraft 'net.minecraftforge:forge:1.16.5-36.2.21'
minecraft 'net.minecraftforge:forge:1.16.5-36.2.35'
compileOnly 'com.google.code.gson:gson:2.8.7'
implementation 'org.spongepowered:mixin:0.8-SNAPSHOT'

View File

@@ -110,7 +110,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
if (recipe.matches(inputPorts, structure.getStructureId(), processData)) {
// TODO Make sure the recipe doesn't stop progress when some inputs aren't present
if (!recipe.equals(processData.getRecipe())) {
if (processData.getRecipe() != null){
if (processData.getRecipe() != null) {
processData.getRecipe().onInterrupted(inputPorts, outputPorts);
}
processData.setTicksTaken(0);

View File

@@ -63,11 +63,11 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
if (takenIndices.contains(i)) {
continue;
}
if (!input.isConsumePerTick()) {
//if (!input.isConsumePerTick()) {
if (!input.validateRequirement(inputPorts)) {
return false;
}
}
//}
}
return true;
}

View File

@@ -38,7 +38,7 @@ public class RotationPortState extends PortState {
@Override
public boolean validateRequirement(List<PortStorage> storage) {
for (PortStorage portStorage : storage) {
if (portStorage instanceof RotationPortStorage){
if (portStorage instanceof RotationPortStorage) {
RotationPortStorage rot = (RotationPortStorage) portStorage;
if (!rot.isOverStressed() && rot.getSpeed() >= speed) {
return true;
@@ -51,7 +51,7 @@ public class RotationPortState extends PortState {
@Override
public void processResult(List<PortStorage> storage) {
for (PortStorage portStorage : storage) {
if (portStorage instanceof RotationPortStorage){
if (portStorage instanceof RotationPortStorage) {
RotationPortStorage rot = (RotationPortStorage) portStorage;
rot.setSpeed(speed);
}
@@ -81,7 +81,7 @@ public class RotationPortState extends PortState {
@Override
public void setupRecipe(IRecipeLayout layout, Integer typeIndex, int x, int y, boolean input) {
IGuiIngredientGroup<RotationStack> group = layout.getIngredientsGroup(MMJeiPlugin.ROT_TYPE);
group.init(typeIndex, input, x+ 1, y +1);
group.init(typeIndex, input, x + 1, y + 1);
group.set(typeIndex, new RotationStack(speed));
}

View File

@@ -0,0 +1,25 @@
{
"type": "masterfulmachinery:machine_structure",
"id": "test_constant_mana",
"controllerId": "basic",
"name": "Test Constant Mana",
"layout": [
[
"C1234"
]
],
"legend": {
"1": {
"block": "masterfulmachinery:basic_simple_port_items_input"
},
"2": {
"block": "masterfulmachinery:basic_simple_port_items_output"
},
"3": {
"block": "masterfulmachinery:basic_simple_port_create_rotation_input"
},
"4": {
"block": "masterfulmachinery:basic_simple_port_botania_mana_input"
}
}
}

View File

@@ -2,14 +2,15 @@
"type": "masterfulmachinery:machine_process",
"structureId": "test_items",
"controllerId": "basic",
"ticks": 200,
"ticks": 40,
"inputs": [
{
"type": "masterfulmachinery:items",
"data": {
"item": "minecraft:oak_log",
"count": 2
}
},
"perTick": true
}
],
"outputs":[

View File

@@ -0,0 +1,40 @@
{
"type": "masterfulmachinery:machine_process",
"structureId": "test_constant_mana",
"controllerId": "basic",
"ticks": 100,
"inputs": [
{
"type": "masterfulmachinery:items",
"consumeInstantly": false,
"data": {
"item": "minecraft:stone",
"count": 1
}
},
{
"type": "masterfulmachinery:botania_mana",
"perTick": true,
"consumeInstantly": true,
"data": {
"amount": 25
}
},
{
"type": "masterfulmachinery:create_rotation",
"perTick": true,
"data": {
"speed": 16
}
}
],
"outputs": [
{
"type": "masterfulmachinery:items",
"data": {
"item": "minecraft:cobblestone",
"count": 9
}
}
]
}

View File

@@ -1,2 +1,2 @@
#Wed Apr 13 12:36:09 BST 2022
VERSION_CODE=920
#Mon Jun 06 12:45:37 BST 2022
VERSION_CODE=953