Skip to content

Commit

Permalink
Fixed variable handler bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Iteranya committed Nov 19, 2024
1 parent 5d0aa01 commit 380c05d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public InteractionResult interactLivingEntity(ItemStack stack, Player player, Li
try{
// Check if the entity has a custom name
if (target.getCustomName() != null) {
String entityName = target.getCustomName().getString();
String entityName = target.getCustomName().getString().toLowerCase().replace(" ", "_");

if (!world.isClientSide()) { // Only run on the server side

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ public static void processConditional(Map<String, Object> condition, VisualNovel
Object value = condition.get("value");
long end = (long) condition.get("end");

System.out.println("Is it day time???: "+vn.isDay);

switch (conditionType) {
case "equal":
result = (var != null) && var.equals(value);
result = (var != null && value != null) &&
((var instanceof Number && value instanceof Number)
? ((Number) var).doubleValue() == ((Number) value).doubleValue()
: var.equals(value));
break;
case "not_equal":
result = (var == null) || !var.equals(value);
result = (var == null || value == null) ||
((var instanceof Number && value instanceof Number)
? ((Number) var).doubleValue() != ((Number) value).doubleValue()
: !var.equals(value));
break;
case "less_than":
result = (var instanceof Number && value instanceof Number) && ((Number) var).doubleValue() < ((Number) value).doubleValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void modifyVariable(String variable, String operation, Object valu
((Number) value).doubleValue();
variables.put(variable, result);
}
} else if (operation.equals("substract_var")) {
} else if (operation.equals("subtract_var")) {
if (variables.get(variable) instanceof Number && value instanceof Number) {
double result = ((Number) variables.get(variable)).doubleValue() -
((Number) value).doubleValue();
Expand Down

0 comments on commit 380c05d

Please sign in to comment.