Search in sources :

Example 6 with ReagentStack

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack in project BloodMagic by WayofTime.

the class AlchemicalWizardry method initReagentRegistries.

public static void initReagentRegistries() {
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.sanctus), new ReagentStack(ReagentRegistry.sanctusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.incendium), new ReagentStack(ReagentRegistry.incendiumReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aquasalus), new ReagentStack(ReagentRegistry.aquasalusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.magicales), new ReagentStack(ReagentRegistry.magicalesReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aether), new ReagentStack(ReagentRegistry.aetherReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crepitous), new ReagentStack(ReagentRegistry.crepitousReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crystallos), new ReagentStack(ReagentRegistry.crystallosReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.terrae), new ReagentStack(ReagentRegistry.terraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.tennebrae), new ReagentStack(ReagentRegistry.tenebraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 0), new ReagentStack(ReagentRegistry.offensaReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 1), new ReagentStack(ReagentRegistry.praesidiumReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 2), new ReagentStack(ReagentRegistry.orbisTerraeReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 6), new ReagentStack(ReagentRegistry.virtusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 7), new ReagentStack(ReagentRegistry.reductusReagent, 1000));
    ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 8), new ReagentStack(ReagentRegistry.potentiaReagent, 1000));
    OmegaRegistry.registerParadigm(ReagentRegistry.aquasalusReagent, new OmegaParadigmWater((OmegaArmour) ModItems.boundHelmetWater, (OmegaArmour) ModItems.boundPlateWater, (OmegaArmour) ModItems.boundLeggingsWater, (OmegaArmour) ModItems.boundBootsWater));
    OmegaRegistry.registerParadigm(ReagentRegistry.terraeReagent, new OmegaParadigmEarth((OmegaArmour) ModItems.boundHelmetEarth, (OmegaArmour) ModItems.boundPlateEarth, (OmegaArmour) ModItems.boundLeggingsEarth, (OmegaArmour) ModItems.boundBootsEarth));
    OmegaRegistry.registerParadigm(ReagentRegistry.aetherReagent, new OmegaParadigmWind((OmegaArmour) ModItems.boundHelmetWind, (OmegaArmour) ModItems.boundPlateWind, (OmegaArmour) ModItems.boundLeggingsWind, (OmegaArmour) ModItems.boundBootsWind));
    OmegaRegistry.registerParadigm(ReagentRegistry.incendiumReagent, new OmegaParadigmFire((OmegaArmour) ModItems.boundHelmetFire, (OmegaArmour) ModItems.boundPlateFire, (OmegaArmour) ModItems.boundLeggingsFire, (OmegaArmour) ModItems.boundBootsFire));
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) OmegaParadigmWind(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWind) OmegaParadigmWater(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWater) OmegaParadigmEarth(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmEarth) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ItemStack(net.minecraft.item.ItemStack) OmegaParadigmFire(WayofTime.alchemicalWizardry.common.omega.OmegaParadigmFire)

Example 7 with ReagentStack

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack in project BloodMagic by WayofTime.

the class RitualEffectOmegaTest method performEffect.

@Override
public void performEffect(IMasterRitualStone ritualStone) {
    String owner = ritualStone.getOwner();
    int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
    World world = ritualStone.getWorld();
    int x = ritualStone.getXCoord();
    int y = ritualStone.getYCoord();
    int z = ritualStone.getZCoord();
    if (world.getWorldTime() % 200 != 0) {
        return;
    }
    OmegaStructureParameters param = OmegaStructureHandler.getStructureStabilityFactor(world, x, y, z, 5, new Int3(0, 1, 0));
    int stab = param.stability;
    int enchantability = param.enchantability;
    int enchantmentLevel = param.enchantmentLevel;
    if (stab <= 0) {
        return;
    }
    // System.out.println("Stability: " + stab + ", Enchantability: " + enchantability + ", Enchantment Level: " + enchantmentLevel);
    double range = 0.5;
    List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 1.5, z + 0.5, range, range);
    Reagent reagent = null;
    Map<Reagent, Integer> reagentMap = new HashMap();
    for (int i = 0; i < 4; i++) {
        Int3 jarLoc = this.getJarLocation(i);
        TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
        if (tile instanceof IReagentHandler) {
            IReagentHandler container = (IReagentHandler) tile;
            ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP);
            if (containerInfoArray == null) {
                continue;
            }
            for (ReagentContainerInfo containerInfo : containerInfoArray) {
                ReagentStack containedReagent = containerInfo.reagent;
                if (containedReagent == null) {
                    continue;
                }
                Reagent rea = containedReagent.reagent;
                int amt = containedReagent.amount;
                if (reagentMap.containsKey(rea)) {
                    reagentMap.put(rea, reagentMap.get(rea) + amt);
                } else {
                    reagentMap.put(rea, amt);
                }
            }
        }
    }
    for (Entry<Reagent, Integer> entry : reagentMap.entrySet()) {
        if (entry.getValue() >= drainTotal) {
            reagent = entry.getKey();
            break;
        }
    }
    if (reagent == null) {
        return;
    }
    int tickDuration = isTesting ? 20 * 30 : 15 * 20 * 60 + (int) ((15 * 20 * 60) * Math.sqrt(stab / 700));
    int affinity = 0;
    for (EntityPlayer player : playerList) {
        OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent);
        if (waterParadigm != null && waterParadigm.convertPlayerArmour(player, x, y, z, stab, affinity, enchantability, enchantmentLevel)) {
            APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration);
            APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration);
            APISpellHelper.setPlayerReagentType(player, reagent);
            APISpellHelper.setCurrentAdditionalMaxHP(player, waterParadigm.getMaxAdditionalHealth());
            NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(reagent, APISpellHelper.getPlayerCurrentReagentAmount(player), APISpellHelper.getPlayerMaxReagentAmount(player)), (EntityPlayerMP) player);
            if (!isTesting) {
                int drainLeft = this.drainTotal;
                for (int i = 0; i < 4; i++) {
                    if (drainLeft <= 0) {
                        break;
                    }
                    Int3 jarLoc = this.getJarLocation(i);
                    TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
                    if (tile instanceof IReagentHandler) {
                        IReagentHandler container = (IReagentHandler) tile;
                        ReagentStack drained = container.drain(ForgeDirection.UP, new ReagentStack(reagent, drainLeft), true);
                        if (drained != null) {
                            drainLeft -= drained.amount;
                            world.markBlockForUpdate(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord);
                            world.addWeatherEffect(new EntityLightningBolt(world, x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord));
                        }
                    }
                }
                ritualStone.setActive(false);
            }
            break;
        }
    }
}
Also used : HashMap(java.util.HashMap) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) Int3(WayofTime.alchemicalWizardry.api.Int3) OmegaStructureParameters(WayofTime.alchemicalWizardry.common.omega.OmegaStructureParameters) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) IReagentHandler(WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) OmegaParadigm(WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)

