Compare commits

...
Author SHA1 Message Date
Nilau1998 5b2a65d2aa [minor] add ability to display bee lore and add Discoverd by tag 2024-09-01 12:17:39 +02:00
4 changed files with 49 additions and 0 deletions

No files matched your search

@@ -65,6 +65,7 @@ import forestry.core.errors.EnumErrorCode;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.GenericRatings;
import forestry.core.genetics.IndividualLiving;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.Log;
import forestry.core.utils.StringUtil;
@@ -456,6 +457,21 @@ public class Bee extends IndividualLiving implements IBee {
if (genome.getTolerantFlyer()) {
list.add(EnumChatFormatting.WHITE + StringUtil.localize("gui.flyer.tooltip"));
}
// Add lore and discovered by
String descTokens[] = primary.getDescription().split("\\|");
if (descTokens.length > 0) {
String speciesLore = descTokens[0];
if (!speciesLore.isEmpty() && Proxies.common.isCtrlDown()) {
list.addAll(StringUtil.multilineStrings(speciesLore, 50));
}
}
if (descTokens.length > 2) {
String discoveredBy = descTokens[2];
if (!discoveredBy.isEmpty()) {
list.add("Discovered by " + discoveredBy);
}
}
}
@Override
@@ -61,6 +61,10 @@ public class ProxyCommon {
return false;
}
public boolean isCtrlDown() {
return false;
}
public void playSoundFX(World world, int x, int y, int z, Block block) {
Proxies.net.sendNetworkPacket(new PacketFXSignal(PacketFXSignal.SoundFXType.LEAF, x, y, z, block, 0), world);
}
@@ -63,6 +63,11 @@ public class ProxyCommonClient extends ProxyCommon {
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
}
@Override
public boolean isCtrlDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
}
@Override
public String getDisplayName(ItemStack itemstack) {
return itemstack.getItem().getItemStackDisplayName(itemstack);
@@ -8,7 +8,9 @@
******************************************************************************/
package forestry.core.utils;
import java.util.ArrayList;
import java.util.IllegalFormatException;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@@ -116,4 +118,26 @@ public class StringUtil {
return lineCount * fontRenderer.FONT_HEIGHT;
}
public static List<String> multilineStrings(String input, int n) {
List<String> result = new ArrayList<>();
int start = 0;
while (start < input.length()) {
// Find the end index by starting with n characters ahead
int end = Math.min(start + n, input.length());
// If end is not at the end of the string, backtrack to the last space
if (end < input.length() && !Character.isWhitespace(input.charAt(end))) {
int lastSpace = input.lastIndexOf(' ', end);
if (lastSpace > start) {
end = lastSpace;
}
}
result.add(input.substring(start, end).trim());
start = end;
}
return result;
}
}