Skip to content

Commit

Permalink
🐛 correct travelling merchant spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
LocusAzzurro committed Aug 13, 2024
1 parent 8dfff4e commit 7c643cc
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
Expand Down Expand Up @@ -132,15 +133,15 @@ public static void accelerateTraderTick(TickEvent.WorldTickEvent event){

@SubscribeEvent
public static void travellingMerchantSpawnAttempt(TickEvent.WorldTickEvent event){
if (event.world.isClientSide() || event.phase != TickEvent.Phase.START) return;
if (event.world.isClientSide() || event.phase != TickEvent.Phase.START || event.world.dimension() != Level.OVERWORLD) return;
ServerLevel world = (ServerLevel) event.world;
ServerLevelData levelData = (ServerLevelData) world.getLevelData();
if (!world.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING) ||
!world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) ||
!world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) return;
int wanderingTraderSpawnDelay = levelData.getWanderingTraderSpawnDelay();
int wanderingTraderSpawnChance = levelData.getWanderingTraderSpawnChance();
if (world.getDayTime() % 24000 == 0 && wanderingTraderSpawnDelay <= 0 && world.random.nextInt(100) > wanderingTraderSpawnChance){
if (world.getDayTime() % 24000 == 0 && wanderingTraderSpawnDelay <= 0 && world.random.nextInt(100) < wanderingTraderSpawnChance){
spawnTrader(world);
}
}
Expand Down

0 comments on commit 7c643cc

Please sign in to comment.