summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/events
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-04-25 00:05:51 +0100
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2015-04-25 00:05:51 +0100
commit84d260f4d50b4fc91c7263e87981170941d8da70 (patch)
tree98243affb35551f16f376ebf69f174a0dfbb7605 /src/main/java/darkknight/jewelrycraft/events
parent3e53920504f6daf81ccea6144eb00a68658860c2 (diff)
Fixed a Jenkins issue
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/events')
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/EventList.java51
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java123
-rw-r--r--src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java21
3 files changed, 126 insertions, 69 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/events/EventList.java b/src/main/java/darkknight/jewelrycraft/events/EventList.java
new file mode 100644
index 0000000..4b3fff4
--- /dev/null
+++ b/src/main/java/darkknight/jewelrycraft/events/EventList.java
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package darkknight.jewelrycraft.events;
+
+import net.minecraftforge.common.MinecraftForge;
+import cpw.mods.fml.common.FMLCommonHandler;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLPostInitializationEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import darkknight.jewelrycraft.JewelrycraftMod;
+import darkknight.jewelrycraft.block.BlockList;
+import darkknight.jewelrycraft.client.gui.GuiHandler;
+import darkknight.jewelrycraft.config.ConfigHandler;
+import darkknight.jewelrycraft.damage.DamageSourceList;
+import darkknight.jewelrycraft.effects.EffectsList;
+import darkknight.jewelrycraft.item.ItemList;
+import darkknight.jewelrycraft.util.JewelrycraftUtil;
+import darkknight.jewelrycraft.worldGen.Generation;
+
+public class EventList
+{
+ public static void preInit(FMLPreInitializationEvent e)
+ {
+ MinecraftForge.EVENT_BUS.register(new EntityEventHandler());
+ MinecraftForge.EVENT_BUS.register(new BlockEventHandler());
+ MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
+ FMLCommonHandler.instance().bus().register(new EventCommonHandler());
+ BucketHandler.INSTANCE.buckets.put(BlockList.moltenMetal, ItemList.bucket);
+ JewelrycraftMod.proxy.preInit();
+ }
+
+ public static void init(FMLInitializationEvent e)
+ {
+ GameRegistry.registerWorldGenerator(new Generation(), 0);
+ if (FMLCommonHandler.instance().getSide() == Side.CLIENT) FMLCommonHandler.instance().bus().register(new KeyBindings());
+ new GuiHandler();
+ FMLCommonHandler.instance().bus().register(ConfigHandler.INSTANCE);
+ }
+
+ public static void postInit(FMLPostInitializationEvent e)
+ {
+ JewelrycraftUtil.addMetals();
+ JewelrycraftUtil.jamcrafters();
+ EffectsList.postInit(e);
+ DamageSourceList.postInit(e);
+ JewelrycraftMod.proxy.postInit();
+ }
+}
diff --git a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
index c5595fa..b69374b 100644
--- a/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/PlayerRenderHandler.java
@@ -4,22 +4,21 @@ import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import darkknight.jewelrycraft.curses.Curse;
import darkknight.jewelrycraft.curses.CurseList;
-import darkknight.jewelrycraft.entities.renders.RenderHelper;
import darkknight.jewelrycraft.item.render.BraceletRender;
import darkknight.jewelrycraft.item.render.EarringsRender;
-import darkknight.jewelrycraft.item.render.MaskRender;
-import darkknight.jewelrycraft.model.ModelBracelet;
import darkknight.jewelrycraft.util.JewelryNBT;
-import darkknight.jewelrycraft.util.PlayerUtils;
import darkknight.jewelrycraft.util.Variables;
public class PlayerRenderHandler
@@ -27,84 +26,96 @@ public class PlayerRenderHandler
EarringsRender earrings = new EarringsRender();
BraceletRender bracelet = new BraceletRender();
public static NBTTagCompound playersInfo = new NBTTagCompound();
+ float size = 0.055F;
@SubscribeEvent
public void renderScreen(RenderPlayerEvent.Specials.Post event)
{
ModelBiped main = event.renderer.modelBipedMain;
+ ModelRenderer rightArm = event.renderer.modelBipedMain.bipedRightArm;
+ ModelRenderer leftArm = event.renderer.modelBipedMain.bipedLeftArm;
+ ModelRenderer head = event.renderer.modelBipedMain.bipedHead;
Iterator<EntityPlayer> players = event.entityPlayer.worldObj.playerEntities.iterator();
+ int[] gemColor = {-1, -1, -1, -1};
+ int[] ingotColor = {-1, -1, -1, -1};
+ int earringGem = -1;
+ int earringIngot = -1;
if (playersInfo != null){
while (players.hasNext()){
EntityPlayer player = players.next();
NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
for(Curse curse: Curse.getCurseList())
- if (playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0)
- curse.playerRender(player, event);
+ if (playerInfo.getInteger(curse.getName()) > 0 && event.entityPlayer.getDisplayName().equals(player.getDisplayName()) && playerInfo.getInteger("cursePoints") > 0) curse.playerRender(player, event);
if (playerInfo.hasKey("ext17") && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext17");
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick;
- float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick;
- float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick;
GL11.glPushMatrix();
- GL11.glColor4f(1, 1, 1, 1);
- GL11.glRotatef(yawOffset, 0, -1, 0);
- GL11.glRotatef(yaw - 90, 0, 1, 0);
- GL11.glRotatef(pitch, 0, 0, -1);
- GL11.glRotatef(90F, 0, 1F, 0F);
- RenderHelper.translateToHeadLevel(player);
- GL11.glScalef(0.07f, 0.07f, 0.07f);
- GL11.glTranslatef(0.0F, 3.0F, -2.0F);
- int gemColor = -1;
- int ingotColor = -1;
- if (JewelryNBT.gem(item) != null) gemColor = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingotColor = JewelryNBT.ingotColor(item);
- earrings.doRender(event.entityPlayer, 0F, 0F, (float)ingotColor, (float)gemColor, 0F);
+ if (head.rotateAngleX == 0.0F && head.rotateAngleY == 0.0F && head.rotateAngleZ == 0.0F){
+ if (head.rotationPointX != 0.0F || head.rotationPointY != 0.0F || head.rotationPointZ != 0.0F) GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
+ }else{
+ GL11.glTranslatef(head.rotationPointX * size, head.rotationPointY * size, head.rotationPointZ * size);
+ if (head.rotateAngleZ != 0.0F) GL11.glRotatef(head.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ if (head.rotateAngleY != 0.0F) GL11.glRotatef(head.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ if (head.rotateAngleX != 0.0F) GL11.glRotatef(head.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ GL11.glScalef(0.0625f, 0.0625f, 0.0625f);
+ GL11.glTranslatef(0.0F, 1.0F, -2.0F);
+ if (JewelryNBT.gem(item) != null) earringGem = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) earringIngot = JewelryNBT.ingotColor(item);
+ earrings.doRender(event.entityPlayer, 0F, 0F, (float)earringIngot, (float)earringGem, 0F);
GL11.glPopMatrix();
}
for(int i = 10; i <= 13; i++)
if (playerInfo.hasKey("ext" + i) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
NBTTagCompound nbt = (NBTTagCompound)playerInfo.getTag("ext" + i);
ItemStack item = ItemStack.loadItemStackFromNBT(nbt);
- GL11.glPushMatrix();
- GL11.glColor4f(1, 1, 1, 1);
- GL11.glTranslatef((i / 12 == 1) ? -0.275F : 0.475F, 0.2F + ((i / 12 == 1) ? (i - 12) * 0.08F : (i - 10) * 0.08F), 0F);
- if (player.isSneaking()) GL11.glTranslatef(0F, 0F, -((i == 10 || i == 12) ? (0.1F) : 0.05F));
- if (i / 12 == 1){
- GL11.glScalef(0.05f, 0.03f, 0.05f);
- GL11.glRotatef(main.bipedRightArm.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
- GL11.glRotatef(main.bipedRightArm.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
- GL11.glRotatef(main.bipedRightArm.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
- int gemColor = -1;
- int ingotColor = -1;
- if (JewelryNBT.gem(item) != null) gemColor = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingotColor = JewelryNBT.ingotColor(item);
- bracelet.doRender(event.entityPlayer, 0F, 0F, (float)ingotColor, (float)gemColor, 0.0F);
- }else{
- GL11.glScalef(0.05f, 0.03f, 0.05f);
- GL11.glRotatef(main.bipedLeftArm.rotateAngleX * (180F / (float)Math.PI), 1F, 0F, 0F);
- GL11.glRotatef(main.bipedLeftArm.rotateAngleY * (180F / (float)Math.PI), 0F, 1F, 0F);
- GL11.glRotatef(main.bipedLeftArm.rotateAngleZ * (180F / (float)Math.PI), 0F, 0F, 1F);
- int gemColor = -1;
- int ingotColor = -1;
- if (JewelryNBT.gem(item) != null) gemColor = JewelryNBT.gemColor(item);
- if (JewelryNBT.ingot(item) != null) ingotColor = JewelryNBT.ingotColor(item);
- bracelet.doRender(event.entityPlayer, 0F, 0F, (float)ingotColor, (float)gemColor, 0F);
- }
- GL11.glPopMatrix();
+ if (JewelryNBT.gem(item) != null) gemColor[i - 10] = JewelryNBT.gemColor(item);
+ if (JewelryNBT.ingot(item) != null) ingotColor[i - 10] = JewelryNBT.ingotColor(item);
+ }
+ if ((playerInfo.hasKey("ext10") || playerInfo.hasKey("ext11")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
+ GL11.glPushMatrix();
+ GL11.glColor4f(1, 1, 1, 1);
+ if (rightArm.rotateAngleX == 0.0F && rightArm.rotateAngleY == 0.0F && rightArm.rotateAngleZ == 0.0F){
+ if (rightArm.rotationPointX != 0.0F || rightArm.rotationPointY != 0.0F || rightArm.rotationPointZ != 0.0F) GL11.glTranslatef(rightArm.rotationPointX * size, rightArm.rotationPointY * size, rightArm.rotationPointZ * size);
+ }else{
+ GL11.glTranslatef(rightArm.rotationPointX * size, rightArm.rotationPointY * size, rightArm.rotationPointZ * size);
+ if (rightArm.rotateAngleZ != 0.0F) GL11.glRotatef(rightArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ if (rightArm.rotateAngleY != 0.0F) GL11.glRotatef(rightArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ if (rightArm.rotateAngleX != 0.0F) GL11.glRotatef(rightArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ GL11.glScalef(0.05f, 0.03f, 0.05f);
+ bracelet.doRender(event.entityPlayer, (float)ingotColor[0], (float)gemColor[0], (float)ingotColor[1], (float)gemColor[1], 0.0F);
+ GL11.glPopMatrix();
+ }
+ if ((playerInfo.hasKey("ext12") || playerInfo.hasKey("ext13")) && event.entityPlayer.getDisplayName().equals(player.getDisplayName())){
+ GL11.glPushMatrix();
+ GL11.glColor4f(1, 1, 1, 1);
+ if (leftArm.rotateAngleX == 0.0F && leftArm.rotateAngleY == 0.0F && leftArm.rotateAngleZ == 0.0F){
+ if (leftArm.rotationPointX != 0.0F || leftArm.rotationPointY != 0.0F || leftArm.rotationPointZ != 0.0F) GL11.glTranslatef(leftArm.rotationPointX * size, leftArm.rotationPointY * size, leftArm.rotationPointZ * size);
+ }else{
+ GL11.glTranslatef(leftArm.rotationPointX * size + 0.2F, leftArm.rotationPointY * size, leftArm.rotationPointZ * size);
+ if (leftArm.rotateAngleZ != 0.0F) GL11.glRotatef(leftArm.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ if (leftArm.rotateAngleY != 0.0F) GL11.glRotatef(leftArm.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ if (leftArm.rotateAngleX != 0.0F) GL11.glRotatef(leftArm.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
}
+ GL11.glScalef(0.05f, 0.03f, 0.05f);
+ bracelet.doRender(event.entityPlayer, (float)ingotColor[2], (float)gemColor[2], (float)ingotColor[3], (float)gemColor[3], 0F);
+ GL11.glPopMatrix();
+ }
}
}
}
- /**
- * @param string
- * @return
- */
- private boolean checkPlayerInfamy(String string)
+ float rot = 0F;
+
+ @SubscribeEvent
+ public void renderHand(RenderHandEvent event)
{
- NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(string);
- if(playerInfo.getInteger(CurseList.infamy.getName()) > 0) return true;
- return false;
+ if (playersInfo != null){
+ EntityPlayer player = Minecraft.getMinecraft().thePlayer;
+ NBTTagCompound playerInfo = (NBTTagCompound)playersInfo.getTag(player.getDisplayName());
+ for(Curse curse: Curse.getCurseList())
+ if (playerInfo.getInteger(curse.getName()) > 0 && playerInfo.getInteger("cursePoints") > 0) curse.playerHandRender(player, event);
+ }
}
}
diff --git a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
index 5a7b728..5f15ed5 100644
--- a/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
+++ b/src/main/java/darkknight/jewelrycraft/events/ScreenHandler.java
@@ -9,7 +9,6 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
-import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import darkknight.jewelrycraft.curses.Curse;
@@ -20,14 +19,11 @@ public class ScreenHandler extends Gui
private Minecraft mc;
public static NBTTagCompound tagCache = null;
public static int cooldown;
- static ResourceLocation texture;
- static ResourceLocation hearts = new ResourceLocation(Variables.MODID, "textures/gui/hearts.png");
- public ScreenHandler(Minecraft mc, ResourceLocation tex)
+ public ScreenHandler(Minecraft mc)
{
super();
this.mc = mc;
- texture = tex;
}
@SubscribeEvent
@@ -39,18 +35,18 @@ public class ScreenHandler extends Gui
int size = 32;
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
if (tagCache.hasKey("cursePoints") && tagCache.getInteger("cursePoints") > 0){
- mc.renderEngine.bindTexture(hearts);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
for(Curse curse: Curse.getCurseList()){
if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
drawTexturedModalRect(-16, -16 + (size - 6) * count, 0, 32, 144, 60);
count++;
}
}
- mc.renderEngine.bindTexture(texture);
count = 0;
for(Curse curse: Curse.getCurseList())
if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
- int tag = curse.getID();
+ mc.renderEngine.bindTexture(new ResourceLocation(Variables.MODID, "textures/gui/" + curse.getTexturePack() + ".png"));
+ int tag = curse.getTextureID();
GL11.glPushMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
@@ -63,10 +59,9 @@ public class ScreenHandler extends Gui
size = 16;
for(Curse curse: Curse.getCurseList())
if (tagCache.hasKey(curse.getName()) && tagCache.getInteger(curse.getName()) > 0){
- int tag = curse.getID();
mc.fontRenderer.drawStringWithShadow(curse.getName().split(":")[1], 30, 11 + (size + 10) * count, 16777215);
if (tagCache.getInteger(curse.getName()) == 2){
- mc.renderEngine.bindTexture(hearts);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -79,7 +74,7 @@ public class ScreenHandler extends Gui
}
GL11.glPushMatrix();
GL11.glColor4f(1f, 1f, 1f, 1.0f);
- mc.renderEngine.bindTexture(hearts);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
count = 0;
size = 16;
if (tagCache.getFloat("BlueHeart") > 0){
@@ -87,13 +82,13 @@ public class ScreenHandler extends Gui
mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlueHeart")) / 2.0F), 15 + 35*count, resolution.getScaledHeight() - 16, 16777215);
}
count++;
- mc.renderEngine.bindTexture(hearts);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
if (tagCache.getFloat("BlackHeart") > 0){
drawTexturedModalRect(5 + 35*count, resolution.getScaledHeight() - 20, 1 * size, 0 * size, size, size);
mc.fontRenderer.drawStringWithShadow("x" + (MathHelper.ceiling_float_int(tagCache.getFloat("BlackHeart")) / 2.0F), 15 + 35*count, resolution.getScaledHeight() - 16, 16777215);
}
count++;
- mc.renderEngine.bindTexture(hearts);
+ mc.renderEngine.bindTexture(Variables.MISC_TEXTURE);
if (tagCache.getFloat("WhiteHeart") > 0)
drawTexturedModalRect(5 + 35*count, resolution.getScaledHeight() - 20, 2 * size, 1 * size, size, size);
GL11.glPopMatrix();