Search in sources :

Example 1 with ActiveSimpleAltarRecipe

use of hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe in project AstralSorcery by HellFirePvP.

the class RenderAltar method render.

@Override
public void render(TileAltar tile, float pTicks, MatrixStack renderStack, IRenderTypeBuffer renderTypeBuffer, int combinedLight, int combinedOverlay) {
    if (tile.getAltarType().isThisGEThan(AltarType.RADIANCE) && tile.hasMultiblock()) {
        IConstellation cst = tile.getFocusedConstellation();
        if (cst != null) {
            float dayAlpha = DayTimeHelper.getCurrentDaytimeDistribution(tile.getWorld()) * 0.6F;
            int max = 3000;
            int t = (int) (ClientScheduler.getClientTick() % max);
            float halfAge = max / 2F;
            float tr = 1F - (Math.abs(halfAge - t) / halfAge);
            tr *= 1.3;
            RenderingConstellationUtils.renderConstellationIntoWorldFlat(cst, renderStack, renderTypeBuffer, new Vector3(0.5, 0.03, 0.5), 5.5 + tr, 2, 0.1F + dayAlpha);
        }
    }
    ActiveSimpleAltarRecipe recipe = tile.getActiveRecipe();
    if (recipe != null) {
        recipe.getRecipeToCraft().getCraftingEffects().forEach(effect -> effect.onTESR(tile, recipe.getState(), renderStack, renderTypeBuffer, pTicks, combinedLight));
    }
    if (tile.getAltarType().isThisGEThan(AltarType.RADIANCE) && tile.hasMultiblock()) {
        renderStack.push();
        renderStack.translate(0.5F, 4.5F, 0.5F);
        long id = tile.getPos().toLong();
        if (recipe != null) {
            List<WrappedIngredient> traitInputs = recipe.getRecipeToCraft().getRelayInputs();
            if (!traitInputs.isEmpty()) {
                int amount = 60 / traitInputs.size();
                for (int i = 0; i < traitInputs.size(); i++) {
                    WrappedIngredient ingredient = traitInputs.get(i);
                    ItemStack traitInput = ingredient.getRandomMatchingStack(ClientScheduler.getClientTick());
                    Color color = ColorizationHelper.getColor(traitInput).orElse(ColorsAS.CELESTIAL_CRYSTAL);
                    RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, color, 0x1231943167156902L | id | (i * 0x5151L), 20, 2F, amount);
                }
            } else {
                RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, Color.WHITE, id * 31L, 15, 1.5F, 35);
                RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, ColorsAS.CELESTIAL_CRYSTAL, id * 16L, 10, 1F, 25);
            }
            RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, Color.WHITE, id * 31L, 10, 1F, 10);
        } else {
            RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, Color.WHITE, id * 31L, 15, 1.5F, 35);
            RenderingDrawUtils.renderLightRayFan(renderStack, renderTypeBuffer, ColorsAS.CELESTIAL_CRYSTAL, id * 16L, 10, 1F, 25);
        }
        renderStack.pop();
    }
}
Also used : ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) WrappedIngredient(hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient) ItemStack(net.minecraft.item.ItemStack) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Example 2 with ActiveSimpleAltarRecipe

use of hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe in project AstralSorcery by HellFirePvP.

the class EffectFocusDustSwirl method onTick.

@Override
@OnlyIn(Dist.CLIENT)
public void onTick(TileAltar altar, ActiveSimpleAltarRecipe.CraftingState state) {
    if (state == ActiveSimpleAltarRecipe.CraftingState.ACTIVE) {
        ActiveSimpleAltarRecipe recipe = altar.getActiveRecipe();
        if (recipe == null) {
            // Uh... what
            return;
        }
        IConstellation focus = recipe.getRecipeToCraft().getFocusConstellation();
        long tick = getClientTick();
        float total = 180;
        float percCycle = (float) (((tick % total) / total) * 2 * Math.PI);
        int parts = 5;
        Vector3 center = new Vector3(altar).add(0.5, 0.1, 0.5);
        float angleSwirl = 70F;
        float dst = 3.5F;
        for (int i = 0; i < parts; i++) {
            Vector3 v = Vector3.RotAxis.X_AXIS.clone();
            float originalAngle = (((float) i) / ((float) parts)) * 360F;
            double angle = originalAngle + (MathHelper.sin(percCycle) * angleSwirl);
            v.rotate(-Math.toRadians(angle), Vector3.RotAxis.Y_AXIS).normalize().multiply(dst);
            Vector3 pos = center.clone().add(v);
            Vector3 mot = center.clone().subtract(pos).normalize().multiply(0.07);
            Color c = getFocusColor(focus, rand);
            EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(pos).setScaleMultiplier(0.25F + rand.nextFloat() * 0.7F).setMotion(mot).color(VFXColorFunction.constant(c)).setMaxAge(50);
        }
    }
}
Also used : ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 3 with ActiveSimpleAltarRecipe

