Search in sources :

Example 1 with Ritual

use of WayofTime.bloodmagic.ritual.Ritual in project BloodMagic by WayofTime.

the class ClientHandler method renderRitualStones.

public static void renderRitualStones(TileMasterRitualStone masterRitualStone, float partialTicks) {
    EntityPlayerSP player = minecraft.player;
    World world = player.getEntityWorld();
    EnumFacing direction = mrsHoloDirection;
    Ritual ritual = mrsHoloRitual;
    if (ritual == null)
        return;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.color(1F, 1F, 1F, 0.5F);
    BlockPos vec3, vX;
    vec3 = masterRitualStone.getPos();
    double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
    List<RitualComponent> components = Lists.newArrayList();
    ritual.gatherComponents(components::add);
    for (RitualComponent ritualComponent : components) {
        vX = vec3.add(ritualComponent.getOffset(direction));
        double minX = vX.getX() - posX;
        double minY = vX.getY() - posY;
        double minZ = vX.getZ() - posZ;
        if (!world.getBlockState(vX).isOpaqueCube()) {
            TextureAtlasSprite texture = null;
            switch(ritualComponent.getRuneType()) {
                case BLANK:
                    texture = ritualStoneBlank;
                    break;
                case WATER:
                    texture = ritualStoneWater;
                    break;
                case FIRE:
                    texture = ritualStoneFire;
                    break;
                case EARTH:
                    texture = ritualStoneEarth;
                    break;
                case AIR:
                    texture = ritualStoneAir;
                    break;
                case DAWN:
                    texture = ritualStoneDawn;
                    break;
                case DUSK:
                    texture = ritualStoneDusk;
                    break;
            }
            RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
        }
    }
    GlStateManager.popMatrix();
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) Ritual(WayofTime.bloodmagic.ritual.Ritual) RitualComponent(WayofTime.bloodmagic.ritual.RitualComponent) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) World(net.minecraft.world.World)

Example 2 with Ritual

use of WayofTime.bloodmagic.ritual.Ritual in project BloodMagic by WayofTime.

the class ItemRitualDiviner method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    if (!stack.hasTagCompound())
        return;
    Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
    if (ritual != null) {
        tooltip.add(TextHelper.localize("tooltip.bloodmagic.diviner.currentRitual") + TextHelper.localize(ritual.getUnlocalizedName()));
        boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
        boolean extraInfo = sneaking && Keyboard.isKeyDown(Keyboard.KEY_M);
        if (extraInfo) {
            tooltip.add("");
            for (EnumDemonWillType type : EnumDemonWillType.values()) {
                if (TextHelper.canTranslate(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info")) {
                    tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info"))));
                }
            }
        } else if (sneaking) {
            tooltip.add(TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(getDirection(stack).getName())));
            tooltip.add("");
            List<RitualComponent> components = Lists.newArrayList();
            ritual.gatherComponents(components::add);
            int blankRunes = 0;
            int airRunes = 0;
            int waterRunes = 0;
            int fireRunes = 0;
            int earthRunes = 0;
            int duskRunes = 0;
            int dawnRunes = 0;
            int totalRunes = components.size();
            for (RitualComponent component : components) {
                switch(component.getRuneType()) {
                    case BLANK:
                        blankRunes++;
                        break;
                    case AIR:
                        airRunes++;
                        break;
                    case EARTH:
                        earthRunes++;
                        break;
                    case FIRE:
                        fireRunes++;
                        break;
                    case WATER:
                        waterRunes++;
                        break;
                    case DUSK:
                        duskRunes++;
                        break;
                    case DAWN:
                        dawnRunes++;
                        break;
                }
            }
            if (blankRunes > 0)
                tooltip.add(EnumRuneType.BLANK.colorCode + TextHelper.localize(tooltipBase + "blankRune", blankRunes));
            if (waterRunes > 0)
                tooltip.add(EnumRuneType.WATER.colorCode + TextHelper.localize(tooltipBase + "waterRune", waterRunes));
            if (airRunes > 0)
                tooltip.add(EnumRuneType.AIR.colorCode + TextHelper.localize(tooltipBase + "airRune", airRunes));
            if (fireRunes > 0)
                tooltip.add(EnumRuneType.FIRE.colorCode + TextHelper.localize(tooltipBase + "fireRune", fireRunes));
            if (earthRunes > 0)
                tooltip.add(EnumRuneType.EARTH.colorCode + TextHelper.localize(tooltipBase + "earthRune", earthRunes));
            if (duskRunes > 0)
                tooltip.add(EnumRuneType.DUSK.colorCode + TextHelper.localize(tooltipBase + "duskRune", duskRunes));
            if (dawnRunes > 0)
                tooltip.add(EnumRuneType.DAWN.colorCode + TextHelper.localize(tooltipBase + "dawnRune", dawnRunes));
            tooltip.add("");
            tooltip.add(TextHelper.localize(tooltipBase + "totalRune", totalRunes));
        } else {
            tooltip.add("");
            if (TextHelper.canTranslate(ritual.getUnlocalizedName() + ".info")) {
                tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + ".info"))));
                tooltip.add("");
            }
            tooltip.add(TextHelper.localizeEffect(tooltipBase + "extraInfo"));
            tooltip.add(TextHelper.localizeEffect(tooltipBase + "extraExtraInfo"));
        }
    }
}
Also used : Ritual(WayofTime.bloodmagic.ritual.Ritual) RitualComponent(WayofTime.bloodmagic.ritual.RitualComponent) List(java.util.List) EnumDemonWillType(WayofTime.bloodmagic.soul.EnumDemonWillType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with Ritual

use of WayofTime.bloodmagic.ritual.Ritual in project BloodMagic by WayofTime.

the class ItemRitualDiviner method addRuneToRitual.

/**
 * Adds a single rune to the ritual.
 *
 * @param stack  - The Ritual Diviner stack
 * @param world  - The World
 * @param pos    - Block Position of the MRS.
 * @param player - The Player attempting to place the ritual
 * @return - True if a rune was successfully added
 */
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileMasterRitualStone) {
        Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
        if (ritual != null) {
            EnumFacing direction = getDirection(stack);
            List<RitualComponent> components = Lists.newArrayList();
            ritual.gatherComponents(components::add);
            for (RitualComponent component : components) {
                if (!canPlaceRitualStone(component.getRuneType(), stack)) {
                    return false;
                }
                BlockPos offset = component.getOffset(direction);
                BlockPos newPos = pos.add(offset);
                IBlockState state = world.getBlockState(newPos);
                Block block = state.getBlock();
                if (RitualHelper.isRune(world, newPos)) {
                    if (RitualHelper.isRuneType(world, newPos, component.getRuneType())) {
                        if (world.isRemote) {
                            undisplayHologram();
                        }
                    } else {
                        // Replace existing ritual stone
                        RitualHelper.setRuneType(world, newPos, component.getRuneType());
                        return true;
                    }
                } else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos)) {
                    if (!consumeStone(stack, world, player)) {
                        return false;
                    }
                    int meta = component.getRuneType().ordinal();
                    IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta);
                    world.setBlockState(newPos, newState);
                    return true;
                } else {
                    // TODO: Possibly replace the block with a
                    return false;
                // ritual stone
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) Ritual(WayofTime.bloodmagic.ritual.Ritual) RitualComponent(WayofTime.bloodmagic.ritual.RitualComponent) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with Ritual

