From 183572c45331536cfdb0a6d0cdff4ed136aa3a40 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 18 Dec 2024 12:59:08 +0100 Subject: [PATCH] Expose game test helpers to other mods --- .../logicprogrammer/ValueTypeLPElementBase.java | 2 +- .../gametest/GameTestHelpersIntegratedDynamics.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) rename src/{integrationtest => main}/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java (86%) diff --git a/src/main/java/org/cyclops/integrateddynamics/core/logicprogrammer/ValueTypeLPElementBase.java b/src/main/java/org/cyclops/integrateddynamics/core/logicprogrammer/ValueTypeLPElementBase.java index aa59da57968..105efabe131 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/logicprogrammer/ValueTypeLPElementBase.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/logicprogrammer/ValueTypeLPElementBase.java @@ -187,7 +187,7 @@ public void setValueInGui(ISubGuiBox subGui) { } - protected static class ValueTypeVariableFacadeFactory implements IVariableFacadeHandlerRegistry.IVariableFacadeFactory { + public static class ValueTypeVariableFacadeFactory implements IVariableFacadeHandlerRegistry.IVariableFacadeFactory { private final IValueType valueType; private final IValue value; diff --git a/src/integrationtest/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java b/src/main/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java similarity index 86% rename from src/integrationtest/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java rename to src/main/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java index 1739ebc387c..7dee16374a1 100644 --- a/src/integrationtest/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java +++ b/src/main/java/org/cyclops/integrateddynamics/gametest/GameTestHelpersIntegratedDynamics.java @@ -8,6 +8,7 @@ import org.cyclops.integrateddynamics.RegistryEntries; import org.cyclops.integrateddynamics.api.evaluate.operator.IOperator; import org.cyclops.integrateddynamics.api.evaluate.variable.IValue; +import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType; import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext; import org.cyclops.integrateddynamics.api.item.IAspectVariableFacade; import org.cyclops.integrateddynamics.api.item.IVariableFacade; @@ -20,10 +21,11 @@ import org.cyclops.integrateddynamics.api.part.write.IPartStateWriter; import org.cyclops.integrateddynamics.api.part.write.IPartTypeWriter; import org.cyclops.integrateddynamics.core.evaluate.operator.Operators; -import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeInteger; +import org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypes; import org.cyclops.integrateddynamics.core.helper.PartHelpers; import org.cyclops.integrateddynamics.core.item.AspectVariableFacade; import org.cyclops.integrateddynamics.core.logicprogrammer.OperatorLPElement; +import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeLPElementBase; import org.cyclops.integrateddynamics.part.PartTypePanelDisplay; import org.cyclops.integrateddynamics.part.aspect.Aspects; @@ -40,6 +42,13 @@ public static void assertValueEqual(IValue value1, IValue value2) { } } + public static ItemStack createVariableForValue(Level level, IValueType valueType, IValue value) { + IVariableFacadeHandlerRegistry registry = IntegratedDynamics._instance.getRegistryManager().getRegistry(IVariableFacadeHandlerRegistry.class); + ItemStack itemStack = new ItemStack(RegistryEntries.ITEM_VARIABLE); + return registry.writeVariableFacadeItem(true, itemStack, ValueTypes.REGISTRY, + new ValueTypeLPElementBase.ValueTypeVariableFacadeFactory(valueType, value), level, null, RegistryEntries.BLOCK_LOGIC_PROGRAMMER.get().defaultBlockState()); + } + public static ItemStack createVariableForOperator(Level level, IOperator operator, int[] variableIds) { IVariableFacadeHandlerRegistry registry = IntegratedDynamics._instance.getRegistryManager().getRegistry(IVariableFacadeHandlerRegistry.class); ItemStack itemStack = new ItemStack(RegistryEntries.ITEM_VARIABLE); @@ -71,7 +80,7 @@ public IAspectVariableFacade create(int id) { }, level, null, null); } - public static void placeVariableInWriter(Level level, PartPos partPos, final IAspectWrite aspect, ItemStack variableAspect) { + public static void placeVariableInWriter(Level level, PartPos partPos, final IAspectWrite aspect, ItemStack variableAspect) { PartHelpers.PartStateHolder partStateHolder = PartHelpers.getPart(partPos); IPartTypeWriter part = (IPartTypeWriter) partStateHolder.getPart(); IPartStateWriter state = (IPartStateWriter) partStateHolder.getState();