Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cbcb098
[KillTheRNG] Added random seed display above entities
ScribbleTAS Jan 6, 2024
eae6886
[KillTheRNG] Cleanup files
ScribbleTAS Aug 6, 2025
8e489b3
[KillTheRNG] Add testing code
ScribbleTAS Sep 11, 2025
21da0bf
[KillTheRNG] Adding global randomness timer
ScribbleTAS Sep 11, 2025
a8aa2d3
[KillTheRNG] Add global seed to savestate storage
ScribbleTAS Sep 12, 2025
a40e54f
Update KTRNGSeedStorage to new format
ScribbleTAS Sep 13, 2025
c5927c9
[Events] Add ServerStart Event
ScribbleTAS Sep 13, 2025
436ced4
Bump version
ScribbleTAS Oct 25, 2025
0bc8d7b
[Savestate] Fix gross workaround when applying motion
ScribbleTAS Nov 3, 2025
605b674
[KillTheRNG] Add entity randomness saving and loading
ScribbleTAS Nov 3, 2025
8f220ed
[KillTheRNG] Add world randomness saving and loading
ScribbleTAS Nov 8, 2025
dc2d2ff
[KillTheRNG] Add RNG logging
ScribbleTAS Nov 10, 2025
5827f1f
[KillTheRNG] Only redirect server EntityRNG, add initial seed to Enti…
ScribbleTAS Nov 12, 2025
a3a1436
[Savestates] Add more loadstate events to SavestateStorage
ScribbleTAS Nov 12, 2025
80beee5
[KillTheRNG] Fix GlobalRandomness not advancing correctly
ScribbleTAS Nov 16, 2025
ff69c8f
[KillTheRNG] Add world.updateLCG to randomness pool
ScribbleTAS Nov 19, 2025
1e3e3e2
[KillTheRNG] Improve logging in RandomBase
ScribbleTAS Nov 19, 2025
d833ed9
[Tickrate] Remove processing the server task queue in Tickrate 0
ScribbleTAS Nov 27, 2025
813d919
[KillTheRNG] Started adding MathRandomness
ScribbleTAS Dec 1, 2025
b1bbf87
[KillTheRNG] Finish MathRandomness
ScribbleTAS Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ [email protected]
# TASmod properties
group=com.minecrafttas
artifact=TASmod-1.12.2
version=Beta2.1
version=Beta3
release=false
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public interface EventBase {
*/
public static void register(EventBase eventListener) {
if (eventListener == null) {
throw new NullPointerException("Tried to register a packethandler with value null");
throw new NullPointerException("Tried to register an eventListener with value null");
}

for (Class<?> type : searchForInterfaces(eventListener.getClass())) {
Expand Down Expand Up @@ -153,7 +153,7 @@ public static void register(List<? extends EventBase> eventListeners) {
*/
public static void unregister(EventBase eventListener) {
if (eventListener == null) {
throw new NullPointerException("Tried to unregister a packethandler with value null");
throw new NullPointerException("Tried to unregister an eventListener with value null");
}
for (Class<?> type : searchForInterfaces(eventListener.getClass())) {
if (EventBase.class.isAssignableFrom(type)) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/minecrafttas/mctcommon/events/EventServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
*/
public interface EventServer {

/**
* Fired, just before the server initialised, for both integrated and dedicated server.
*/
@FunctionalInterface
public static interface EventServerStart extends EventBase {

/**
* Fired, when the server is initialised, for both integrated and dedicated server.
* @param server The server
*/
public void onServerStart(MinecraftServer server);
}

/**
* Fired, when the server is initialised, for both integrated and dedicated server.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.minecrafttas.mctcommon.events.EventListenerRegistry;
import com.minecrafttas.mctcommon.events.EventServer.EventServerGameLoop;
import com.minecrafttas.mctcommon.events.EventServer.EventServerInit;
import com.minecrafttas.mctcommon.events.EventServer.EventServerStart;
import com.minecrafttas.mctcommon.events.EventServer.EventServerStop;
import com.minecrafttas.mctcommon.events.EventServer.EventServerTick;

Expand All @@ -17,6 +18,11 @@
@Mixin(MinecraftServer.class)
public class MixinMinecraftServer {

@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;init()Z"))
public void inject_initStart(CallbackInfo ci) {
EventListenerRegistry.fireEvent(EventServerStart.class, (MinecraftServer) (Object) this);
}

@Inject(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;init()Z", shift = Shift.AFTER))
public void inject_init(CallbackInfo ci) {
EventListenerRegistry.fireEvent(EventServerInit.class, (MinecraftServer) (Object) this);
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/com/minecrafttas/tasmod/TASmod.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.minecrafttas.mctcommon.CommandRegistry;
import com.minecrafttas.mctcommon.events.EventListenerRegistry;
import com.minecrafttas.mctcommon.events.EventServer.EventServerInit;
import com.minecrafttas.mctcommon.events.EventServer.EventServerStart;
import com.minecrafttas.mctcommon.events.EventServer.EventServerStop;
import com.minecrafttas.mctcommon.networking.PacketHandlerRegistry;
import com.minecrafttas.mctcommon.networking.Server;
Expand All @@ -24,6 +25,8 @@
import com.minecrafttas.tasmod.commands.CommandSavestate;
import com.minecrafttas.tasmod.commands.CommandTickrate;
import com.minecrafttas.tasmod.handlers.PlayUntilHandler;
import com.minecrafttas.tasmod.ktrng.GlobalRandomnessTimer;
import com.minecrafttas.tasmod.ktrng.MathRandomness;
import com.minecrafttas.tasmod.playback.PlaybackControllerServer;
import com.minecrafttas.tasmod.playback.metadata.builtin.StartpositionMetadataExtension;
import com.minecrafttas.tasmod.registries.TASmodAPIRegistry;
Expand All @@ -32,6 +35,7 @@
import com.minecrafttas.tasmod.savestates.handlers.SavestateGuiHandlerServer;
import com.minecrafttas.tasmod.savestates.handlers.SavestateResourcePackHandler;
import com.minecrafttas.tasmod.savestates.storage.builtin.ClientMotionStorage;
import com.minecrafttas.tasmod.savestates.storage.builtin.KTRNGSeedStorage;
import com.minecrafttas.tasmod.tickratechanger.TickrateChangerServer;
import com.minecrafttas.tasmod.ticksync.TickSyncServer;
import com.minecrafttas.tasmod.util.LoggerMarkers;
Expand All @@ -48,7 +52,7 @@
*
* @author Scribble
*/
public class TASmod implements ModInitializer, EventServerInit, EventServerStop {
public class TASmod implements ModInitializer, EventServerStart, EventServerInit, EventServerStop {

public static final Logger LOGGER = LogManager.getLogger("TASmod");

Expand Down Expand Up @@ -85,6 +89,12 @@ public class TASmod implements ModInitializer, EventServerInit, EventServerStop

public static ClientMotionStorage motionStorage = new ClientMotionStorage();

public static GlobalRandomnessTimer globalRandomness;

public static KTRNGSeedStorage seedStorage = new KTRNGSeedStorage();

public static MathRandomness mathRandomness = new MathRandomness(0);

@Override
public void onInitialize() {

Expand Down Expand Up @@ -128,12 +138,18 @@ public void onInitialize() {
EventListenerRegistry.register(resourcepackHandler);
PacketHandlerRegistry.register(playUntil);
EventListenerRegistry.register(playUntil);

EventListenerRegistry.register(TASmodAPIRegistry.SAVESTATE_STORAGE);

registerSavestateStorage();
}

@Override
public void onServerStart(MinecraftServer server) {
globalRandomness = new GlobalRandomnessTimer();
EventListenerRegistry.register(globalRandomness);
mathRandomness = new MathRandomness();
}

@Override
public void onServerInit(MinecraftServer server) {
LOGGER.info("Initializing server");
Expand Down Expand Up @@ -196,6 +212,7 @@ public void onServerStop(MinecraftServer mcserver) {

private void registerSavestateStorage() {
TASmodAPIRegistry.SAVESTATE_STORAGE.register(motionStorage);
TASmodAPIRegistry.SAVESTATE_STORAGE.register(seedStorage);
}

public static MinecraftServer getServerInstance() {
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/minecrafttas/tasmod/events/EventSavestate.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ interface EventServerSavestate extends EventBase {
* Fired when loading a savestate, before the savestate folder is copied
*/
@FunctionalInterface
interface EventServerLoadstate extends EventBase {
interface EventServerLoadstatePre extends EventBase {

/**
* Fired when loading a savestate, before the savestate folder is copied
*
* @param server The server instance
* @param paths The {@link SavestatePaths} object
*/
public void onServerLoadstate(MinecraftServer server, SavestatePaths paths);
public void onServerLoadstatePre(MinecraftServer server, SavestatePaths paths);
}

/**
* Fired when loading a savestate, after the savestate folder is copied
*/
@FunctionalInterface
interface EventServerLoadstatePost extends EventBase {

/**
* Fired when loading a savestate, after the savestate folder is copied
*
* @param server The server instance
* @param paths The {@link SavestatePaths} object
*/
public void onServerLoadstatePost(MinecraftServer server, SavestatePaths paths);
}

/**
Expand All @@ -47,7 +62,7 @@ interface EventServerCompleteLoadstate extends EventBase {
/**
* Fired one tick after a loadstate was carried out
*/
public void onServerLoadstateComplete();
public void onServerLoadstateComplete(MinecraftServer server, SavestatePaths paths);
}

/**
Expand Down
43 changes: 32 additions & 11 deletions src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.minecrafttas.tasmod.TASmod;
import com.minecrafttas.tasmod.TASmodClient;
import com.minecrafttas.tasmod.events.EventClient.EventDrawHotbar;
import com.minecrafttas.tasmod.ktrng.KTRNGWorldHandler;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
import com.minecrafttas.tasmod.playback.filecommands.builtin.DesyncMonitorFileCommandExtension;
Expand Down Expand Up @@ -296,17 +297,37 @@ public boolean checkInit() {

y += 14;

// if (TASmod.ktrngHandler.isLoaded()) {
// title = "ktrng_randomseed";
// if (configuration.getProperty(title + "_x", "err").equals("err"))
// setDefaults(title, y);
// lists.add(new InfoLabel(title, Integer.parseInt(configuration.getProperty(title + "_x")), Integer.parseInt(configuration.getProperty(title + "_y")), Boolean.parseBoolean(configuration.getProperty(title
// + "_visible")), Boolean.parseBoolean(configuration.getProperty(title + "_rect")), () -> {
// if (Minecraft.getMinecraft().currentScreen == this)
// return "KTRNG";
// return "RandomSeed: " + TASmod.ktrngHandler.getGlobalSeedClient();
// }));
// }
title = "ktrng_randomseed";
if (configuration.getProperty(title + "_x", "err").equals("err"))
setDefaults(title, y);
lists.add(new InfoLabel(title, Integer.parseInt(configuration.getProperty(title + "_x")), Integer.parseInt(configuration.getProperty(title + "_y")), Boolean.parseBoolean(configuration.getProperty(title
+ "_visible")), Boolean.parseBoolean(configuration.getProperty(title + "_rect")), () -> {
if (Minecraft.getMinecraft().currentScreen == this)
return "KTRNG";
return "Global RandomSeed: " + TASmod.globalRandomness.getCurrentSeed();
}));

// y += 14;
// title = "ktrng_entitycount";
// if (configuration.getProperty(title + "_x", "err").equals("err"))
// setDefaults(title, y);
// lists.add(new InfoLabel(title, Integer.parseInt(configuration.getProperty(title + "_x")), Integer.parseInt(configuration.getProperty(title + "_y")), Boolean.parseBoolean(configuration.getProperty(title
// + "_visible")), Boolean.parseBoolean(configuration.getProperty(title + "_rect")), () -> {
// if (Minecraft.getMinecraft().currentScreen == this)
// return "EntityCount";
// return "EntityCount: " + EntityRandomness.entityCounter;
// }));

y += 14;
title = "ktrng_worldseed";
if (configuration.getProperty(title + "_x", "err").equals("err"))
setDefaults(title, y);
lists.add(new InfoLabel(title, Integer.parseInt(configuration.getProperty(title + "_x")), Integer.parseInt(configuration.getProperty(title + "_y")), Boolean.parseBoolean(configuration.getProperty(title
+ "_visible")), Boolean.parseBoolean(configuration.getProperty(title + "_rect")), () -> {
if (Minecraft.getMinecraft().currentScreen == this)
return "WorldRNG";
return "WorldRNG: " + KTRNGWorldHandler.getWorldRandom();
}));

title = "facing";
y += 14;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/minecrafttas/tasmod/ktrng/EntityRandomness.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.minecrafttas.tasmod.ktrng;

import com.minecrafttas.tasmod.TASmod;

public class EntityRandomness extends RandomBase {

public static long entityCount = 0;

public EntityRandomness() {
super(TASmod.globalRandomness.getCurrentSeed());
}

public EntityRandomness(long seed) {
super(seed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.minecrafttas.tasmod.ktrng;

import com.minecrafttas.mctcommon.events.EventServer;

import net.minecraft.server.MinecraftServer;

public class GlobalRandomnessTimer implements EventServer.EventServerTick {

private final RandomBase globalRandomness;

private long currentSeed = 0L;

public GlobalRandomnessTimer() {
globalRandomness = new RandomBase(0L);
}

@Override
public void onServerTick(MinecraftServer server) {
globalRandomness.advance();
currentSeed = globalRandomness.getSeed();
}

public long getCurrentSeed() {
return currentSeed;
}

public void setSeed(long newSeed) {
globalRandomness.setSeed(newSeed);
currentSeed = newSeed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.minecrafttas.tasmod.ktrng;

import com.minecrafttas.mctcommon.events.EventClient;

import net.minecraft.client.Minecraft;

public class GlobalRandomnessTimerClient implements EventClient.EventClientTick {

private final RandomBase globalRandomness;
private final RandomBase uuidRandomness;

private long currentSeed = 0L;

public GlobalRandomnessTimerClient() {
globalRandomness = new RandomBase(0L);
uuidRandomness = new RandomBase(0L);
}

@Override
public void onClientTick(Minecraft mc) {
currentSeed = globalRandomness.nextLong();
uuidRandomness.setSeed(currentSeed);
}

public long getCurrentSeed() {
return currentSeed;
}

public RandomBase getUUIDRandom() {
return uuidRandomness;
}

public void setSeed(long newSeed) {
globalRandomness.setSeed(newSeed);
currentSeed = newSeed;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.minecrafttas.tasmod.ktrng;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import com.minecrafttas.tasmod.TASmod;

import net.minecraft.entity.Entity;
import net.minecraft.world.WorldServer;

public class KTRNGEntityHandler {

public static Map<UUID, EntityRandomness> getRandomnessList() {
Map<UUID, EntityRandomness> out = new HashMap<>();
WorldServer[] worlds = TASmod.getServerInstance().worlds;
for (WorldServer worldServer : worlds) {
for (Entity entity : worldServer.loadedEntityList) {
UUID entityUUID = entity.getUniqueID();
EntityRandomness entityRandomness = (EntityRandomness) entity.rand;
out.put(entityUUID, entityRandomness);
}
}
return out;
}

public static void setRandomnessList(Map<UUID, EntityRandomness> randomnessList) {
WorldServer[] worlds = TASmod.getServerInstance().worlds;
for (WorldServer worldServer : worlds) {
for (Entity entity : worldServer.loadedEntityList) {
UUID uuid = entity.getUniqueID();
EntityRandomness rand = randomnessList.get(uuid);
if (rand != null)
entity.rand = rand;
}
}
}
}
Loading