add BeeMoveGoalsUnsynchronizedRandomAccessFix

This commit is contained in:
dfsek
2022-06-16 16:37:14 -07:00
parent 01ba75a29b
commit ba179c0991
2 changed files with 32 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
package com.dfsek.terra.fabric.mixin.fix;
import com.dfsek.terra.fabric.FabricEntryPoint;
import com.dfsek.terra.fabric.util.FabricUtil;
import net.minecraft.entity.passive.BeeEntity.MoveToFlowerGoal;
import net.minecraft.entity.passive.BeeEntity.MoveToHiveGoal;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.random.CheckedRandom;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
/**
* Bees spawning uses world.random without synchronization. This causes issues when spawning bees during world generation.
*/
@Mixin({
MoveToHiveGoal.class,
MoveToFlowerGoal.class
})
public class BeeMoveGoalsUnsynchronizedRandomAccessFix {
@Redirect(method = "<init>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;random:Lnet/minecraft/util/math/random/Random;"))
public Random redirectRandomAccess(World instance) {
return new CheckedRandom(FabricEntryPoint.getPlatform().getServer().getTicks()); // replace with new random seeded by tick time.
}
}

View File

@@ -8,13 +8,14 @@
"access.MobSpawnerLogicAccessor",
"access.StateAccessor",
"access.StructureAccessorAccessor",
"fix.BeeMoveGoalsUnsynchronizedRandomAccessFix",
"fix.NetherFossilOptimization",
"implementations.cache.ChunkRegionMixin",
"implementations.cache.ProtoChunkMixin",
"implementations.compat.GenerationSettingsFloraFeaturesMixin",
"implementations.entity_holder.ProtoChunkMixin",
"fix.NetherFossilOptimization",
"implementations.terra.BiomeMixin",
"implementations.terra.HandleImplementationMixin",
"implementations.terra.HandleImplementationMixin",
"implementations.terra.block.BlockMixin",
"implementations.terra.block.entity.BlockEntityMixin",
"implementations.terra.block.entity.LootableContainerBlockEntityMixin",