use of hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient 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.helper.WrappedIngredient in project AstralSorcery by HellFirePvP.
the class SimpleAltarRecipe method write.
public final void write(JsonObject object) {
object.addProperty("altar_type", this.getAltarType().ordinal());
object.addProperty("duration", this.getDuration());
object.addProperty("starlight", this.getStarlightRequirement());
this.getInputs().serialize(object);
if (this.getCustomRecipeType() != null) {
object.addProperty("recipe_class", this.getCustomRecipeType().toString());
}
JsonArray outputs = new JsonArray();
for (ItemStack output : this.outputs) {
outputs.add(JsonHelper.serializeItemStack(output));
}
object.add("output", outputs);
JsonObject options = new JsonObject();
this.serializeAdditionalJson(options);
if (!options.entrySet().isEmpty()) {
object.add("options", options);
}
if (this.getFocusConstellation() != null) {
object.addProperty("focus_constellation", this.getFocusConstellation().getRegistryName().toString());
}
if (!this.getRelayInputs().isEmpty()) {
JsonArray inputs = new JsonArray();
for (WrappedIngredient traitInput : this.getRelayInputs()) {
inputs.add(traitInput.getIngredient().serialize());
}
object.add("relay_inputs", inputs);
}
if (!this.getCraftingEffects().isEmpty()) {
JsonArray effects = new JsonArray();
for (AltarRecipeEffect effect : this.getCraftingEffects()) {
effects.add(effect.getRegistryName().toString());
}
object.add("effects", effects);
}
}
use of hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient 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.helper.WrappedIngredient 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);
}
}
}
}
}
use of hellfirepvp.astralsorcery.common.crafting.helper.WrappedIngredient in project AstralSorcery by HellFirePvP.
the class ActiveSimpleAltarRecipe method tickCraftingRelayInputs.
private boolean tickCraftingRelayInputs(TileAltar altar, List<WrappedIngredient> iIngredients) {
// Start the surrounding stack intake past 66%
int part = totalCraftingTime / 3;
// Every input is evenly spread
int cttPart = part / (iIngredients.size()) + 1;
boolean waitMissingInputs = false;
for (int i = 0; i < iIngredients.size(); i++) {
WrappedIngredient input = iIngredients.get(i);
int index = i;
int offset = part + (index * cttPart);
if (this.ticksCrafting >= offset) {
CraftingFocusStack found = MiscUtils.iterativeSearch(this.focusStacks, fStack -> fStack.getStackIndex() == index);
if (found == null) {
Set<BlockPos> relays = altar.nearbyRelays();
relays.removeIf(pos -> MiscUtils.contains(this.focusStacks, fs -> fs.getRealPosition().equals(pos)));
// No unused relay found for a new focus-stack..
if (relays.isEmpty()) {
waitMissingInputs = true;
continue;
}
BlockPos at = MiscUtils.getRandomEntry(relays, rand);
TileSpectralRelay tar = MiscUtils.getTileAt(altar.getWorld(), at, TileSpectralRelay.class, true);
if (tar == null) {
// We were lied to. lol.
waitMissingInputs = true;
continue;
}
found = new CraftingFocusStack(index, input, at);
this.focusStacks.add(found);
}
TileSpectralRelay tar = MiscUtils.getTileAt(altar.getWorld(), found.getRealPosition(), TileSpectralRelay.class, true);
if (tar == null) {
waitMissingInputs = true;
continue;
}
if (!input.getIngredient().test(tar.getInventory().getStackInSlot(0))) {
waitMissingInputs = true;
}
}
}
return waitMissingInputs;
}
Aggregations