Search in sources :

Example 16 with Soul

use of net.silentchaos512.gems.item.ItemSoulGem.Soul in project SilentGems by SilentChaos512.

the class ToolSoul method readFromNBT.

public static ToolSoul readFromNBT(NBTTagCompound tags) {
    ToolSoul soul = new ToolSoul();
    soul.name = tags.getString("name");
    String e1 = tags.getString("element1");
    String e2 = tags.getString("element2");
    for (EnumSoulElement element : EnumSoulElement.values()) {
        if (element.name().equalsIgnoreCase(e1)) {
            soul.element1 = element;
        } else if (element.name().equalsIgnoreCase(e2)) {
            soul.element2 = element;
        }
    }
    soul.xp = tags.getInteger("xp");
    soul.level = tags.getInteger("level");
    soul.actionPoints = tags.getInteger("ap");
    // Load skills
    soul.skills.clear();
    NBTTagList tagList = tags.getTagList("skills", 10);
    for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
        SoulSkill skill = SoulSkill.getById(tagCompound.getString("id"));
        if (skill != null) {
            int level = tagCompound.getShort("level");
            soul.skills.put(skill, level);
        }
    // Skills with unknown IDs are ignored!
    }
    return soul;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ItemToolSoul(net.silentchaos512.gems.item.ItemToolSoul) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 17 with Soul

use of net.silentchaos512.gems.item.ItemSoulGem.Soul in project SilentGems by SilentChaos512.

the class GuiToolSouls method renderAPBarForItem.

private static void renderAPBarForItem(ItemStack stack, int xPosition, int yPosition) {
    if (!stack.isEmpty()) {
        ToolSoul soul = SoulManager.getSoul(stack);
        if (soul != null) {
            // SilentGems.logHelper.debug(soul);
            GlStateManager.disableLighting();
            GlStateManager.disableDepth();
            GlStateManager.disableTexture2D();
            GlStateManager.disableAlpha();
            GlStateManager.disableBlend();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder bufferbuilder = tessellator.getBuffer();
            double ap = 1.0 - ((double) soul.getActionPoints() / soul.getMaxActionPoints());
            int rgbfordisplay = new Color(0f, 0.75f * (1f - (float) ap), 1f).getColor();
            int i = Math.round(13.0F - (float) ap * 13.0F);
            int j = rgbfordisplay;
            draw(bufferbuilder, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
            draw(bufferbuilder, xPosition + 2, yPosition + 13, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255, 255);
            GlStateManager.enableBlend();
            GlStateManager.enableAlpha();
            GlStateManager.enableTexture2D();
            GlStateManager.enableLighting();
            GlStateManager.enableDepth();
        }
    // EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
    // float f3 = entityplayersp == null ? 0.0F
    // : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(),
    // Minecraft.getMinecraft().getRenderPartialTicks());
    // 
    // if (f3 > 0.0F) {
    // GlStateManager.disableLighting();
    // GlStateManager.disableDepth();
    // GlStateManager.disableTexture2D();
    // Tessellator tessellator1 = Tessellator.getInstance();
    // BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
    // this.draw(bufferbuilder1, xPosition, yPosition + MathHelper.floor(16.0F * (1.0F - f3)), 16,
    // MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
    // //        GlStateManager.enableTexture2D();
    // //        GlStateManager.enableLighting();
    // //        GlStateManager.enableDepth();
    // }
    }
}
Also used : ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Color(net.silentchaos512.lib.util.Color)

Example 18 with Soul

use of net.silentchaos512.gems.item.ItemSoulGem.Soul in project SilentGems by SilentChaos512.

the class ItemSoulGem method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack stack) {
    LocalizationHelper loc = SilentGems.localizationHelper;
    Soul soul = getSoul(stack);
    if (soul == null) {
        return getUnlocalizedName(stack);
    }
    if (StackHelper.isValid(soul.matchStack)) {
        return loc.getItemSubText(Names.SOUL_GEM, "name_proper", soul.matchStack.getDisplayName());
    } else {
        String name = "entity." + soul.id + ".name";
        name = loc.getLocalizedString(name);
        return loc.getItemSubText(Names.SOUL_GEM, "name_proper", name);
    }
}
Also used : LocalizationHelper(net.silentchaos512.lib.util.LocalizationHelper)

