Search in sources :

Example 6 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class BlockAltar method getComparatorInputOverride.

@Override
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
    if (world.isRemote)
        return 0;
    TileEntity tile = world.getTileEntity(pos);
    if (tile != null && tile instanceof TileAltar) {
        TileAltar altar = (TileAltar) tile;
        ItemStack orbStack = altar.getStackInSlot(0);
        if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) {
            if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) {
                BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
                Binding binding = ((IBindable) orbStack.getItem()).getBinding(orbStack);
                if (orb != null && binding != null) {
                    SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(binding);
                    int maxEssence = orb.getCapacity();
                    int currentEssence = soulNetwork.getCurrentEssence();
                    int level = currentEssence * 15 / maxEssence;
                    return Math.min(15, level) % 16;
                }
            }
        } else {
            int maxEssence = altar.getCapacity();
            int currentEssence = altar.getCurrentBlood();
            int level = currentEssence * 15 / maxEssence;
            return Math.min(15, level) % 16;
        }
    }
    return 0;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Binding(WayofTime.bloodmagic.core.data.Binding) IBindable(WayofTime.bloodmagic.iface.IBindable) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) ItemStack(net.minecraft.item.ItemStack) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Example 7 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class Elements method createHUDElements.

public static void createHUDElements() {
    new HUDElementHolding();
    new HUDElementDemonWillAura();
    // Blood Altar with Divination Sigil
    new HUDElementCornerTile.DivinedView<TileAltar>(TileAltar.class, true) {

        @Override
        protected void addInformation(List<Pair<Sprite, Function<TileAltar, String>>> information) {
            // Current tier
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> NumeralHelper.toRoman(altar.getTier().toInt())));
            // Stored/Capacity
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity())));
        }
    };
    // Blood Altar with Seers Sigil
    new HUDElementCornerTile.DivinedView<TileAltar>(TileAltar.class, false) {

        @Override
        protected void addInformation(List<Pair<Sprite, Function<TileAltar, String>>> information) {
            // Current tier
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 0, 46, 16, 16), altar -> NumeralHelper.toRoman(altar.getTier().toInt())));
            // Stored/Capacity
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 16, 46, 16, 16), altar -> String.format("%d/%d", altar.getCurrentBlood(), altar.getCapacity())));
            // Crafting progress/Crafting requirement
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 32, 46, 16, 16), altar -> {
                if (!altar.isActive())
                    // FIXME localize
                    return "Inactive";
                int progress = altar.getProgress();
                int totalLiquidRequired = altar.getLiquidRequired() * altar.getStackInSlot(0).getCount();
                return String.format("%d/%d", progress, totalLiquidRequired);
            }));
            // Consumption rate
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 48, 46, 16, 16), altar -> String.valueOf((int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1)))));
            // Total charge
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 64, 46, 16, 16), altar -> String.valueOf(altar.getTotalCharge())));
        }
    };
    // Incense Altar
    new HUDElementCornerTile.DivinedView<TileIncenseAltar>(TileIncenseAltar.class, true) {

        @Override
        protected void addInformation(List<Pair<Sprite, Function<TileIncenseAltar, String>>> information) {
            // Current tranquility
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 80, 46, 16, 16), incense -> String.valueOf((int) ((100D * (int) (100 * incense.tranquility)) / 100D))));
            // Sacrifice bonus
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 96, 46, 16, 16), incense -> String.valueOf((int) (100 * incense.incenseAddition))));
        }
    };
    // Inversion Pillar
    new HUDElementCornerTile.DivinedView<TileInversionPillar>(TileInversionPillar.class, true) {

        @Override
        protected void addInformation(List<Pair<Sprite, Function<TileInversionPillar, String>>> information) {
            // Current inversion
            information.add(Pair.of(new Sprite(new ResourceLocation(BloodMagic.MODID, "textures/gui/widgets.png"), 112, 46, 16, 16), pillar -> String.valueOf(((int) (10 * pillar.getCurrentInversion())) / 10D)));
        }
    };
}
Also used : Sprite(WayofTime.bloodmagic.client.Sprite) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) BloodMagic(WayofTime.bloodmagic.BloodMagic) TileIncenseAltar(WayofTime.bloodmagic.tile.TileIncenseAltar) TileInversionPillar(WayofTime.bloodmagic.tile.TileInversionPillar) ResourceLocation(net.minecraft.util.ResourceLocation) TileAltar(WayofTime.bloodmagic.tile.TileAltar) NumeralHelper(WayofTime.bloodmagic.util.helper.NumeralHelper) Function(java.util.function.Function) Function(java.util.function.Function) Sprite(WayofTime.bloodmagic.client.Sprite) ResourceLocation(net.minecraft.util.ResourceLocation) List(java.util.List)

