Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions src/main/java/com/minecrafttas/tasmod/TASmod.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.minecrafttas.tasmod.commands.CommandTickrate;
import com.minecrafttas.tasmod.config.TASmodServerConfig;
import com.minecrafttas.tasmod.handlers.PlayUntilHandler;
import com.minecrafttas.tasmod.ktrng.GlobalRandomnessTimer;
import com.minecrafttas.tasmod.ktrng.builtin.MathRandomness;
import com.minecrafttas.tasmod.ktrng.builtin.WorldSeedRandomness;
import com.minecrafttas.tasmod.ktrng.GlobalRNG;
import com.minecrafttas.tasmod.ktrng.builtin.MathRNG;
import com.minecrafttas.tasmod.ktrng.builtin.WorldSeedRNG;
import com.minecrafttas.tasmod.ktrng.events.KillTheRNGMonitor;
import com.minecrafttas.tasmod.playback.PlaybackControllerServer;
import com.minecrafttas.tasmod.playback.metadata.builtin.StartpositionMetadataExtension;
Expand Down Expand Up @@ -95,13 +95,13 @@ public class TASmod implements ModInitializer, EventServerStart, EventServerInit

public static ClientMotionStorage motionStorage = new ClientMotionStorage();

public static GlobalRandomnessTimer globalRandomness;
public static GlobalRNG globalRandomness;

public static KTRNGSeedStorage seedStorage = new KTRNGSeedStorage();

public static MathRandomness mathRandomness = new MathRandomness(0);
public static MathRNG mathRandomness = new MathRNG(0);

public static WorldSeedRandomness worldSeedRandomness = new WorldSeedRandomness(0);
public static WorldSeedRNG worldSeedRandomness = new WorldSeedRNG(0);

public static KillTheRNGMonitor debugRand = new KillTheRNGMonitor();

Expand Down Expand Up @@ -158,9 +158,9 @@ public void onInitialize() {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public interface EventKillTheRNGServer {

@FunctionalInterface
public interface EventRNG extends EventBase {
public void onRNGCall(RNGSide side, String eventType, long seed, String value, String rngClass);
public void onRNGCall(RNGSide side, String eventType, long seed, String value, String rngClass, int offset);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ public boolean checkInit() {
}));

y += 14;
title = "ktrng_mathseed";
title = "ktrng_blockHitDelay";
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 "MathRNG";
return "MathRNG: " + TASmod.mathRandomness.getSeed();
return "BlockHitDelay";
return "BlockHitDelay: " + Minecraft.getMinecraft().playerController.blockHitDelay;
}));

title = "facing";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,33 @@
import kaptainwutax.seedutils.rand.JRand;
import net.minecraft.server.MinecraftServer;

