diff options
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/Config.java | 4 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/Main.java | 4 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/features/CropNuker.java | 3 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/features/HardstoneAura.java | 30 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/mixins/MixinEntity.java | 33 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/mixins/MixinRenderString.java | 61 | ||||
-rw-r--r-- | src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java | 63 | ||||
-rw-r--r-- | src/main/resources/mixins.rosegoldaddons.json | 3 |
9 files changed, 84 insertions, 119 deletions
diff --git a/build.gradle b/build.gradle index 1189864..39a236a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id "org.spongepowered.mixin" version "0.6-SNAPSHOT" } -version = "2.7.3" +version = "2.7.4" group = "rosegoldaddons" archivesBaseName = "RoseGoldAddons" diff --git a/src/main/java/rosegoldaddons/Config.java b/src/main/java/rosegoldaddons/Config.java index 807e687..f9e11d0 100644 --- a/src/main/java/rosegoldaddons/Config.java +++ b/src/main/java/rosegoldaddons/Config.java @@ -194,6 +194,10 @@ public class Config extends Vigilant { category = "RoseGoldAddons", subcategory = "General", options = {"None", "Zombie 3", "Zombie 4", "Zombie 5", "Spider 3", "Spider 4", "Sven 3", "Sven 4", "Enderman 2", "Enderman 3", "Enderman 4"}) public int slayerTypeIndex = 0; + @Property(type = PropertyType.SELECTOR, name = "Custom Name Type", description = "ignore if you dont know what these mean", + category = "RoseGoldAddons", subcategory = "General", options = {"MixinEntityPlayer", "MixinEntityPlayer + MixinEntity"}) + public int nameRenderType = 0; + @Property(type = PropertyType.SWITCH, name = "Potato Mode", description = "This brings back memories...", category = "Memes", subcategory = "General") public boolean guilag = false; diff --git a/src/main/java/rosegoldaddons/Main.java b/src/main/java/rosegoldaddons/Main.java index 3efcf31..ebdb7d7 100644 --- a/src/main/java/rosegoldaddons/Main.java +++ b/src/main/java/rosegoldaddons/Main.java @@ -158,7 +158,7 @@ public class Main { set.forEach(stringJsonElementEntry -> { names.put(stringJsonElementEntry.getKey(), stringJsonElementEntry.getValue().getAsString().replace("&", "§")); - //System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); }); replacions = rga.get("ranks").getAsJsonObject(); @@ -166,7 +166,7 @@ public class Main { set.forEach(stringJsonElementEntry -> { ranks.put(stringJsonElementEntry.getKey(), stringJsonElementEntry.getValue().getAsString().replace("&", "§")); - //System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); + System.out.println(stringJsonElementEntry.getKey()+": "+stringJsonElementEntry.getValue().getAsString().replace("&", "§")); }); init = true; diff --git a/src/main/java/rosegoldaddons/features/CropNuker.java b/src/main/java/rosegoldaddons/features/CropNuker.java index ab76cc3..44469bd 100644 --- a/src/main/java/rosegoldaddons/features/CropNuker.java +++ b/src/main/java/rosegoldaddons/features/CropNuker.java @@ -28,6 +28,9 @@ public class CropNuker { broken.clear(); return; } + if(broken.size() > 40) { + broken.clear(); + } crop = closestCrop(); if (crop != null) { Main.mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, crop, EnumFacing.DOWN)); diff --git a/src/main/java/rosegoldaddons/features/HardstoneAura.java b/src/main/java/rosegoldaddons/features/HardstoneAura.java index 2551d56..62a10dc 100644 --- a/src/main/java/rosegoldaddons/features/HardstoneAura.java +++ b/src/main/java/rosegoldaddons/features/HardstoneAura.java @@ -190,16 +190,16 @@ public class HardstoneAura { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + if ((blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore - || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } if(Main.configFile.includeExcavatable) { - if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { + if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -218,16 +218,16 @@ public class HardstoneAura { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + if ((blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore - || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } if(Main.configFile.includeExcavatable) { - if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { + if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -242,16 +242,16 @@ public class HardstoneAura { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + if ((blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore - || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } if(Main.configFile.includeExcavatable) { - if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { + if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -266,16 +266,16 @@ public class HardstoneAura { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + if ((blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore - || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } if(Main.configFile.includeExcavatable) { - if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { + if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } @@ -290,16 +290,16 @@ public class HardstoneAura { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } if (Main.configFile.includeOres) { - if (blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore + if ((blockState.getBlock() == Blocks.coal_ore || blockState.getBlock() == Blocks.diamond_ore || blockState.getBlock() == Blocks.gold_ore || blockState.getBlock() == Blocks.redstone_ore || blockState.getBlock() == Blocks.iron_ore || blockState.getBlock() == Blocks.lapis_ore - || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack + || blockState.getBlock() == Blocks.emerald_ore || blockState.getBlock() == Blocks.netherrack) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } if(Main.configFile.includeExcavatable) { - if (blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand && !broken.contains(blockPos)) { + if ((blockState.getBlock() == Blocks.gravel || blockState.getBlock() == Blocks.sand) && !broken.contains(blockPos)) { stones.add(new Vec3(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5)); } } diff --git a/src/main/java/rosegoldaddons/mixins/MixinEntity.java b/src/main/java/rosegoldaddons/mixins/MixinEntity.java new file mode 100644 index 0000000..3319fc1 --- /dev/null +++ b/src/main/java/rosegoldaddons/mixins/MixinEntity.java @@ -0,0 +1,33 @@ +package rosegoldaddons.mixins; + +import net.minecraft.entity.Entity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import rosegoldaddons.Main; + +import java.util.Map; + +@Mixin(Entity.class) +public class MixinEntity { + @Inject(method = "getDisplayName", at = @At(value = "RETURN"), cancellable = true) + public void getFormattedText(CallbackInfoReturnable<IChatComponent> cir) { + if(Main.pauseCustom || Main.configFile.nameRenderType == 0) return; + if (Main.init && Main.configFile.alchsleep != 63 || Main.configFile.skiblock != 263) { + IChatComponent ict = new ChatComponentText(""); + ict.setChatStyle(cir.getReturnValue().getChatStyle()); + String text = cir.getReturnValue().getFormattedText(); + for (Map.Entry<String, String> entry : Main.nameCache.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + + text = text.replace(key, value); + } + ict.appendText(text); + cir.setReturnValue(ict); + } + } +} diff --git a/src/main/java/rosegoldaddons/mixins/MixinRenderString.java b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java index d7a80b8..b010d84 100644 --- a/src/main/java/rosegoldaddons/mixins/MixinRenderString.java +++ b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java @@ -1,48 +1,47 @@ package rosegoldaddons.mixins; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.util.StringUtils; import org.apache.commons.codec.digest.DigestUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; import rosegoldaddons.Main; +import rosegoldaddons.utils.ChatUtils; @Mixin(FontRenderer.class) public abstract class MixinRenderString { + private boolean replacedRank = false; + @ModifyVariable(method = "drawString(Ljava/lang/String;FFIZ)I", at = @At(value = "FIELD")) private String replaceName(String text) { if (Main.mc.theWorld == null || Main.mc.thePlayer == null) return text; - if(Main.pauseCustom) return text; + if (Main.pauseCustom) return text; if (Main.configFile.wydsi && text.contains("727")) { text = text.replace("727", "726"); } if (Main.init && Main.configFile.alchsleep != 88 || Main.configFile.skiblock != 263) { - String[] words = stripString(text).replace(":"," ").replace("'"," ").split(" "); - String[] formatteds = text.replace(":"," ").replace("'"," ").split(" "); + String[] words = removeFormatting(text).replace(":", " ").replace("'", " ").split(" "); + String[] formatteds = text.replace(":", " ").replace("'", " ").split(" "); for (String word : words) { - if(word.equals("")) continue; - if (Main.hashedCache.contains(word)) continue; - if(Main.rankCache.containsKey(word)) { + if (word.equals("") || Main.hashedCache.contains(word)) continue; + if (Main.rankCache.containsKey(word)) { String rank = getRank(text, word); - if(rank != null) { + if (rank != null) { text = text.replace(rank, Main.rankCache.get(word)); } } else { String hashed = DigestUtils.sha256Hex(word + word); - if (Main.ranks.containsKey(hashed)) { + if (Main.ranks.containsKey(hashed) && !Main.rankCache.containsKey(word)) { String rank = getRank(text, word); - if(rank != null) { + if (rank != null) { Main.rankCache.put(word, Main.ranks.get(hashed)); - System.out.println(word+":"+Main.ranks.get(hashed)); } } + if (!Main.names.containsKey(hashed) && !Main.ranks.containsKey(hashed) && !Main.hashedCache.contains(word)) { + Main.hashedCache.add(word); + } } - } - for (String word : words) { - if(word.equals("")) continue; - if (Main.hashedCache.contains(word)) continue; if (Main.nameCache.containsKey(word)) { String[] replaces = Main.nameCache.get(word).split(" "); for (String replace : replaces) { @@ -54,9 +53,10 @@ public abstract class MixinRenderString { text = text.replace(word, Main.nameCache.get(word) + color); } else { String hashed = DigestUtils.sha256Hex(word + word); - if (Main.names.containsKey(hashed)) { + if (Main.names.containsKey(hashed) && !Main.nameCache.containsKey(word)) { Main.nameCache.put(word, Main.names.get(hashed)); - } else { + } + if (!Main.names.containsKey(hashed) && !Main.ranks.containsKey(hashed) && !Main.hashedCache.contains(word)) { Main.hashedCache.add(word); } } @@ -66,12 +66,12 @@ public abstract class MixinRenderString { } private String getRank(String str, String sub) { - if(!str.contains("[") || !str.contains("]")) return null; - if(sub.contains("[") || sub.contains("]")) return null; - if(str.indexOf(sub)-sub.length() >= str.indexOf("]")) return null; - if(str.indexOf(sub) < str.indexOf("[")) return null; + if (!str.contains("[") || !str.contains("]")) return null; + if (sub.contains("[") || sub.contains("]")) return null; + if (str.indexOf(sub) - sub.length() >= str.indexOf("]")) return null; + if (str.indexOf(sub) < str.indexOf("[")) return null; - return str.substring(str.indexOf("["), str.indexOf("]")+1); + return str.substring(str.indexOf("["), str.indexOf("]") + 1); } private String getColorBeforeIndex(String str, int index) { @@ -86,20 +86,7 @@ public abstract class MixinRenderString { return lastColor; } - private String stripString(String s) { - char[] nonValidatedString; - try { - nonValidatedString = StringUtils.stripControlCodes(s).toCharArray(); - } catch (Exception e) { - return ""; - } - StringBuilder validated = new StringBuilder(); - for (char a : nonValidatedString) { - if ((int) a < 127 && (int) a > 20) { - validated.append(a); - } - } - - return validated.toString(); + private String removeFormatting(String input) { + return input.replaceAll("§[0-9a-fk-or]", ""); } } diff --git a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java index dc06069..c83028b 100644 --- a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java +++ b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java @@ -3,19 +3,14 @@ package rosegoldaddons.mixins; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.StringUtils; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.codec.digest.DigestUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import rosegoldaddons.Main; import rosegoldaddons.events.RenderLivingEntityEvent; @Mixin(value = RendererLivingEntity.class, priority = 1001) @@ -29,62 +24,4 @@ public abstract class MixinRendererLivingEntity { if (MinecraftForge.EVENT_BUS.post(new RenderLivingEntityEvent(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor, mainModel))) ci.cancel(); } - - /* - @Redirect(method = "renderName(Lnet/minecraft/entity/EntityLivingBase;DDD)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/IChatComponent;getFormattedText()Ljava/lang/String;")) - public String redirectGetFormattedText(IChatComponent instance) { - if(!Main.configFile.customNames) return instance.getFormattedText(); - if (Main.init && Main.configFile.alchsleep == 63 && Main.configFile.skiblock == 263) return instance.getFormattedText(); - String unformatted = stripString(instance.getUnformattedText()).replace(":"," ").replace("'"," "); - String[] words = unformatted.split(" "); - String[] formatteds = instance.getUnformattedText().replace(":"," ").replace("'"," ").split(" "); - for(String word : words) { - if (Main.hashedCache.contains(word)) continue; - if(word.equals("")) continue; - if (Main.nameCache.containsKey(word)) { - String[] replaces = Main.nameCache.get(word).split(" "); - for(String replace : replaces) { - for(String formatted : formatteds) { - if(replace.equals(formatted)) return instance.getFormattedText(); - } - } - String color = getColorBeforeIndex(instance.getUnformattedText(), instance.getUnformattedText().indexOf(word)); - return instance.getUnformattedText().replace(word, Main.nameCache.get(word) + color); - } else { - String hashed = DigestUtils.sha256Hex(word + word); - if (Main.names.containsKey(hashed)) { - Main.nameCache.put(word, Main.names.get(hashed)); - } else { - Main.hashedCache.add(word); - } - } - } - return instance.getFormattedText(); - } - */ - - private String getColorBeforeIndex(String str, int index) { - String lastColor = ""; - for (int i = 0; i < str.length(); i++) { - if (i == index) break; - if (str.charAt(i) == '§' && i + 1 < str.length() && str.charAt(i + 1) != 'r' && str.charAt(i + 1) != 'l' && str.charAt(i + 1) != 'k' - && str.charAt(i + 1) != 'm' && str.charAt(i + 1) != 'n' && str.charAt(i + 1) != 'o') { - lastColor = str.charAt(i) + "" + str.charAt(i + 1); - } - } - return lastColor; - } - - private String stripString(String s) { - char[] nonValidatedString = StringUtils.stripControlCodes(s).toCharArray(); - StringBuilder validated = new StringBuilder(); - - for (char a : nonValidatedString) { - if ((int) a < 127 && (int) a > 20) { - validated.append(a); - } - } - - return validated.toString(); - } } diff --git a/src/main/resources/mixins.rosegoldaddons.json b/src/main/resources/mixins.rosegoldaddons.json index caa4d26..5c4d575 100644 --- a/src/main/resources/mixins.rosegoldaddons.json +++ b/src/main/resources/mixins.rosegoldaddons.json @@ -7,9 +7,10 @@ "MixinNetworkManager" ], "client": [ + "MixinEntityPlayer", "MixinMinecraft", "MixinRendererLivingEntity", - "MixinEntityPlayer", + "MixinEntity", "MixinRenderString" ] } |