Skip to content

Commit

Permalink
made changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV committed Dec 2, 2024
1 parent 6923b87 commit 29a4a0a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 41 deletions.
Binary file added docs/villager_rng_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand All @@ -266,23 +266,17 @@ private static void checkVillagerSetup() {
return;
}

List<BlockPos> validBedHeadPositions = List.of(blockPos.north(3), blockPos.east(3), blockPos.south(3), blockPos.west(3));
List<BlockPos> 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<BlockPos> 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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
29 changes: 14 additions & 15 deletions src/main/resources/assets/clientcommands/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,36 +266,35 @@
"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",
"commands.cvillager.resetCracker": "Successfully reset cracked villager RNG",
"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",

Expand Down
Binary file removed villager_rng_setup.png
Binary file not shown.

0 comments on commit 29a4a0a

Please sign in to comment.