Skip to content

Commit

Permalink
Merge pull request #27 from jaredlll08/master
Browse files Browse the repository at this point in the history
Removed reliance on ARL Closes #22
  • Loading branch information
Lanse505 authored Mar 11, 2018
2 parents 5fcb5d3 + eb129df commit 2c10592
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 126 deletions.
8 changes: 4 additions & 4 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#
#Sat Mar 10 15:19:18 CET 2018
#Sun Mar 11 19:14:41 CAT 2018
version=beta
mc_mappings=snapshot_20170624
dir_output=../Build Output/Reskillable/
dir_repo=./
forge_version=14.23.2.2624
mc_version=1.12.2
build_number=39
forge_version=14.23.2.2624
dir_repo=./
build_number=40
mod_name=Reskillable
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package codersafterdark.reskillable.base;

import codersafterdark.reskillable.event.RegisterUnlockablesEvent;
import codersafterdark.reskillable.network.MessageRegister;
import codersafterdark.reskillable.network.PacketHandler;
import codersafterdark.reskillable.skill.Skills;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -18,7 +18,7 @@ public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(PlayerDataHandler.EventHandler.class);
MinecraftForge.EVENT_BUS.register(LevelLockHandler.class);
ConfigHandler.init(event.getSuggestedConfigurationFile());
MessageRegister.init();
PacketHandler.preInit();
}

