Search in sources :

Example 1 with Reagent

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

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

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

the class RitualEffectDemonPortal 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 (currentEssence < this.getCostPerRefresh()) {
        SoulNetworkHandler.causeNauseaToPlayer(owner);
    } else {
        NBTTagCompound tag = ritualStone.getCustomRitualTag();
        boolean reagentsFulfilled = true;
        for (Reagent reagent : reagents) {
            int reagentAmount = tag.getInteger(ReagentRegistry.getKeyForReagent(reagent));
            if (reagentAmount < neededAmount) {
                reagentsFulfilled = false;
                // System.out.println("Reagents not fulfilled. Missing: " + ReagentRegistry.getKeyForReagent(reagent));
                int drainAmount = Math.min(drainRate, neededAmount - reagentAmount);
                if (drainAmount <= 0) {
                    continue;
                }
                if (this.canDrainReagent(ritualStone, reagent, drainAmount, true)) {
                    if (rand.nextInt(10) == 0) {
                        this.createRandomLightning(world, x, y, z);
                    }
                    reagentAmount += drainAmount;
                    tag.setInteger(ReagentRegistry.getKeyForReagent(reagent), reagentAmount);
                    break;
                }
            }
        }
        ritualStone.setCustomRitualTag(tag);
        if (reagentsFulfilled && checkCreatePortal(ritualStone)) {
            world.setBlock(x, y + 1, z, ModBlocks.blockDemonPortal);
            TEDemonPortal portal = (TEDemonPortal) world.getTileEntity(x, y + 1, z);
            portal.start();
            ritualStone.setActive(false);
        }
        SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
    }
}
Also used : TEDemonPortal(WayofTime.alchemicalWizardry.common.demonVillage.tileEntity.TEDemonPortal) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 4 with Reagent

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

the class TEMasterStone method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    isActive = tag.getBoolean("isActive");
    owner = tag.getString("owner");
    cooldown = tag.getInteger("cooldown");
    var1 = tag.getInteger("var1");
    direction = tag.getInteger("direction");
    currentRitualString = tag.getString("currentRitualString");
    isRunning = tag.getBoolean("isRunning");
    runningTime = tag.getInteger("runningTime");
    NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
    int size = tagList.tagCount();
    this.tanks = new ReagentContainer[size];
    for (int i = 0; i < size; i++) {
        NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
        this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
    }
    NBTTagList attunedTagList = tag.getTagList("attunedTankMap", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < attunedTagList.tagCount(); i++) {
        NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
        Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
        this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
    }
    customRitualTag = tag.getCompoundTag("customRitualTag");
    LocalRitualStorage newStorage = Rituals.getLocalStorage(currentRitualString);
    NBTTagCompound localStorageTag = tag.getCompoundTag("localStorage");
    if (newStorage != null) {
        newStorage.readFromNBT(localStorageTag);
        storage = newStorage;
        storage.xCoord = xCoord;
        storage.yCoord = yCoord;
        storage.zCoord = zCoord;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) LocalRitualStorage(WayofTime.alchemicalWizardry.api.rituals.LocalRitualStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent)

Example 5 with Reagent

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

the class AlchemicalWizardryEventHooks method omegaUpdateReagentAndHpEvent.

@SubscribeEvent
public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) {
    if (event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        Reagent reagent = APISpellHelper.getPlayerReagentType(player);
        float reagentAmount = APISpellHelper.getPlayerCurrentReagentAmount(player);
        boolean hasReagentChanged = false;
        if (reagentAmount > 0 && OmegaRegistry.hasParadigm(reagent)) {
            int cooldown = APISpellHelper.getPlayerReagentRegenCooldownTag(player);
            boolean canHealHPBar = true;
            if (cooldown > 0) {
                float extra = 0;
                if (player.isPotionActive(AlchemicalWizardry.customPotionSoulHarden)) {
                    extra += 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulHarden).getAmplifier());
                }
                if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) {
                    extra -= 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulFray).getAmplifier());
                }
                int deduction = -1 - (extra >= 0 ? (rand.nextFloat() < extra ? 1 : 0) : (rand.nextFloat() < -extra / 2 ? -1 : 0));
                APISpellHelper.setPlayerReagentRegenCooldownTag(player, Math.max(cooldown + deduction, 0));
                canHealHPBar = false;
            }
            OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
            ReagentRegenConfiguration config = parad.getRegenConfig(player);
            if (parad.isPlayerWearingFullSet(player)) {
                if (canHealHPBar) {
                    int tickRate = config.tickRate;
                    if (player.isPotionActive(Potion.regeneration)) {
                        int i = player.getActivePotionEffect(Potion.regeneration).getAmplifier();
                        double factor = Math.pow(1.5, i + 1);
                        tickRate = Math.max((int) (tickRate / factor), 1);
                    }
                    if (event.entityLiving.worldObj.getWorldTime() % tickRate == 0) {
                        boolean hasHealthChanged = false;
                        int maxHealth = parad.getMaxAdditionalHealth();
                        float health = APISpellHelper.getCurrentAdditionalHP(player);
                        if (health > maxHealth) {
                            health = maxHealth;
                            hasHealthChanged = true;
                        } else if (health < maxHealth) {
                            float addedAmount = Math.min(Math.min((reagentAmount / config.costPerPoint), config.healPerTick), maxHealth - health);
                            float drain = addedAmount * config.costPerPoint;
                            reagentAmount -= drain;
                            hasReagentChanged = true;
                            health += addedAmount;
                            hasHealthChanged = true;
                        }
                        if (player instanceof EntityPlayerMP) {
                            if (hasHealthChanged) {
                                APISpellHelper.setCurrentAdditionalHP(player, health);
                                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(health, maxHealth), (EntityPlayerMP) player);
                            }
                        }
                    }
                }
            } else {
                reagentAmount = 0;
                APISpellHelper.setPlayerMaxReagentAmount(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(null, 0, 0), (EntityPlayerMP) player);
                APISpellHelper.setCurrentAdditionalHP(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
            }
            // Consumes the amount
            float costPerTick = parad.getCostPerTickOfUse(player);
            if (parad.doDrainReagent(player)) {
                if (reagentAmount > costPerTick) {
                    hasReagentChanged = true;
                    reagentAmount = Math.max(0, reagentAmount - costPerTick);
                } else {
                    hasReagentChanged = true;
                    reagentAmount = 0;
                }
            }
            hasReagentChanged = true;
        }
        if (reagentAmount <= 0) {
            boolean hasRevertedArmour = false;
            ItemStack[] armourInventory = player.inventory.armorInventory;
            for (ItemStack stack : armourInventory) {
                if (stack != null && stack.getItem() instanceof OmegaArmour) {
                    ((OmegaArmour) stack.getItem()).revertArmour(player, stack);
                    hasRevertedArmour = true;
                }
            }
            if (hasRevertedArmour) {
                APISpellHelper.setCurrentAdditionalHP(player, 0);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
            }
        }
        if (player instanceof EntityPlayerMP) {
            if (hasReagentChanged) {
                APISpellHelper.setPlayerCurrentReagentAmount(player, reagentAmount);
                NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(reagent, reagentAmount, APISpellHelper.getPlayerMaxReagentAmount(player)), (EntityPlayerMP) player);
            }
        }
    }
}
Also used : OmegaArmour(WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) OmegaParadigm(WayofTime.alchemicalWizardry.common.omega.OmegaParadigm) ItemStack(net.minecraft.item.ItemStack) Reagent(WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent) ReagentRegenConfiguration(WayofTime.alchemicalWizardry.common.omega.ReagentRegenConfiguration) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

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