Skip to content

Commit ba67032

Browse files
committed
Chroma Changes (is now by XY position on screen) & Dungeon Map. Search bar now searches separately for each separate word they type in (should get better matches)...
1 parent 1810820 commit ba67032

11 files changed

Lines changed: 369 additions & 66 deletions

File tree

src/main/java/codes/biscuit/skyblockaddons/asm/FontRendererTransformer.java

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import org.objectweb.asm.Opcodes;
77
import org.objectweb.asm.tree.*;
88

9-
import java.util.Iterator;
10-
119
public class FontRendererTransformer implements ITransformer {
1210

1311
/**
@@ -23,33 +21,14 @@ public void transform(ClassNode classNode, String name) {
2321
for (MethodNode methodNode : classNode.methods) {
2422

2523
// Objective:
26-
// Find:
27-
// return (float value)
28-
// Change to:
29-
// float f4 = (float value)
24+
// Find Method Head: Add:
3025
// FontRendererHook.changeTextColor(); <- insert the call right before the return
31-
// return f4;
3226

27+
// TODO Test with patcher...
3328
if (TransformerMethod.renderChar.matches(methodNode) || methodNode.name.equals("renderChar")) {
34-
Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator();
35-
while (iterator.hasNext()) {
36-
AbstractInsnNode abstractNode = iterator.next();
37-
38-
if (abstractNode.getOpcode() == Opcodes.FRETURN) {
39-
methodNode.instructions.insertBefore(abstractNode, insertChangeTextColor());
40-
}
41-
}
29+
methodNode.instructions.insertBefore(methodNode.instructions.getFirst(),
30+
new MethodInsnNode(Opcodes.INVOKESTATIC, "codes/biscuit/skyblockaddons/asm/hooks/FontRendererHook", "changeTextColor", "()V", false));
4231
}
4332
}
4433
}
45-
46-
private InsnList insertChangeTextColor() {
47-
InsnList list = new InsnList();
48-
49-
list.add(new VarInsnNode(Opcodes.FSTORE, 4)); // Store it in a variable for now.
50-
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "codes/biscuit/skyblockaddons/asm/hooks/FontRendererHook", "changeTextColor", "()V", false));
51-
list.add(new VarInsnNode(Opcodes.FLOAD, 4)); // Call back the stored variable to return it.
52-
53-
return list;
54-
}
5534
}

src/main/java/codes/biscuit/skyblockaddons/asm/hooks/FontRendererHook.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package codes.biscuit.skyblockaddons.asm.hooks;
22

3-
import codes.biscuit.skyblockaddons.SkyblockAddons;
43
import codes.biscuit.skyblockaddons.misc.ChromaManager;
54
import net.minecraft.client.Minecraft;
65
import net.minecraft.client.gui.FontRenderer;
@@ -15,13 +14,11 @@ public static void changeTextColor() {
1514
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
1615

1716
float[] HSB = Color.RGBtoHSB((int)(fontRenderer.red * 255), (int)(fontRenderer.green * 255), (int)(fontRenderer.blue * 255), null);
17+
int newColor = ChromaManager.getChromaColor(fontRenderer.posX, fontRenderer.posY, HSB);
1818

19-
float chromaWidth = (SkyblockAddons.getInstance().getUtils().denormalizeScale(SkyblockAddons.getInstance().getConfigValues().getChromaFadeWidth(), 1, 42, 1)/360) % 1F;
20-
int newColorRGB = Color.HSBtoRGB(HSB[0] + chromaWidth, HSB[1], HSB[2]);
21-
22-
fontRenderer.red = (float)(newColorRGB >> 16 & 255) / 255.0F;
23-
fontRenderer.green = (float)(newColorRGB >> 8 & 255) / 255.0F;
24-
fontRenderer.blue = (float)(newColorRGB & 255) / 255.0F;
19+
fontRenderer.red = (float)(newColor >> 16 & 255) / 255.0F;
20+
fontRenderer.green = (float)(newColor >> 8 & 255) / 255.0F;
21+
fontRenderer.blue = (float)(newColor & 255) / 255.0F;
2522

2623
// Swap blue & green because they are swapped in FontRenderer's color model.
2724
GlStateManager.color(fontRenderer.red, fontRenderer.blue, fontRenderer.green, fontRenderer.alpha);

src/main/java/codes/biscuit/skyblockaddons/core/Feature.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ public enum Feature {
123123
CHANGE_ZEALOT_COLOR(96, Message.SETTING_CHANGE_ZEALOT_COLOR, new GuiFeatureData(ColorCode.LIGHT_PURPLE), true),
124124
HIDE_SVEN_PUP_NAMETAGS(97, Message.SETTING_HIDE_SVEN_PUP_NAMETAGS, true),
125125
REPEAT_SLAYER_BOSS_WARNING(98, null, true),
126+
DUNGEONS_MAP_DISPLAY(99, Message.SETTING_DUNGEONS_MAP_DISPLAY, new GuiFeatureData(EnumUtils.DrawType.DUNGEONS_MAP, ColorCode.BLACK, EnumUtils.AnchorPoint.TOP_LEFT, 36, 100), false, EnumUtils.FeatureSetting.ROTATE_MAP, EnumUtils.FeatureSetting.CENTER_ROTATION_ON_PLAYER, EnumUtils.FeatureSetting.MAP_ZOOM),
127+
ROTATE_MAP(100, Message.SETTING_ROTATE_MAP, false),
128+
CENTER_ROTATION_ON_PLAYER(101, Message.SETTING_CENTER_ROTATION_ON_PLAYER, false),
129+
MAP_ZOOM(-1, Message.SETTING_MAP_ZOOM, false),
130+
MAKE_DROPPED_ITEMS_GLOW(102, Message.SETTING_GLOWING_DROPPED_ITEMS, false),
131+
MAKE_DUNGEON_TEAMMATES_GLOW(103, Message.SETTING_GLOWING_DUNGEON_TEAMMATES, false),
126132

127133
WARNING_TIME(-1, Message.SETTING_WARNING_DURATION, false),
128134

@@ -163,7 +169,7 @@ public enum Feature {
163169
@Getter private static final Set<Feature> guiFeatures = new LinkedHashSet<>(Arrays.asList(MAGMA_BOSS_TIMER, MANA_BAR, MANA_TEXT, DEFENCE_ICON, DEFENCE_TEXT,
164170
DEFENCE_PERCENTAGE, HEALTH_BAR, HEALTH_TEXT, SKELETON_BAR, HEALTH_UPDATES, ITEM_PICKUP_LOG, DARK_AUCTION_TIMER, SKILL_DISPLAY, SPEED_PERCENTAGE, SLAYER_INDICATOR,
165171
POWER_ORB_STATUS_DISPLAY, ZEALOT_COUNTER, TICKER_CHARGES_DISPLAY, TAB_EFFECT_TIMERS, SHOW_TOTAL_ZEALOT_COUNT, SHOW_SUMMONING_EYE_COUNT,
166-
SHOW_AVERAGE_ZEALOTS_PER_EYE, BIRCH_PARK_RAINMAKER_TIMER, COMBAT_TIMER_DISPLAY, ENDSTONE_PROTECTOR_DISPLAY, BAIT_LIST));
172+
SHOW_AVERAGE_ZEALOTS_PER_EYE, BIRCH_PARK_RAINMAKER_TIMER, COMBAT_TIMER_DISPLAY, ENDSTONE_PROTECTOR_DISPLAY, BAIT_LIST, DUNGEONS_MAP_DISPLAY));
167173

168174
private static final int ID_AT_PREVIOUS_UPDATE = 63;
169175

@@ -247,6 +253,8 @@ public void draw(float scale, Minecraft mc, ButtonLocation buttonLocation) {
247253
main.getRenderListener().drawPotionEffectTimers(scale, buttonLocation);
248254
} else if(guiFeatureData.getDrawType() == EnumUtils.DrawType.BAIT_LIST_DISPLAY) {
249255
main.getRenderListener().drawBaitList(mc, scale, buttonLocation);
256+
} else if(guiFeatureData.getDrawType() == EnumUtils.DrawType.DUNGEONS_MAP) {
257+
main.getRenderListener().drawDungeonsMap(mc, scale, buttonLocation);
250258
}
251259
}
252260
}

src/main/java/codes/biscuit/skyblockaddons/core/Message.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public enum Message {
128128
SETTING_CHANGE_ZEALOT_COLOR(MessageObject.SETTING, "changeZealotColor"),
129129
SETTING_HIDE_SVEN_PUP_NAMETAGS(MessageObject.SETTING, "hideSvenPupNametags"),
130130
SETTING_TURN_ALL_FEATURES_CHROMA(MessageObject.SETTING, "turnAllFeaturesChroma"),
131+
SETTING_DUNGEONS_MAP_DISPLAY(MessageObject.SETTING, "dungeonsMapDisplay"),
132+
SETTING_ROTATE_MAP(MessageObject.SETTING, "rotateMap"),
133+
SETTING_CENTER_ROTATION_ON_PLAYER(MessageObject.SETTING, "centerRotationOnYourPlayer"),
134+
SETTING_MAP_ZOOM(MessageObject.SETTING, "mapZoom"),
135+
SETTING_GLOWING_DROPPED_ITEMS(MessageObject.SETTING, "glowingDroppedItems"),
136+
SETTING_GLOWING_DUNGEON_TEAMMATES(MessageObject.SETTING, "glowingDungeonTeammates"),
131137

132138
BACKPACK_STYLE_REGULAR(MessageObject.BACKPACK_STYLE, "regular"),
133139
BACKPACK_STYLE_COMPACT(MessageObject.BACKPACK_STYLE, "compact"),

src/main/java/codes/biscuit/skyblockaddons/gui/SkyblockAddonsGui.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,18 @@ public void initGui() {
140140
Keyboard.enableRepeatEvents(true);
141141
}
142142

143-
private boolean matchesSearch(String text) {
144-
if (StringUtils.isEmpty(featureSearchBar.getText())) return true;
143+
private boolean matchesSearch(String textToSearch) {
144+
String searchBarText = featureSearchBar.getText();
145+
if (searchBarText == null || searchBarText.isEmpty()) return true;
145146

146-
return text.toLowerCase().contains(featureSearchBar.getText().toLowerCase());
147+
String[] searchTerms = searchBarText.toLowerCase().split(" ");
148+
textToSearch = textToSearch.toLowerCase();
149+
150+
for (String searchTerm : searchTerms) {
151+
if (textToSearch.contains(searchTerm)) return true;
152+
}
153+
154+
return false;
147155
}
148156

149157
private int findDisplayCount() {

src/main/java/codes/biscuit/skyblockaddons/listeners/RenderListener.java

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import net.minecraftforge.fml.client.GuiNotification;
4848
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
4949
import net.minecraftforge.fml.common.gameevent.TickEvent;
50+
import org.lwjgl.opengl.GL11;
5051

5152
import java.awt.*;
5253
import java.math.BigDecimal;
@@ -72,6 +73,8 @@ public class RenderListener {
7273
private final static ResourceLocation SLASH_ICON = new ResourceLocation("skyblockaddons", "icons/slash.png");
7374
private final static ResourceLocation IRON_GOLEM_ICON = new ResourceLocation("skyblockaddons", "icons/irongolem.png");
7475

76+
private final static ResourceLocation DUNGEON_MAP = new ResourceLocation("skyblockaddons", "dungeonsmap.png");
77+
7578
private final static ItemStack WATER_BUCKET = new ItemStack(Items.water_bucket);
7679
private final static ItemStack IRON_SWORD = new ItemStack(Items.iron_sword);
7780
private static ItemStack NETHER_STAR;
@@ -1356,6 +1359,162 @@ private void drawDetailedPowerOrbStatus(Minecraft mc, float scale, ButtonLocatio
13561359
main.getUtils().restoreGLOptions();
13571360
}
13581361

1362+
float originalPlayerX = Integer.MIN_VALUE;
1363+
float originalPlayerZ = -1;
1364+
float originalMapX = -1;
1365+
float originalMapZ = -1;
1366+
1367+
public void drawDungeonsMap(Minecraft mc, float scale, ButtonLocation buttonLocation) {
1368+
ItemStack possibleMapItemStack = mc.thePlayer.inventory.getStackInSlot(8);
1369+
if (buttonLocation == null && (possibleMapItemStack == null || possibleMapItemStack.getItem() != Items.filled_map ||
1370+
!possibleMapItemStack.hasDisplayName())) {
1371+
return;
1372+
}
1373+
boolean isScoreSummary = false;
1374+
if (buttonLocation == null) {
1375+
isScoreSummary = possibleMapItemStack.getDisplayName().contains("Your Score Summary");
1376+
1377+
if (!possibleMapItemStack.getDisplayName().contains("Magical Map") && !isScoreSummary) {
1378+
return;
1379+
}
1380+
}
1381+
1382+
float x = main.getConfigValues().getActualX(Feature.DUNGEONS_MAP_DISPLAY);
1383+
float y = main.getConfigValues().getActualY(Feature.DUNGEONS_MAP_DISPLAY);
1384+
1385+
GlStateManager.pushMatrix();
1386+
1387+
int originalSize = 128;
1388+
float initialScaleFactor = 0.5F;
1389+
1390+
int size = (int) (originalSize * initialScaleFactor);
1391+
1392+
int minecraftScale = new ScaledResolution(mc).getScaleFactor();
1393+
GL11.glEnable(GL11.GL_SCISSOR_TEST);
1394+
GL11.glScissor(Math.round((x - size * scale / 2F)*minecraftScale),
1395+
mc.displayHeight-Math.round((y + size * scale / 2F)*minecraftScale), Math.round(size * minecraftScale * scale), Math.round(size * minecraftScale * scale));
1396+
1397+
x = transformXY(x, size, scale);
1398+
y = transformXY(y, size, scale);
1399+
1400+
if (buttonLocation != null) {
1401+
buttonLocation.checkHoveredAndDrawBox(x, x+size, y, y+size, scale);
1402+
}
1403+
1404+
GL11.glDisable(GL11.GL_SCISSOR_TEST);
1405+
Color color = main.getConfigValues().getColor(Feature.DUNGEONS_MAP_DISPLAY);
1406+
main.getUtils().drawRect(x, y, x+size, y+size, 0x55000000);
1407+
main.getUtils().drawRectOutline(x, y, size, size, 1, color.getRGB(), main.getConfigValues().getChromaFeatures().contains(Feature.DUNGEONS_MAP_DISPLAY));
1408+
GlStateManager.color(1,1,1,1);
1409+
GL11.glEnable(GL11.GL_SCISSOR_TEST);
1410+
1411+
main.getUtils().enableStandardGLOptions();
1412+
1413+
GlStateManager.color(1,1,1,1);
1414+
1415+
float rotation = 180 - MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw);
1416+
1417+
float zoomScaleFactor = main.getUtils().denormalizeScale(main.getConfigValues().getMapZoom().getValue(), 0.5F, 5, 0.1F);
1418+
if (isScoreSummary) {
1419+
zoomScaleFactor = 1;
1420+
}
1421+
1422+
float totalScaleFactor = initialScaleFactor * zoomScaleFactor;
1423+
1424+
float mapSize = (originalSize * totalScaleFactor);
1425+
1426+
// float mapCenterX = x + size/2F;
1427+
// float mapCenterY = y + size/2F;
1428+
1429+
GlStateManager.scale(totalScaleFactor, totalScaleFactor, 1);
1430+
x /= totalScaleFactor;
1431+
y /= totalScaleFactor;
1432+
GlStateManager.translate(x, y, 0);
1433+
1434+
float rotationCenterX = originalSize * initialScaleFactor;
1435+
float rotationCenterY = originalSize * initialScaleFactor;
1436+
1437+
float centerOffset = -((mapSize-size)/zoomScaleFactor);
1438+
GlStateManager.translate(centerOffset, centerOffset, 0);
1439+
1440+
boolean rotate = main.getConfigValues().isEnabled(Feature.ROTATE_MAP);
1441+
boolean rotateOnPlayer = main.getConfigValues().isEnabled(Feature.CENTER_ROTATION_ON_PLAYER);
1442+
1443+
if (isScoreSummary) {
1444+
rotate = false;
1445+
}
1446+
1447+
if (buttonLocation == null) {
1448+
try {
1449+
MapData mapData = Items.filled_map.getMapData(possibleMapItemStack, mc.theWorld);
1450+
1451+
if (mapData != null) {
1452+
if (mapData.mapDecorations != null) {
1453+
for (Map.Entry<String, Vec4b> entry : mapData.mapDecorations.entrySet()) {
1454+
if (entry.getValue().func_176110_a() == 1) {
1455+
if (originalPlayerX == Integer.MIN_VALUE) {
1456+
originalPlayerX = (float) mc.thePlayer.posX;
1457+
originalPlayerZ = (float) mc.thePlayer.posZ;
1458+
originalMapX = entry.getValue().func_176112_b() / 2.0F + 64.0F;
1459+
originalMapZ = entry.getValue().func_176113_c() / 2.0F + 64.0F;
1460+
}
1461+
}
1462+
}
1463+
}
1464+
1465+
float xMovement = (float) mc.thePlayer.posX - originalPlayerX;
1466+
float zMovement = (float) mc.thePlayer.posZ - originalPlayerZ;
1467+
1468+
float playerMarkerX = originalMapX + xMovement / 1.5F;
1469+
float playerMarkerY = originalMapZ + zMovement / 1.5F;
1470+
1471+
if (rotate && rotateOnPlayer && originalPlayerX != Integer.MIN_VALUE) {
1472+
rotationCenterX = playerMarkerX;
1473+
rotationCenterY = playerMarkerY;
1474+
}
1475+
1476+
if (rotate) {
1477+
if (rotateOnPlayer) {
1478+
GlStateManager.translate(size - rotationCenterX, size - rotationCenterY, 0);
1479+
}
1480+
1481+
GlStateManager.translate(rotationCenterX, rotationCenterY, 0);
1482+
GlStateManager.rotate(rotation, 0, 0, 1);
1483+
GlStateManager.translate(-rotationCenterX, -rotationCenterY, 0);
1484+
}
1485+
1486+
MapItemRenderer.Instance instance = mc.entityRenderer.getMapItemRenderer().getMapRendererInstance(mapData);
1487+
main.getUtils().drawMapEdited(instance, playerMarkerX, playerMarkerY, 180-rotation, !isScoreSummary);
1488+
} else {
1489+
originalPlayerX = Integer.MIN_VALUE;
1490+
originalPlayerZ = -1;
1491+
originalMapX = -1;
1492+
originalMapZ = -1;
1493+
}
1494+
} catch (Exception ex) {
1495+
ex.printStackTrace();
1496+
}
1497+
} else {
1498+
if (rotate) {
1499+
long ticks = System.currentTimeMillis() % 18000 / 50;
1500+
1501+
GlStateManager.translate(rotationCenterX, rotationCenterY, 0);
1502+
GlStateManager.rotate(ticks, 0, 0, 1);
1503+
GlStateManager.translate(-rotationCenterX, -rotationCenterY, 0);
1504+
}
1505+
1506+
mc.getTextureManager().bindTexture(DUNGEON_MAP);
1507+
main.getUtils().drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 128,128, 128, 128);
1508+
}
1509+
// main.getUtils().drawRect(rotationCenterX-2, rotationCenterY-2, rotationCenterX+2, rotationCenterY+2, 0xFFFF0000);
1510+
GL11.glDisable(GL11.GL_SCISSOR_TEST);
1511+
1512+
GlStateManager.popMatrix();
1513+
// main.getUtils().drawRect(mapCenterX-2, mapCenterY-2, mapCenterX+2, mapCenterY+2, 0xFF00FF00);
1514+
1515+
main.getUtils().restoreGLOptions();
1516+
}
1517+
13591518
/**
13601519
* Easily grab an attribute from utils.
13611520
*/

src/main/java/codes/biscuit/skyblockaddons/utils/EnumUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ public enum DrawType {
366366
POWER_ORB_DISPLAY,
367367
TICKER,
368368
BAIT_LIST_DISPLAY,
369-
TAB_EFFECT_TIMERS
369+
TAB_EFFECT_TIMERS,
370+
DUNGEONS_MAP
370371
}
371372

372373
@Getter

0 commit comments

Comments
 (0)