Search in sources :

Example 16 with LivingArmourUpgrade

use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade in project BloodMagic by WayofTime.

the class ItemLivingArmour method onArmorTick.

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    super.onArmorTick(world, player, stack);
    if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        if (// Sanity check
        player instanceof EntityPlayerSP) {
            EntityPlayerSP spPlayer = (EntityPlayerSP) player;
            if (FLAGS == null) {
                try {
                    FLAGS = (DataParameter<Byte>) _FLAGS.get(null);
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
            if (FLAGS != null) {
                if (LivingArmour.hasFullSet(player)) {
                    ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
                    LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.elytra", chestStack);
                    if (upgrade instanceof LivingArmourUpgradeElytra) {
                        if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) {
                            if (spPlayer.motionY > -0.5D) {
                                BloodMagicPacketHandler.INSTANCE.sendToServer(new PlayerFallDistancePacketProcessor(1));
                            }
                            if (!spPlayer.isElytraFlying()) {
                                byte b0 = player.getDataManager().get(FLAGS);
                                player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7));
                            }
                        } else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) {
                            byte b0 = player.getDataManager().get(FLAGS);
                            player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7)));
                        }
                    }
                }
            }
        }
    }
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        if (!hasLivingArmour(stack)) {
            setLivingArmour(stack, getLivingArmourFromStack(stack));
        }
        LivingArmour armour = getLivingArmour(stack);
        if (LivingArmour.hasFullSet(player)) {
            this.setIsEnabled(stack, true);
            armour.onTick(world, player);
        }
        setLivingArmour(stack, armour, false);
    }
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) LivingArmourUpgradeElytra(WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra) PlayerFallDistancePacketProcessor(WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack)

Example 17 with LivingArmourUpgrade

use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade in project BloodMagic by WayofTime.

the class ItemLivingArmour method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    if (!stack.hasTagCompound())
        return;
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        LivingArmour armour = getLivingArmourFromStack(stack);
        for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
            LivingArmourUpgrade upgrade = entry.getValue();
            if (upgrade != null) {
                if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) {
                    StatTracker tracker = null;
                    for (StatTracker searchTracker : armour.trackerMap.values()) {
                        if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) {
                            tracker = searchTracker;
                            break;
                        }
                    }
                    if (tracker != null) {
                        double progress = tracker.getProgress(armour, upgrade.getUpgradeLevel());
                        tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp((int) (progress * 100D), 0, 100)));
                    }
                } else {
                    tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
                }
            }
        }
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.points", armour.totalUpgradePoints, armour.maxUpgradePoints));
        if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) {
            tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.extraExtraInfo"));
        }
    }
    super.addInformation(stack, world, tooltip, flag);
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) StatTracker(WayofTime.bloodmagic.livingArmour.StatTracker) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 18 with LivingArmourUpgrade

use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade in project BloodMagic by WayofTime.

the class ItemLivingArmour method getProperties.

@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
    double armourReduction = 0.0;
    double damageAmount = 0.25;
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) {
        damageAmount = 3d / 20d * 0.6;
    } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGGINGS) {
        damageAmount = 6d / 20d * 0.6;
    } else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        damageAmount = 0.64;
    }
    double armourPenetrationReduction = 0;
    int maxAbsorption = 100000;
    if (source.equals(DamageSource.DROWN)) {
        return new ArmorProperties(-1, 0, 0);
    }
    if (source.equals(DamageSource.OUT_OF_WORLD)) {
        return new ArmorProperties(-1, 0, 0);
    }
    if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
        // This values puts it at iron level
        armourReduction = 0.24 / 0.64;
        ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
        ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
        ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
        if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) {
            damageAmount *= (armourReduction);
            return new ArmorProperties(-1, damageAmount, maxAbsorption);
        }
        if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour) {
            // Multiply this number by the armour upgrades for protection
            double remainder = 1;
            if (hasLivingArmour(stack)) {
                LivingArmour armour = getLivingArmour(stack);
                if (armour != null && isEnabled(stack)) {
                    for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
                        LivingArmourUpgrade upgrade = entry.getValue();
                        remainder *= (1 - upgrade.getArmourProtection(player, source));
                    }
                }
            }
            armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
            damageAmount *= (armourReduction);
            return new ArmorProperties(-1, source.isUnblockable() ? 1 - remainder : damageAmount, maxAbsorption);
        }
    } else {
        if (source.isUnblockable()) {
            return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
        }
        return new ArmorProperties(-1, damageAmount, maxAbsorption);
    }
    return new ArmorProperties(-1, 0, 0);
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) ItemStack(net.minecraft.item.ItemStack)

