From d08a348266d7af3144e067b0048a9c2cbd216f69 Mon Sep 17 00:00:00 2001 From: gnembon Date: Fri, 3 Apr 2020 00:50:22 -0300 Subject: [PATCH 1/3] block not pos --- docs/scarpet/Full.md | 2 +- docs/scarpet/api/Events.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/scarpet/Full.md b/docs/scarpet/Full.md index e45949d4..572c8123 100644 --- a/docs/scarpet/Full.md +++ b/docs/scarpet/Full.md @@ -2860,7 +2860,7 @@ __on_tick_ender() // can access blocks and entities in the end __on_chunk_generated(x,z) // called after a chunk is promoted to the full chunk, // prodiving lowest x and z coords in the chunk // event will not work with optifine installed in the game -__on_lightning(pos, mode) // mode is `true` if lightning caused horse trap to spawn +__on_lightning(block, mode) // mode is `true` if lightning caused horse trap to spawn // player specific callbacks __on_player_uses_item(player, item_tuple, hand) // right click action __on_player_releases_item(player, item_tuple, hand) // client action (e.g. bow) diff --git a/docs/scarpet/api/Events.md b/docs/scarpet/api/Events.md index 488ed040..aa9f1c98 100644 --- a/docs/scarpet/api/Events.md +++ b/docs/scarpet/api/Events.md @@ -21,7 +21,7 @@ __on_tick_ender() // can access blocks and entities in the end __on_chunk_generated(x,z) // called after a chunk is promoted to the full chunk, // prodiving lowest x and z coords in the chunk // event will not work with optifine installed in the game -__on_lightning(pos, mode) // mode is `true` if lightning caused horse trap to spawn +__on_lightning(block, mode) // mode is `true` if lightning caused horse trap to spawn // player specific callbacks __on_player_uses_item(player, item_tuple, hand) // right click action __on_player_releases_item(player, item_tuple, hand) // client action (e.g. bow) From a867c04b117089e3a2dee8b875a9fc6780073a85 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sat, 4 Apr 2020 01:31:44 -0300 Subject: [PATCH 2/3] inhabited_time --- src/main/java/carpet/script/CarpetExpression.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index a6846d92..63615671 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -1281,6 +1281,15 @@ public class CarpetExpression return (_c, _t) -> result[0]; }); + this.expr.addLazyFunction("inhabited_time", -1, (c, t, lv) -> + { + CarpetContext cc = (CarpetContext)c; + BlockValue.LocatorResult locator = BlockValue.fromParams(cc, lv, 0); + BlockPos pos = locator.block.getPos(); + Value ret = new NumericValue(cc.s.getWorld().getChunk(pos).getInhabitedTime()); + return (_c, _t) -> ret; + }); + } private void API_Scoreboard() From cdf7445e205ea573890076063f33b6c972d6af39 Mon Sep 17 00:00:00 2001 From: gnembon Date: Wed, 8 Apr 2020 01:28:43 -0300 Subject: [PATCH 3/3] counter results sorted by rate --- src/main/java/carpet/helpers/HopperCounter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/carpet/helpers/HopperCounter.java b/src/main/java/carpet/helpers/HopperCounter.java index d31876a4..4c7163c5 100644 --- a/src/main/java/carpet/helpers/HopperCounter.java +++ b/src/main/java/carpet/helpers/HopperCounter.java @@ -126,7 +126,7 @@ public class HopperCounter color, ticks*1.0/(20*60), (realTime?" - real time":""), total, total*1.0*(20*60*60)/ticks), "nb [X]", "^g reset", "!/counter "+color+" reset" )); - items.addAll(counter.object2LongEntrySet().stream().map(e -> + items.addAll(counter.object2LongEntrySet().stream().sorted((e, f) -> Long.compare(f.getLongValue(), e.getLongValue())).map(e -> { BaseText itemName = new TranslatableText(e.getKey().getTranslationKey()); long count = e.getLongValue();