Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remake KillTheRNG for Fabric #190

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
35 changes: 35 additions & 0 deletions src/main/java/com/minecrafttas/killtherng/mixin/MixinRender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.minecrafttas.killtherng.mixin;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLivingBase;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Random;

@Mixin(RenderLivingBase.class)
public abstract class MixinRender extends Render {
protected MixinRender(RenderManager renderManager) {
super(renderManager);
}

@Inject(method = "renderName", at = @At(value = "HEAD"))
public void inject_renderName(EntityLivingBase entity, double d, double e, double f, CallbackInfo ci){
long seed = getSeed(entity.rand);
GlStateManager.alphaFunc(516, 0.1F);
this.renderEntityName(entity, d, e+0.23D, f, Long.toString(seed), 64);
}

private long getSeed(Random rand) {
long in = rand.nextLong();
long seed = (((7847617*((24667315*(in >>> 32) + 18218081*(in & 0xffffffffL) + 67552711) >> 32) - 18218081*((-4824621*(in >>> 32) + 7847617*(in & 0xffffffffL) + 7847617) >> 32)) - 11) * 246154705703781L) & 0xffffffffffffL;
seed = seed ^ 0x5deece66dL;
rand.setSeed(seed);
return seed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ public class KillTheRNGHandler implements EventServerTick, EventPlayerJoinedClie
* @param isLoaded If the KillTheRNG mod is loaded
*/
public KillTheRNGHandler(boolean isLoaded) {

this.isLoaded = isLoaded;

if (isLoaded) {
KillTheRNG.LOGGER.info("Connection established with TASmod");
KillTheRNG.isLibrary = true;
KillTheRNG.mode = SeedingModes.TickChange;

KillTheRNG.annotations.register(new KTRNGMonitor());
// KillTheRNG.LOGGER.info("Connection established with TASmod");
// KillTheRNG.isLibrary = true;
// KillTheRNG.mode = SeedingModes.TickChange;
//
// KillTheRNG.annotations.register(new KTRNGMonitor());
} else {
LOGGER.info("KillTheRNG doesn't appear to be loaded");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
]
},
"mixins": [
"tasmod.mixin.json"
"mctcommon.mixin.json",
"tasmod.mixin.json",
"killtherng.mixin.json"
],
"depends": {
"fabricloader": ">=0.14.19",
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/killtherng.mixin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8.5",
"package": "com.minecrafttas.killtherng.mixin",
"refmap": "tasmod.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [

],
"client": [
"MixinRender"
]
}
3 changes: 3 additions & 0 deletions src/main/resources/tasmod.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ accessible field net/minecraft/world/WorldServer pendingTickListEntriesHashSet L
accessible method net/minecraft/world/storage/SaveHandler setSessionLock ()V

accessible field net/minecraft/client/settings/KeyBinding CATEGORY_ORDER Ljava/util/Map;

#KillTheRNG
accessible field net/minecraft/entity/Entity rand Ljava/util/Random;