Skip to content

Commit

Permalink
Custom Pets Menu & Powertools (REL-1.0.4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nat3z committed Nov 28, 2021
1 parent 698d8e5 commit 05d953e
Show file tree
Hide file tree
Showing 79 changed files with 2,527 additions and 527 deletions.
176 changes: 158 additions & 18 deletions src/main/java/com/natia/secretmod/SecretUtils.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
package com.natia.secretmod;

import com.google.common.base.Stopwatch;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.natia.secretmod.config.SecretModConfig;
import com.natia.secretmod.config.SkyTweaksConfig;
import com.natia.secretmod.core.ItemPickupEvent;
import com.natia.secretmod.core.TickedEvent;
import com.natia.secretmod.utils.FileUtils;
import com.natia.secretmod.utils.ItemDiff;
import com.natia.secretmod.utils.Location;
import com.natia.secretmod.utils.RenderUtils;
import com.natia.secretmod.utils.*;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityOtherPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.tileentity.TileEntitySign;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

import javax.vecmath.Vector3f;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -61,7 +49,7 @@ public class SecretUtils {
public static TileEntitySign CURRENT_SIGN;

public static void sendMessage(String message) {
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[SkyTweaks] " + EnumChatFormatting.WHITE + message));
Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[SkyTweaks] " + EnumChatFormatting.YELLOW + message));
}

public static boolean isValid() {
Expand Down Expand Up @@ -123,7 +111,7 @@ public static String getLatestProfile(String UUID, String key) {
// Get profiles
System.out.println("Fetching profiles...");
System.out.println(UUID);
fetch("https://api.hypixel.net/skyblock/profiles?uuid=" + UUID + "&key=" + key, res -> {
fetch("https://api.hypixel.net/skyblock/profiles?key=" + key + "&uuid=" + UUID, res -> {
JsonObject profilesResponse = res.asJson();
if (!profilesResponse.get("success").getAsBoolean()) {
String reason = profilesResponse.get("cause").getAsString();
Expand Down Expand Up @@ -359,6 +347,16 @@ public static Map<Block, BlockPos> getBlocksInBox(World world, BlockPos pos1, Bl
return blocks;
}

/**
* Generates an Empty Runnable. Useful for SkyblockTimers
* @author NatiaDev
*/
public static Runnable generateEmptyRunnable() {
return () -> {

};
}

/**
* @author NatiaDev
* Simulates a title and sends it to client.
Expand All @@ -381,10 +379,24 @@ public static boolean withinRange(BlockPos range, BlockPos pos1, BlockPos pos2)
);
}

/**
* Allows you to bind a color to entities, blocks, whatever you want!
* @author NatiaDev
* @param color
*/
public static void bindColor(Color color) {
GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f);
}

/**
* Draws a centered string on the screen based on text length
* @author NatiaDev ext. Minecraft
* @param text
* @param x
* @param y
* @param color
* @param scale
*/
public static void drawCenteredString(String text, int x, int y, int color, double scale) {
GlStateManager.pushMatrix();
GlStateManager.scale(scale, scale, 1);
Expand All @@ -399,4 +411,132 @@ public static File getGeneralFolder() {
if (!folder.exists()) folder.mkdir();
return folder;
}

public static double calcArbitraryDamage(double strength, double critDamage, double additiveMultipliers, double weaponDamage) {
return (5 + weaponDamage) * (1 + strength/100) * (1 + critDamage / 100) * (1 + additiveMultipliers / 100);
}

private static List<Double> cachedStats = new ArrayList<>();
private static Map<String, Double> enchantsAdditivesEnderman = new HashMap<>();
private static Map<String, Double> enchantAdditives = new HashMap<>();

public static void addEnchantAdditives() {
if (enchantsAdditivesEnderman.isEmpty()) {
/* if someone can make this more optimized, please do :D */
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer I", 0.12);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer II", 0.24);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer III", 0.36);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer IV", 0.48);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer V", 0.60);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer VI", 0.72);
enchantsAdditivesEnderman.putIfAbsent("Ender Slayer VII", 0.84);

enchantAdditives.putIfAbsent("First Strike I", 0.25);
enchantAdditives.putIfAbsent("First Strike II", 0.5);
enchantAdditives.putIfAbsent("First Strike III", 0.75);
enchantAdditives.putIfAbsent("First Strike IV", 1d);
enchantAdditives.putIfAbsent("First Strike V", 1.25);

enchantAdditives.putIfAbsent("Sharpness I", 0.05);
enchantAdditives.putIfAbsent("Sharpness II", 0.1);
enchantAdditives.putIfAbsent("Sharpness III", 0.15);
enchantAdditives.putIfAbsent("Sharpness IV", 0.2);
enchantAdditives.putIfAbsent("Sharpness V", 0.25);
enchantAdditives.putIfAbsent("Sharpness VI", 0.3);
enchantAdditives.putIfAbsent("Sharpness VII", 0.35);
}
}

public static double calcCurrentDamage(String name, Entity entityDamaged) {
Minecraft mc = Minecraft.getMinecraft();
if (cachedStats.isEmpty()) {
AtomicReference<String> latest = new AtomicReference<>("");
fetch("https://sky.shiiyu.moe/api/v2/profile/" + name, res -> {
if (res == null) return;
JsonObject jsonObject = res.asJson().get("profiles").getAsJsonObject();
Set<Map.Entry<String, JsonElement>> entrySet = jsonObject.entrySet();
for (Map.Entry<String,JsonElement> entry : entrySet) {
if (entry.getValue().getAsJsonObject().get("current").getAsBoolean()) {
latest.set(entry.getKey());
break;
}
}
});
if (latest.get().equals("")) return -404;

fetch("https://sky.shiiyu.moe/api/v2/profile/" + name, res -> {
JsonObject profileData = res.asJson().getAsJsonObject("profiles").getAsJsonObject(latest.get()).get("data").getAsJsonObject();

double critDamage = profileData.getAsJsonObject("stats").get("crit_damage").getAsDouble();
double strength = profileData.getAsJsonObject("stats").get("strength").getAsDouble();
double additive = profileData.getAsJsonObject("stats").get("damage_increase").getAsDouble();

cachedStats.add(strength);
cachedStats.add(critDamage);
cachedStats.add(additive);
});
}
double itemdamage = 0;
double itemcritDamage = 0;
double itemStrength = 0;
final double[] itemAdditive = {0};

for (String line : ItemUtils.getLore(mc.thePlayer.getHeldItem())) {
line = StringUtils.stripControlCodes(line);

if (line.startsWith("Damage:")) {
try {
itemdamage = Double.parseDouble(line.split(" ")[1].replace("+", ""));
} catch (NumberFormatException ex) {
itemdamage = 0;
}
} else if (line.startsWith("Strength")) {
try {
itemStrength = Double.parseDouble(line.split(" ")[1].replace("+", ""));
} catch (NumberFormatException ex) {
itemStrength = 0;
}
} else if (line.startsWith("Crit Damage")) {
try {
itemcritDamage = Double.parseDouble(line.split(" ")[2].replace("+", "").replace("%", ""));
} catch (NumberFormatException ex) {
itemcritDamage = 0;
}
}

else if (line.contains(",")) {

String[] enchants = line.split(",");
for (String enchant : enchants) {
if (enchant.startsWith(" ")) enchant = enchant.replaceFirst(" ", "");
final String enchantFinal = StringUtils.stripControlCodes(enchant);

if (entityDamaged instanceof EntityEnderman)
enchantsAdditivesEnderman.forEach((theEnchant, additive) -> {
if (enchantFinal.startsWith(theEnchant)) {
itemAdditive[0] += additive;
}
});


enchantAdditives.forEach((theEnchant, additive) -> {
if (theEnchant.contains("First Strike") && SkyTweaksConfig.assumeFirstStrike) {
if (enchantFinal.startsWith(theEnchant)) {
itemAdditive[0] += additive;
}
} else if (!theEnchant.contains("First Strike"))
if (enchantFinal.startsWith(theEnchant)) {
itemAdditive[0] += additive;
}
});
}
}
}

if (StringUtils.stripControlCodes(mc.thePlayer.getHeldItem().getDisplayName()).contains("Fabled")) {
itemAdditive[0] += 1;
}
return calcArbitraryDamage(cachedStats.get(0) + itemStrength, cachedStats.get(1) + itemcritDamage, cachedStats.get(2) + itemAdditive[0], itemdamage);
}

}
47 changes: 21 additions & 26 deletions src/main/java/com/natia/secretmod/SkyTweaks.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package com.natia.secretmod;

import com.natia.secretmod.commands.RepartyCommand;
import com.natia.secretmod.config.SecretModCommand;
import com.natia.secretmod.config.SecretModHUD;
import com.natia.secretmod.config.SkyTweaksCommand;
import com.natia.secretmod.config.SkyTweaksHUD;
import com.natia.secretmod.config.CoreExtension;
import com.natia.secretmod.commands.SavePickupLog;
import com.natia.secretmod.core.TickedEvent;
import com.natia.secretmod.features.altC.QuickTab;
import com.natia.secretmod.hooks.*;
import com.natia.secretmod.extensions.ExtensionList;
import com.natia.secretmod.core.BlockRenderingHook;
import com.natia.secretmod.features.AlertPickups;
import com.natia.secretmod.features.MinionAnalyzer;
import com.natia.secretmod.features.RepartyHook;
import com.natia.secretmod.features.dungeons.BonzoSpiritHook;
import com.natia.secretmod.features.dungeons.CopyFails;
import com.natia.secretmod.features.dungeons.TerminalHighlight;
import com.natia.secretmod.features.slayers.VoidGloom;
import com.natia.secretmod.features.*;
import com.natia.secretmod.gui.GuiHook;
import com.natia.secretmod.networking.ColorText;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -31,7 +27,7 @@
)
public class SkyTweaks {
public static final String MODID = "skytweaks-mod";
public static final String VERSION = "v1.0.3.1";
public static final String VERSION = "v1.0.4";
public static final boolean IS_UNSTABLE = false;

public static CoreExtension configHandler;
Expand All @@ -44,39 +40,38 @@ public void preInit(FMLPreInitializationEvent event)
configHandler = new CoreExtension();
ExtensionList.addExtension(configHandler);
configHandler.updateConfigVariables();
SecretUtils.addEnchantAdditives();
}

@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
/* Minecraft - Hooks */
MinecraftForge.EVENT_BUS.register(new TickedEvent());
MinecraftForge.EVENT_BUS.register(new RenderHook());
MinecraftForge.EVENT_BUS.register(new TickHook());
MinecraftForge.EVENT_BUS.register(new BlockRenderingHook());
MinecraftForge.EVENT_BUS.register(new GuiHook());
MinecraftForge.EVENT_BUS.register(new GuiScreenHook());
MinecraftForge.EVENT_BUS.register(new KeyboardInputHook());
MinecraftForge.EVENT_BUS.register(new ItemPickupHook());
MinecraftForge.EVENT_BUS.register(new MessageHook());
MinecraftForge.EVENT_BUS.register(new WorldHook());

/* Dungeons*/
MinecraftForge.EVENT_BUS.register(new BonzoSpiritHook());
MinecraftForge.EVENT_BUS.register(new CopyFails());
MinecraftForge.EVENT_BUS.register(new TerminalHighlight());
MinecraftForge.EVENT_BUS.register(RepartyHook.getInstance());

/* Quality of Life */
MinecraftForge.EVENT_BUS.register(new MinionAnalyzer());
MinecraftForge.EVENT_BUS.register(new AlertPickups());
/* Only do this for things that only have 1 event. */
MinecraftForge.EVENT_BUS.register(DamagePerSecond.getInstance());
MinecraftForge.EVENT_BUS.register(new QuickTab());

/* Cosmetics */
MinecraftForge.EVENT_BUS.register(new ColorText());

/* Slayers - Voidgloom */
MinecraftForge.EVENT_BUS.register(VoidGloom.getInstance());

System.out.println("SkyTweaks Mod Initialized");
}

@Mod.EventHandler
public void postinit(FMLPostInitializationEvent event) {
ClientCommandHandler.instance.registerCommand(new SavePickupLog());
ClientCommandHandler.instance.registerCommand(new SecretModCommand());
ClientCommandHandler.instance.registerCommand(new SecretModHUD());
ClientCommandHandler.instance.registerCommand(new SkyTweaksCommand());
ClientCommandHandler.instance.registerCommand(new SkyTweaksHUD());
ClientCommandHandler.instance.registerCommand(new RepartyCommand());

configHandler.saveConfig();
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/natia/secretmod/commands/RepartyCommand.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.natia.secretmod.commands;

import com.natia.secretmod.SecretUtils;
import com.natia.secretmod.config.SecretModConfig;
import com.natia.secretmod.core.TickedEvent;
import com.natia.secretmod.config.SkyTweaksConfig;
import com.natia.secretmod.features.RepartyHook;
import com.natia.secretmod.utils.AsyncAwait;
import net.minecraft.client.Minecraft;
Expand All @@ -12,7 +11,6 @@
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -49,8 +47,8 @@ public String getCommandUsage(ICommandSender sender) {
*/
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if (SecretModConfig.rpCommand) {
mc.thePlayer.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GRAY + "[Secret Mod] " + EnumChatFormatting.GRAY + "Attempting to reparty members..."));
if (SkyTweaksConfig.rpCommand) {
SecretUtils.sendMessage("Attempting to reparty party members....");
RepartyHook.getInstance().cancelChats = true;
mc.thePlayer.sendChatMessage("/p list");
AsyncAwait.start(() -> {
Expand All @@ -75,7 +73,7 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE

RepartyHook.getInstance().partyMembers.clear();
mc.thePlayer.sendChatMessage(command);
}, 700);
}, 1700);
}, 1100);
} else {
SecretUtils.sendMessage("The feature 'Reparty Command' is not enabled.");
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/natia/secretmod/config/CoreExtension.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.natia.secretmod.config;

import com.natia.secretmod.extensions.Extension;
import com.natia.secretmod.vicious.ViciousConfig;
import com.natia.secretmod.vicious.ViciousMod;

public class CoreExtension extends Extension {
public CoreExtension() {
super(new SecretModConfig(), "Core Extension", "Required to activate Skyblock Secret Mod and corresponding extensions.");
super(new SkyTweaksConfig(), "Core Extension", "Required to activate Skyblock Secret Mod and corresponding extensions.");
}
}
Loading

0 comments on commit 05d953e

Please sign in to comment.