This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
RelicCraft/src/main/java/com/thebrokenrail/reliccraft/mixin/MixinServerChunkManager.java

27 lines
1.1 KiB
Java

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$Key;)I"), method = "tickChunks")
public int adjustRandomTickSpeed(GameRules gameRules, GameRules.Key<GameRules.IntRule> rule) {
if (rule.equals(GameRules.RANDOM_TICK_SPEED)) {
return (int) (gameRules.getInt(rule) * TimeDilaterItem.getTimeDilationFactor(((TimeDilaterItem.DilatedWorld) getWorld()).getTimeSpeed()));
} else {
return gameRules.getInt(rule);
}
}
}