Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03c8a8f7fe | |||
| aa4dd64700 |
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Ваш лучший помощник в вопросах настройки времени! На Forge версии 1.16.5 и только. Отдельная благодарность Мсе за большую часть логики, которую я взял у него.
|
Ваш лучший помощник в вопросах настройки времени! На Forge версии 1.16.5 и только. Отдельная благодарность Мсе за большую часть логики, которую я взял у него.
|
||||||
|
|
||||||
|
Для личного использования - пожалуйста и сколько угодно, если хотите взять себе на сервер и у вас не донатная помойка, я не против, но ради приличия сообщите мне об этом лично. О багах тоже лучше всего сообщать в личку.
|
||||||
|
|
||||||
## Как это работает
|
## Как это работает
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
1. Если задан fixedDayTime в пределах от 0 до 24000, то назначается он. Это позволяет сделать в дименшене фиксированное время. Значения остальных полей игнорируются, т.е. если вы не хотите, чтобы было фиксированное время, то сделайте -1 или 24001 и так далее.
|
1. Если задан fixedDayTime в пределах от 0 до 24000, то назначается он. Это позволяет сделать в дименшене фиксированное время. Значения остальных полей игнорируются, т.е. если вы не хотите, чтобы было фиксированное время, то сделайте -1 или 24001 и так далее.
|
||||||
2. Если scale больше нуля, то считается, что вы хотите именно его. Скейл это ускорение или замедление течения времени относительно обычного времени. Например, если scale 3.0, то время будет идти в три раза быстрее, а если 0.5 - то в 2 раза медленнее. Если активируется scale, то игнорируется hours_offset.
|
2. Если scale больше нуля, то считается, что вы хотите именно его. Скейл это ускорение или замедление течения времени относительно обычного времени. Например, если scale 3.0, то время будет идти в три раза быстрее, а если 0.5 - то в 2 раза медленнее. Если активируется scale, то игнорируется hours_offset.
|
||||||
3. Наконец, hours_offset. Он может быть от -18 до 18 и выражает собой отступ в часах от текущего серверного времени. Он может быть 0, тогда игровое время будет полностью соответствовать времени сервера. Если вы хотите и его отключить, то сделайте его больше 18 или меньше -18.
|
3. Наконец, hours_offset. Он может быть от -18 до 18 и выражает собой отступ в часах от текущего серверного времени. Он может быть 0, тогда игровое время будет полностью соответствовать времени сервера. Если вы хотите и его отключить, то сделайте его больше 18 или меньше -18.
|
||||||
Таким образом, если у вас hours_offset: 9, scale: 0 и fixed_day_time: -1, то время будет идти как в ванилле. Это может быть полезно, если вам нужно сохранить фичи дождя.
|
Таким образом, если у вас hours_offset: 19, scale: 0 и fixed_day_time: -1, то время будет идти как в ванилле. Это может быть полезно, если вам нужно сохранить фичи дождя.
|
||||||
|
|
||||||
Перейдем к rain.
|
Перейдем к rain.
|
||||||
|
|
||||||
|
|||||||
17
build.gradle
17
build.gradle
@@ -7,6 +7,10 @@ buildscript {
|
|||||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "com.diffplug.spotless" version "6.11.0"
|
||||||
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
@@ -156,9 +160,20 @@ jar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
ratchetFrom 'origin/master'
|
||||||
|
|
||||||
|
java {
|
||||||
|
importOrder()
|
||||||
|
removeUnusedImports()
|
||||||
|
palantirJavaFormat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Example configuration to allow publishing using the maven-publish task
|
// Example configuration to allow publishing using the maven-publish task
|
||||||
// This is the preferred method to reobfuscate your jar file
|
// This is the preferred method to reobfuscate your jar file
|
||||||
jar.finalizedBy('reobfJar')
|
jar.finalizedBy('reobfJar')
|
||||||
|
assemble.finalizedBy('spotlessJavaApply')
|
||||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
||||||
//publish.dependsOn('reobfJar')
|
//publish.dependsOn('reobfJar')
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package stargazer.timelord.commands;
|
package stargazer.timelord.commands;
|
||||||
|
|
||||||
|
import static stargazer.timelord.Timelord.getDimensionsConfigMap;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
@@ -10,30 +12,45 @@ import net.minecraft.world.server.ServerWorld;
|
|||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
import stargazer.timelord.Timelord;
|
import stargazer.timelord.Timelord;
|
||||||
import stargazer.timelord.config.Configuration;
|
import stargazer.timelord.config.Configuration;
|
||||||
|
import stargazer.timelord.logic.TimelordWorldData;
|
||||||
import stargazer.timelord.net.TimePacket;
|
import stargazer.timelord.net.TimePacket;
|
||||||
|
|
||||||
import static stargazer.timelord.Timelord.getDimensionsConfigMap;
|
|
||||||
|
|
||||||
public class TimelordCommands {
|
public class TimelordCommands {
|
||||||
public TimelordCommands(CommandDispatcher<CommandSource> dispatcher) {
|
public TimelordCommands(CommandDispatcher<CommandSource> dispatcher) {
|
||||||
dispatcher.register(Commands.literal("timelord").then(Commands.literal("reload").requires(s -> s.hasPermissionLevel(4)).executes((command) -> {
|
dispatcher.register(Commands.literal("timelord")
|
||||||
return reload(command.getSource());
|
.then(Commands.literal("reload")
|
||||||
})));
|
.requires(s -> s.hasPermissionLevel(4))
|
||||||
|
.executes((command) -> reload(command.getSource())))
|
||||||
|
.then(Commands.literal("rain")
|
||||||
|
.requires(s -> s.hasPermissionLevel(4))
|
||||||
|
.executes((command) -> getRainAcc(command.getSource()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int reload(CommandSource source) throws CommandSyntaxException {
|
private int reload(CommandSource source) throws CommandSyntaxException {
|
||||||
|
|
||||||
ServerWorld sw = source.getWorld();
|
ServerWorld sw = source.getWorld();
|
||||||
for (ServerWorld world : sw.getServer().getWorlds()) {
|
for (ServerWorld world : sw.getServer().getWorlds()) {
|
||||||
ResourceLocation rl = world.getDimensionKey().getLocation();
|
ResourceLocation rl = world.getDimensionKey().getLocation();
|
||||||
getDimensionsConfigMap().put(rl, Configuration.init(world));
|
getDimensionsConfigMap().put(rl, Configuration.init(world));
|
||||||
Timelord.TIME_CHANNEL.send(PacketDistributor.ALL.noArg(),
|
Timelord.TIME_CHANNEL.send(
|
||||||
new TimePacket(rl, Configuration.getConfigAsString(getDimensionsConfigMap().get(rl)))
|
PacketDistributor.ALL.noArg(),
|
||||||
);
|
new TimePacket(
|
||||||
|
rl,
|
||||||
|
Configuration.getConfigAsString(
|
||||||
|
getDimensionsConfigMap().get(rl))));
|
||||||
|
|
||||||
source.sendFeedback(new StringTextComponent("Timelord config reloaded for " + world.getDimensionKey().getLocation()), true);
|
source.sendFeedback(
|
||||||
|
new StringTextComponent("Timelord config reloaded for "
|
||||||
|
+ world.getDimensionKey().getLocation()),
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
source.sendFeedback(new StringTextComponent("Timelord config succesfully reloaded!"), true);
|
source.sendFeedback(new StringTextComponent("Timelord config succesfully reloaded!"), true);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getRainAcc(CommandSource source) throws CommandSyntaxException {
|
||||||
|
ServerWorld sw = source.getWorld();
|
||||||
|
TimelordWorldData worldData = TimelordWorldData.getForWorld(sw);
|
||||||
|
source.sendFeedback(new StringTextComponent("Rain acc: " + worldData.getRainAcc()), true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package stargazer.timelord.logic;
|
package stargazer.timelord.logic;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraft.world.storage.DimensionSavedDataManager;
|
import net.minecraft.world.storage.DimensionSavedDataManager;
|
||||||
import net.minecraft.world.storage.WorldSavedData;
|
import net.minecraft.world.storage.WorldSavedData;
|
||||||
import stargazer.timelord.Timelord;
|
import stargazer.timelord.Timelord;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
|
|
||||||
public class TimelordWorldData extends WorldSavedData implements Supplier {
|
public class TimelordWorldData extends WorldSavedData implements Supplier {
|
||||||
|
|
||||||
public TimelordWorldData() {
|
public TimelordWorldData() {
|
||||||
@@ -34,7 +32,6 @@ public class TimelordWorldData extends WorldSavedData implements Supplier {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(CompoundNBT nbt) {
|
public void read(CompoundNBT nbt) {
|
||||||
rainAcc = nbt.getLong("rain");
|
rainAcc = nbt.getLong("rain");
|
||||||
@@ -46,6 +43,10 @@ public class TimelordWorldData extends WorldSavedData implements Supplier {
|
|||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getRainAcc() {
|
||||||
|
return rainAcc;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
return true;
|
return true;
|
||||||
@@ -55,4 +56,4 @@ public class TimelordWorldData extends WorldSavedData implements Supplier {
|
|||||||
public Object get() {
|
public Object get() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user