Skip to content

Commit

Permalink
fix(recipes): ✏️fix vanilla wood cant be cut inside [Precision Sawmill]
Browse files Browse the repository at this point in the history
  • Loading branch information
Krutoy242 committed Feb 28, 2024
1 parent 1efc744 commit c00ff4c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
3 changes: 1 addition & 2 deletions scripts/process.zs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ function beneficiate(

val oreName = (_oreName == 'Aluminum') ? 'Aluminium' : _oreName;

var exceptions = D(opts).getString('exceptions', '');
exceptions = exceptions == '' ? null : exceptions;
val exceptions = D(opts).getString('exceptions', '');

// Determine extra output based on JAOPCA
val JA = mods.jaopca.JAOPCA.getOre(oreName);
Expand Down
38 changes: 28 additions & 10 deletions scripts/processUtils.zs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,38 @@ import crafttweaker.liquid.ILiquidStack;
function I(id as string, n as int) as IItemStack { return itemUtils.getItem(id, n); }

// Check if exception string contains lookup string, case NOT sensetive
function isNotException(exceptions as string, machineName as string) as bool {
if (isNull(exceptions)) {
return true;
function isException(exceptions as string, machineName as string) as bool {
if (exceptions == '') return false;
var exc = exceptions;

var haveOnly = false;
val indexOfOnly = exc.indexOf('only:');
if (indexOfOnly != -1) {
haveOnly = true;
exc = exc.substring(indexOfOnly + 5);
}
else {
val exc = exceptions.toLowerCase();
val name = machineName.toLowerCase();

val isHaveWord = exc.matches('.*\b' ~ name ~ '\b.*');
val isAfterStrict = exc.matches('.*strict:.*' ~ name ~ '\b.*');
val isOnly = exc.matches('^(only|strict):.*');
val isHaveName = exc.matches('.*\b'~machineName~'\b.*');

if (haveOnly) {
val result = !isHaveName;
return result;
}

return isAfterStrict || !(isHaveWord ^ isOnly);
var isAfterStrict = false;
var haveStrict = false;
val indexOfStrict = exc.indexOf('strict:');
if (indexOfStrict != -1) {
haveStrict = true;
isAfterStrict = exc.substring(indexOfStrict + 7).matches('.*\b'~machineName~'\b.*');
}

if (haveStrict) {
val result = !(isHaveName && isAfterStrict);
return result;
}

return isHaveName;
}

// Check machineName comes after keyword "strict:"
Expand Down
7 changes: 4 additions & 3 deletions scripts/processWork.zs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scripts.processUtils.defaultChance0_int;
import scripts.processUtils.defaultItem0;
import scripts.processUtils.enderioXmlRecipe;
import scripts.processUtils.info;
import scripts.processUtils.isNotException;
import scripts.processUtils.isException;
import scripts.processUtils.isStrict;
import scripts.processUtils.normalizeChances;
import scripts.processUtils.warning;
Expand Down Expand Up @@ -51,15 +51,16 @@ function getOptionTime(options as IData, default as int) as int {
// Function receive all possible combinations of input and outputs of one machine
// Any argument can be null except machine name
// Returns name of machine if recipe was added. If not, returns empty string
function workEx(machineNameAnyCase as string, exceptions as string,
function workEx(machineNameAnyCase as string, exceptionsAnyCase as string,
inputItems as IIngredient[], inputLiquids as ILiquidStack[],
outputItems as IItemStack[], outputLiquids as ILiquidStack[] = null,
extra as IItemStack[] = null, extraChance as float[] = null, options as IData = null) as string {
// Prepare machine name
val machineName = machineNameAnyCase.toLowerCase();
val exceptions = isNull(exceptionsAnyCase) ? '' : exceptionsAnyCase.toLowerCase();

// Machine is exception -> exit function
if (!isNotException(exceptions, machineName)) { return ''; }
if (isException(exceptions, machineName)) { return ''; }

// Strict indicates that old recipe should be removed first
val strict as bool = isStrict(exceptions, machineName);
Expand Down

0 comments on commit c00ff4c

Please sign in to comment.