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();
}
}
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);
}
}
}
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);
}
}
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();
}
}
}
}
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);
}
}
}
}
}
Aggregations