Skip to content

Commit

Permalink
fix: assertions issue in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
sylv256 committed Aug 13, 2024
1 parent e66eb4e commit 57fa1e0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,29 @@ static void tick(Level level, BlockPos pos, BlockState state, NetherReactorBlock
blockEntity.progress = blockEntity.progress.next();

boolean hasSpawned = false;
for (int i = 0; i < 4; i++) {
boolean willSpawn = level.random.nextBoolean();
if (!hasSpawned && i == 3) {
willSpawn = true; // spawn no matter what
}

if (willSpawn && blockEntity.progress.ordinal() >= Progress.MID1.ordinal() && blockEntity.progress.ordinal() < Progress.FINISH1.ordinal()) {
hasSpawned = true;
ZombifiedPiglin zombifiedPiglin = EntityType.ZOMBIFIED_PIGLIN.create(level);
Vec3 mobPos = randomPos(pos, level.random);
assert zombifiedPiglin != null;
zombifiedPiglin.setPos(mobPos);
if (level.random.nextFloat() <= Constants.LEFT_HANDEDNESS_OCCURRENCE) {
zombifiedPiglin.setLeftHanded(true);
if (blockEntity.progress.ordinal() >= Progress.MID1.ordinal() && blockEntity.progress.ordinal() < Progress.FINISH1.ordinal()) {
for (int i = 0; i < 4; i++) {
boolean willSpawn = level.random.nextBoolean();
if (!hasSpawned && i == 3) {
willSpawn = true; // spawn no matter what
}

if (willSpawn) {
hasSpawned = true;
ZombifiedPiglin zombifiedPiglin = EntityType.ZOMBIFIED_PIGLIN.create(level);
Vec3 mobPos = randomPos(pos, level.random);
assert zombifiedPiglin != null;
zombifiedPiglin.setPos(mobPos);
if (level.random.nextFloat() <= Constants.LEFT_HANDEDNESS_OCCURRENCE) {
zombifiedPiglin.setLeftHanded(true);
}
zombifiedPiglin.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_SWORD));
level.addFreshEntity(zombifiedPiglin);
}
zombifiedPiglin.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(Items.GOLDEN_SWORD));
level.addFreshEntity(zombifiedPiglin);
}

Assertions.check(hasSpawned, "Failed to spawn at least one Zombified Piglin.");
}
Assertions.check(hasSpawned, "Failed to spawn at least one Zombified Piglin.");

BlockPos upPos = pos.above();
BlockPos downPos = pos.below();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/gay/sylv/weird_wares/impl/util/Assertions.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2024 Vulpixel
* <p>
* For more information, read the LICENSE file in the project root.
* You should have received a copy of the Lambda License with The Software.
* If not, visit {@link https://sylv.gay/licenses/lambda}.
*/
package gay.sylv.weird_wares.impl.util;

/**
Expand Down

0 comments on commit 57fa1e0

Please sign in to comment.