Skip to content

Commit 57fa1e0

Browse files
committed
fix: assertions issue in prod
1 parent e66eb4e commit 57fa1e0

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

src/main/java/gay/sylv/weird_wares/impl/block/NetherReactorBlock.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,29 @@ static void tick(Level level, BlockPos pos, BlockState state, NetherReactorBlock
190190
blockEntity.progress = blockEntity.progress.next();
191191

192192
boolean hasSpawned = false;
193-
for (int i = 0; i < 4; i++) {
194-
boolean willSpawn = level.random.nextBoolean();
195-
if (!hasSpawned && i == 3) {
196-
willSpawn = true; // spawn no matter what
197-
}
198-
199-
if (willSpawn && blockEntity.progress.ordinal() >= Progress.MID1.ordinal() && blockEntity.progress.ordinal() < Progress.FINISH1.ordinal()) {
200-
hasSpawned = true;
201-
ZombifiedPiglin zombifiedPiglin = EntityType.ZOMBIFIED_PIGLIN.create(level);
202-
Vec3 mobPos = randomPos(pos, level.random);
203-
assert zombifiedPiglin != null;
204-
zombifiedPiglin.setPos(mobPos);
205-
if (level.random.nextFloat() <= Constants.LEFT_HANDEDNESS_OCCURRENCE) {
206-
zombifiedPiglin.setLeftHanded(true);
193+
if (blockEntity.progress.ordinal() >= Progress.MID1.ordinal() && blockEntity.progress.ordinal() < Progress.FINISH1.ordinal()) {
194+
for (int i = 0; i < 4; i++) {
195+
boolean willSpawn = level.random.nextBoolean();
196+
if (!hasSpawned && i == 3) {
197+
willSpawn = true; // spawn no matter what
198+
}
199+
200+
if (willSpawn) {
201+
hasSpawned = true;
202+
ZombifiedPiglin zombifiedPiglin = EntityType.ZOMBIFIED_PIGLIN.create(level);
203+
Vec3 mobPos = randomPos(pos, level.random);
204+
assert zombifiedPiglin != null;
205+
zombifiedPiglin.setPos(mobPos);
206+
if (level.random.nextFloat() <= Constants.LEFT_HANDEDNESS_OCCURRENCE) {
207+
zombifiedPiglin.setLeftHanded(true);
208+
}
209+
zombifiedPiglin.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_SWORD));
210+
level.addFreshEntity(zombifiedPiglin);
207211
}
208-
zombifiedPiglin.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_SWORD));
209-
level.addFreshEntity(zombifiedPiglin);
210212
}
213+
214+
Assertions.check(hasSpawned, "Failed to spawn at least one Zombified Piglin.");
211215
}
212-
Assertions.check(hasSpawned, "Failed to spawn at least one Zombified Piglin.");
213216

214217
BlockPos upPos = pos.above();
215218
BlockPos downPos = pos.below();

src/main/java/gay/sylv/weird_wares/impl/util/Assertions.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Copyright (c) 2024 Vulpixel
3+
* <p>
4+
* For more information, read the LICENSE file in the project root.
5+
* You should have received a copy of the Lambda License with The Software.
6+
* If not, visit {@link https://sylv.gay/licenses/lambda}.
7+
*/
18
package gay.sylv.weird_wares.impl.util;
29

310
/**

0 commit comments

Comments
 (0)