use of WayofTime.bloodmagic.ritual.Ritual in project BloodMagic by WayofTime.

the class ItemRitualDiviner method trySetDisplayedRitual.

@SideOnly(Side.CLIENT)
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileMasterRitualStone) {
        Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack));
        TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
        if (ritual != null) {
            EnumFacing direction = getDirection(itemStack);
            ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMasterRitualStone(WayofTime.bloodmagic.tile.TileMasterRitualStone) Ritual(WayofTime.bloodmagic.ritual.Ritual) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Ritual

use of WayofTime.bloodmagic.ritual.Ritual in project BloodMagic by WayofTime.

the class ItemRitualDiviner method cycleRitual.

/**
 * Cycles the selected ritual to the next available ritual that is enabled.
 *
 * @param stack  - The ItemStack of the ritual diviner
 * @param player - The player using the ritual diviner
 */
public void cycleRitual(ItemStack stack, EntityPlayer player) {
    String key = getCurrentRitual(stack);
    List<String> idList = RitualRegistry.getOrderedIds();
    String firstId = "";
    boolean foundId = false;
    boolean foundFirst = false;
    for (String str : idList) {
        Ritual ritual = RitualRegistry.getRitualForId(str);
        if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) {
            continue;
        }
        if (!foundFirst) {
            firstId = str;
            foundFirst = true;
        }
        if (foundId) {
            setCurrentRitual(stack, str);
            notifyRitualChange(str, player);
            return;
        } else {
            if (str.equals(key)) {
                foundId = true;
                continue;
            }
        }
    }
    if (foundFirst) {
        setCurrentRitual(stack, firstId);
        notifyRitualChange(firstId, player);
    }
}
Also used : Ritual(WayofTime.bloodmagic.ritual.Ritual)

Aggregations

Ritual (WayofTime.bloodmagic.ritual.Ritual)8 RitualComponent (WayofTime.bloodmagic.ritual.RitualComponent)5 BlockPos (net.minecraft.util.math.BlockPos)4 TileMasterRitualStone (WayofTime.bloodmagic.tile.TileMasterRitualStone)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 World (net.minecraft.world.World)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ItemRitualDiviner (WayofTime.bloodmagic.item.ItemRitualDiviner)1 EnumDemonWillType (WayofTime.bloodmagic.soul.EnumDemonWillType)1 List (java.util.List)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 ItemBlock (net.minecraft.item.ItemBlock)1