Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for SBA outline incompatibility #18

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package club.sk1er.mods.levelhead.guis;

import club.sk1er.mods.core.universal.ChatColor;
import club.sk1er.mods.core.universal.UniversalChat;
import club.sk1er.mods.core.universal.UniversalDesktop;
import club.sk1er.mods.core.universal.wrappers.message.UniversalTextComponent;
import club.sk1er.mods.core.universal.UDesktop;
import club.sk1er.mods.core.universal.wrappers.message.UTextComponent;
import club.sk1er.mods.levelhead.Levelhead;
import club.sk1er.mods.levelhead.display.AboveHeadDisplay;
import club.sk1er.mods.levelhead.display.ChatDisplay;
Expand Down Expand Up @@ -233,7 +232,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
if (isCustom) {
mc.displayGuiScreen(new CustomLevelheadConfigurer());
} else {
UniversalDesktop.browse(new URI("http://sk1er.club/customlevelhead"));
UDesktop.browse(new URI("http://sk1er.club/customlevelhead"));
}
} catch (URISyntaxException e) {
e.printStackTrace();
Expand All @@ -242,7 +241,7 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
});
reg(new GuiButton(++currentID, 1, 23, 150, 20, YELLOW + "Purchase Levelhead Credits"), button -> {
try {
UniversalDesktop.browse(new URI("https://purchase.sk1er.club/category/1050972"));
UDesktop.browse(new URI("https://purchase.sk1er.club/category/1050972"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -413,8 +412,8 @@ private void doHead(DisplayConfig config, Levelhead instance, int editWidth, int
valueIn.setChatStyle(style2);
style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, valueIn));
text.setChatStyle(style);
ModCoreAPI.getMinecraftUtil().sendMessage(UniversalTextComponent.from(valueIn).get());
ModCoreAPI.getMinecraftUtil().sendMessage(UniversalTextComponent.from(text).get());
ModCoreAPI.getMinecraftUtil().sendMessage(UTextComponent.Companion.from(valueIn));
ModCoreAPI.getMinecraftUtil().sendMessage(UTextComponent.Companion.from(text));


} catch (UnsupportedEncodingException e2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.modcore.api.ModCoreAPI;
import org.lwjgl.opengl.GL11;
Expand All @@ -32,17 +34,20 @@ public LevelheadAboveHeadRender(Levelhead levelhead) {
}

@SubscribeEvent
public void render(RenderPlayerEvent.Pre event) {
public void render(RenderLivingEvent.Specials.Pre<EntityLivingBase> event) {
if (levelhead == null
|| levelhead.getDisplayManager() == null
|| levelhead.getDisplayManager().getMasterConfig() == null
|| !levelhead.getDisplayManager().getMasterConfig().isEnabled()) {
return;
}
if (!(event.entity instanceof EntityPlayer)) {
return;
}
//#if MC<=10809
EntityPlayer player = event.entityPlayer;
EntityPlayer player = (EntityPlayer)event.entity;
//#else
//$$ EntityPlayer player = event.getEntityPlayer();
//$$ EntityPlayer player = (EntityPlayer)event.getEntity();
//#endif
int o = 0;
for (AboveHeadDisplay display : levelhead.getDisplayManager().getAboveHead()) {
Expand All @@ -69,9 +74,9 @@ public void render(RenderPlayerEvent.Pre event) {
offset = 0;
offset += levelhead.getDisplayManager().getMasterConfig().getOffset();
//#if MC<=10809
renderName(event, levelheadTag, player, event.x, event.y + offset + o * .3D, event.z);
renderName(levelheadTag, player, event.x, event.y + offset + o * .3D, event.z);
//#else
//$$ renderName(event, levelheadTag, player, event.getX(), event.getY() + offset + o * .3D, event.getZ());
//$$ renderName(levelheadTag, player, event.getX(), event.getY() + offset + o * .3D, event.getZ());
//#endif
}
}
Expand All @@ -80,11 +85,11 @@ public void render(RenderPlayerEvent.Pre event) {

}

public void renderName(RenderPlayerEvent event, LevelheadTag tag, EntityPlayer entityIn, double x, double y, double z) {
public void renderName(LevelheadTag tag, EntityPlayer entityIn, double x, double y, double z) {
//#if MC<=10809
FontRenderer fontrenderer = event.renderer.getFontRendererFromRenderManager();
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
//#else
//$$ FontRenderer fontrenderer = event.getRenderer().getFontRendererFromRenderManager();
//$$ FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
//#endif
float f = (float) (1.6F * Levelhead.getInstance().getDisplayManager().getMasterConfig().getFontSize());
float f1 = 0.016666668F * f;
Expand All @@ -98,11 +103,13 @@ public void renderName(RenderPlayerEvent event, LevelheadTag tag, EntityPlayer e
GlStateManager.translate((float) x + 0.0F, (float) y + entityIn.height + 0.5F, (float) z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
//#if MC<=10809
GlStateManager.rotate(-event.renderer.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(event.renderer.getRenderManager().playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
//#else
//$$ GlStateManager.rotate(-event.getRenderer().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
//$$ GlStateManager.rotate(event.getRenderer().getRenderManager().playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
//$$ RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
//$$ GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
//$$ GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
//#endif
GlStateManager.scale(-f1, -f1, f1);
GlStateManager.disableLighting();
Expand Down