package com.thebrokenrail.reliccraft.mixin; import com.thebrokenrail.reliccraft.item.TimeDilaterItem; import net.minecraft.server.world.ServerChunkManager; import net.minecraft.world.GameRules; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @SuppressWarnings("unused") @Mixin(ServerChunkManager.class) public abstract class MixinServerChunkManager { @Shadow public abstract World getWorld(); @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getInt(Lnet/minecraft/world/GameRules$RuleKey;)I"), method = "tickChunks") public int adjustRandomTickSpeed(GameRules gameRules, GameRules.RuleKey rule) { if (rule.equals(GameRules.RANDOM_TICK_SPEED)) { return (int) (gameRules.getInt(rule) * TimeDilaterItem.getTimeDilationFactor(((TimeDilaterItem.DilatedWorld) getWorld()).getTimeSpeed())); } else { return gameRules.getInt(rule); } } }