Example 8 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class RitualWellOfSuffering 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 pos = masterRitualStone.getBlockPos();
    int maxEffects = currentEssence / getRefreshCost();
    int totalEffects = 0;
    BlockPos altarPos = pos.add(altarOffsetPos);
    TileEntity tile = world.getTileEntity(altarPos);
    AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE);
    if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof TileAltar)) {
        for (BlockPos newPos : altarRange.getContainedPositions(pos)) {
            TileEntity nextTile = world.getTileEntity(newPos);
            if (nextTile instanceof TileAltar) {
                tile = nextTile;
                altarOffsetPos = newPos.subtract(pos);
                altarRange.resetCache();
                break;
            }
        }
    }
    if (tile instanceof TileAltar) {
        TileAltar tileAltar = (TileAltar) tile;
        AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE);
        AxisAlignedBB range = damageRange.getAABB(pos);
        List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range);
        for (EntityLivingBase entity : entities) {
            EntityEntry entityEntry = EntityRegistry.getEntry(entity.getClass());
            if (entityEntry == null || BloodMagicAPI.INSTANCE.getBlacklist().getSacrifice().contains(entityEntry.getRegistryName()))
                continue;
            int lifeEssenceRatio = BloodMagicAPI.INSTANCE.getValueManager().getSacrificial().getOrDefault(entityEntry.getRegistryName(), SACRIFICE_AMOUNT);
            if (lifeEssenceRatio <= 0)
                continue;
            if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) {
                if (entity.attackEntityFrom(DamageSource.OUT_OF_WORLD, 1)) {
                    if (entity.isChild())
                        lifeEssenceRatio *= 0.5F;
                    tileAltar.sacrificialDaggerCall(lifeEssenceRatio, true);
                    totalEffects++;
                    if (totalEffects >= maxEffects) {
                        break;
                    }
                }
            }
        }
    }
    masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityEntry(net.minecraftforge.fml.common.registry.EntityEntry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Aggregations

TileAltar (WayofTime.bloodmagic.tile.TileAltar)8 TileEntity (net.minecraft.tileentity.TileEntity)5 ItemStack (net.minecraft.item.ItemStack)4 Nonnull (javax.annotation.Nonnull)2 BlockPos (net.minecraft.util.math.BlockPos)2 BloodMagic (WayofTime.bloodmagic.BloodMagic)1 Sprite (WayofTime.bloodmagic.client.Sprite)1 Binding (WayofTime.bloodmagic.core.data.Binding)1 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 SacrificeKnifeUsedEvent (WayofTime.bloodmagic.event.SacrificeKnifeUsedEvent)1 IAltarReader (WayofTime.bloodmagic.iface.IAltarReader)1 IBindable (WayofTime.bloodmagic.iface.IBindable)1 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)1 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)1 TileIncenseAltar (WayofTime.bloodmagic.tile.TileIncenseAltar)1 TileInversionPillar (WayofTime.bloodmagic.tile.TileInversionPillar)1 NumeralHelper (WayofTime.bloodmagic.util.helper.NumeralHelper)1 List (java.util.List)1 Function (java.util.function.Function)1 IBlockState (net.minecraft.block.state.IBlockState)1