Example 8 with ReagentStack

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack in project BloodMagic by WayofTime.

the class TEMasterStone method drain.

@Override
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain) {
    if (resource == null) {
        return null;
    }
    if (doDrain) {
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
    int maxDrain = resource.amount;
    Reagent reagent = resource.reagent;
    int drained = 0;
    for (int i = 0; i < tanks.length; i++) {
        if (drained >= maxDrain) {
            break;
        }
        if (resource.isReagentEqual(tanks[i].getReagent())) {
            ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
            if (drainStack != null) {
                drained += drainStack.amount;
            }
        }
    }
    return new ReagentStack(reagent, drained);
}
Also used : ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 9 with ReagentStack

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack in project BloodMagic by WayofTime.

the class TEMasterStone method fill.

/* ISegmentedReagentHandler */
@Override
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) {
    if (doFill) {
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
    int totalFill = 0;
    boolean useTankLimit = !this.attunedTankMap.isEmpty();
    if (resource != null) {
        int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length;
        int tanksFilled = 0;
        int maxFill = resource.amount;
        for (int i = this.tanks.length - 1; i >= 0; i--) {
            ReagentStack remainingStack = resource.copy();
            remainingStack.amount = maxFill - totalFill;
            boolean doesReagentMatch = tanks[i].getReagent() != null && tanks[i].getReagent().isReagentEqual(remainingStack);
            if (doesReagentMatch) {
                totalFill += tanks[i].fill(remainingStack, doFill);
                tanksFilled++;
            } else {
                continue;
            }
            if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) {
                return totalFill;
            }
        }
        if (tanksFilled >= totalTanksFillable) {
            return totalFill;
        }
        for (int i = this.tanks.length - 1; i >= 0; i--) {
            ReagentStack remainingStack = resource.copy();
            remainingStack.amount = maxFill - totalFill;
            boolean isTankEmpty = tanks[i].getReagent() == null;
            if (isTankEmpty) {
                totalFill += tanks[i].fill(remainingStack, doFill);
                tanksFilled++;
            } else {
                continue;
            }
            if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) {
                return totalFill;
            }
        }
    }
    return totalFill;
}
Also used : ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)

Example 10 with ReagentStack

use of WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack in project BloodMagic by WayofTime.

the class TEAlchemicCalcinator method tickProgress.

public void tickProgress() {
    int lpPerTick = 10;
    int ticksPerReagent = 200;
    ItemStack reagentItemStack = this.getStackInSlot(1);
    if (reagentItemStack == null) {
        progress = 0;
        return;
    }
    ReagentStack possibleReagent = ReagentRegistry.getReagentStackForItem(reagentItemStack);
    if (possibleReagent == null || !this.canReagentFitBuffer(possibleReagent)) {
        return;
    }
    ItemStack orbStack = this.getStackInSlot(0);
    if (orbStack == null || !(orbStack.getItem() instanceof IBloodOrb)) {
        return;
    }
    if (!SoulNetworkHandler.canSyphonFromOnlyNetwork(orbStack, lpPerTick)) {
        SoulNetworkHandler.causeNauseaToPlayer(orbStack);
        return;
    }
    if (!SoulNetworkHandler.syphonFromNetworkWhileInContainer(orbStack, lpPerTick)) {
        return;
    }
    progress++;
    if (worldObj.getWorldTime() % 4 == 0) {
        SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
    }
    if (progress >= ticksPerReagent) {
        progress = 0;
        this.bufferTank.fill(possibleReagent, true);
        this.decrStackSize(1, 1);
    }
}
Also used : IBloodOrb(WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ReagentStack (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)12 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)5 ReagentContainerInfo (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo)4 ItemStack (net.minecraft.item.ItemStack)3 OmegaArmour (WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Int3 (WayofTime.alchemicalWizardry.api.Int3)1 IReagentHandler (WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler)1 ReagentContainer (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)1 IBloodOrb (WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb)1 OmegaParadigm (WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)1 OmegaParadigmEarth (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmEarth)1 OmegaParadigmFire (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmFire)1 OmegaParadigmWater (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWater)1 OmegaParadigmWind (WayofTime.alchemicalWizardry.common.omega.OmegaParadigmWind)1 OmegaStructureParameters (WayofTime.alchemicalWizardry.common.omega.OmegaStructureParameters)1 TEAlchemicCalcinator (WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator)1 TEBellJar (WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar)1 HashMap (java.util.HashMap)1