Search in sources :

Example 36 with RitualComponent

use of WayofTime.alchemicalWizardry.api.rituals.RitualComponent in project BloodMagic by WayofTime.

the class RitualDivinerRender method render.

@SubscribeEvent
public void render(RenderWorldLastEvent event) {
    Minecraft minecraft = Minecraft.getMinecraft();
    EntityClientPlayerMP player = minecraft.thePlayer;
    World world = player.worldObj;
    if (minecraft.objectMouseOver == null || minecraft.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
        return;
    }
    TileEntity tileEntity = world.getTileEntity(minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ);
    if (!(tileEntity instanceof IMasterRitualStone)) {
        return;
    }
    Vector3 vec3 = new Vector3(minecraft.objectMouseOver.blockX, minecraft.objectMouseOver.blockY, minecraft.objectMouseOver.blockZ);
    double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks;
    double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks;
    double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks;
    if (player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof ItemRitualDiviner) {
        ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
        int direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
        RitualEffect ritualEffect = getEffectFromString(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
        if (ritualEffect == null) {
            return;
        }
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        for (RitualComponent ritualComponent : ritualEffect.getRitualComponentList()) {
            Vector3 vX = vec3.add(new Vector3(ritualComponent.getX(direction), ritualComponent.getY(), ritualComponent.getZ(direction)));
            double minX = vX.x - posX;
            double minY = vX.y - posY;
            double minZ = vX.z - posZ;
            if (!world.getBlock(vX.x, vX.y, vX.z).isOpaqueCube()) {
                RenderFakeBlocks.drawFakeBlock(vX, ModBlocks.ritualStone, ritualComponent.getStoneType(), minX, minY, minZ, world);
            }
        }
        GL11.glPopMatrix();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) RitualEffect(WayofTime.alchemicalWizardry.api.rituals.RitualEffect) IMasterRitualStone(WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone) RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent) Vector3(WayofTime.alchemicalWizardry.api.Vector3) World(net.minecraft.world.World) ItemRitualDiviner(WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 37 with RitualComponent

use of WayofTime.alchemicalWizardry.api.rituals.RitualComponent in project BloodMagic by WayofTime.

the class ItemRitualDismantler method breakRitualStoneAtMasterStone.

public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity instanceof TEMasterStone) {
        TEMasterStone masterStone = (TEMasterStone) tileEntity;
        int direction = masterStone.getDirection();
        String ritualName = Rituals.checkValidRitual(world, x, y, z);
        List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
        if (ritualList == null) {
            return false;
        }
        for (RitualComponent rc : ritualList) {
            if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) instanceof RitualStone) {
                if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode) {
                    world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                    EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(ModBlocks.ritualStone));
                    if (world.isRemote) {
                        world.playAuxSFX(2005, x, y + 1, z, 0);
                    } else {
                        world.spawnEntityInWorld(entityItem);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent) TEMasterStone(WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone) ItemStack(net.minecraft.item.ItemStack) RitualStone(WayofTime.alchemicalWizardry.common.block.RitualStone) EntityItem(net.minecraft.entity.item.EntityItem)

Example 38 with RitualComponent

use of WayofTime.alchemicalWizardry.api.rituals.RitualComponent in project BloodMagic by WayofTime.

the class ItemRitualDiviner method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List par3List, boolean x) {
    par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.desc"));
    if (this.getMaxRuneDisplacement(stack) == 1) {
        par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplace"));
    } else if (this.getMaxRuneDisplacement(stack) >= 2) {
        par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.canplacedawn"));
    } else {
        par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.cannotplace"));
    }
    par3List.add(StatCollector.translateToLocal("tooltip.ritualdiviner.ritualtunedto") + " " + this.getNameForDirection(this.getDirection(stack)));
    boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
    if (sneaking) {
        if (!(stack.getTagCompound() == null)) {
            String ritualID = this.getCurrentRitual(stack);
            // TODO
            par3List.add(StatCollector.translateToLocal("tooltip.owner.currentowner") + " " + stack.getTagCompound().getString("ownerName"));
            par3List.add(StatCollector.translateToLocal("tooltip.alchemy.ritualid") + " " + ritualID);
            List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(stack));
            if (ritualList == null) {
                return;
            }
            int blankStones = 0;
            int airStones = 0;
            int waterStones = 0;
            int fireStones = 0;
            int earthStones = 0;
            int duskStones = 0;
            int dawnStones = 0;
            for (RitualComponent rc : ritualList) {
                switch(rc.getStoneType()) {
                    case RitualComponent.BLANK:
                        blankStones++;
                        break;
                    case RitualComponent.AIR:
                        airStones++;
                        break;
                    case RitualComponent.WATER:
                        waterStones++;
                        break;
                    case RitualComponent.FIRE:
                        fireStones++;
                        break;
                    case RitualComponent.EARTH:
                        earthStones++;
                        break;
                    case RitualComponent.DUSK:
                        duskStones++;
                        break;
                    case RitualComponent.DAWN:
                        dawnStones++;
                        break;
                }
            }
            int totalStones = blankStones + airStones + waterStones + fireStones + earthStones + duskStones + dawnStones;
            par3List.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("tooltip.ritualdiviner.blankstones") + " " + blankStones);
            par3List.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("tooltip.ritualdiviner.airstones") + " " + airStones);
            par3List.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("tooltip.ritualdiviner.waterstones") + " " + waterStones);
            par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocal("tooltip.ritualdiviner.firestones") + " " + fireStones);
            par3List.add(EnumChatFormatting.DARK_GREEN + StatCollector.translateToLocal("tooltip.ritualdiviner.earthstones") + " " + earthStones);
            par3List.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tooltip.ritualdiviner.duskstones") + " " + duskStones);
            par3List.add(EnumChatFormatting.GOLD + StatCollector.translateToLocal("tooltip.ritualdiviner.dawnstones") + " " + dawnStones);
            par3List.add(EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("tooltip.ritualdiviner.totalStones") + " " + totalStones);
        }
    } else {
        par3List.add(EnumChatFormatting.AQUA + "-" + StatCollector.translateToLocal("tooltip.ritualdiviner.moreinfo") + "-");
    }
}
Also used : RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent)

