diff options
Diffstat (limited to 'src/main/java/de/hysky/skyblocker')
4 files changed, 35 insertions, 19 deletions
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..02bc2301 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 @@ -25,6 +25,7 @@ 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"); @@ -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()) diff --git a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java index 1b16b138..97c040c9 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/RenderHelper.java @@ -31,6 +31,7 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.ColorHelper; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.BlockView; import org.joml.Matrix3f; import org.joml.Matrix4f; import org.joml.Vector3f; @@ -60,6 +61,20 @@ public class RenderHelper { renderFilled(context, pos, colorComponents, alpha, throughWalls); renderBeaconBeam(context, pos, colorComponents); } + public static void renderFilled(WorldRenderContext context, Box boundingBox, float[] colorComponents, float alpha, boolean throughWalls) { + MatrixStack matrices = context.matrixStack(); + Vec3d camera = context.camera().getPos(); + + matrices.push(); + matrices.translate(-camera.x, -camera.y, -camera.z); + + VertexConsumerProvider consumers = context.consumers(); + VertexConsumer buffer = consumers.getBuffer(throughWalls ? SkyblockerRenderLayers.FILLED_THROUGH_WALLS : SkyblockerRenderLayers.FILLED); + + WorldRenderer.renderFilledBox(matrices, buffer, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ, colorComponents[0], colorComponents[1], colorComponents[2], alpha); + + matrices.pop(); + } public static void renderFilled(WorldRenderContext context, BlockPos pos, float[] colorComponents, float alpha, boolean throughWalls) { renderFilled(context, Vec3d.of(pos), ONE, colorComponents, alpha, throughWalls); @@ -459,4 +474,16 @@ public class RenderHelper { 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); + } } |