aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/rosegoldaddons/mixins')
-rw-r--r--src/main/java/rosegoldaddons/mixins/MixinRenderString.java34
-rw-r--r--src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java6
2 files changed, 39 insertions, 1 deletions
diff --git a/src/main/java/rosegoldaddons/mixins/MixinRenderString.java b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java
new file mode 100644
index 0000000..7990f61
--- /dev/null
+++ b/src/main/java/rosegoldaddons/mixins/MixinRenderString.java
@@ -0,0 +1,34 @@
+package rosegoldaddons.mixins;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+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.callback.CallbackInfo;
+import rosegoldaddons.Main;
+import rosegoldaddons.utils.ChatUtils;
+
+import java.util.Map;
+
+@Mixin(value = FontRenderer.class, priority = 999)
+public abstract class MixinRenderString {
+ @Shadow
+ protected abstract void renderStringAtPos(String text, boolean shadow);
+
+ @Inject(method = "renderStringAtPos", at = @At("HEAD"), cancellable = true)
+ private void renderString(String text, boolean shadow, CallbackInfo ci) {
+ if (Main.init) {
+ for (Map.Entry<String, String> entry : Main.resp.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+
+ if (text.contains(key)) {
+ ci.cancel();
+ renderStringAtPos(text.replaceAll(key, value).replace("&", "ยง"), shadow);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java
index bc1033f..f7e715a 100644
--- a/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java
+++ b/src/main/java/rosegoldaddons/mixins/MixinRendererLivingEntity.java
@@ -3,6 +3,8 @@ package rosegoldaddons.mixins;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityArmorStand;
+import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -10,10 +12,12 @@ 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.events.RenderLivingEntityEvent;
+import rosegoldaddons.utils.ChatUtils;
-@Mixin(RendererLivingEntity.class)
+@Mixin(value = RendererLivingEntity.class, priority = 1001)
@SideOnly(Side.CLIENT)
public abstract class MixinRendererLivingEntity {