Example 39 with RitualComponent

use of WayofTime.alchemicalWizardry.api.rituals.RitualComponent in project BloodMagic by WayofTime.

the class ItemRitualDiviner method placeRitualStoneAtMasterStone.

public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
    int direction = this.getDirection(stack);
    ItemStack[] playerInventory = player.inventory.mainInventory;
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity instanceof TEMasterStone) {
        List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(stack));
        if (ritualList == null) {
            return false;
        }
        int playerInvRitualStoneLocation = -1;
        for (int i = 0; i < playerInventory.length; i++) {
            if (playerInventory[i] == null) {
                continue;
            }
            if (new ItemStack(ModBlocks.ritualStone).isItemEqual(playerInventory[i])) {
                playerInvRitualStoneLocation = i;
                break;
            }
        }
        for (RitualComponent rc : ritualList) {
            if (world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction))) {
                if (playerInvRitualStoneLocation >= 0 || player.capabilities.isCreativeMode) {
                    if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
                        world.playAuxSFX(200, x, y + 1, z, 0);
                        return true;
                    }
                    if (!player.capabilities.isCreativeMode) {
                        player.inventory.decrStackSize(playerInvRitualStoneLocation, 1);
                    }
                    if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
                        world.setBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), ModBlocks.ritualStone, rc.getStoneType(), 3);
                        if (world.isRemote) {
                            world.playAuxSFX(2005, x, y + 1, z, 0);
                            return true;
                        }
                    }
                    return true;
                }
            } else {
                Block block = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                if (block == ModBlocks.ritualStone) {
                    int metadata = world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
                    if (metadata != rc.getStoneType()) {
                        if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
                            if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
                                world.playAuxSFX(200, x, y + 1, z, 0);
                                return true;
                            }
                            world.setBlockMetadataWithNotify(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), rc.getStoneType(), 3);
                            return true;
                        }
                    }
                } else {
                    world.playAuxSFX(0, x, y + 1, z, 0);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) RitualComponent(WayofTime.alchemicalWizardry.api.rituals.RitualComponent) Block(net.minecraft.block.Block) TEMasterStone(WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone) ItemStack(net.minecraft.item.ItemStack)

Aggregations

RitualComponent (WayofTime.alchemicalWizardry.api.rituals.RitualComponent)39 ArrayList (java.util.ArrayList)34 ItemStack (net.minecraft.item.ItemStack)3 TileEntity (net.minecraft.tileentity.TileEntity)3 TEMasterStone (WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone)2 Vector3 (WayofTime.alchemicalWizardry.api.Vector3)1 IMasterRitualStone (WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone)1 RitualEffect (WayofTime.alchemicalWizardry.api.rituals.RitualEffect)1 RitualStone (WayofTime.alchemicalWizardry.common.block.RitualStone)1 ItemRitualDiviner (WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Block (net.minecraft.block.Block)1 Minecraft (net.minecraft.client.Minecraft)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 EntityItem (net.minecraft.entity.item.EntityItem)1 World (net.minecraft.world.World)1