Allow Dilating Random Tick Speed
This commit is contained in:
parent
0d55d8089d
commit
918d0bc9b9
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
**1.0.10**
|
||||
* Allow Dilating Random Tick Speed
|
||||
|
||||
**1.0.9**
|
||||
* Fix Structure Generation Bug with Modded Biomes
|
||||
|
||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
||||
fabric_loader_version = 0.7.10+build.191
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.9
|
||||
mod_version = 1.0.10
|
||||
maven_group = com.thebrokenrail
|
||||
archives_base_name = reliccraft
|
||||
|
||||
|
@ -89,4 +89,19 @@ public class TimeDilaterItem extends Item {
|
||||
tag.putByte("Artificial", (byte) 2);
|
||||
}
|
||||
}
|
||||
|
||||
public static long getTimeDilationFactor(TimeSpeed speed) {
|
||||
switch (speed) {
|
||||
case FAST: {
|
||||
return 4L;
|
||||
}
|
||||
case VERY_FAST: {
|
||||
return 8L;
|
||||
}
|
||||
default:
|
||||
case NORMAL: {
|
||||
return 1L;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
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<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);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,18 +24,7 @@ public abstract class MixinWorld implements TimeDilaterItem.DilatedWorld {
|
||||
|
||||
@ModifyConstant(constant = @Constant(longValue = 1L), method = "tickTime")
|
||||
public long tickTime(long value) {
|
||||
switch (getTimeSpeed()) {
|
||||
case FAST: {
|
||||
return value * 4L;
|
||||
}
|
||||
case VERY_FAST: {
|
||||
return value * 8L;
|
||||
}
|
||||
default:
|
||||
case NORMAL: {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value * TimeDilaterItem.getTimeDilationFactor(getTimeSpeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@
|
||||
"MixinLivingEntity",
|
||||
"MixinLocateCommand",
|
||||
"MixinNetherStarItem",
|
||||
"MixinServerChunkManager",
|
||||
"MixinServerWorld",
|
||||
"MixinThrownEnderpearlEntity",
|
||||
"MixinWorld"
|
||||
|
Reference in New Issue
Block a user