Skip to content

Commit

Permalink
Merge pull request #3 from Gaider10/villager_rng_cracking
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV authored Jun 21, 2024
2 parents a6f6ed5 + e4732b9 commit badfe97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void setTargetVillager(@Nullable Villager villager) {

ClientLevel level = Minecraft.getInstance().level;

if (level.getDayTime() < 12000 || (level.dimensionType().fixedTime().isPresent() && level.dimensionType().fixedTime().getAsLong() < 12000)) {
if (level.getDayTime() % 24000 < 12000) {
ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.day"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,20 @@ public String toString() {
}

public void onAmbientSoundPlayed(float pitch) {
boolean justReset = false;
if (totalAmbientSounds == 2 && !madeSound) {
ClientCommandHelper.addOverlayMessage(Component.translatable("commands.cvillager.outOfSync.generic").withStyle(ChatFormatting.RED), 100);
reset();
justReset = true;
}

if (totalAmbientSounds == 0) {
totalAmbientSounds++;
firstPitch = pitch;
ambientSoundTime = -80;
madeSound = true;
ClientCommandHelper.addOverlayMessage(((MutableComponent) getCrackedState().getMessage(false)).withStyle(ChatFormatting.RED), 100);
if (!justReset) {
ClientCommandHelper.addOverlayMessage(((MutableComponent) getCrackedState().getMessage(false)).withStyle(ChatFormatting.RED), 100);
}
return;
}

Expand All @@ -266,7 +274,6 @@ public void onAmbientSoundPlayed(float pitch) {
ticksBetweenSounds = ambientSoundTime - (-80);
secondPitch = pitch;
ambientSoundTime = -80;
madeSound = true;

if (seedsFromTwoPitches != null) {
int matchingSeeds = 0;
Expand Down Expand Up @@ -311,12 +318,6 @@ public void onAmbientSoundPlayed(float pitch) {
ambientSoundTime = -80;
ClientCommandHelper.addOverlayMessage(Component.translatable("commands.cvillager.crack.failed", seeds.length).withStyle(ChatFormatting.RED), 100);
}
return;
}

if (!madeSound) {
ClientCommandHelper.addOverlayMessage(Component.translatable("commands.cvillager.outOfSync.generic").withStyle(ChatFormatting.RED), 100);
reset();
}
}

Expand Down

0 comments on commit badfe97

Please sign in to comment.