Search in sources :

Example 6 with Reagent

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

the class BlockBelljar method getSubBlocks.

@SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
    if (this.equals(ModBlocks.blockCrystalBelljar)) {
        par3List.add(new ItemStack(par1, 1, 0));
        for (Reagent reagent : ReagentRegistry.reagentList.values()) {
            ItemStack stack = new ItemStack(par1, 1, 0);
            NBTTagCompound tag = new NBTTagCompound();
            ReagentContainer[] tanks = new ReagentContainer[1];
            tanks[0] = new ReagentContainer(reagent, 16000, 16000);
            NBTTagList tagList = new NBTTagList();
            NBTTagCompound savedTag = new NBTTagCompound();
            if (tanks[0] != null) {
                tanks[0].writeToNBT(savedTag);
            }
            tagList.appendTag(savedTag);
            tag.setTag("reagentTanks", tagList);
            stack.setTagCompound(tag);
            par3List.add(stack);
        }
    } else {
        super.getSubBlocks(par1, par2CreativeTabs, par3List);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 7 with Reagent

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

the class RitualEffectOmegaStalling 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() % 20 != 0) {
        return;
    }
    TileEntity tile = world.getTileEntity(x, y + 5, z);
    if (tile instanceof TileEntityBeacon) {
        int levels = ((TileEntityBeacon) tile).getLevels();
        if (levels >= 4) {
            int horizontalRadius = 100;
            int verticalRadius = 100;
            List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 0.5, z + 0.5, horizontalRadius, verticalRadius);
            for (EntityPlayer player : playerList) {
                if (SoulNetworkHandler.canSyphonFromOnlyNetwork(owner, getCostPerRefresh())) {
                    Reagent reagent = APISpellHelper.getPlayerReagentType(player);
                    OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
                    if (parad != null) {
                        float costOffset = parad.getCostPerTickOfUse(player);
                        parad.setOmegaStalling(player, 100);
                        SoulNetworkHandler.syphonFromNetwork(owner, (int) (getCostPerRefresh() * Math.min(costOffset, 1)));
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBeacon(net.minecraft.tileentity.TileEntityBeacon) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) OmegaParadigm(WayofTime.alchemicalWizardry.common.omega.OmegaParadigm) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 8 with Reagent

use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent 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 9 with Reagent

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

the class TEMasterStone method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    tag.setBoolean("isActive", isActive);
    tag.setString("owner", owner);
    tag.setInteger("cooldown", cooldown);
    tag.setInteger("var1", var1);
    tag.setInteger("direction", direction);
    tag.setString("currentRitualString", currentRitualString);
    tag.setBoolean("isRunning", isRunning);
    tag.setInteger("runningTime", runningTime);
    NBTTagList tagList = new NBTTagList();
    for (int i = 0; i < this.tanks.length; i++) {
        NBTTagCompound savedTag = new NBTTagCompound();
        if (this.tanks[i] != null) {
            this.tanks[i].writeToNBT(savedTag);
        }
        tagList.appendTag(savedTag);
    }
    tag.setTag("reagentTanks", tagList);
    NBTTagList attunedTagList = new NBTTagList();
    for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet()) {
        NBTTagCompound savedTag = new NBTTagCompound();
        savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
        savedTag.setInteger("amount", entry.getValue());
        attunedTagList.appendTag(savedTag);
    }
    tag.setTag("attunedTankMap", attunedTagList);
    tag.setTag("customRitualTag", customRitualTag);
    if (storage != null) {
        NBTTagCompound localStorageTag = new NBTTagCompound();
        storage.writeToNBT(localStorageTag);
        tag.setTag("localStorage", localStorageTag);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 10 with Reagent

use of WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent 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)

Aggregations

Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)13 ReagentStack (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)5 ReagentContainerInfo (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo)4 OmegaParadigm (WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemStack (net.minecraft.item.ItemStack)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 World (net.minecraft.world.World)3 OmegaArmour (WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Int3 (WayofTime.alchemicalWizardry.api.Int3)1 IReagentHandler (WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler)1 ReagentContainer (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)1 LocalRitualStorage (WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage)1 TEDemonPortal (WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal)1 OmegaStructureParameters (WayofTime.alchemicalWizardry.common.omega.OmegaStructureParameters)1 ReagentRegenConfiguration (WayofTime.alchemicalWizardry.common.omega.ReagentRegenConfiguration)1