Search in sources :

Example 1 with RitualEffect

use of WayofTime.alchemicalWizardry.api.rituals.RitualEffect 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)

Aggregations

Vector3 (WayofTime.alchemicalWizardry.api.Vector3)1 IMasterRitualStone (WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone)1 RitualComponent (WayofTime.alchemicalWizardry.api.rituals.RitualComponent)1 RitualEffect (WayofTime.alchemicalWizardry.api.rituals.RitualEffect)1 ItemRitualDiviner (WayofTime.alchemicalWizardry.common.items.ItemRitualDiviner)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Minecraft (net.minecraft.client.Minecraft)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1