Example 19 with LivingArmourUpgrade

use of WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade in project BloodMagic by WayofTime.

the class RitualLivingArmourDowngrade method performRitual.

@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
    World world = masterRitualStone.getWorldObj();
    int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
    if (currentEssence < getRefreshCost()) {
        masterRitualStone.getOwnerNetwork().causeNausea();
        return;
    }
    BlockPos masterPos = masterRitualStone.getBlockPos();
    AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE);
    boolean isActivatorPresent = false;
    for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) {
        if (player.getGameProfile().getId().equals(masterRitualStone.getOwner())) {
            ItemStack keyStack = getStackFromItemFrame(world, masterPos, masterRitualStone.getDirection());
            if (keyStack.isEmpty()) {
                return;
            }
            List<ITextComponent> textList = LivingArmourDowngradeRecipeRegistry.getDialogForProcessTick(keyStack, internalTimer);
            if (textList != null) {
                ChatUtil.sendChat(player, textList.toArray(new ITextComponent[textList.size()]));
            }
            internalTimer++;
            if (player.isSneaking()) {
                double distance2 = masterPos.offset(EnumFacing.UP).distanceSqToCenter(player.posX, player.posY, player.posZ);
                if (distance2 > 1) {
                    return;
                }
                BlockPos chestPos = masterPos.offset(masterRitualStone.getDirection(), 2).offset(EnumFacing.UP);
                TileEntity tile = world.getTileEntity(chestPos);
                if (tile == null) {
                    return;
                }
                IItemHandler inv = Utils.getInventory(tile, null);
                if (inv != null) {
                    List<ItemStack> recipeList = new ArrayList<>();
                    for (int i = 0; i < inv.getSlots(); i++) {
                        ItemStack invStack = inv.getStackInSlot(i);
                        if (!invStack.isEmpty()) {
                            recipeList.add(invStack);
                        }
                    }
                    LivingArmourDowngradeRecipe recipe = LivingArmourDowngradeRecipeRegistry.getMatchingRecipe(keyStack, recipeList, world, masterPos);
                    if (recipe != null) {
                        LivingArmourUpgrade upgrade = recipe.getRecipeOutput();
                        if (LivingArmour.hasFullSet(player)) {
                            ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
                            LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
                            if (armour != null) {
                                if (armour.canApplyUpgrade(player, upgrade)) {
                                    if (armour.upgradeArmour(player, upgrade)) {
                                        ItemLivingArmour.setLivingArmour(chestStack, armour);
                                        recipe.consumeInventory(inv);
                                        EntityLightningBolt lightning = new EntityLightningBolt(world, chestPos.getX(), chestPos.getY(), chestPos.getZ(), true);
                                        world.spawnEntity(lightning);
                                        masterRitualStone.setActive(false);
                                    }
                                } else {
                                // TODO: You are not able to receive my blessing...
                                // TODO: Need to add a timer that will stop it from working.
                                }
                            }
                        }
                    }
                }
            }
            return;
        }
    }
    if (!isActivatorPresent) {
        internalTimer = 0;
    }
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) LivingArmourDowngradeRecipe(WayofTime.bloodmagic.recipe.LivingArmourDowngradeRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)19 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)18 ItemStack (net.minecraft.item.ItemStack)18 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)12 World (net.minecraft.world.World)4 BlockPos (net.minecraft.util.math.BlockPos)3 StatTracker (WayofTime.bloodmagic.livingArmour.StatTracker)2 StatTrackerGrimReaperSprint (WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint)2 LivingArmourUpgradeSelfSacrifice (WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice)2 ArrayList (java.util.ArrayList)2 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)2 EntityArrow (net.minecraft.entity.projectile.EntityArrow)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IBloodAltar (WayofTime.bloodmagic.altar.IBloodAltar)1 IUpgradeTrainer (WayofTime.bloodmagic.iface.IUpgradeTrainer)1 ItemPackSacrifice (WayofTime.bloodmagic.item.gear.ItemPackSacrifice)1 LivingArmourUpgradeBattleHungry (WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeBattleHungry)1 LivingArmourUpgradeCrippledArm (WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeCrippledArm)1