summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/curses/CurseInfamy.java
blob: 4716ff2c9a39d98cbeb6b8163d93b70f69946536 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package darkknight.jewelrycraft.curses;

import org.lwjgl.opengl.GL11;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderPlayerEvent;
import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.damage.DamageSourceList;
import darkknight.jewelrycraft.entities.EntityHalfHeart;
import darkknight.jewelrycraft.entities.EntityHeart;
import darkknight.jewelrycraft.entities.renders.RenderHelper;
import darkknight.jewelrycraft.item.render.MaskRender;
import darkknight.jewelrycraft.util.JewelrycraftUtil;
import darkknight.jewelrycraft.util.PlayerUtils;
import darkknight.jewelrycraft.util.Variables;

public class CurseInfamy extends Curse
{
    MaskRender mask = new MaskRender();
    public CurseInfamy(String name, int txtID, String pack)
    {
        super(name, txtID, pack);
    }
    
    @Override
    public void attackedByPlayerAction(World world, EntityPlayer player, Entity target)
    {
        if (rand.nextInt(5) == 0 && !world.isRemote && !(target instanceof EntityMob) && target instanceof EntityLiving && !(target instanceof EntityHeart) && !(target instanceof EntityHalfHeart) && target.canAttackWithItem()){
            NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(player, Variables.MODID);
            playerInfo.setFloat("BlackHeart", playerInfo.getFloat("BlackHeart") + 1.0F);
            if (player.getMaxHealth() >= 3F){
                player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(player.getMaxHealth() - 1.0F);
                player.setHealth(player.getHealth() - 1.0F);
            }
            JewelrycraftUtil.addCursePoints(player, 10);
        }
    }
    
    @Override
    public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event)
    {
        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(1.6f, 1.6f, 1.6f);
        GL11.glTranslatef(-0.25F, -0.25F, -0.25F);
        mask.doRender(event.entityPlayer, 0F, 0F, 0F, 0F, 0F);
        GL11.glPopMatrix();
    }
    
    public String getDescription()
    {
        return "What have you done?!";
    }
}