Skip to content

Commit

Permalink
2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Seosean committed Apr 13, 2024
1 parent 551014a commit cb93373
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "2.0.6"
version = "2.0.7"
group= "com.seosean.showspawntime" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ShowSpawnTime"

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/seosean/showspawntime/ShowSpawnTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.seosean.showspawntime.handler.GameTickHandler;
import com.seosean.showspawntime.handler.Renderer;
import com.seosean.showspawntime.handler.ScoreboardManager;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
Expand All @@ -47,7 +48,7 @@
public class ShowSpawnTime
{
public static final String MODID = "showspawntime";
public static final String VERSION = "2.0.6";
public static final String VERSION = "2.0.7";
public static final String EMOJI_REGEX = "(?:[\uD83C\uDF00-\uD83D\uDDFF]|[\uD83E\uDD00-\uD83E\uDDFF]|[\uD83D\uDE00-\uD83D\uDE4F]|[\uD83D\uDE80-\uD83D\uDEFF]|[\u2600-\u26FF]\uFE0F?|[\u2700-\u27BF]\uFE0F?|\u24C2\uFE0F?|[\uD83C\uDDE6-\uD83C\uDDFF]{1,2}|[\uD83C\uDD70\uD83C\uDD71\uD83C\uDD7E\uD83C\uDD7F\uD83C\uDD8E\uD83C\uDD91-\uD83C\uDD9A]\uFE0F?|[\u0023\u002A\u0030-\u0039]\uFE0F?\u20E3|[\u2194-\u2199\u21A9-\u21AA]\uFE0F?|[\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55]\uFE0F?|[\u2934\u2935]\uFE0F?|[\u3030\u303D]\uFE0F?|[\u3297\u3299]\uFE0F?|[\uD83C\uDE01\uD83C\uDE02\uD83C\uDE1A\uD83C\uDE2F\uD83C\uDE32-\uD83C\uDE3A\uD83C\uDE50\uD83C\uDE51]\uFE0F?|[\u203C\u2049]\uFE0F?|[\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE]\uFE0F?|[\u00A9\u00AE]\uFE0F?|[\u2122\u2139]\uFE0F?|\uD83C\uDC04\uFE0F?|\uD83C\uDCCF\uFE0F?|[\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA]\uFE0F?)";
public static final String COLOR_REGEX = "§[a-zA-Z0-9]";
public static boolean isAutoSplitsLoaded;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.seosean.showspawntime.mixins;

import com.seosean.showspawntime.ShowSpawnTime;
import com.seosean.showspawntime.commands.CommandDebug;
import com.seosean.showspawntime.config.MainConfiguration;
import com.seosean.showspawntime.features.powerups.Powerup;
import com.seosean.showspawntime.utils.DebugUtils;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
Expand All @@ -19,11 +16,9 @@
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(RendererLivingEntity.class)
public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> extends Render<T> {
Expand All @@ -32,34 +27,25 @@ protected MixinRendererLivingEntity(RenderManager renderManager) {
super(renderManager);
}

@ModifyArgs(method = "renderName*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RendererLivingEntity;renderOffsetLivingLabel(Lnet/minecraft/entity/Entity;DDDLjava/lang/String;FD)V"))
private void modifiedArgs(Args args) {
if (MainConfiguration.PowerupCountDown) {
Entity entity = args.get(0);
String str = args.get(4);

if (entity instanceof EntityArmorStand && Powerup.powerups.containsKey(entity)) {
int offsetTime = Powerup.powerups.get(entity).getOffsetTime() / 2;
args.set(4, str + EnumChatFormatting.WHITE + (" ✨" + (offsetTime / 10.0) + "s"));
}
}
}



@Redirect(method = "renderName*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RendererLivingEntity;renderOffsetLivingLabel(Lnet/minecraft/entity/Entity;DDDLjava/lang/String;FD)V"))
private void onRedirecting(RendererLivingEntity<?> instance, Entity entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_) {
if (entityIn instanceof EntityArmorStand && Powerup.powerups.containsKey(entityIn)) {
this.overrideRenderLivingLabel((T) entityIn, str, x, y, z, 128);
if (MainConfiguration.PowerupCountDown && entityIn instanceof EntityArmorStand && Powerup.powerups.containsKey(entityIn)) {
this.showSpawnTime$overrideRenderLivingLabel((T) entityIn, str, x, y, z, 128);
} else {
this.renderOffsetLivingLabel((T) entityIn, x, y - (((T) entityIn).isChild() ? (double)(entityIn.height / 2.0F) : 0.0D), z, str, 0.02666667F, p_177069_10_);
}
}



protected void overrideRenderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance)
@Unique
protected void showSpawnTime$overrideRenderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance)
{
int offsetTime = Powerup.powerups.get((EntityArmorStand) entityIn).getOffsetTime() / 2;
String nameTagStr = str;
String countdownStr = EnumChatFormatting.WHITE + (" " + (offsetTime / 10.0) + "s");
str = str + countdownStr;

double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
if (d0 <= (double)(maxDistance * maxDistance))
{
Expand Down Expand Up @@ -96,27 +82,15 @@ protected void overrideRenderLivingLabel(T entityIn, String str, double x, doubl
tessellator.draw();
GlStateManager.enableTexture2D();

boolean flag = false;
if (str.contains("✨")) {
String[] strings = str.split("✨");
if (strings.length == 2) {
fontrenderer.drawString(strings[0], (float) (-fontrenderer.getStringWidth(str) / 2.0), (float) i, MainConfiguration.powerupNameTagRenderColor, MainConfiguration.PowerupNameTagShadow);
fontrenderer.drawString(strings[1].replace("§f", ""), (float) (-fontrenderer.getStringWidth(str) / 2.0 + fontrenderer.getStringWidth("A" + strings[0])), (float) i, MainConfiguration.powerupCountDownRenderColor, true);
fontrenderer.drawString(nameTagStr, (float) (-fontrenderer.getStringWidth(str) / 2.0), (float) i, MainConfiguration.powerupNameTagRenderColor, MainConfiguration.PowerupNameTagShadow);
fontrenderer.drawString(countdownStr.replace("§f", ""), (float) (-fontrenderer.getStringWidth(str) / 2.0 + fontrenderer.getStringWidth(nameTagStr)), (float) i, MainConfiguration.powerupCountDownRenderColor, true);

GlStateManager.enableDepth();
GlStateManager.depthMask(true);
GlStateManager.enableDepth();
GlStateManager.depthMask(true);

fontrenderer.drawString(strings[0], (float) (-fontrenderer.getStringWidth(str) / 2.0), (float) i, -1, MainConfiguration.PowerupNameTagShadow);
fontrenderer.drawString(strings[1].replace("§f", ""), (float) (-fontrenderer.getStringWidth(str) / 2.0 + fontrenderer.getStringWidth("A" + strings[0])), (float) i, 0x99CCFF, true);
flag = true;
}
}
fontrenderer.drawString(nameTagStr, (float) (-fontrenderer.getStringWidth(str) / 2.0), (float) i, -1, MainConfiguration.PowerupNameTagShadow);
fontrenderer.drawString(countdownStr.replace("§f", ""), (float) (-fontrenderer.getStringWidth(str) / 2.0 + fontrenderer.getStringWidth(nameTagStr)), (float) i, 0x99CCFF, true);

if (!flag) {
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
fontrenderer.drawString(str, (float) (-fontrenderer.getStringWidth(str) / 2.0), i, MainConfiguration.powerupNameTagRenderColor, MainConfiguration.PowerupNameTagShadow);
}
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Expand Down

0 comments on commit cb93373

Please sign in to comment.