diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-07-26 15:15:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-26 15:15:00 +0800 |
commit | f53edcc01a94be3da0e83d2fc0fe4d13f58f13da (patch) | |
tree | 9d8a07764036b23e906547445152940c762e7361 /src/main/java/de/hysky/skyblocker/skyblock | |
parent | 192b16d5d5ec2baf0f561dcbaa8e1edad2fcd1b0 (diff) | |
parent | c314749a48affe7d1ddc74aa0b5772cdc1afdf0e (diff) | |
download | Skyblocker-f53edcc01a94be3da0e83d2fc0fe4d13f58f13da.tar.gz Skyblocker-f53edcc01a94be3da0e83d2fc0fe4d13f58f13da.tar.bz2 Skyblocker-f53edcc01a94be3da0e83d2fc0fe4d13f58f13da.zip |
Merge pull request #726 from LifeIsAParadox/use_boundingbox
use bounding box instead of block size
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock')
4 files changed, 12 insertions, 24 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/device/SimonSays.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/device/SimonSays.java index 5aa97dd9..eeb6608f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/device/SimonSays.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/device/SimonSays.java @@ -5,7 +5,6 @@ import java.util.Objects; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dungeon.DungeonBoss; import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager; -import de.hysky.skyblocker.utils.Boxes; import de.hysky.skyblocker.utils.ColorUtils; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.render.RenderHelper; @@ -101,7 +100,7 @@ public class SimonSays { Box outline = RenderHelper.getBlockBoundingBox(world, state, buttonPos); float[] colour = buttonsRendered == 0 ? GREEN : YELLOW; - RenderHelper.renderFilled(context, Boxes.getMinVec(outline), Boxes.getLengthVec(outline), colour, 0.5f, true); + RenderHelper.renderFilled(context, outline, colour, 0.5f, true); RenderHelper.renderOutline(context, outline, colour, 5f, true); if (++buttonsRendered == 2) return; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/ThreeWeirdos.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/ThreeWeirdos.java index 98d32c68..d703acb6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/ThreeWeirdos.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/ThreeWeirdos.java @@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; @@ -15,7 +16,6 @@ import net.minecraft.util.Formatting; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; -import net.minecraft.world.World; import java.util.List; import java.util.regex.Matcher; @@ -25,11 +25,12 @@ public class ThreeWeirdos extends DungeonPuzzle { protected static final Pattern PATTERN = Pattern.compile("^\\[NPC] ([A-Z][a-z]+): (?:The reward is(?: not in my chest!|n't in any of our chests\\.)|My chest (?:doesn't have the reward\\. We are all telling the truth\\.|has the reward and I'm telling the truth!)|At least one of them is lying, and the reward is not in [A-Z][a-z]+'s chest!|Both of them are telling the truth\\. Also, [A-Z][a-z]+ has the reward in their chest!)$"); private static final float[] GREEN_COLOR_COMPONENTS = new float[]{0, 1, 0}; private static BlockPos pos; + static Box boundingBox; private ThreeWeirdos() { super("three-weirdos", "three-chests"); ClientReceiveMessageEvents.GAME.register((message, overlay) -> { - World world = MinecraftClient.getInstance().world; + ClientWorld world = MinecraftClient.getInstance().world; if (overlay || !shouldSolve() || !SkyblockerConfigManager.get().dungeons.puzzleSolvers.solveThreeWeirdos || world == null || !DungeonManager.isCurrentRoomMatched()) return; @SuppressWarnings("DataFlowIssue") @@ -54,7 +55,7 @@ public class ThreeWeirdos extends DungeonPuzzle { new ThreeWeirdos(); } - private void checkForNPC(World world, Room room, BlockPos relative, String name) { + private void checkForNPC(ClientWorld world, Room room, BlockPos relative, String name) { BlockPos npcPos = room.relativeToActual(relative); List<ArmorStandEntity> npcs = world.getEntitiesByClass( ArmorStandEntity.class, @@ -63,6 +64,7 @@ public class ThreeWeirdos extends DungeonPuzzle { ); if (!npcs.isEmpty()) { pos = room.relativeToActual(relative.add(1, 0, 0)); + boundingBox = RenderHelper.getBlockBoundingBox(world, pos); npcs.forEach(entity -> entity.setCustomName(Text.literal(name).formatted(Formatting.GREEN))); } } @@ -72,8 +74,8 @@ public class ThreeWeirdos extends DungeonPuzzle { @Override public void render(WorldRenderContext context) { - if (shouldSolve() && pos != null) { - RenderHelper.renderFilled(context, pos, GREEN_COLOR_COMPONENTS, 0.5f, true); + if (shouldSolve() && boundingBox != null) { + RenderHelper.renderFilled(context, boundingBox, GREEN_COLOR_COMPONENTS, 0.5f, false); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/TicTacToe.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/TicTacToe.java index 5a497c19..9e9d20f6 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/TicTacToe.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/TicTacToe.java @@ -23,6 +23,7 @@ import java.util.List; public class TicTacToe extends DungeonPuzzle { private static final Logger LOGGER = LoggerFactory.getLogger(TicTacToe.class); private static final float[] RED_COLOR_COMPONENTS = { 1.0F, 0.0F, 0.0F }; + private static final float[] GREEN_COLOR_COMPONENTS = { 0.0F, 1.0F, 0.0F }; @SuppressWarnings("unused") private static final TicTacToe INSTANCE = new TicTacToe(); private static Box nextBestMoveToMake = null; @@ -101,7 +102,7 @@ public class TicTacToe extends DungeonPuzzle { double nextZ = 17 - bestMove.column(); BlockPos nextPos = DungeonManager.getCurrentRoom().relativeToActual(BlockPos.ofFloored(nextX, nextY, nextZ)); - nextBestMoveToMake = new Box(nextPos); + nextBestMoveToMake = RenderHelper.getBlockBoundingBox(client.world, nextPos); } } catch (Exception e) { LOGGER.error("[Skyblocker Tic Tac Toe] Encountered an exception while determining a tic tac toe solution!", e); @@ -112,7 +113,7 @@ public class TicTacToe extends DungeonPuzzle { public void render(WorldRenderContext context) { try { if (SkyblockerConfigManager.get().dungeons.puzzleSolvers.solveTicTacToe && nextBestMoveToMake != null) { - RenderHelper.renderOutline(context, nextBestMoveToMake, RED_COLOR_COMPONENTS, 5, false); + RenderHelper.renderFilled(context, nextBestMoveToMake, GREEN_COLOR_COMPONENTS, 0.5f, false); } } catch (Exception e) { LOGGER.error("[Skyblocker Tic Tac Toe] Encountered an exception while rendering the tic tac toe solution!", e); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/boulder/Boulder.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/boulder/Boulder.java index aef9109f..2b61940b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/boulder/Boulder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/puzzle/boulder/Boulder.java @@ -9,7 +9,6 @@ import de.hysky.skyblocker.utils.render.RenderHelper; import de.hysky.skyblocker.utils.render.title.Title; import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.world.ClientWorld; @@ -18,7 +17,6 @@ import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.BlockView; import java.util.Arrays; import java.util.List; @@ -106,7 +104,7 @@ public class Boulder extends DungeonPuzzle { button = checkForButtonBlocksOnLine(client.world, point1, point2); if (button != null) { // If a button is found, calculate its bounding box - boundingBox = getBlockBoundingBox(client.world, button); + boundingBox = RenderHelper.getBlockBoundingBox(client.world, button); break; } } @@ -179,18 +177,6 @@ public class Boulder extends DungeonPuzzle { return null; } - /** - * Retrieves the bounding box of a block in the world. - * - * @param world The client world. - * @param pos The position of the block. - * @return The bounding box of the block. - */ - public static Box getBlockBoundingBox(BlockView world, BlockPos pos) { - BlockState blockState = world.getBlockState(pos); - return blockState.getOutlineShape(world, pos).getBoundingBox().offset(pos); - } - @Override public void render(WorldRenderContext context) { if (!shouldSolve() || !SkyblockerConfigManager.get().dungeons.puzzleSolvers.solveBoulder || !DungeonManager.isCurrentRoomMatched()) |