Search in sources :

Example 6 with ReagentContainerInfo

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

the class RenderHelper method getHUDElements.

private static List<HUDElement> getHUDElements(Minecraft mc) {
    List<HUDElement> elements = new ArrayList();
    MovingObjectPosition movingobjectposition = mc.objectMouseOver;
    World world = mc.theWorld;
    if (movingobjectposition == null) {
        return elements;
    } else {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            int x = movingobjectposition.blockX;
            int y = movingobjectposition.blockY;
            int z = movingobjectposition.blockZ;
            TileEntity tile = world.getTileEntity(x, y, z);
            if (!(tile instanceof IReagentHandler)) {
                return elements;
            }
            IReagentHandler relay = (IReagentHandler) tile;
            ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.getOrientation(movingobjectposition.sideHit));
            if (infos != null) {
                for (ReagentContainerInfo info : infos) {
                    if (info == null || info.reagent == null || info.reagent.reagent == null) {
                        continue;
                    }
                    ItemStack itemStack = ReagentRegistry.getItemForReagent(info.reagent.reagent);
                    if (itemStack != null)
                        elements.add(new HUDElement(itemStack, 16, 16, 2, info.reagent.amount));
                }
            }
        }
    }
    return elements;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) ArrayList(java.util.ArrayList) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) IReagentHandler(WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler)

Example 7 with ReagentContainerInfo

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

the class SigilDivination method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
    if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer.worldObj.isRemote) {
        return par1ItemStack;
    }
    if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 0)) {
        return par1ItemStack;
    }
    NBTTagCompound itemTag = par1ItemStack.getTagCompound();
    if (itemTag == null || itemTag.getString("ownerName").equals("")) {
        return par1ItemStack;
    }
    String ownerName = itemTag.getString("ownerName");
    MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
    if (movingobjectposition == null) {
        par3EntityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.divinationsigil.currentessence") + " " + SoulNetworkHandler.getCurrentEssence(ownerName) + "LP"));
        return par1ItemStack;
    } else {
        if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            int x = movingobjectposition.blockX;
            int y = movingobjectposition.blockY;
            int z = movingobjectposition.blockZ;
            TileEntity tile = par2World.getTileEntity(x, y, z);
            if (!(tile instanceof IReagentHandler)) {
                par3EntityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("message.divinationsigil.currentessence") + " " + SoulNetworkHandler.getCurrentEssence(ownerName) + "LP"));
                return par1ItemStack;
            }
            IReagentHandler relay = (IReagentHandler) tile;
            ReagentContainerInfo[] infoList = relay.getContainerInfo(ForgeDirection.UNKNOWN);
            if (infoList != null) {
                for (ReagentContainerInfo info : infoList) {
                    if (info != null && info.reagent != null && info.reagent.reagent != null) {
                        par3EntityPlayer.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.divinationsigil.reagent") + " " + ReagentRegistry.getKeyForReagent(info.reagent.reagent) + "," + StatCollector.translateToLocal("message.divinationsigil.amount") + " " + info.reagent.amount));
                    }
                }
            }
        }
    }
    return par1ItemStack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ChatComponentText(net.minecraft.util.ChatComponentText) IReagentHandler(WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler)

Aggregations

ReagentContainerInfo (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo)7 Reagent (WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)4 ReagentStack (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack)4 IReagentHandler (WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ItemBlock (net.minecraft.item.ItemBlock)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 World (net.minecraft.world.World)2 Int3 (WayofTime.alchemicalWizardry.api.Int3)1 ReagentContainer (WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)1 OmegaParadigm (WayofTime.alchemicalWizardry.common.omega.OmegaParadigm)1 OmegaStructureParameters (WayofTime.alchemicalWizardry.common.omega.OmegaStructureParameters)1 TEAlchemicCalcinator (WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator)1 TEBellJar (WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1