Skip to content

Commit

Permalink
time set command adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
CmdrJane committed Jun 22, 2021
1 parent 9474b98 commit d74f477
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 40 additions & 0 deletions src/main/java/ru/aiefu/timeandwind/mixin/TimeCommandMixins.java
Original file line number Diff line number Diff line change
@@ -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<ServerCommandSource> 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<ServerCommandSource> 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<ServerCommandSource> 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<ServerCommandSource> 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<ServerCommandSource> context){
return ((IDimType)context.getSource().getWorld().getDimension()).getCycleDuration();
}
}
1 change: 1 addition & 0 deletions src/main/resources/taw.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"NoBrainInjection",
"PlayerManagerMixins",
"ServerWorldInjection",
"TimeCommandMixins",
"VillagerInjection",
"WorldMixins"
],
Expand Down

0 comments on commit d74f477

Please sign in to comment.