-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Villager RNG Manipulation #642
Draft
RealRTTV
wants to merge
47
commits into
Earthcomputer:fabric
Choose a base branch
from
RealRTTV:villager_rng_cracking
base: fabric
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 42 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
3e36064
temp changes
RealRTTV 1cca6b4
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV 5552602
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV b935782
finally i can hold on to a villager's rng state
RealRTTV fe4133a
ok, now that it's been held on to, i can try to predict it, but for s…
RealRTTV 800fd92
ok now i can crack it, gotta figure out how to
RealRTTV 5fcbf15
ok, now it works
RealRTTV b5fe87c
whoopsie
RealRTTV fa0fde5
need to check the ping checking
RealRTTV 406d55a
ping checking might work, idk
RealRTTV f416f2b
Merge remote-tracking branch 'refs/remotes/upstream/fabric' into vill…
RealRTTV 70aaf2a
yo, check out this broken code
RealRTTV f047024
Fixes to villager cracking
Earthcomputer c419414
IT WORKS!! btw i still have villager adjustment shenanigans
RealRTTV 48bf868
Fix two pitch cracking and add three pitch cracking
Gaider10 2734f64
Add simulation for unhappy no and water splashing sounds
Gaider10 bff08d1
Merge pull request #1 from Gaider10/villager_rng_cracking
RealRTTV 47e53f2
Add simulation for more actions and add trade cracking for levels abo…
Gaider10 4910518
Handle ambient sound inside trading gui correctly
Gaider10 e92307e
Merge pull request #2 from Gaider10/villager_rng_cracking
RealRTTV 5e8f1f2
ok changed some stuff lol i think this might be good
RealRTTV 4642e34
removed latticg code
RealRTTV 0bc4167
removed unused diff
RealRTTV 4e65243
added help dialog for failed clock, no clock set, cracking during the…
RealRTTV a6f6ed5
shit
RealRTTV deeb1e6
Use the ambient sound that detected the desync for recracking
Gaider10 e4732b9
Fix nighttime check
Gaider10 badfe97
Merge pull request #3 from Gaider10/villager_rng_cracking
RealRTTV 5c304e4
- added custom out of sync messages
RealRTTV 38b8d69
- added nicer display to goals using ItemParser
RealRTTV 3813d7b
added toString
RealRTTV 7c2fe74
??
RealRTTV 9519911
changes in response to review
RealRTTV 42e3a20
added three-item-goal and two-item-enchanted-goal
RealRTTV 6ecb586
whoop
RealRTTV d6894f8
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV c453a39
updated and some minor, minor stuff
RealRTTV 6293252
Update clientcommands.aw
RealRTTV b4a94ef
removed wildcard import
RealRTTV 75bd52e
Update DebugRandom.java
RealRTTV c170054
Update DebugRandom.java
RealRTTV c3e4090
Update DebugRandom.java
RealRTTV 7ac0113
Update ItemAndEnchantmentsPredicateArgument.java
RealRTTV 210dbf4
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV d2fb531
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV 02ee3c7
fixed some todo items
RealRTTV 295840b
Merge remote-tracking branch 'upstream/fabric' into villager_rng_crac…
RealRTTV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
357 changes: 357 additions & 0 deletions
357
src/main/java/net/earthcomputer/clientcommands/command/VillagerCommand.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/main/java/net/earthcomputer/clientcommands/features/VillagerCracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package net.earthcomputer.clientcommands.features; | ||
|
||
import net.earthcomputer.clientcommands.command.ClientCommandHelper; | ||
import net.earthcomputer.clientcommands.command.VillagerCommand; | ||
import net.earthcomputer.clientcommands.interfaces.IVillager; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.core.GlobalPos; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.protocol.game.ClientboundAddExperienceOrbPacket; | ||
import net.minecraft.network.protocol.game.ClientboundSoundPacket; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.npc.Villager; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.lang.ref.WeakReference; | ||
import java.util.UUID; | ||
|
||
public class VillagerCracker { | ||
// This value was computed by brute forcing all seeds | ||
public static final float MAX_ERROR = 5 * 0x1.0p-24f; | ||
|
||
@Nullable | ||
private static UUID villagerUuid = null; | ||
@Nullable | ||
private static WeakReference<Villager> cachedVillager = null; | ||
@Nullable | ||
private static GlobalPos clockPos = null; | ||
@Nullable | ||
public static VillagerCommand.Offer targetOffer = null; | ||
@Nullable | ||
private static Long lastServerTick = null; | ||
private static boolean receivedClockRateWarning = false; | ||
|
||
@Nullable | ||
public static Villager getVillager() { | ||
if (villagerUuid == null) { | ||
cachedVillager = null; | ||
return null; | ||
} | ||
if (cachedVillager != null) { | ||
Villager villager = cachedVillager.get(); | ||
if (villager != null && !villager.isRemoved()) { | ||
return villager; | ||
} | ||
} | ||
ClientLevel level = Minecraft.getInstance().level; | ||
if (level != null) { | ||
for (Entity entity : level.entitiesForRendering()) { | ||
if (entity.getUUID() == villagerUuid && entity instanceof Villager villager) { | ||
cachedVillager = new WeakReference<>(villager); | ||
return villager; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Nullable | ||
public static GlobalPos getClockPos() { | ||
return clockPos; | ||
} | ||
|
||
public static void setTargetVillager(@Nullable Villager villager) { | ||
Villager oldVillager = getVillager(); | ||
if (oldVillager != null) { | ||
((IVillager) oldVillager).clientcommands_getVillagerRngSimulator().reset(); | ||
} | ||
|
||
if (clockPos == null) { | ||
ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.noClock")); | ||
} | ||
|
||
ClientLevel level = Minecraft.getInstance().level; | ||
|
||
if (level.getDayTime() % 24000 < 12000) { | ||
ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.day")); | ||
} | ||
|
||
VillagerCracker.cachedVillager = new WeakReference<>(villager); | ||
VillagerCracker.villagerUuid = villager == null ? null : villager.getUUID(); | ||
} | ||
|
||
public static void setClockPos(@Nullable GlobalPos pos) { | ||
VillagerCracker.clockPos = pos; | ||
} | ||
|
||
public static void onSoundEventPlayed(ClientboundSoundPacket packet) { | ||
Villager targetVillager = getVillager(); | ||
if (targetVillager == null || getClockPos() == null) { | ||
return; | ||
} | ||
|
||
switch (packet.getSound().value().getLocation().toString()) { | ||
case "minecraft:entity.villager.ambient", "minecraft:entity.villager.trade" -> ((IVillager) targetVillager).clientcommands_onAmbientSoundPlayed(packet.getPitch()); | ||
case "minecraft:entity.villager.no" -> ((IVillager) targetVillager).clientcommands_onNoSoundPlayed(packet.getPitch()); | ||
case "minecraft:entity.villager.yes" -> ((IVillager) targetVillager).clientcommands_onYesSoundPlayed(packet.getPitch()); | ||
case "minecraft:entity.generic.splash" -> ((IVillager) targetVillager).clientcommands_onSplashSoundPlayed(packet.getPitch()); | ||
} | ||
} | ||
|
||
public static void onXpOrbSpawned(ClientboundAddExperienceOrbPacket packet) { | ||
Villager targetVillager = getVillager(); | ||
if (targetVillager == null) { | ||
return; | ||
} | ||
|
||
((IVillager) targetVillager).clientcommands_onXpOrbSpawned(packet.getValue()); | ||
} | ||
|
||
public static void onServerTick() { | ||
long now = System.currentTimeMillis(); | ||
|
||
Villager targetVillager = getVillager(); | ||
if (targetVillager == null) { | ||
lastServerTick = now; | ||
return; | ||
} | ||
|
||
if (lastServerTick != null && now - lastServerTick > 80L && !receivedClockRateWarning) { | ||
ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.tooSlow")); | ||
receivedClockRateWarning = true; | ||
} | ||
|
||
((IVillager) targetVillager).clientcommands_onServerTick(); | ||
|
||
lastServerTick = now; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove in favor of ping adjustments