Skip to content

Commit

Permalink
Dev-6!
Browse files Browse the repository at this point in the history
  • Loading branch information
strubium committed Jun 5, 2024
1 parent 319d230 commit 7b9c704
Show file tree
Hide file tree
Showing 24 changed files with 86 additions and 55 deletions.
3 changes: 2 additions & 1 deletion src/main/java/mcjty/theoneprobe/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

import static mcjty.theoneprobe.api.IProbeConfig.ConfigMode.EXTENDED;
import static mcjty.theoneprobe.api.IProbeConfig.ConfigMode.NORMAL;
Expand All @@ -35,7 +36,7 @@ public static String getModName(Block block) {
init();
}
ResourceLocation itemResourceLocation = block.getRegistryName();
String modId = itemResourceLocation.getResourceDomain();
String modId = Objects.requireNonNull(itemResourceLocation).getResourceDomain();
String lowercaseModId = modId.toLowerCase(Locale.ENGLISH);
String modName = modNamesForIds.get(lowercaseModId);
if (modName == null) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/mcjty/theoneprobe/api/ILayoutStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Style for a horizontal or vertical layout.
*/
public interface ILayoutStyle {
/// The color that is used for the border of the progress bar
/**
* The color that is used for the border of the progress bar
*/
ILayoutStyle borderColor(Integer c);

/**
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/mcjty/theoneprobe/api/IProbeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
*/
public interface IProbeConfig {

public static enum ConfigMode {
NOT, // Don't show
NORMAL, // Show
EXTENDED // Show only when sneaking
enum ConfigMode {
/**Don't show*/
NOT,
/**Show*/
NORMAL,
/**Show only when sneaking*/
EXTENDED
}

/**
Expand Down Expand Up @@ -62,7 +65,10 @@ public static enum ConfigMode {
IProbeConfig showChestContents(ConfigMode mode);
ConfigMode getShowChestContents();

// This controls when detailed chest info is shown in case the amount of items is below showItemDetailThresshold
/**
* This controls when detailed chest info is shown in case
* the amount of items is below showItemDetailThresshold
*/
IProbeConfig showChestContentsDetailed(ConfigMode mode);
ConfigMode getShowChestContentsDetailed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public interface IProbeInfoEntityProvider {

/**
* Return a unique ID (usually combined with the modid) to identify this provider.
* @return
* Get a unique ID (usually combined with the modid) to identify this provider.
* @return The unique ID
*/
String getID();

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/mcjty/theoneprobe/api/IProgressStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
* Style for the progress bar.
*/
public interface IProgressStyle {
/// The color that is used for the border of the progress bar
/**The color that is used for the border of the progress bar*/
IProgressStyle borderColor(int c);

/// The color that is used for the background of the progress bar
/**The color that is used for the background of the progress bar*/
IProgressStyle backgroundColor(int c);

/// The color that is used for the filled part of the progress bar
/** The color that is used for the filled part of the progress bar*/
IProgressStyle filledColor(int c);

/// If this is different from the filledColor then the fill color will alternate
/** If this is different from the filledColor then the fill color will alternate*/
IProgressStyle alternateFilledColor(int c);

/// If true then text is shown inside the progress bar
/** If true then text is shown inside the progress bar*/
IProgressStyle showText(boolean b);

/// The number format to use for the text inside the progress bar
/** The number format to use for the text inside the progress bar*/
IProgressStyle numberFormat(NumberFormat f);

IProgressStyle prefix(String prefix);

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
30 changes: 20 additions & 10 deletions src/main/java/mcjty/theoneprobe/api/TextStyleClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@
* probeInfo.text(TextStyleClass.ERROR + "Error! World will explode in 5 seconds!");
*/
public enum TextStyleClass {
MODNAME("m", "ModName"), // Name of the mod
NAME("n", "Name"), // Name of the block or entity
INFO("i", "Info"), // General info, neutral
INFOIMP("I", "InfoImportant"), // General info, important
WARNING("w", "Warning"), // Warning, something is not ready (not mature), or missing stuff
ERROR("e", "Error"), // Error, bad situation, out of power, things like that
OBSOLETE("O", "Obsolete"), // Obsolete, deprecated, old information
LABEL("l", "Label"), // A label, use the 'context' code to set the same as the style that follows
OK("o", "Ok"), // Status ok
PROGRESS("p", "Progress"); // Progress rendering in case the bar is not used
/**Name of the mod*/
MODNAME("m", "ModName"),
/**Name of the block or entity*/
NAME("n", "Name"),
/**General info, neutral*/
INFO("i", "Info"),
/**General info, important*/
INFOIMP("I", "InfoImportant"),
/**Warning, something is not ready (not mature), or missing stuff*/
WARNING("w", "Warning"),
/**Error, bad situation, out of power, things like that*/
ERROR("e", "Error"),
/**Obsolete, deprecated, old information*/
OBSOLETE("O", "Obsolete"),
/**A label, use the 'context' code to set the same as the style that follows*/
LABEL("l", "Label"),
/**Status ok*/
OK("o", "Ok"),
/** Progress rendering in case the bar is not used*/
PROGRESS("p", "Progress");

private final String code;
private final String readableName;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/mcjty/theoneprobe/apiimpl/TheOneProbeImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public void configureProviders(String[] sortedProviders, Set<String> excludedPro
}
}

// Add all providers that are not in the list of sortedProviders and are also not
// excluded.
// Add all providers that are not in the list of sortedProviders and are also not excluded.
for (IProbeInfoProvider provider : providers) {
if ((!newProviders.contains(provider)) && !excludedProviders.contains(provider.getID())) {
newProviders.add(provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void render(String entityName, NBTTagCompound entityNBT, IEntitySt
* the given id
* This does not work for modded entities.
* @param id an old-style entity id as used in 1.10
* @return
* @return nbt of fixed id
*/
public static String fixEntityId(String id) {
NBTTagCompound nbt = new NBTTagCompound();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void render(ItemStack itemStack, IItemStyle style, int x, int y) {

if (!RenderHelper.renderItemStack(Minecraft.getMinecraft(), itemRender, itemStack, x + (style.getWidth() - 18) / 2, y + (style.getHeight() - 18) / 2, amount)) {
// There was a crash rendering this item
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.RED + "ERROR: " + itemStack.getDisplayName());
RenderHelper.renderText(Minecraft.getMinecraft(), x, y, TextFormatting.RED + "{*theoneprobe.probe.error_indicator*} " + itemStack.getDisplayName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlaye
float aiMoveSpeed = entityLivingBase.getAIMoveSpeed();
int revengeTimer = entityLivingBase.getRevengeTimer();
vertical
.text(LABEL + "Tot armor: " + INFO + totalArmorValue)
.text(LABEL + "Total armor: " + INFO + totalArmorValue)
.text(LABEL + "Age: " + INFO + age)
.text(LABEL + "Absorption: " + INFO + absorptionAmount)
.text(LABEL + "AI Move Speed: " + INFO + aiMoveSpeed)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mcjty.theoneprobe.apiimpl.providers;

import mcjty.lib.api.power.IBigPower;
import mcjty.theoneprobe.compat.RedstoneFluxTools;
import mcjty.theoneprobe.config.ConfigSetup;
import mcjty.theoneprobe.TheOneProbe;
import mcjty.theoneprobe.api.IProbeHitData;
Expand Down Expand Up @@ -45,11 +47,20 @@ private void showDebugInfo(IProbeInfo probeInfo, World world, IBlockState blockS
.text(LABEL + "Class: " + INFO + simpleName)
.text(LABEL + "Hardness: " + INFO + block.getBlockHardness(blockState, world, pos))
.text(LABEL + "Power W: " + INFO + block.getWeakPower(blockState, world, pos, side.getOpposite())
+ LABEL + ", S: " + INFO + block.getStrongPower(blockState, world, pos, side.getOpposite()))
.text(LABEL + "Light: " + INFO + block.getLightValue(blockState, world, pos));
+ LABEL + ", S: " + INFO + block.getStrongPower(blockState, world, pos, side.getOpposite()));

int lightValue = block.getLightValue(blockState, world, pos);
if (lightValue > 0) {
vertical.text(LABEL + "Light: " + INFO + lightValue);
}

TileEntity te = world.getTileEntity(pos);
if (te != null) {
vertical.text(LABEL + "TileEntity: " + INFO + te.getClass().getSimpleName());
if (te instanceof IBigPower) {
vertical.text(LABEL + "Energy: " + INFO + RedstoneFluxTools.getEnergy(te));
vertical.text(LABEL + "Max Energy: " + INFO + RedstoneFluxTools.getMaxEnergy(te));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ static void showHarvestInfo(IProbeInfo probeInfo, World world, BlockPos pos, Blo
int harvestLevel = block.getHarvestLevel(blockState);
if (harvestLevel < 0) {
// NOTE: When a block doesn't have an explicitly-set harvest tool, getHarvestLevel will return -1 for ANY tool. (Expected behavior)
// TheOneProbe.logger.info("HarvestLevel out of bounds (less than 0). Found " + harvestLevel);
// ModSetup.getLogger().info("HarvestLevel out of bounds (less than 0). Found " + harvestLevel);
} else if (harvestLevel >= harvestLevels.length) {
// TheOneProbe.logger.info("HarvestLevel out of bounds (Max value " + harvestLevels.length + "). Found " + harvestLevel);
// ModSetup.getLogger().info("HarvestLevel out of bounds (Max value " + harvestLevels.length + "). Found " + harvestLevel);
} else {
harvestName = harvestLevels[harvestLevel];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public String getID() {
@Override
public void addProbeEntityInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, Entity entity, IProbeHitEntityData data) {
if (entity instanceof EntityTNTPrimed) {
probeInfo.text(TextStyleClass.LABEL + "{*theoneprobe.probe.tnt_fuse_indicator*} " + TextStyleClass.WARNING + StringUtils.ticksToElapsedTime(((EntityTNTPrimed) entity).getFuse()));
probeInfo.text(TextStyleClass.LABEL + "{*theoneprobe.probe.fuse_indicator*} " + TextStyleClass.WARNING + StringUtils.ticksToElapsedTime(((EntityTNTPrimed) entity).getFuse()));
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/mcjty/theoneprobe/config/ConfigSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class ConfigSetup {
public static int tankbarFilledColor = 0xff0000dd;
public static int tankbarAlternateFilledColor = 0xff000043;
public static int tankbarBorderColor = 0xff555555;
public static int probeNoteStackSize = 1;

public static Map<TextStyleClass, String> defaultTextStyleClasses = new HashMap<>();
public static Map<TextStyleClass, String> textStyleClasses;
Expand Down Expand Up @@ -154,7 +155,7 @@ public static void init(Configuration cfg) {
tankbarFilledColor = parseColor(cfg.getString("tankbarFilledColor", CATEGORY_THEONEPROBE, Integer.toHexString(tankbarFilledColor), "Color for the tank bar"));
tankbarAlternateFilledColor = parseColor(cfg.getString("tankbarAlternateFilledColor", CATEGORY_THEONEPROBE, Integer.toHexString(tankbarAlternateFilledColor), "Alternate color for the tank bar"));
tankbarBorderColor = parseColor(cfg.getString("tankbarBorderColor", CATEGORY_THEONEPROBE, Integer.toHexString(tankbarBorderColor), "Color for the tank bar border"));

probeNoteStackSize = cfg.getInt("probeNoteStackSize", CATEGORY_THEONEPROBE, tankFormat.ordinal(), 1, 64, "Stack size of the Readme note");
showItemDetailThresshold = cfg.getInt("showItemDetailThresshold", CATEGORY_THEONEPROBE, showItemDetailThresshold, 0, 20, "If the number of items in an inventory is lower or equal then this number then more info is shown");
showSmallChestContentsWithoutSneaking = cfg.getInt("showSmallChestContentsWithoutSneaking", CATEGORY_THEONEPROBE, showSmallChestContentsWithoutSneaking, 0, 1000, "The maximum amount of slots (empty or not) to show without sneaking");
showContentsWithoutSneaking = cfg.getStringList("showContentsWithoutSneaking", CATEGORY_THEONEPROBE, showContentsWithoutSneaking, "A list of blocks for which we automatically show chest contents even if not sneaking");
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/mcjty/theoneprobe/items/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class ModItems {
public static Item probeGoggles;
public static ProbeNote probeNote;

public static String PROBETAG = "theoneprobe";
public static String PROBETAG_HAND = "theoneprobe_hand";
public static final String PROBETAG = "theoneprobe";
private static final String PROBETAG_HAND = "theoneprobe_hand";

public static void init() {
probe = new Probe();
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void initClient() {
BaubleTools.initProbeModel(probeGoggles);
}
}

@SideOnly(Side.CLIENT)
public static boolean isProbeInHand(ItemStack stack) {
if (stack.isEmpty()) {
return false;
Expand All @@ -108,7 +108,7 @@ public static boolean isProbeInHand(ItemStack stack) {
}
return stack.getTagCompound().hasKey(PROBETAG_HAND);
}

@SideOnly(Side.CLIENT)
private static boolean isProbeHelmet(ItemStack stack) {
if (stack.isEmpty()) {
return false;
Expand All @@ -118,23 +118,22 @@ private static boolean isProbeHelmet(ItemStack stack) {
}
return stack.getTagCompound().hasKey(PROBETAG);
}

@SideOnly(Side.CLIENT)
public static boolean hasAProbeSomewhere(EntityPlayer player) {
return hasProbeInHand(player, EnumHand.MAIN_HAND) || hasProbeInHand(player, EnumHand.OFF_HAND) || hasProbeInHelmet(player)
|| hasProbeInBauble(player);
}

@SideOnly(Side.CLIENT)
private static boolean hasProbeInHand(EntityPlayer player, EnumHand hand) {
ItemStack item = player.getHeldItem(hand);
return isProbeInHand(item);
}

@SideOnly(Side.CLIENT)
private static boolean hasProbeInHelmet(EntityPlayer player) {
ItemStack helmet = player.inventory.getStackInSlot(36+3);
// ItemStack helmet = player.inventory.armorInventory.get(3);
return isProbeHelmet(helmet);
}

@SideOnly(Side.CLIENT)
private static boolean hasProbeInBauble(EntityPlayer player) {
if (ModSetup.baubles) {
return BaubleTools.hasProbeGoggle(player);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/mcjty/theoneprobe/items/ProbeNote.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mcjty.theoneprobe.items;

import mcjty.theoneprobe.TheOneProbe;
import mcjty.theoneprobe.config.ConfigSetup;
import mcjty.theoneprobe.setup.GuiProxy;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -22,7 +23,7 @@ public ProbeNote() {
setUnlocalizedName(TheOneProbe.MODID + ".probenote");
setRegistryName("probenote");
setCreativeTab(TheOneProbe.tabProbe);
setMaxStackSize(1);
setMaxStackSize(ConfigSetup.probeNoteStackSize);
}

@SideOnly(Side.CLIENT)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/mcjty/theoneprobe/network/NetworkTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.IOException;
import java.util.Collection;
import java.util.Objects;

public class NetworkTools {

Expand Down Expand Up @@ -53,7 +54,7 @@ public static ItemStack readItemStack(ByteBuf dataIn) {
PacketBuffer buf = new PacketBuffer(dataIn);
try {
NBTTagCompound nbt = buf.readCompoundTag();
ItemStack stack = new ItemStack(nbt);
ItemStack stack = new ItemStack(Objects.requireNonNull(nbt));
stack.setCount(buf.readInt());
return stack;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static ProbeInfo getProbeInfo(EntityPlayer player, ProbeMode mode, World
}
}
} else if (ConfigSetup.needsProbe == PROBE_NEEDEDHARD && !ModItems.hasAProbeSomewhere(player)) {
// The server says we need a probe but we don't have one in our hands or on our head
// The server says we need a probe, but we don't have one in our hands or on our head
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mcjty/theoneprobe/network/PacketGetInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private static ProbeInfo getProbeInfo(EntityPlayer player, ProbeMode mode, World
}
}
} else if (ConfigSetup.needsProbe == PROBE_NEEDEDHARD && !ModItems.hasAProbeSomewhere(player)) {
// The server says we need a probe but we don't have one in our hands
// The server says we need a probe, but we don't have one in our hands
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/theoneprobe/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ theoneprobe.probe.empty_indicator=Leer
theoneprobe.probe.bottle_indicator=Flasche
theoneprobe.probe.bottles_indicator=Flaschen
theoneprobe.probe.enchanting_power_indicator=Verzauberungsstufe:
theoneprobe.probe.tnt_fuse_indicator=TNT-Zündzeit:
theoneprobe.probe.fuse_indicator=TNT-Zündzeit:
theoneprobe.probe.fuel_indicator=Brennstoff:
theoneprobe.probe.power_indicator=Energie:
theoneprobe.probe.time_indicator=Zeit:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/theoneprobe/lang/en_ud.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ theoneprobe.probe.empty_indicator=ʎʇdɯǝ
theoneprobe.probe.bottle_indicator=ǝʅʇʇoq
theoneprobe.probe.bottles_indicator=ǝʅʇʇoʅq
theoneprobe.probe.enchanting_power_indicator= :ɹǝʍoԀ ƃuıʇuɐɥɔuǝ
theoneprobe.probe.tnt_fuse_indicator= :ǝsuɟ ʇuʇ
theoneprobe.probe.fuse_indicator= :ǝsuɟ ʇuʇ
theoneprobe.probe.fuel_indicator= :ʅǝnɟ
theoneprobe.probe.power_indicator= :ɹǝʍoԀ
theoneprobe.probe.time_indicator= :ǝɯıʇ
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/theoneprobe/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ theoneprobe.probe.empty_indicator=Empty
theoneprobe.probe.bottle_indicator=Bottle
theoneprobe.probe.bottles_indicator=Bottles
theoneprobe.probe.enchanting_power_indicator=Enchanting Power:
theoneprobe.probe.tnt_fuse_indicator=TNT Fuse:
theoneprobe.probe.fuse_indicator=Fuse:
theoneprobe.probe.fuel_indicator=Fuel:
theoneprobe.probe.power_indicator=Power:
theoneprobe.probe.time_indicator=Time:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/theoneprobe/lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ theoneprobe.probe.empty_indicator=Vide
theoneprobe.probe.bottle_indicator=Bouteille
theoneprobe.probe.bottles_indicator=Bouteilles
theoneprobe.probe.enchanting_power_indicator=Pouvoir d'enchantement:
theoneprobe.probe.tnt_fuse_indicator=Mèche de TNT:
theoneprobe.probe.fuse_indicator=Mèche de TNT:
theoneprobe.probe.fuel_indicator=Carburant:
theoneprobe.probe.power_indicator=Puissance:
theoneprobe.probe.time_indicator=Temps:
Expand Down
Loading

0 comments on commit 7b9c704

Please sign in to comment.