Skip to content

Commit

Permalink
Offline stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Jul 12, 2024
1 parent 6af0ac0 commit 00b6ec7
Show file tree
Hide file tree
Showing 27 changed files with 119 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/main/java/mcjty/theoneprobe/api/IElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IElement {
void toBytes(ByteBuf buf);

/**
* Get the identifier for this element as returned by {@link ITheOneProbe}.registerElementFactory()
* Get the identifier for this element as returned by {@link ITheOneProbe#registerElementFactory}
*/
int getID();
}
2 changes: 1 addition & 1 deletion src/main/java/mcjty/theoneprobe/api/IProgressStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IProgressStyle {

IProgressStyle suffix(String suffix);

/** If the progressbar is a lifebar then this is the maximum width*/
/** If the progressbar is a lifeBar then this is the maximum width*/
IProgressStyle width(int w);

IProgressStyle height(int h);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mcjty/theoneprobe/api/ITheOneProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public interface ITheOneProbe {

/**
* Get a copy of the default configuration as it is given to the probe providers. This is
* only useful for checking what options are enabled. It is not useful to make changes here
* only useful for checking what options are enabled. You cannot make changes here
* as this is a copy and changes will not have any effect
*/
IProbeConfig createProbeConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,6 +26,7 @@ public abstract class AbstractElementPanel implements IElement, IProbeInfo {
protected ElementAlignment alignment;

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
if (borderColor != null) {
int w = getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementEntity implements IElement {

Expand Down Expand Up @@ -58,6 +60,7 @@ public ElementEntity(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
if (playerID != null) {
ElementEntityRender.renderPlayer(entityName, playerID, style, x, y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import mcjty.theoneprobe.api.ElementAlignment;
import mcjty.theoneprobe.api.IElement;
import mcjty.theoneprobe.apiimpl.TheOneProbeImp;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementHorizontal extends AbstractElementPanel {

Expand All @@ -16,6 +18,7 @@ public ElementHorizontal(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
super.render(x, y);
if (borderColor != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import mcjty.theoneprobe.apiimpl.styles.IconStyle;
import mcjty.theoneprobe.network.NetworkTools;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Objects;

Expand Down Expand Up @@ -43,6 +45,7 @@ public ElementIcon(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
ElementIconRender.render(icon, x, y, w, h, u, v, style.getTextureWidth(), style.getTextureHeight());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import mcjty.theoneprobe.apiimpl.client.ElementTextRender;
import mcjty.theoneprobe.network.NetworkTools;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementItemLabel implements IElement {

Expand All @@ -24,6 +26,7 @@ public ElementItemLabel(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
if (!itemStack.isEmpty()) {
String text = itemStack.getDisplayName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import mcjty.theoneprobe.apiimpl.styles.ItemStyle;
import mcjty.theoneprobe.network.NetworkTools;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementItemStack implements IElement {

Expand All @@ -31,6 +33,7 @@ public ElementItemStack(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
ElementItemStackRender.render(itemStack, style, x, y);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import mcjty.theoneprobe.apiimpl.client.ElementProgressRender;
import mcjty.theoneprobe.apiimpl.styles.ProgressStyle;
import mcjty.theoneprobe.network.NetworkTools;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.text.DecimalFormat;

Expand Down Expand Up @@ -79,6 +81,7 @@ public static String format(long in, NumberFormat style, String suffix) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
ElementProgressRender.render(style, current, max, x, y, getWidth(), getHeight());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import mcjty.theoneprobe.apiimpl.TheOneProbeImp;
import mcjty.theoneprobe.apiimpl.client.ElementTextRender;
import mcjty.theoneprobe.network.NetworkTools;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementText implements IElement {

Expand All @@ -19,6 +21,7 @@ public ElementText(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
ElementTextRender.render(text, x, y);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import mcjty.theoneprobe.api.ElementAlignment;
import mcjty.theoneprobe.api.IElement;
import mcjty.theoneprobe.apiimpl.TheOneProbeImp;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ElementVertical extends AbstractElementPanel {

Expand All @@ -18,6 +20,7 @@ public ElementVertical(ByteBuf buf) {
}

@Override
@SideOnly(Side.CLIENT)
public void render(int x, int y) {
super.render(x, y);
if (borderColor != null) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play
if (Tools.show(mode, config.getShowMobSpawnerSetting())) {
showMobSpawnerInfo(probeInfo, world, data, block);
}
if (blockState.getBlock() instanceof BlockCauldron) {
for (IProperty<?> property : blockState.getProperties().keySet()) {
if (!"level".equals(property.getName())) continue;
if (property.getValueClass() == Integer.class) {
//noinspection unchecked
IProperty<Integer> integerProperty = (IProperty<Integer>) property;
int fill = blockState.getValue(integerProperty);

if (fill > 0) {
probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER))
.text(TextStyleClass.LABEL + ((fill == 1) ? fill + " {*theoneprobe.probe.bottle_indicator*}" : fill + " {*theoneprobe.probe.bottles_indicator*}"));
} else {
probeInfo.horizontal(probeInfo.defaultLayoutStyle().alignment(ElementAlignment.ALIGN_CENTER))
.text(TextStyleClass.LABEL + "{*theoneprobe.probe.empty_indicator*}");
}
return;
}
}
}
}

private void showBrewingStandInfo(IProbeInfo probeInfo, World world, IProbeHitData data, Block block) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/mcjty/theoneprobe/compat/BaubleTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Utility class for handling operations related to baubles.
*/
public class BaubleTools {

/**
* Checks if the given player is wearing Probe Goggles.
*
* @param player The {@link EntityPlayer} to check.
* @return True if the player is wearing Probe Goggles, false otherwise.
*/
public static boolean hasProbeGoggle(EntityPlayer player) {
IBaublesItemHandler handler = BaublesApi.getBaublesHandler(player);
if (handler == null) {
Expand All @@ -20,6 +29,11 @@ public static boolean hasProbeGoggle(EntityPlayer player) {
return !stackInSlot.isEmpty() && stackInSlot.getItem() == ModItems.probeGoggles;
}

/**
* Initializes and returns a new instance of Probe Goggles.
*
* @return A new {@link ProbeGoggles} instance.
*/
public static Item initProbeGoggle() {
return new ProbeGoggles();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/mcjty/theoneprobe/compat/ProbeGoggles.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Represents the Probe Goggles item, which implements {@link IBauble} for compatibility with baubles.
*/
public class ProbeGoggles extends Item implements IBauble {

public ProbeGoggles() {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/mcjty/theoneprobe/compat/RedstoneFluxTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,40 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;


/**
* Utility class for handling operations related to Redstone Flux (RF) energy.
*/
public class RedstoneFluxTools {

/**
* Gets the amount of energy stored in the given TileEntity.
*
* @param te The {@link TileEntity} to query for energy storage.
* @return The amount of energy stored in the TileEntity.
*/
public static int getEnergy(TileEntity te) {
IEnergyHandler handler = (IEnergyHandler) te;
return handler.getEnergyStored(EnumFacing.DOWN);
}

/**
* Gets the maximum amount of energy that can be stored in the given TileEntity.
*
* @param te The {@link TileEntity} to query for maximum energy storage.
* @return The maximum amount of energy that can be stored in the TileEntity.
*/
public static int getMaxEnergy(TileEntity te) {
IEnergyHandler handler = (IEnergyHandler) te;
return handler.getMaxEnergyStored(EnumFacing.DOWN);
}

/**
* Checks if the given TileEntity is an energy handler.
*
* @param te The {@link TileEntity} to check.
* @return True if the TileEntity is an instance of {@link IEnergyHandler}, false otherwise.
*/
public static boolean isEnergyHandler(TileEntity te) {
return te instanceof IEnergyHandler;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/mcjty/theoneprobe/config/TopModConfigGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
* Config GUI for The One Probe
*
* @author McJty
*/
@SideOnly(Side.CLIENT)
public class TopModConfigGui extends GuiConfig {

Expand Down
7 changes: 2 additions & 5 deletions src/main/java/mcjty/theoneprobe/gui/GuiNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class GuiNote extends GuiScreen {
private int guiLeft;
private int guiTop;

private static final ResourceLocation background = new ResourceLocation(TheOneProbe.MODID, "textures/gui/note.png");

@Override
public boolean doesGuiPauseGame() {
return false;
Expand All @@ -49,7 +47,7 @@ public void initGui() {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
mc.getTextureManager().bindTexture(background);
mc.getTextureManager().bindTexture(new ResourceLocation(TheOneProbe.MODID, "textures/gui/note.png"));
drawTexturedModalRect(guiLeft, guiTop, 0, 0, WIDTH, HEIGHT);
int x = guiLeft + 5;
int y = guiTop + 8;
Expand All @@ -67,8 +65,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, I18n.format("gui.theoneprobe.gui_note.body.1"));
y += 10;
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, I18n.format("gui.theoneprobe.gui_note.body.2"));
y += 10;
y += 16;
y += 26;
y = setInConfig(x, y);
break;
case PROBE_NOTNEEDED:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mcjty/theoneprobe/gui/Preset.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Preset {
* @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.
* @param styles Pairs of {@link TextStyleClass} and their associated style names.
*/
@SafeVarargs
public Preset(String name, int boxBorderColor, int boxFillColor, int boxThickness, int boxOffset, Pair<TextStyleClass, String>... styles) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/mcjty/theoneprobe/keys/KeyInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import mcjty.theoneprobe.config.ConfigSetup;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class KeyInputHandler {

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void registerThrowable(Throwable e) {
if (catchedThrowables.containsKey(identity)) {
long lasttime = catchedThrowables.get(identity);
if (curtime < lasttime + ConfigSetup.loggingThrowableTimeout) {
// If this exception occurred less then some time ago we don't report it.
// If this exception occurred less than some time ago we don't report it.
return;
}
}
Expand Down
Loading

0 comments on commit 00b6ec7

Please sign in to comment.