Search in sources :

Example 1 with ReagentContainerInfo

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

the class RenderAlchemicCalcinator method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) {
    if (tileEntity instanceof TEAlchemicCalcinator) {
        TEAlchemicCalcinator tileAltar = (TEAlchemicCalcinator) tileEntity;
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
        ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/AlchemicalCalcinator.png");
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(test);
        GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        this.modelConduit.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        if (tileAltar.getStackInSlot(1) != null) {
            boolean fancySaved = Minecraft.isFancyGraphicsEnabled();
            Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
            float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(1));
            EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj());
            ghostEntityItem.hoverStart = 0.0F;
            ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(1));
            float displacement = 0.2F;
            if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) {
                GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F);
            } else {
                GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 10.4f / 16.0f, (float) d2 + 0.5F - 0.0625f * 2f);
            }
            GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
            if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) {
                GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F);
            }
            customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
            Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved;
        }
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        if (tileAltar.getStackInSlot(0) != null) {
            boolean fancySaved = Minecraft.isFancyGraphicsEnabled();
            Minecraft.getMinecraft().gameSettings.fancyGraphics = true;
            float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0));
            EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorldObj());
            ghostEntityItem.hoverStart = 0.0F;
            ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0));
            float displacement = -0.5F;
            if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock) {
                GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F);
            } else {
                GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 10.4f / 16.0f, (float) d2 + 0.5F - 0.0625f * 2f);
            }
            GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
            if (!(ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)) {
                GL11.glRotatef(90f, 1.0f, 0.0f, 0.0F);
            }
            customRenderItem.doRender(ghostEntityItem, 0, 0, 0, 0, 0);
            Minecraft.getMinecraft().gameSettings.fancyGraphics = fancySaved;
        }
        GL11.glPopMatrix();
        ReagentContainerInfo[] info = tileAltar.getContainerInfo(ForgeDirection.UNKNOWN);
        if (info.length >= 1 && info[0] != null) {
            ReagentStack reagentStack = info[0].reagent;
            int capacity = info[0].capacity;
            if (reagentStack != null && reagentStack.reagent != null) {
                Reagent reagent = reagentStack.reagent;
                this.renderTankContents(d0, d1, d2, reagent.getColourRed(), reagent.getColourGreen(), reagent.getColourBlue(), 200 * reagentStack.amount / capacity);
            }
        }
    }
}
Also used : TEAlchemicCalcinator(WayofTime.alchemicalWizardry.common.tileEntity.TEAlchemicCalcinator) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) ResourceLocation(net.minecraft.util.ResourceLocation) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) ItemBlock(net.minecraft.item.ItemBlock) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with ReagentContainerInfo

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

the class RenderCrystalBelljar method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) {
    if (tileEntity instanceof TEBellJar) {
        TEBellJar tileAltar = (TEBellJar) tileEntity;
        GL11.glPushMatrix();
        GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
        ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/CrystalBelljar.png");
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(test);
        GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        this.modelConduit.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
        ReagentContainerInfo[] info = tileAltar.getContainerInfo(ForgeDirection.UNKNOWN);
        if (info.length >= 1 && info[0] != null) {
            ReagentStack reagentStack = info[0].reagent;
            int capacity = info[0].capacity;
            if (reagentStack != null && reagentStack.reagent != null) {
                Reagent reagent = reagentStack.reagent;
                this.renderTankContents(d0, d1, d2, reagent.getColourRed(), reagent.getColourGreen(), reagent.getColourBlue(), 200 * reagentStack.amount / capacity);
            }
        }
    }
}
Also used : ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) ResourceLocation(net.minecraft.util.ResourceLocation) TEBellJar(WayofTime.alchemicalWizardry.common.tileEntity.TEBellJar) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 3 with ReagentContainerInfo

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

the class TEBellJar method getContainerInfoFromItem.

public static ReagentContainerInfo[] getContainerInfoFromItem(ItemStack stack) {
    if (stack != null && stack.getItem() instanceof ItemBlock && ModBlocks.blockCrystalBelljar == ((ItemBlock) stack.getItem()).field_150939_a) {
        NBTTagCompound tag = stack.getTagCompound();
        if (tag != null) {
            NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
            int size = tagList.tagCount();
            ReagentContainer[] tanks = new ReagentContainer[size];
            ReagentContainerInfo[] infos = new ReagentContainerInfo[size];
            for (int i = 0; i < size; i++) {
                NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
                tanks[i] = ReagentContainer.readFromNBT(savedTag);
                if (tanks[i] != null) {
                    infos[i] = tanks[i].getInfo();
                }
            }
            return infos;
        }
    }
    return new ReagentContainerInfo[0];
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemBlock(net.minecraft.item.ItemBlock) ReagentContainer(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer)

Example 4 with ReagentContainerInfo

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

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

the class TEBellJarItemRenderer method renderConduitItem.

private void renderConduitItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    GL11.glPushMatrix();
    GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(mainResource);
    GL11.glPushMatrix();
    GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
    this.modelConduit.renderSpecialItem((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 0);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
    ReagentContainerInfo[] info = TEBellJar.getContainerInfoFromItem(item);
    if (info.length >= 1 && info[0] != null) {
        ReagentStack reagentStack = info[0].reagent;
        int capacity = info[0].capacity;
        if (reagentStack != null && reagentStack.reagent != null) {
            Reagent reagent = reagentStack.reagent;
            this.renderTankContents(translateX, translateY, translateZ, reagent.getColourRed(), reagent.getColourGreen(), reagent.getColourBlue(), 200 * reagentStack.amount / capacity);
        }
    }
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) translateX + 0.5F, (float) translateY + 1.5F, (float) translateZ + 0.5F);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(mainResource);
    GL11.glPushMatrix();
    GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
    this.modelConduit.renderSpecialItem((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, 1);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);
}
Also used : ReagentContainerInfo(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo) ReagentStack(WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

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