Skip to content

Commit

Permalink
Expose game test helpers to other mods
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 18, 2024
1 parent 0a2a32f commit 183572c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void setValueInGui(ISubGuiBox subGui) {

}

protected static class ValueTypeVariableFacadeFactory implements IVariableFacadeHandlerRegistry.IVariableFacadeFactory<IValueTypeVariableFacade> {
public static class ValueTypeVariableFacadeFactory implements IVariableFacadeHandlerRegistry.IVariableFacadeFactory<IValueTypeVariableFacade> {

private final IValueType valueType;
private final IValue value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -71,7 +80,7 @@ public IAspectVariableFacade create(int id) {
}, level, null, null);
}

public static void placeVariableInWriter(Level level, PartPos partPos, final IAspectWrite<ValueTypeInteger.ValueInteger, ValueTypeInteger> 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();
Expand Down

0 comments on commit 183572c

Please sign in to comment.