Skip to content

Commit

Permalink
Many changes, too many to list
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Jul 11, 2024
1 parent 6bafaaf commit db93231
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 16 deletions.
13 changes: 6 additions & 7 deletions src/main/java/mcjty/theoneprobe/api/IOverlayRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
public interface IOverlayRenderer {

/**
* Return the default overlay style as configured in the The One Probe config.
* You can make modifications to this and use it for your own overlays. The
* Return the default overlay style as configured in The One Probe's config.
* You can make modifications to this and use it for your own overlays, but the
* default style will not be modified. Note that if you call this client side
* then this will also contain the settings as the player modified it locally.
* If you call this server side then you will get the default settings from the
Expand All @@ -17,21 +17,20 @@ public interface IOverlayRenderer {
IOverlayStyle createDefaultStyle();

/**
* Create an empty default IProbeInfo (which actually represents the
* Create an empty default {@link IProbeInfo} (which actually represents the
* default vertical element that is always used to start with). You can then
* modify this as you wish and give it to render().
*/
IProbeInfo createProbeInfo();

/**
* Render an overlay with the given style and probe info.
* This has to be called client side and you have to call it every
* This has to be called client side, and you have to call it every
* frame for as long as you want this overlay to be visible.
*
* Typically, you might want to call this in a RenderGameOverlayEvent.
* Typically, you might want to call this in a {@link net.minecraftforge.client.event.RenderGameOverlayEvent}.
*
* Note that calling this does not prevent the normal overlay from
* rendering.
* Note that calling this does <b>not</b> prevent the normal overlay from rendering.
*/
void render(IOverlayStyle style, IProbeInfo probeInfo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

/**
* You can implement IProbeInfoEntityAccessor in your entities or else you can use
* this and register that to the ITheOneProbe. Note that TheOneProbe already
* adds default providers which gives basic entity information.
* this and register that to the {@link ITheOneProbe}. Note that TheOneProbe already
* adds default providers which will give basic entity information.
*/
public interface IProbeInfoEntityProvider {

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/mcjty/theoneprobe/apiimpl/ProbeHitData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@

import javax.annotation.Nullable;

/**
* Represents data related to probing a block.
*/
public class ProbeHitData implements IProbeHitData {

private final BlockPos pos;
private final Vec3d hitVec;
private final EnumFacing side;
private final ItemStack pickBlock;

/**
* Constructs a new instance of ProbeHitData with the given parameters.
*
* @param pos The {@link BlockPos} position where the hit occurred.
* @param hitVec The {@link Vec3d} coordinates indicating where the hit occurred on the block.
* @param side The side of the block that was hit, or {@code null} if not applicable.
* @param pickBlock The {@link ItemStack} representing the block as an item, or {@code null} if not applicable.
*/
public ProbeHitData(BlockPos pos, Vec3d hitVec, EnumFacing side, ItemStack pickBlock) {
this.pos = pos;
this.hitVec = hitVec;
Expand Down
42 changes: 35 additions & 7 deletions src/main/java/mcjty/theoneprobe/gui/GuiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -44,7 +45,7 @@ public class GuiConfig extends GuiScreen {
static {
presets.add(new Preset("Default style", 0xff999999, 0x55006699, 2, 0));
presets.add(new Preset("WAILA style", 0xff4503d0, 0xff000000, 1, 1));
presets.add(new Preset("Full transparent style", 0x00000000, 0x00000000, 0, 0));
presets.add(new Preset("Fully transparent style", 0x00000000, 0x00000000, 0, 0));
presets.add(new Preset("Black & White style", 0xffffffff, 0xff000000, 2, 0,
Pair.of(MODNAME, "white,italic"),
Pair.of(NAME, "white,bold"),
Expand All @@ -53,10 +54,37 @@ public class GuiConfig extends GuiScreen {
Pair.of(WARNING, "white"),
Pair.of(ERROR, "white,underline"),
Pair.of(OBSOLETE, "white,strikethrough"),
Pair.of(LABEL, "white,underline"),
Pair.of(LABEL, "white,bold"),
Pair.of(OK, "white"),
Pair.of(PROGRESS, "white")
));
presets.add(new Preset("Crazy!", 0xff00ff00, 0x55ff0000, 2, 0,
Pair.of(MODNAME, "green"),
Pair.of(NAME, "yellow,bold"),
Pair.of(INFO, "cyan,bold"),
Pair.of(INFOIMP, "magenta,bold"),
Pair.of(WARNING, "orange,bold"),
Pair.of(ERROR, "red,bold"),
Pair.of(OBSOLETE, "gray,bold"),
Pair.of(LABEL, "blue,bold"),
Pair.of(OK, "green,bold"),
Pair.of(PROGRESS, "white,bold")
));
presets.add(new Preset("Soft Pastels", 0xffe0bbff, 0x00000000, 1, 1,
Pair.of(MODNAME, "pink,bold,italic")
));
presets.add(new Preset("Ocean Blue", 0xff003366, 0x556699cc, 2, 0,
Pair.of(MODNAME, "cyan"),
Pair.of(NAME, "light_blue,bold"),
Pair.of(INFO, "white"),
Pair.of(INFOIMP, "white,bold"),
Pair.of(WARNING, "yellow,bold"),
Pair.of(ERROR, "red,bold"),
Pair.of(OBSOLETE, "gray,bold,italic"),
Pair.of(LABEL, "aqua,bold"),
Pair.of(OK, "green,bold"),
Pair.of(PROGRESS, "white,bold")
));
}


Expand Down Expand Up @@ -84,23 +112,23 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {

int x = WIDTH + guiLeft + 10;
int y = guiTop + 10;
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + "Placement:");
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + I18n.format("gui.theoneprobe.gui_note_config.title.placement"));
y += 12;
RenderHelper.renderText(Minecraft.getMinecraft(), x+10, y, "Click a corner in the screenshot");
RenderHelper.renderText(Minecraft.getMinecraft(), x+10, y, I18n.format("gui.theoneprobe.gui_note_config.body.1"));
y += 10;
RenderHelper.renderText(Minecraft.getMinecraft(), x+10, y, "to move the tooltip there");
RenderHelper.renderText(Minecraft.getMinecraft(), x+10, y, I18n.format("gui.theoneprobe.gui_note_config.body.2"));
y += 30;

hitboxes = new ArrayList<>();
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + "Presets:");
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + I18n.format("gui.theoneprobe.gui_note_config.title.presets"));
y += 12;
for (Preset preset : presets) {
y = addPreset(x, y, preset);
}

y += 20;

RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + "Scale:");
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.GOLD + I18n.format("gui.theoneprobe.gui_note_config.title.scale"));
y += 12;
addButton(x+10, y, "--", () -> ConfigSetup.setScale(1.2f)); x += 36;
addButton(x+10, y, "-", () -> ConfigSetup.setScale(1.1f)); x += 36;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/GuiNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import java.io.IOException;

import static mcjty.theoneprobe.config.ConfigSetup.*;

/**
* GUI for The One Probe Read Me note
*/
@SideOnly(Side.CLIENT)
public class GuiNote extends GuiScreen {
private static final int WIDTH = 256;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/HitBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class HitBox {
private final int y2;
private final Runnable runnable;

/**
* Constructs a HitBox with specified coordinates and an action to execute when clicked.
*
* @param x1 The x-coordinate of the top-left corner of the hit area.
* @param y1 The y-coordinate of the top-left corner of the hit area.
* @param x2 The x-coordinate of the bottom-right corner of the hit area (exclusive).
* @param y2 The y-coordinate of the bottom-right corner of the hit area (exclusive).
* @param runnable The action to execute when the hit area is clicked.
*/
public HitBox(int x1, int y1, int x2, int y2, Runnable runnable) {
this.x1 = x1;
this.y1 = y1;
Expand All @@ -19,10 +28,20 @@ public HitBox(int x1, int y1, int x2, int y2, Runnable runnable) {
this.runnable = runnable;
}

/**
* Checks if the given coordinates are within the hit area.
*
* @param xx The x-coordinate to check.
* @param yy The y-coordinate to check.
* @return true if the coordinates are within the hit area, false otherwise.
*/
public boolean isHit(int xx, int yy) {
return xx >= x1 && xx < x2 && yy >= y1 && yy < y2;
}

/**
* Executes the action associated with this HitBox.
*/
public void call() {
runnable.run();
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/mcjty/theoneprobe/gui/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.Map;

@SideOnly(Side.CLIENT)
class Preset {
private final String name;
Expand All @@ -15,6 +16,16 @@ class Preset {
private final int boxOffset;
private final Map<TextStyleClass, String> textStyleClasses;

/**
* Constructs a Preset with specified parameters.
*
* @param name The name of the preset.
* @param boxBorderColor The color of the border of the box.
* @param boxFillColor The color to fill the box.
* @param boxThickness The thickness of the box border.
* @param boxOffset The offset of the box.
* @param styles Pairs of TextStyleClass and their associated style names.
*/
@SafeVarargs
public Preset(String name, int boxBorderColor, int boxFillColor, int boxThickness, int boxOffset, Pair<TextStyleClass, String>... styles) {
this.name = name;
Expand Down Expand Up @@ -48,6 +59,11 @@ public int getBoxOffset() {
return boxOffset;
}

/**
* Gets the map of TextStyleClass to their associated style names.
*
* @return The map of TextStyleClass to their associated style names.
*/
public Map<TextStyleClass, String> getTextStyleClasses() {
return textStyleClasses;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/theoneprobe/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ gui.theoneprobe.gui_note.button.needed=Needed
gui.theoneprobe.gui_note.button.not_needed=Not needed
gui.theoneprobe.gui_note.button.extended=Extended

gui.theoneprobe.gui_note_config.title.placement=Placement:
gui.theoneprobe.gui_note_config.title.presets=Presets:
gui.theoneprobe.gui_note_config.title.scale=Scale:
gui.theoneprobe.gui_note_config.body.1=Click on the image to move around
gui.theoneprobe.gui_note_config.body.2=the tooltip

item.theoneprobe.probenote.name=The One Probe Read Me

itemGroup.Probe=The One Probe

0 comments on commit db93231

Please sign in to comment.