diff --git a/gradle.properties b/gradle.properties index d84b1bf..0a2f1cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ yarn_mappings=1.16.5+build.6 loader_version=0.11.3 # Mod Properties - mod_version = 1.3.2 + mod_version = 1.3.5 maven_group = net.fabricmc archives_base_name = time-and-wind diff --git a/src/main/java/ru/aiefu/timeandwind/mixin/TimeCommandMixins.java b/src/main/java/ru/aiefu/timeandwind/mixin/TimeCommandMixins.java new file mode 100644 index 0000000..6deafd7 --- /dev/null +++ b/src/main/java/ru/aiefu/timeandwind/mixin/TimeCommandMixins.java @@ -0,0 +1,40 @@ +package ru.aiefu.timeandwind.mixin; + +import com.mojang.brigadier.context.CommandContext; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.command.TimeCommand; +import net.minecraft.server.world.ServerWorld; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; +import ru.aiefu.timeandwind.IDimType; + +@Mixin(TimeCommand.class) +public class TimeCommandMixins { + @ModifyConstant(method = "method_13794(Lcom/mojang/brigadier/context/CommandContext;)I", constant = @Constant(intValue = 6000)) + private static int modifyNoonValue(int value, CommandContext context){ + return (int) (((IDimType) context.getSource().getWorld().getDimension()).getDayDuration() / 2); + } + @ModifyConstant(method = "method_13792(Lcom/mojang/brigadier/context/CommandContext;)I", constant = @Constant(intValue = 1000)) + private static int modifyDayValue(int value, CommandContext context){ + return (int) (((IDimType) context.getSource().getWorld().getDimension()).getDayDuration() / 100 * 5); + } + @ModifyConstant(method = "method_13797(Lcom/mojang/brigadier/context/CommandContext;)I", constant = @Constant(intValue = 13000)) + private static int modifyNightValue(int value, CommandContext context){ + IDimType dim = ((IDimType) context.getSource().getWorld().getDimension()); + return (int) (dim.getDayDuration() + (dim.getNightDuration() / 100 * 5)); + } + @ModifyConstant(method = "method_13785(Lcom/mojang/brigadier/context/CommandContext;)I", constant = @Constant(intValue = 18000)) + private static int modifyMidnightValue(int value, CommandContext context){ + IDimType dim = ((IDimType) context.getSource().getWorld().getDimension()); + return (int) (dim.getDayDuration() + dim.getNightDuration() / 2); + } + @ModifyConstant(method = "getDayTime(Lnet/minecraft/server/world/ServerWorld;)I", constant = @Constant(longValue = 24000L)) + private static long modifyGetDayTimeValue(long value, ServerWorld world){ + return ((IDimType)world.getDimension()).getCycleDuration(); + } + @ModifyConstant(method = "method_13795(Lcom/mojang/brigadier/context/CommandContext;)I", constant = @Constant(longValue = 24000L)) + private static long modifyTotalDaysValue(long value, CommandContext context){ + return ((IDimType)context.getSource().getWorld().getDimension()).getCycleDuration(); + } +} diff --git a/src/main/resources/taw.mixins.json b/src/main/resources/taw.mixins.json index 52a4a2d..658ebbb 100644 --- a/src/main/resources/taw.mixins.json +++ b/src/main/resources/taw.mixins.json @@ -10,6 +10,7 @@ "NoBrainInjection", "PlayerManagerMixins", "ServerWorldInjection", + "TimeCommandMixins", "VillagerInjection", "WorldMixins" ],