Skip to content

Commit

Permalink
Properly support fluid buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
beckadamtheinventor committed Jul 26, 2024
1 parent d455615 commit e5f1579
Show file tree
Hide file tree
Showing 27 changed files with 601 additions and 347 deletions.
25 changes: 20 additions & 5 deletions _m3ec/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def execActions(actions, d):
if "iterate" in ak:
l = action["iterate"]
if type(l) is str:
l = d[readf(l, d).lower()]
l = readf(l, d).lower()
if l not in d.keys():
continue
l = d[l]
for i in range(len(l)):
d["%i"] = i
d["%v"] = l[i]
Expand Down Expand Up @@ -121,7 +124,10 @@ def execActions(actions, d):
d["%a"] = []
l = action["iterate"]
if type(l) is str:
l = d[readf(l, d).lower()]
l = readf(l, d).lower()
if l not in d.keys():
continue
l = d[l]
for i in range(len(l)):
d["%i"] = i
d["%v"] = l[i]
Expand Down Expand Up @@ -199,7 +205,10 @@ def execActions(actions, d):
if "iterate" in ak:
l = action["iterate"]
if type(l) is str:
l = d[readf(l, d).lower()]
l = readf(l, d).lower()
if l not in d.keys():
continue
l = d[l]
iterating = True
else:
l = [None]
Expand All @@ -214,7 +223,10 @@ def execActions(actions, d):
if "iterate" in ak:
l = action["iterate"]
if type(l) is str:
l = d[readf(l, d).lower()]
l = readf(l, d).lower()
if l not in d.keys():
continue
l = d[l]
iterating = True
else:
l = [None]
Expand Down Expand Up @@ -320,7 +332,10 @@ def execActions(actions, d):
iterating = True
l = action["iterate"]
if type(l) is str:
l = d[readf(l, d).lower()]
l = readf(l, d).lower()
if l not in d.keys():
continue
l = d[l]
else:
iterating = False
l = [action["source"]]
Expand Down
51 changes: 27 additions & 24 deletions _m3ec/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,64 +153,67 @@ def checkConditionString(condition, d):
inverted = False
if val in d.keys():
val = d[val]
val2 = None
if len(condition) >= 2:
val2 = readf(condition[1], d)
# print(val, condition)
if condition[0] == "#contains":
if type(val) is str and condition[1] in val:
if type(val) is str and val2 in val:
return not inverted
elif condition[0] == "#containskey":
if type(val) is dict and condition[1] in val.keys():
if type(val) is dict and val2 in val.keys():
return not inverted
elif condition[0] == "#typeis":
if condition[1] == "int" and type(val) is int:
if val2 == "int" and type(val) is int:
return not inverted
elif condition[1] == "float" and type(val) is float:
elif val2 == "float" and type(val) is float:
return not inverted
elif condition[1] == "str" and type(val) is str:
elif val2 == "str" and type(val) is str:
return not inverted
elif condition[1] == "list" and type(val) is list:
elif val2 == "list" and type(val) is list:
return not inverted
elif condition[1] == "tuple" and type(val) is tuple:
elif val2 == "tuple" and type(val) is tuple:
return not inverted
elif condition[1] == "dict" and type(val) is dict:
elif val2 == "dict" and type(val) is dict:
return not inverted
elif condition[1] == "number" and (type(val) is int or type(val) is float):
elif val2 == "number" and (type(val) is int or type(val) is float):
return not inverted
elif condition[1] == "iterable" and (type(val) is list or type(val) is tuple):
elif val2 == "iterable" and (type(val) is list or type(val) is tuple):
return not inverted
elif condition[1] == "none" and val is None:
elif val2 == "none" and val is None:
return not inverted
elif condition[0] == "#startswith":
if type(val) is str and val.startswith(condition[1]):
if type(val) is str and val.startswith(val2):
return not inverted
elif condition[0] == "#equals":
if val == condition[1]:
if val == val2:
return not inverted
elif condition[0] == "#endswith":
if type(val) is str and val.endswith(condition[1]):
if type(val) is str and val.endswith(val2):
return not inverted
elif condition[0] == "#length":
if type(val) is str or type(val) is list or type(val) is tuple:
if condition[1] == "nonzero" and len(val) > 0:
if val2 == "nonzero" and len(val) > 0:
return not inverted
elif condition[1] == "zero" and len(val) <= 0:
elif val2 == "zero" and len(val) <= 0:
return not inverted
elif condition[0] == ">":
if toNumber(val, default=0) > toNumber(condition[1], default=0):
if toNumber(val, default=0) > toNumber(val2, default=0):
return not inverted
elif condition[0] == "<":
if toNumber(val, default=0) < toNumber(condition[1], default=0):
if toNumber(val, default=0) < toNumber(val2, default=0):
return not inverted
elif condition[0] == ">=":
if toNumber(val, default=0) >= toNumber(condition[1], default=0):
if toNumber(val, default=0) >= toNumber(val2, default=0):
return not inverted
elif condition[0] == "<=":
if toNumber(val, default=0) <= toNumber(condition[1], default=0):
if toNumber(val, default=0) <= toNumber(val2, default=0):
return not inverted
elif condition[0] == "==":
if toNumber(val, default=0) == toNumber(condition[1], default=0):
if toNumber(val, default=0) == toNumber(val2, default=0):
return not inverted
elif condition[0] == "!=":
if toNumber(val, default=0) != toNumber(condition[1], default=0):
if toNumber(val, default=0) != toNumber(val2, default=0):
return not inverted
return inverted

Expand Down Expand Up @@ -342,6 +345,7 @@ def readDictString(data, d=None, f=None, md=None):
checkverstr = line.split(" ", maxsplit=1)[1]
checkver = checkverstr.lstrip("<>= \t").split(".")
deltaver = [int(checkver[i])-int(gameversion[i]) for i in range(min(len(gameversion), len(checkver)))]
# print(gameversion, checkverstr, checkver, deltaver)
if len(deltaver) < 3:
deltaver += [0] * (3 - len(deltaver))
if checkverstr.startswith(">="):
Expand Down Expand Up @@ -394,8 +398,7 @@ def readDictString(data, d=None, f=None, md=None):
isthisapplicable = False

if hasversionselector and not isthisapplicable:
print(f"File {f} was not applicable to this modloader/version, skipping it")
return False
return None

if d is None:
d = {}
Expand Down
4 changes: 2 additions & 2 deletions data/common/item_models/BucketItem.m3ecjson
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"parent": "item/generated",
"textures": {
"layer0": "minecraft:item/water_bucket"
"layer0": "${texture}"
}
}
2 changes: 1 addition & 1 deletion data/fabric1.20.1/MainClass.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class ${mod.class} implements ModInitializer {
entries.add(ModItems.${mod.sapling.$%v^upper});---end
---iter mod.registry.fluid.names
---if1 mod.fluid.$%v.bucketable
entries.add(ModFluids.${mod.fluid.$%v^upper}_BUCKET);---1fi---end
entries.add(ModItems.${mod.fluid.$%v^upper}_BUCKET);---1fi---end
})
.build()
);---fi
Expand Down
Loading

0 comments on commit e5f1579

Please sign in to comment.