From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/WeighedRandom.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Minecraft.World/WeighedRandom.h (limited to 'Minecraft.World/WeighedRandom.h') diff --git a/Minecraft.World/WeighedRandom.h b/Minecraft.World/WeighedRandom.h new file mode 100644 index 00000000..71066c22 --- /dev/null +++ b/Minecraft.World/WeighedRandom.h @@ -0,0 +1,28 @@ +#pragma once +// 4J - this WeighedRandomItem class was a nested static class within WeighedRandom, but we need to be able to refer to it externally + +class WeighedRandomItem +{ + friend class WeighedRandom; +protected: + int randomWeight; + +public: + WeighedRandomItem(int randomWeight) + { + this->randomWeight = randomWeight; + } +}; + +class WeighedRandom +{ +public: + // 4J - vectors here were Collection + static int getTotalWeight(vector *items); + static WeighedRandomItem *getRandomItem(Random *random, vector *items, int totalWeight); + static WeighedRandomItem *getRandomItem(Random *random, vector *items); + static int getTotalWeight(WeighedRandomItemArray items); + static WeighedRandomItem *getRandomItem(Random *random, WeighedRandomItemArray items, int totalWeight); + static WeighedRandomItem *getRandomItem(Random *random, WeighedRandomItemArray items); + +}; -- cgit v1.2.3