From 1c1fb5eb5926e8decd42a05a0b95f87796004a0e Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 2 Oct 2020 18:07:59 -0300 Subject: [PATCH] fixes #486 --- docs/scarpet/Full.md | 8 ++++---- docs/scarpet/api/Auxiliary.md | 8 ++++---- src/main/java/carpet/fakes/SpawnHelperInnerInterface.java | 2 ++ src/main/java/carpet/mixins/SpawnHelperInnerMixin.java | 6 ++++++ src/main/java/carpet/script/api/Monitoring.java | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/scarpet/Full.md b/docs/scarpet/Full.md index c10c979e..69b6e7e9 100644 --- a/docs/scarpet/Full.md +++ b/docs/scarpet/Full.md @@ -3777,7 +3777,7 @@ Consult section about container operations in `Expression` to learn about possib Excapes all the special characters in the string or nbt tag and returns a string that can be stored in nbt directly as a string value. -### parse_nbt(tag) +### `parse_nbt(tag)` Converts NBT tag to a scarpet value, which you can navigate through much better. @@ -3787,7 +3787,7 @@ Converts: - Numbers (Ints, Floats, Doubles, Longs) into a number - Rest is converted to strings. -### encode_nbt(expr, force?) +### `encode_nbt(expr, force?)` Encodes value of the expression as an NBT tag. By default (or when `force` is false), it will only allow to encode values that are guaranteed to return the same value when applied the resulting tag to `parse_nbt()`. @@ -4032,11 +4032,11 @@ world-localized block, so not `block('stone')`, or a string representing a dimen ### `view_distance()` Returns the view distance of the server. -### `mob_counts()`, `mob_counts(category)` 1.16+ +### `get_mob_counts()`, `get_mob_counts(category)` 1.16+ Returns either a map of mob categories with its respective counts and capacities (a.k.a. mobcaps) or just a tuple of count and limit for a specific category. If a category was not spawning for whatever reason it may not be -returned from `mob_counts()`, but could be retrieved for `mob_counts(category)`. Returned counts is what spawning +returned from `get_mob_counts()`, but could be retrieved for `get_mob_counts(category)`. Returned counts is what spawning algorithm has taken in to account last time mobs spawned. ### `schedule(delay, function, args...)` diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index 4b27a290..38644763 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -163,7 +163,7 @@ Consult section about container operations in `Expression` to learn about possib Excapes all the special characters in the string or nbt tag and returns a string that can be stored in nbt directly as a string value. -### parse_nbt(tag) +### `parse_nbt(tag)` Converts NBT tag to a scarpet value, which you can navigate through much better. @@ -173,7 +173,7 @@ Converts: - Numbers (Ints, Floats, Doubles, Longs) into a number - Rest is converted to strings. -### encode_nbt(expr, force?) +### `encode_nbt(expr, force?)` Encodes value of the expression as an NBT tag. By default (or when `force` is false), it will only allow to encode values that are guaranteed to return the same value when applied the resulting tag to `parse_nbt()`. @@ -418,11 +418,11 @@ world-localized block, so not `block('stone')`, or a string representing a dimen ### `view_distance()` Returns the view distance of the server. -### `mob_counts()`, `mob_counts(category)` 1.16+ +### `get_mob_counts()`, `get_mob_counts(category)` 1.16+ Returns either a map of mob categories with its respective counts and capacities (a.k.a. mobcaps) or just a tuple of count and limit for a specific category. If a category was not spawning for whatever reason it may not be -returned from `mob_counts()`, but could be retrieved for `mob_counts(category)`. Returned counts is what spawning +returned from `get_mob_counts()`, but could be retrieved for `get_mob_counts(category)`. Returned counts is what spawning algorithm has taken in to account last time mobs spawned. ### `schedule(delay, function, args...)` diff --git a/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java b/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java index 6cdb49e9..4a96f526 100644 --- a/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java +++ b/src/main/java/carpet/fakes/SpawnHelperInnerInterface.java @@ -5,4 +5,6 @@ import net.minecraft.util.math.GravityField; public interface SpawnHelperInnerInterface { GravityField getPotentialCalculator(); + + int cmGetChunkCount(); } diff --git a/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java b/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java index 126a0a46..d14c8e80 100644 --- a/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java +++ b/src/main/java/carpet/mixins/SpawnHelperInnerMixin.java @@ -31,12 +31,18 @@ public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface cir.setReturnValue(groupToCount.getInt(entityCategory) < i); } + + @Override public GravityField getPotentialCalculator() { return densityField; } + @Override + public int cmGetChunkCount() { + return spawningChunkCount; + } } diff --git a/src/main/java/carpet/script/api/Monitoring.java b/src/main/java/carpet/script/api/Monitoring.java index 5f7bd4bb..1a8ee653 100644 --- a/src/main/java/carpet/script/api/Monitoring.java +++ b/src/main/java/carpet/script/api/Monitoring.java @@ -1,5 +1,6 @@ package carpet.script.api; +import carpet.fakes.SpawnHelperInnerInterface; import carpet.script.CarpetContext; import carpet.script.Expression; import carpet.script.LazyValue; @@ -30,7 +31,7 @@ public class Monitoring { SpawnHelper.Info info = world.getChunkManager().getSpawnInfo(); if (info == null) return LazyValue.NULL; Object2IntMap mobcounts = info.getGroupToCount(); - int chunks = info.getSpawningChunkCount(); + int chunks = ((SpawnHelperInnerInterface)info).cmGetChunkCount(); Value retVal; if (lv.size() == 0) {