public class GlobalRandomnessTimer implements EventServer.EventServerTick {
public class GlobalRNG implements EventServer.EventServerTick {

private final JRand globalRandomness;
private final JRand globalRNG;

private long currentSeed = 0L;

public GlobalRandomnessTimer() {
globalRandomness = new JRand(0L);
public GlobalRNG() {
globalRNG = new JRand(0L, false);
}

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

public long getCurrentSeed() {
return currentSeed;
}

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

@Override
public String toString() {
return Long.toString(globalRNG.getSeed());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
import kaptainwutax.seedutils.rand.JRand;
import net.minecraft.client.Minecraft;

public class GlobalRandomnessTimerClient implements EventClient.EventClientTick {
public class GlobalRNGClient implements EventClient.EventClientTick {

private final JRand globalRandomness;
private final JRand globalRNGClient;
private final JRand uuidRandomness;

private long currentSeed = 0L;

public GlobalRandomnessTimerClient() {
globalRandomness = new JRand(0L);
public GlobalRNGClient() {
globalRNGClient = new JRand(0L);
uuidRandomness = new JRand(0L);
}

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

Expand All @@ -32,7 +32,7 @@ public JRand getUUIDRandom() {
}

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

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/minecrafttas/tasmod/ktrng/RandomBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public abstract class RandomBase extends Random implements Registerable {

public RandomBase() {
super(TASmod.globalRandomness.getCurrentSeed());
jrand = new JRand(TASmod.globalRandomness.getCurrentSeed());
initialSeed = TASmod.globalRandomness.getCurrentSeed();
jrand = new JRand(initialSeed);
}

public RandomBase(long seed) {
Expand Down Expand Up @@ -150,15 +151,15 @@ public void fireSetEvent(String eventType, long seed, String value, int stackTra
}

public void fireGetEvent(String eventType, long seed, String value) {
fireRNGEvent(eventType, seed, value, 3);
fireRNGEvent(eventType, seed, value, 10);
}

public long getInitialSeed() {
return initialSeed;
}

public void fireRNGEvent(String eventType, long seed, String value, int stackTraceOffset) {
EventListenerRegistry.fireEvent(EventKillTheRNGServer.EventRNG.class, side, eventType, seed, value, this.getClass().getSimpleName());
EventListenerRegistry.fireEvent(EventKillTheRNGServer.EventRNG.class, side, eventType, seed, value, this.getClass().getSimpleName(), stackTraceOffset);
}

public enum RNGSide {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/minecrafttas/tasmod/ktrng/builtin/EntityRNG.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.minecrafttas.tasmod.ktrng.builtin;

import com.minecrafttas.tasmod.ktrng.RandomBase;

public class EntityRNG extends RandomBase {

public EntityRNG() {
super();
}

public EntityRNG(long seed) {
super(seed);
}

@Override
public String getExtensionName() {
return "EntityRNG";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@
*
* @author Scribble
*/
public class MathRandomness extends RandomBase {
public class MathRNG extends RandomBase {

public MathRandomness() {
public MathRNG() {
super();
}

public MathRandomness(long seed) {
public MathRNG(long seed) {
super(seed);
}

@Override
public void fireRNGEvent(String eventType, long seed, String value, int stackTraceOffset) {
// super.fireEvent(eventType, seed, value, 6);
}

@Override
public String getExtensionName() {
return "MathRNG";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.minecrafttas.tasmod.ktrng.RandomBase;

public class WorldRandomness extends RandomBase {
public class WorldRNG extends RandomBase {

public WorldRandomness() {
public WorldRNG() {
super();
}

public WorldRandomness(long seed) {
public WorldRNG(long seed) {
super(seed);
}

@Override
public void fireRNGEvent(String val, long seed, String value, int offset) {
super.fireRNGEvent(val, seed, value, 5);
super.fireRNGEvent(val, seed, value, 9);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.minecrafttas.tasmod.ktrng.builtin;

import com.minecrafttas.tasmod.ktrng.RandomBase;

public class WorldSeedRNG extends RandomBase {

public WorldSeedRNG() {
super();
}

public WorldSeedRNG(long seed) {
super(seed);
}

@Override
public String getExtensionName() {
return "WorldSeedRNG";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void onRecordingClear() {
}

@Override
public void onRNGCall(RNGSide side, String eventType, long seed, String value, String rngClass) {
public void onRNGCall(RNGSide side, String eventType, long seed, String value, String rngClass, int offset) {

if (!isActive() || !isEnabled()) {
return;
Expand All @@ -96,7 +96,7 @@ public void onRNGCall(RNGSide side, String eventType, long seed, String value, S

List<String> classOut = new ArrayList<>();
if (stackTraceElements != null && stackTraceElements.length != 0) {
int start = 10;
int start = offset;
for (int i = start; i < stackTraceElements.length; i++) {
String out = formatStackTraceElement(stackTraceElements[i]);
if (out != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
import java.util.UUID;

import com.minecrafttas.tasmod.TASmod;
import com.minecrafttas.tasmod.ktrng.builtin.EntityRandomness;
import com.minecrafttas.tasmod.ktrng.builtin.EntityRNG;

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<>();
public static Map<UUID, EntityRNG> getRandomnessList() {
Map<UUID, EntityRNG> 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;
EntityRNG entityRandomness = (EntityRNG) entity.rand;
out.put(entityUUID, entityRandomness);
}
}
return out;
}

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