public void init(FMLInitializationEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package codersafterdark.reskillable.base;

import codersafterdark.reskillable.network.MessageLockedItem;
import codersafterdark.reskillable.network.*;
import mcp.mobius.waila.handlers.NetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
Expand All @@ -19,7 +20,6 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
import net.minecraftforge.fml.relauncher.*;
import vazkii.arl.network.NetworkHandler;

import java.util.*;

Expand Down Expand Up @@ -245,7 +245,7 @@ private static void enforce(PlayerInteractEvent event) {
public static void tellPlayer(EntityPlayer player, ItemStack stack, String msg) {
if(player instanceof EntityPlayerMP) {
MessageLockedItem message = new MessageLockedItem(stack, msg);
NetworkHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player);
PacketHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package codersafterdark.reskillable.base;

import codersafterdark.reskillable.network.MessageDataSync;
import codersafterdark.reskillable.network.*;
import codersafterdark.reskillable.skill.Skill;
import codersafterdark.reskillable.skill.Skills;
import codersafterdark.reskillable.skill.base.Ability;
import codersafterdark.reskillable.skill.base.IAbilityEventHandler;
import mcp.mobius.waila.handlers.NetworkHandler;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementManager;
import net.minecraft.advancements.AdvancementProgress;
Expand All @@ -21,7 +22,6 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
import vazkii.arl.network.NetworkHandler;

import java.lang.ref.WeakReference;
import java.util.HashMap;
Expand Down Expand Up @@ -118,7 +118,7 @@ public void sync() {

if (player != null && player instanceof EntityPlayerMP) {
MessageDataSync message = new MessageDataSync(this);
NetworkHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player);
PacketHandler.INSTANCE.sendTo(message, (EntityPlayerMP) player);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.*;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import vazkii.arl.util.RenderHelper;

public class HUDHandler {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jan 19, 2014, 5:40:38 PM (GMT)]
*/
package codersafterdark.reskillable.client.base;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import org.lwjgl.opengl.GL11;

import java.util.List;

public class RenderHelper {

public static void renderTooltip(int x, int y, List<String> tooltipData) {
int color = 0x505000ff;
int color2 = 0xf0100010;

renderTooltip(x, y, tooltipData, color, color2);
}

public static void renderTooltip(int x, int y, List<String> tooltipData, int color, int color2) {
boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
if(lighting)
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();

if(!tooltipData.isEmpty()) {
int var5 = 0;
int var6;
int var7;
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
for(var6 = 0; var6 < tooltipData.size(); ++var6) {
var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
if(var7 > var5)
var5 = var7;
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if(tooltipData.size() > 1)
var9 += 2 + (tooltipData.size() - 1) * 10;

ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
int right = var6 + var5 + 5;
int swidth = res.getScaledWidth();
if(right > swidth) {
int diff = right - swidth;
var6 -= diff;
}

int bottom = var7 + var9 + 5;
int sheight = res.getScaledHeight();
if(bottom > sheight) {
int diff = bottom - sheight;
var7 -= diff;
}

float z = 300F;
drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216;
drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color);
drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);

GlStateManager.disableDepth();
for(int var13 = 0; var13 < tooltipData.size(); ++var13) {
String var14 = tooltipData.get(var13);
fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
if(var13 == 0)
var7 += 2;
var7 += 10;
}
GlStateManager.enableDepth();
}
if(!lighting)
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GlStateManager.color(1F, 1F, 1F, 1F);
}

public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
float var7 = (par5 >> 24 & 255) / 255F;
float var8 = (par5 >> 16 & 255) / 255F;
float var9 = (par5 >> 8 & 255) / 255F;
float var10 = (par5 & 255) / 255F;
float var11 = (par6 >> 24 & 255) / 255F;
float var12 = (par6 >> 16 & 255) / 255F;
float var13 = (par6 >> 8 & 255) / 255F;
float var14 = (par6 & 255) / 255F;
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
Tessellator var15 = Tessellator.getInstance();
BufferBuilder buff = var15.getBuffer();
buff.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
buff.pos(par3, par2, z).color(var8, var9, var10, var7).endVertex();
buff.pos(par1, par2, z).color(var8, var9, var10, var7).endVertex();
buff.pos(par1, par4, z).color(var12, var13, var14, var11).endVertex();
buff.pos(par3, par4, z).color(var12, var13, var14, var11).endVertex();
var15.draw();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
}

public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F);
}

public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buff = tessellator.getBuffer();
buff.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buff.pos(par1 + 0, par2 + par6, z).tex((par3 + 0) * f, (par4 + par6) * f1).endVertex();
buff.pos(par1 + par5, par2 + par6, z).tex((par3 + par5) * f, (par4 + par6) * f1).endVertex();
buff.pos(par1 + par5, par2 + 0, z).tex((par3 + par5) * f, (par4 + 0) * f1).endVertex();
buff.pos(par1 + 0, par2 + 0, z).tex((par3 + 0) * f, (par4 + 0) * f1).endVertex();
tessellator.draw();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package codersafterdark.reskillable.client.gui;

import codersafterdark.reskillable.base.ConfigHandler;
import codersafterdark.reskillable.base.PlayerData;
import codersafterdark.reskillable.base.PlayerDataHandler;
import codersafterdark.reskillable.base.PlayerSkillInfo;
import codersafterdark.reskillable.client.gui.button.GuiButtonLevelUp;
import codersafterdark.reskillable.client.gui.handler.InventoryTabHandler;
import codersafterdark.reskillable.lib.LibMisc;
import codersafterdark.reskillable.network.MessageLevelUp;
import codersafterdark.reskillable.network.MessageUnlockUnlockable;
import codersafterdark.reskillable.network.*;
import codersafterdark.reskillable.skill.Skill;
import codersafterdark.reskillable.skill.base.Unlockable;
import net.minecraft.block.Block;
Expand All @@ -17,20 +15,19 @@
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import org.lwjgl.opengl.GL11;
import vazkii.arl.network.NetworkHandler;
import vazkii.arl.util.RenderHelper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static codersafterdark.reskillable.client.base.RenderHelper.renderTooltip;

public class GuiSkillInfo extends GuiScreen {

public static final ResourceLocation SKILL_INFO_RES = new ResourceLocation(LibMisc.MOD_ID, "textures/gui/skill_info.png");
Expand Down Expand Up @@ -173,8 +170,8 @@ private void makeUnlockableTooltip(PlayerData data, PlayerSkillInfo info, int mo
hoveredUnlockable.getRequirements().addRequirementsToTooltip(data, tooltip);
else tooltip.add(TextFormatting.GREEN + I18n.translateToLocal("skillable.misc.unlocked"));
tooltip.add(TextFormatting.GRAY + String.format(I18n.translateToLocal("skillable.misc.skillPoints"), hoveredUnlockable.cost));

RenderHelper.renderTooltip(mouseX, mouseY, tooltip);
renderTooltip(mouseX, mouseY, tooltip);
}

private void addLongStringToTooltip(List<String> tooltip, String longStr, int maxLen) {
Expand All @@ -197,7 +194,7 @@ private void addLongStringToTooltip(List<String> tooltip, String longStr, int ma
protected void actionPerformed(GuiButton button) throws IOException {
if (button == levelUpButton) {
MessageLevelUp message = new MessageLevelUp(skill.getKey());
NetworkHandler.INSTANCE.sendToServer(message);
PacketHandler.INSTANCE.sendToServer(message);
}
}

Expand All @@ -208,7 +205,7 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx
if (mouseButton == 0 && hoveredUnlockable != null && canPurchase) {
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
MessageUnlockUnlockable message = new MessageUnlockUnlockable(skill.getKey(), hoveredUnlockable.getKey());
NetworkHandler.INSTANCE.sendToServer(message);
PacketHandler.INSTANCE.sendToServer(message);
} else if (mouseButton == 1 || mouseButton == 3)
mc.displayGuiScreen(new GuiSkills());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package codersafterdark.reskillable.client.gui;

import codersafterdark.reskillable.base.ConfigHandler;
import codersafterdark.reskillable.base.PlayerData;
import codersafterdark.reskillable.base.PlayerDataHandler;
import codersafterdark.reskillable.base.PlayerSkillInfo;
import codersafterdark.reskillable.client.base.RenderHelper;
import codersafterdark.reskillable.client.gui.handler.InventoryTabHandler;
import codersafterdark.reskillable.lib.LibMisc;
import codersafterdark.reskillable.skill.Skill;
Expand All @@ -18,7 +18,6 @@
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import vazkii.arl.util.RenderHelper;

import java.io.IOException;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package codersafterdark.reskillable.client.gui.handler;

import codersafterdark.reskillable.base.ConfigHandler;
import codersafterdark.reskillable.client.base.RenderHelper;
import codersafterdark.reskillable.client.gui.GuiAbilities;
import codersafterdark.reskillable.client.gui.GuiSkillInfo;
import codersafterdark.reskillable.client.gui.GuiSkills;
Expand All @@ -17,7 +18,6 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import scala.actors.threadpool.Arrays;
import vazkii.arl.util.RenderHelper;

import java.util.List;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/codersafterdark/reskillable/lib/LibMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public final class LibMisc {
public static final String MOD_NAME = "Reskillable";
public static final String BUILD = "GRADLE:BUILD";
public static final String VERSION = "GRADLE:VERSION-" + BUILD;
public static final String DEPENDENCIES = "required-before:autoreglib;";
public static final String DEPENDENCIES = "";

// Proxy Constants
public static final String PROXY_COMMON = "codersafterdark.reskillable.base.CommonProxy";
Expand Down
Loading

0 comments on commit 2c10592

Please sign in to comment.