diff --git a/docs/villager_rng_setup.png b/docs/villager_rng_setup.png new file mode 100644 index 00000000..43b7d098 Binary files /dev/null and b/docs/villager_rng_setup.png differ diff --git a/src/main/java/net/earthcomputer/clientcommands/features/VillagerCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/VillagerCracker.java index 6245ed31..cf757844 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/VillagerCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/VillagerCracker.java @@ -134,7 +134,7 @@ public static void setTargetVillager(@Nullable Villager villager) { if (level != null && level.getDayTime() % 24000 < 12000) { simulator.onBadRNG("day"); - ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.day")); + ClientCommandHelper.sendHelp(Component.translatable("villagerManip.help.day")); } if (villager != null) { @@ -248,7 +248,7 @@ private static void checkVillagerSetup() { if (!isResting(targetVillager.level().dayTime())) { simulator.onBadRNG("day"); - ClientCommandHelper.sendHelp(Component.translatable("commands.cvillager.help.day")); + ClientCommandHelper.sendHelp(Component.translatable("villagerManip.help.day")); } else if (targetVillager.isInWater() && targetVillager.getFluidHeight(FluidTags.WATER) > targetVillager.getFluidJumpThreshold() || targetVillager.isInLava()) { simulator.onBadRNG("swim"); } else if (!targetVillager.getActiveEffects().isEmpty()) { @@ -266,23 +266,17 @@ private static void checkVillagerSetup() { return; } - List validBedHeadPositions = List.of(blockPos.north(3), blockPos.east(3), blockPos.south(3), blockPos.west(3)); - List bedHeadPositions = BlockPos.withinManhattanStream(blockPos, 15, 7, 15).map(BlockPos::new).filter(p -> level.getBlockState(p).is(BlockTags.BEDS) && level.getBlockState(p).getValue(BedBlock.OCCUPIED) == Boolean.FALSE && level.getBlockState(p).getValue(BedBlock.PART) == BedPart.HEAD).toList(); - Direction bedDirection; - if (bedHeadPositions.size() == 1 && validBedHeadPositions.contains(bedHeadPositions.getFirst())) { - bedDirection = Direction.Plane.HORIZONTAL.stream().skip(validBedHeadPositions.indexOf(bedHeadPositions.getFirst())).findAny().orElse(null); - } else { + List bedHeadPositions = BlockPos.withinManhattanStream(blockPos, 16, 16, 16).map(BlockPos::new).filter(p -> p.distSqr(blockPos) <= 16.0 * 16.0).filter(p -> level.getBlockState(p).is(BlockTags.BEDS) && level.getBlockState(p).getValue(BedBlock.OCCUPIED) == Boolean.FALSE && level.getBlockState(p).getValue(BedBlock.PART) == BedPart.HEAD).toList(); + if (bedHeadPositions.size() != 1) { simulator.onBadRNG("invalidBedPosition"); sendInvalidSetupHelp(); return; } for (Direction direction : Direction.Plane.HORIZONTAL) { - BlockPos airPos = blockPos.relative(direction); - BlockPos trapdoorPos = airPos.above(); - BlockState airPosState = level.getBlockState(airPos); + BlockPos trapdoorPos = blockPos.relative(direction).above(); BlockState trapdoorPosState = level.getBlockState(trapdoorPos); - if (!((airPosState.isAir() || direction != bedDirection) && trapdoorPosState.is(BlockTags.TRAPDOORS) && trapdoorPosState.getValue(TrapDoorBlock.HALF) == Half.TOP && trapdoorPosState.getValue(TrapDoorBlock.HALF) == Half.TOP && trapdoorPosState.getValue(TrapDoorBlock.OPEN) == Boolean.FALSE)) { + if (!(trapdoorPosState.is(BlockTags.TRAPDOORS) && trapdoorPosState.getValue(TrapDoorBlock.HALF) == Half.TOP && trapdoorPosState.getValue(TrapDoorBlock.HALF) == Half.TOP && trapdoorPosState.getValue(TrapDoorBlock.OPEN) == Boolean.FALSE)) { simulator.onBadRNG("invalidCage"); sendInvalidSetupHelp(); return; @@ -293,7 +287,7 @@ private static void checkVillagerSetup() { } private static void sendInvalidSetupHelp() { - ClientCommandHelper.sendHelp(Component.translatable("villagerManip.help.setup.prefix").append(Component.translatable("villagerManip.help.setup.here").withStyle(ChatFormatting.UNDERLINE).withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://raw.githubusercontent.com/Earthcomputer/clientcommands/refs/heads/fabric/villager_rng_setup.png")))).append(Component.translatable("villagerManip.help.setup.suffix"))); + ClientCommandHelper.sendHelp(Component.translatable("villagerManip.help.setup", Component.translatable("villagerManip.help.setup.link").withStyle(style -> style.withUnderlined(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://raw.githubusercontent.com/Earthcomputer/clientcommands/refs/heads/fabric/dpcs/villager_rng_setup.png"))))); } private static void onDisconnect() { diff --git a/src/main/java/net/earthcomputer/clientcommands/features/VillagerRngSimulator.java b/src/main/java/net/earthcomputer/clientcommands/features/VillagerRngSimulator.java index 3e09e56c..55981b1b 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/VillagerRngSimulator.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/VillagerRngSimulator.java @@ -321,7 +321,7 @@ public void onAmbientSoundPlayed(float pitch) { } public void onBadRNG(@Translatable(prefix = "villagerManip.reset.") String reason) { - ClientCommandHelper.sendFeedback(Component.translatable("villagerManip.reset", Component.translatable("villagerManip.reset." + reason)).withStyle(ChatFormatting.RED)); + ClientCommandHelper.sendError(Component.translatable("villagerManip.reset", Component.translatable("villagerManip.reset." + reason))); reset(); } diff --git a/src/main/java/net/earthcomputer/clientcommands/util/DebugRandom.java b/src/main/java/net/earthcomputer/clientcommands/util/DebugRandom.java index 6a442d92..602304b7 100644 --- a/src/main/java/net/earthcomputer/clientcommands/util/DebugRandom.java +++ b/src/main/java/net/earthcomputer/clientcommands/util/DebugRandom.java @@ -19,18 +19,7 @@ import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; -import javax.swing.DefaultListModel; -import javax.swing.JComponent; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.UIManager; +import javax.swing.*; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -273,6 +262,13 @@ class DebugRandomSourcePanel extends JPanel { add(tabbedPane, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(); + JButton dumpStackTraceButton = new JButton("Dump stack trace"); + dumpStackTraceButton.addActionListener(e -> { + if (selectedStackTrace >= 0 && selectedStackTrace < DebugRandom.stackTraceById.size()) { + DebugRandom.LOGGER.info(DebugRandom.stackTraceById.get(selectedStackTrace)); + } + }); + bottomPanel.add(dumpStackTraceButton); add(bottomPanel, BorderLayout.SOUTH); } diff --git a/src/main/resources/assets/clientcommands/lang/en_us.json b/src/main/resources/assets/clientcommands/lang/en_us.json index 71423dda..08910504 100644 --- a/src/main/resources/assets/clientcommands/lang/en_us.json +++ b/src/main/resources/assets/clientcommands/lang/en_us.json @@ -266,7 +266,6 @@ "commands.cvillager.noProfession": "The targeted villager has no profession", "commands.cvillager.notAVillager": "Target was not a villager", "commands.cvillager.notLevel1": "The targeted villager has level above 1", - "commands.cvillager.uncracked": "Your villager's RNG is not cracked (~18 quintillion seeds remain)", "commands.cvillager.partiallyCracked": "Your villager's RNG is partially cracked (~83m seeds remain)", "commands.cvillager.removeGoal.invalidIndex": "Unable to remove goal %s, you only have %s goals", "commands.cvillager.removeGoal.success": "Successfully removed goal %s", @@ -274,28 +273,28 @@ "commands.cvillager.success": "Got the correct trade with correction of %sms", "commands.cvillager.target.cleared": "Target entity cleared", "commands.cvillager.target.set": "Target entity set", + "commands.cvillager.uncracked": "Your villager's RNG is not cracked (~18 quintillion seeds remain)", + "villagerManip.help.day": "Help: Villager RNG manipulation can only be done at night-time", + "villagerManip.help.setup": "Help: Trap the villager with trapdoors at their head with a bed's head between 3 and 16 blocks away, as seen in %s image", + "villagerManip.help.setup.link": "this", "villagerManip.reset": "Restarting villager RNG manipulation. Reason: %s", - "villagerManip.reset.mobHurt": "Mob Hurt", + "villagerManip.reset.ambient": "Bad Ambient Noise", "villagerManip.reset.day": "Daytime", - "villagerManip.reset.swim": "Swum", - "villagerManip.reset.potion": "Potion Effect Active", - "villagerManip.reset.itemEquipped": "Item Equipped", - "villagerManip.reset.gossip": "Gossip", "villagerManip.reset.distance": "Too far from villager", - "villagerManip.reset.ambient": "Bad Ambient Noise", + "villagerManip.reset.gossip": "Gossip", + "villagerManip.reset.invalidBedPosition": "Invalid Bed Position", + "villagerManip.reset.invalidCage": "Invalid Villager Cage", + "villagerManip.reset.itemEquipped": "Item Equipped", + "villagerManip.reset.itemInMainHand": "Item in Main Hand", + "villagerManip.reset.mobHurt": "Mob Hurt", "villagerManip.reset.no": "Bad Unhappy Noise", + "villagerManip.reset.potion": "Potion Effect Active", "villagerManip.reset.splash": "Bad Splash Noise", + "villagerManip.reset.swim": "Swum", + "villagerManip.reset.tooManyBeds": "Too many beds within 16 block radius of villager", "villagerManip.reset.xpOrb": "Bad XP Orb Size", "villagerManip.reset.yes": "Bad Happy Noise", - "villagerManip.reset.itemInMainHand": "Item in Main Hand", - "villagerManip.reset.invalidBedPosition": "Invalid Bed Position", - "villagerManip.reset.invalidCage": "Invalid Villager Cage", - - "villagerManip.help.day": "Help: Villager RNG manipulation can only be done at night-time", - "villagerManip.help.setup.prefix": "Help: Trap the villager with trapdoors at their head with a bed's head exactly 3 blocks away in any direction, as seen in ", - "villagerManip.help.setup.here": "this", - "villagerManip.help.setup.suffix": " image", "commands.cwe.playerNotFound": "Player not found", diff --git a/villager_rng_setup.png b/villager_rng_setup.png deleted file mode 100644 index cb9e1b27..00000000 Binary files a/villager_rng_setup.png and /dev/null differ