Search in sources :

Example 6 with Binding

use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.

the class BloodAltar method updateAltar.

private void updateAltar() {
    if (!isActive) {
        if (cooldownAfterCrafting > 0)
            cooldownAfterCrafting--;
        return;
    }
    ItemStack input = tileAltar.getStackInSlot(0);
    if (input.isEmpty())
        return;
    World world = tileAltar.getWorld();
    BlockPos pos = tileAltar.getPos();
    if (world.isRemote)
        return;
    if (!canBeFilled) {
        boolean hasOperated = false;
        int stackSize = input.getCount();
        if (totalCharge > 0) {
            int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
            totalCharge -= chargeDrained;
            progress += chargeDrained;
            hasOperated = true;
        }
        if (fluid != null && fluid.amount >= 1) {
            int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
            if (liquidDrained > (liquidRequired * stackSize - progress))
                liquidDrained = liquidRequired * stackSize - progress;
            fluid.amount = fluid.amount - liquidDrained;
            progress += liquidDrained;
            hasOperated = true;
            if (internalCounter % 4 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.2, 0, 0.2, 0);
            }
        } else if (!hasOperated && progress > 0) {
            progress -= (int) (efficiencyMultiplier * drainRate);
            if (internalCounter % 2 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0, 0.1, 0);
            }
        }
        if (hasOperated) {
            if (progress >= liquidRequired * stackSize) {
                ItemStack result = ItemHandlerHelper.copyStackWithSize(recipe.getOutput(), stackSize);
                BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(recipe.getInput(), result);
                MinecraftForge.EVENT_BUS.post(event);
                tileAltar.setInventorySlotContents(0, event.getOutput());
                progress = 0;
                if (world instanceof WorldServer) {
                    WorldServer server = (WorldServer) world;
                    server.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
                }
                this.cooldownAfterCrafting = 30;
                this.isActive = false;
            }
        }
    } else {
        ItemStack contained = tileAltar.getStackInSlot(0);
        if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb) || !(contained.getItem() instanceof IBindable))
            return;
        BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
        Binding binding = ((IBindable) contained.getItem()).getBinding(contained);
        if (binding == null || orb == null)
            return;
        if (fluid != null && fluid.amount >= 1) {
            int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount);
            int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier));
            fluid.amount = fluid.amount - drain;
            if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) {
                WorldServer server = (WorldServer) world;
                server.spawnParticle(EnumParticleTypes.SPELL_WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.001);
            }
        }
    }
    tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) IBindable(WayofTime.bloodmagic.iface.IBindable) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) BloodOrb(WayofTime.bloodmagic.orb.BloodOrb) IBloodOrb(WayofTime.bloodmagic.orb.IBloodOrb) WorldServer(net.minecraft.world.WorldServer) BloodMagicCraftedEvent(WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) RecipeBloodAltar(WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Example 7 with Binding

use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.

the class ItemSigilBase method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    if (TextHelper.canTranslate(tooltipBase + "desc"))
        tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc"))));
    if (!stack.hasTagCompound())
        return;
    Binding binding = getBinding(stack);
    if (binding != null)
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
    super.addInformation(stack, world, tooltip, flag);
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Binding

use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.

the class ItemTelepositionFocus method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.bloodmagic.telepositionFocus." + getItemType(stack).getInternalName()))));
    super.addInformation(stack, world, tooltip, flag);
    Binding binding = getBinding(stack);
    if (binding != null)
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
    if (!stack.hasTagCompound())
        return;
    NBTTagCompound tag = stack.getTagCompound();
    BlockPos coords = getBlockPos(stack);
    if (coords != null && tag != null) {
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ()));
        tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", tag.getInteger(Constants.NBT.DIMENSION_ID)));
    }
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with Binding

use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.

the class TileMasterRitualStone method activateRitual.

@Override
public boolean activateRitual(ItemStack activationCrystal, @Nullable EntityPlayer activator, Ritual ritual) {
    if (PlayerHelper.isFakePlayer(activator))
        return false;
    Binding binding = ((IBindable) activationCrystal.getItem()).getBinding(activationCrystal);
    if (binding != null && ritual != null) {
        if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
            int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
            if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
                if (!getWorld().isRemote) {
                    SoulNetwork network = NetworkHelper.getSoulNetwork(binding);
                    if (!isRedstoned() && network.getCurrentEssence() < ritual.getActivationCost() && (activator != null && !activator.capabilities.isCreativeMode)) {
                        activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.weak"), true);
                        return false;
                    }
                    if (currentRitual != null)
                        currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
                    RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, binding.getOwnerId(), ritual, activator, activationCrystal, crystalLevel);
                    if (MinecraftForge.EVENT_BUS.post(event)) {
                        if (activator != null)
                            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.prevent"), true);
                        return false;
                    }
                    if (ritual.activateRitual(this, activator, binding.getOwnerId())) {
                        if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode))
                            network.syphon(ritual.getActivationCost());
                        if (activator != null)
                            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true);
                        this.active = true;
                        this.owner = binding.getOwnerId();
                        this.cachedNetwork = network;
                        this.currentRitual = ritual;
                        notifyUpdate();
                        return true;
                    }
                }
                notifyUpdate();
                return true;
            }
        }
    } else {
        if (activator != null)
            activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.notValid"), true);
    }
    return false;
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) RitualEvent(WayofTime.bloodmagic.event.RitualEvent) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBindable(WayofTime.bloodmagic.iface.IBindable) SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) ItemActivationCrystal(WayofTime.bloodmagic.item.ItemActivationCrystal)

Example 10 with Binding

use of WayofTime.bloodmagic.core.data.Binding in project BloodMagic by WayofTime.

the class TileMasterRitualStone method onUpdate.

@Override
public void onUpdate() {
    if (getWorld().isRemote)
        return;
    if (isPowered() && isActive()) {
        active = false;
        redstoned = true;
        stopRitual(Ritual.BreakType.REDSTONE);
        return;
    }
    if (!isActive() && !isPowered() && isRedstoned() && getCurrentRitual() != null) {
        active = true;
        ItemStack crystalStack = NBTHelper.checkNBT(new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL, 1, getCurrentRitual().getCrystalLevel()));
        BindableHelper.applyBinding(crystalStack, new Binding(owner, PlayerHelper.getUsernameFromUUID(owner)));
        activateRitual(crystalStack, null, getCurrentRitual());
        redstoned = false;
    }
    if (getCurrentRitual() != null && isActive()) {
        if (activeTime % getCurrentRitual().getRefreshTime() == 0)
            performRitual(getWorld(), getPos());
        activeTime++;
    }
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) ItemStack(net.minecraft.item.ItemStack)

Aggregations

Binding (WayofTime.bloodmagic.core.data.Binding)23 ItemStack (net.minecraft.item.ItemStack)11 IBindable (WayofTime.bloodmagic.iface.IBindable)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)6 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)4 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 BlockPos (net.minecraft.util.math.BlockPos)4 TileEntity (net.minecraft.tileentity.TileEntity)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 World (net.minecraft.world.World)3 TileAltar (WayofTime.bloodmagic.tile.TileAltar)2 BloodMagicCraftedEvent (WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent)1 RecipeBloodAltar (WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar)1 BlockTeleposer (WayofTime.bloodmagic.block.BlockTeleposer)1 ItemBindEvent (WayofTime.bloodmagic.event.ItemBindEvent)1 RitualEvent (WayofTime.bloodmagic.event.RitualEvent)1 SoulNetworkEvent (WayofTime.bloodmagic.event.SoulNetworkEvent)1 TeleposeEvent (WayofTime.bloodmagic.event.TeleposeEvent)1