Example 19 with Soul

use of net.silentchaos512.gems.item.ItemSoulGem.Soul in project SilentGems by SilentChaos512.

the class ItemSkillOrb method clOnItemRightClick.

@Override
protected ActionResult<ItemStack> clOnItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack offhand = player.getHeldItemOffhand();
    // Orb in main hand, tool/armor in offhand.
    if (hand != EnumHand.MAIN_HAND || StackHelper.isEmpty(offhand) || !(offhand.getItem() instanceof ITool || offhand.getItem() instanceof IArmor)) {
        return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
    }
    ItemStack orb = player.getHeldItemMainhand();
    // Check for tool soul.
    ToolSoul soul = SoulManager.getSoul(offhand);
    if (soul == null) {
        if (!world.isRemote) {
            ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "no_soul"));
        }
        return new ActionResult<ItemStack>(EnumActionResult.PASS, orb);
    }
    // Check skill on orb.
    SoulSkill skill = getSkill(orb);
    if (skill == null) {
        if (!world.isRemote) {
            ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "no_skill"));
        }
        return new ActionResult<ItemStack>(EnumActionResult.PASS, orb);
    }
    if (world.isRemote) {
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
    }
    // Try to add or level up the skill.
    if (soul.addOrLevelSkill(skill, offhand, player)) {
        ToolHelper.recalculateStats(offhand);
        StackHelper.shrink(orb, 1);
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, orb);
    } else {
        ChatHelper.sendMessage(player, SilentGems.localizationHelper.getItemSubText(Names.SKILL_ORB, "max_level"));
        return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
    }
}
Also used : ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) SoulSkill(net.silentchaos512.gems.lib.soul.SoulSkill) ItemStack(net.minecraft.item.ItemStack) ITool(net.silentchaos512.gems.api.ITool) IArmor(net.silentchaos512.gems.api.IArmor)

Example 20 with Soul

use of net.silentchaos512.gems.item.ItemSoulGem.Soul in project SilentGems by SilentChaos512.

the class MessageSoulSync method handleMessage.

@Override
@SideOnly(Side.CLIENT)
public IMessage handleMessage(MessageContext context) {
    ClientTickHandler.scheduledActions.add(() -> {
        UUID uuid = new UUID(uuidMost, uuidLeast);
        ToolSoul soul = SoulManager.getSoulByUuid(uuid);
        if (soul != null) {
            soul.setXp(xp);
            soul.setLevel(level);
            soul.setActionPoints(ap);
            if (skillLearned != null && !skillLearned.isEmpty()) {
                SoulSkill skill = SoulSkill.getById(skillLearned);
                soul.setSkillLevel(skill, skillLevel, StackHelper.empty(), Minecraft.getMinecraft().player);
            }
        }
    });
    return null;
}
Also used : ToolSoul(net.silentchaos512.gems.lib.soul.ToolSoul) SoulSkill(net.silentchaos512.gems.lib.soul.SoulSkill) UUID(java.util.UUID) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ToolSoul (net.silentchaos512.gems.lib.soul.ToolSoul)22 ItemStack (net.minecraft.item.ItemStack)11 IArmor (net.silentchaos512.gems.api.IArmor)5 ITool (net.silentchaos512.gems.api.ITool)5 UUID (java.util.UUID)4 IBlockState (net.minecraft.block.state.IBlockState)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ItemToolSoul (net.silentchaos512.gems.item.ItemToolSoul)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 EnumMaterialGrade (net.silentchaos512.gems.api.lib.EnumMaterialGrade)3 ToolPart (net.silentchaos512.gems.api.tool.part.ToolPart)3 Soul (net.silentchaos512.gems.item.ItemSoulGem.Soul)3 SoulSkill (net.silentchaos512.gems.lib.soul.SoulSkill)3 LinkedHashMap (java.util.LinkedHashMap)2 Block (net.minecraft.block.Block)2 Item (net.minecraft.item.Item)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 EnumActionResult (net.minecraft.util.EnumActionResult)2 TextFormatting (net.minecraft.util.text.TextFormatting)2 ToolStats (net.silentchaos512.gems.api.tool.ToolStats)2