use of hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe in project AstralSorcery by HellFirePvP.

the class EffectLuminescenceFlare method onTick.

@Override
@OnlyIn(Dist.CLIENT)
public void onTick(TileAltar altar, ActiveSimpleAltarRecipe.CraftingState state) {
    ActiveSimpleAltarRecipe recipe = altar.getActiveRecipe();
    if (recipe != null && state == ActiveSimpleAltarRecipe.CraftingState.ACTIVE) {
        ResourceLocation recipeName = recipe.getRecipeToCraft().getId();
        FXSpritePlane spr = recipe.getEffectContained(INDEX_CRAFT_FLARE, i -> {
            return EffectHelper.of(EffectTemplatesAS.TEXTURE_SPRITE).spawn(new Vector3(altar).add(0.5, 0.04, 0.5)).setSprite(SpritesAS.SPR_CRAFT_FLARE).setAxis(Vector3.RotAxis.Y_AXIS).setNoRotation(0).color(VFXColorFunction.constant(ColorsAS.EFFECT_CRAFT_FLARE)).alpha(VFXAlphaFunction.fadeIn(30)).setScaleMultiplier(9F).setAlphaMultiplier(0.65F).refresh(RefreshFunction.tileExistsAnd(altar, (tAltar, fx) -> tAltar.getActiveRecipe() != null && tAltar.getActiveRecipe().getState() == ActiveSimpleAltarRecipe.CraftingState.ACTIVE && recipeName.equals(tAltar.getActiveRecipe().getRecipeToCraft().getId())));
        });
        EffectHelper.refresh(spr, EffectTemplatesAS.TEXTURE_SPRITE);
    }
}
Also used : FXSpritePlane(hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) TileAltar(hellfirepvp.astralsorcery.common.tile.altar.TileAltar) Dist(net.minecraftforge.api.distmarker.Dist) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) RefreshFunction(hellfirepvp.astralsorcery.client.effect.function.RefreshFunction) SpritesAS(hellfirepvp.astralsorcery.client.lib.SpritesAS) ResourceLocation(net.minecraft.util.ResourceLocation) ColorsAS(hellfirepvp.astralsorcery.common.lib.ColorsAS) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) FXSpritePlane(hellfirepvp.astralsorcery.client.effect.vfx.FXSpritePlane) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 4 with ActiveSimpleAltarRecipe

use of hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe in project AstralSorcery by HellFirePvP.

the class BuiltInEffectTraitRelayHighlight method onTESR.

@Override
@OnlyIn(Dist.CLIENT)
public void onTESR(TileAltar altar, ActiveSimpleAltarRecipe.CraftingState state, MatrixStack renderStack, IRenderTypeBuffer buffer, float pTicks, int combinedLight) {
    ActiveSimpleAltarRecipe activeRecipe = altar.getActiveRecipe();
    if (activeRecipe != null) {
        List<WrappedIngredient> additionalIngredients = activeRecipe.getRecipeToCraft().getRelayInputs();
        List<CraftingFocusStack> focusStacks = activeRecipe.getFocusStacks();
        for (CraftingFocusStack stack : focusStacks) {
            if (stack.getStackIndex() < 0 || stack.getStackIndex() >= additionalIngredients.size()) {
                continue;
            }
            WrappedIngredient match = additionalIngredients.get(stack.getStackIndex());
            BlockPos offset = stack.getRealPosition().subtract(altar.getPos());
            TileSpectralRelay relay = MiscUtils.getTileAt(altar.getWorld(), stack.getRealPosition(), TileSpectralRelay.class, false);
            if (relay == null || (!match.getIngredient().test(relay.getInventory().getStackInSlot(0)))) {
                ItemStack potential = match.getRandomMatchingStack(getClientTick());
                renderStack.push();
                renderStack.translate(0.5 + offset.getX(), 0.35 + offset.getY(), 0.5 + offset.getZ());
                RenderingUtils.renderTranslucentItemStack(potential, renderStack, pTicks);
                renderStack.pop();
            }
        }
    }
}
Also used : ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) TileSpectralRelay(hellfirepvp.astralsorcery.common.tile.TileSpectralRelay) BlockPos(net.minecraft.util.math.BlockPos) WrappedIngredient(hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient) CraftingFocusStack(hellfirepvp.astralsorcery.common.crafting.helper.CraftingFocusStack) ItemStack(net.minecraft.item.ItemStack) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with ActiveSimpleAltarRecipe

