File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
java/com/shanebeestudios/hg Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -183,16 +183,21 @@ public int logBlocksForRollback() {
183
183
184
184
@ SuppressWarnings ("UnstableApiUsage" )
185
185
public void setupRandomizedBonusChests () {
186
+ if (!Config .CHESTS_BONUS_RANDOMIZE_ENABLED ) return ;
187
+
186
188
Optional <BlockType > first = BlockUtils .getBonusBlockTypes ().stream ().findFirst ();
187
189
if (first .isEmpty ()) return ;
190
+
188
191
BlockData blockData = first .get ().createBlockData ();
192
+ int bonusChestAmount = this .random .nextInt (Config .CHESTS_BONUS_RANDOMIZE_MIN , Config .CHESTS_BONUS_RANDOMIZE_MAX + 1 );
193
+ List <Block > randoms = new ArrayList <>(this .randomBonusChests );
194
+ for (int i = 0 ; i < bonusChestAmount ; i ++) {
195
+ if (randoms .isEmpty ()) return ;
189
196
190
- if (Config .CHESTS_BONUS_RANDOMIZE_ENABLED ) {
191
- this .randomBonusChests .forEach (bonusChest -> {
192
- if (this .random .nextInt (100 ) < Config .CHESTS_BONUS_RANDOMIZE_CHANCE ) {
193
- bonusChest .setBlockData (blockData );
194
- }
195
- });
197
+ Collections .shuffle (randoms );
198
+ Block bonusChest = randoms .getFirst ();
199
+ randoms .remove (bonusChest );
200
+ bonusChest .setBlockData (blockData );
196
201
}
197
202
}
198
203
Original file line number Diff line number Diff line change @@ -74,7 +74,8 @@ public class Config {
74
74
public static List <String > CHESTS_BONUS_BLOCK_TYPES ;
75
75
// Chests - Bonus - Randomize
76
76
public static boolean CHESTS_BONUS_RANDOMIZE_ENABLED ;
77
- public static int CHESTS_BONUS_RANDOMIZE_CHANCE ;
77
+ public static int CHESTS_BONUS_RANDOMIZE_MIN ;
78
+ public static int CHESTS_BONUS_RANDOMIZE_MAX ;
78
79
public static String CHESTS_BONUS_RANDOMIZE_BLOCK ;
79
80
80
81
// Chests - Drops
@@ -177,7 +178,8 @@ private void loadConfig() {
177
178
CHESTS_BONUS_MAX_CONTENT = config .getInt ("chests.bonus.max-content" );
178
179
CHESTS_BONUS_BLOCK_TYPES = config .getStringList ("chests.bonus.block-types" );
179
180
CHESTS_BONUS_RANDOMIZE_ENABLED = config .getBoolean ("chests.bonus.randomize.enabled" );
180
- CHESTS_BONUS_RANDOMIZE_CHANCE = config .getInt ("chests.bonus.randomize.chance" );
181
+ CHESTS_BONUS_RANDOMIZE_MIN = config .getInt ("chests.bonus.randomize.min" );
182
+ CHESTS_BONUS_RANDOMIZE_MAX = config .getInt ("chests.bonus.randomize.max" );
181
183
CHESTS_BONUS_RANDOMIZE_BLOCK = config .getString ("chests.bonus.randomize.block" );
182
184
CHESTS_CHEST_DROP_ENABLED = config .getBoolean ("chests.chest-drop.enabled" );
183
185
CHESTS_CHEST_DROP_INTERVAL = config .getInt ("chests.chest-drop.interval" );
Original file line number Diff line number Diff line change @@ -124,9 +124,12 @@ chests:
124
124
# The blocks will be replaced with the first element of 'chests.bonus.block-types' from above
125
125
enabled : true
126
126
# Place this block randomly around your arena to be replaced when a game starts
127
+ # Place as many as you'd like
127
128
block : ' minecraft:pink_wool'
128
- # Chance a block will be replaced (out of 100)
129
- chance : 50
129
+ # How many random bonus chests to place (randomly selected between min/max)
130
+ # If there aren't enough blocks placed it will just stop (make sure to place plenty more than your max)
131
+ min : 2
132
+ max : 5
130
133
# Chest drops
131
134
chest-drop :
132
135
# Whether to enable chest drops
You can’t perform that action at this time.
0 commit comments