use of hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe in project AstralSorcery by HellFirePvP.

the class BuiltInEffectTraitRelayHighlight method onTick.

@Override
@OnlyIn(Dist.CLIENT)
public void onTick(TileAltar altar, ActiveSimpleAltarRecipe.CraftingState state) {
    ActiveSimpleAltarRecipe recipe = altar.getActiveRecipe();
    if (recipe != null) {
        List<WrappedIngredient> additionalIngredients = recipe.getRecipeToCraft().getRelayInputs();
        for (CraftingFocusStack stack : recipe.getFocusStacks()) {
            if (stack.getStackIndex() < 0 || stack.getStackIndex() >= additionalIngredients.size()) {
                continue;
            }
            WrappedIngredient match = additionalIngredients.get(stack.getStackIndex());
            TileSpectralRelay relay = MiscUtils.getTileAt(altar.getWorld(), stack.getRealPosition(), TileSpectralRelay.class, false);
            if (relay != null) {
                ItemStack in = relay.getInventory().getStackInSlot(0);
                if (!in.isEmpty() && match.getIngredient().test(in)) {
                    Color color = ColorizationHelper.getColor(in).orElse(ColorsAS.CELESTIAL_CRYSTAL);
                    playLightbeam(altar, relay, color);
                    playRelayHighlightParticles(relay, color);
                    if (rand.nextInt(4) == 0) {
                        EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(new Vector3(altar).add(-3 + rand.nextInt(7), 0.02, -3 + rand.nextInt(7))).color(VFXColorFunction.constant(color)).alpha(VFXAlphaFunction.FADE_OUT).setScaleMultiplier(0.15F + rand.nextFloat() * 0.2F);
                    }
                } else {
                    ItemStack chosen = match.getRandomMatchingStack(getClientTick());
                    Color color = ColorizationHelper.getColor(chosen).orElse(ColorsAS.CELESTIAL_CRYSTAL);
                    playLightbeam(altar, relay, color);
                    playRelayHighlightParticles(relay, color);
                }
            }
        }
    }
}
Also used : ActiveSimpleAltarRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe) TileSpectralRelay(hellfirepvp.astralsorcery.common.tile.TileSpectralRelay) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) WrappedIngredient(hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient) CraftingFocusStack(hellfirepvp.astralsorcery.common.crafting.helper.CraftingFocusStack) ItemStack(net.minecraft.item.ItemStack) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ActiveSimpleAltarRecipe (hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe)11 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)9 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)8 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)5 ItemStack (net.minecraft.item.ItemStack)4 WrappedIngredient (hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient)3 TileSpectralRelay (hellfirepvp.astralsorcery.common.tile.TileSpectralRelay)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Dist (net.minecraftforge.api.distmarker.Dist)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 VFXAlphaFunction (hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction)2 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)2 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)2 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)2 CraftingFocusStack (hellfirepvp.astralsorcery.common.crafting.helper.CraftingFocusStack)2 PktPlayEffect (hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)2 TileAltar (hellfirepvp.astralsorcery.common.tile.altar.TileAltar)2 BlockPos (net.minecraft.util.math.BlockPos)2 RefreshFunction (hellfirepvp.astralsorcery.client.effect.function.RefreshFunction)1 RenderOffsetNoisePlane (hellfirepvp.astralsorcery.client.effect.function.impl.RenderOffsetNoisePlane)1