Search in sources :

Example 1 with AltarType

use of hellfirepvp.astralsorcery.common.block.tile.altar.AltarType in project AstralSorcery by HellFirePvP.

the class RenderPageAltarRecipe method render.

@Override
public void render(MatrixStack renderStack, float x, float y, float z, float pTicks, float mouseX, float mouseY) {
    this.clearFrameRectangles();
    this.renderRecipeGrid(renderStack, x, y, z, this.gridTexture);
    this.renderExpectedItemStackOutput(renderStack, x + 78, y + 25, z, 1.4F, this.recipe.getOutputForRender(Collections.emptyList()));
    this.renderInfoStar(renderStack, x, y, z, pTicks);
    this.renderRequiredConstellation(renderStack, x, y, z, this.recipe.getFocusConstellation());
    int widthShift = (AltarRecipeGrid.GRID_SIZE - recipe.getInputs().getWidth()) / 2;
    int heightShift = (AltarRecipeGrid.GRID_SIZE - recipe.getInputs().getHeight()) / 2;
    AltarType type = this.recipe.getAltarType();
    float recipeX = x + 30;
    float recipeY = y + 78;
    for (int xx = 0; xx < AltarRecipeGrid.GRID_SIZE; xx++) {
        for (int yy = 0; yy < AltarRecipeGrid.GRID_SIZE; yy++) {
            int slot = xx + yy * AltarRecipeGrid.GRID_SIZE;
            if (!type.hasSlot(slot)) {
                continue;
            }
            int recipeIndex = (xx - widthShift) + (yy - heightShift) * AltarRecipeGrid.GRID_SIZE;
            if (recipeIndex >= 0 && recipeIndex < AltarRecipeGrid.MAX_INVENTORY_SIZE) {
                float renderX = recipeX + 25 * xx;
                float renderY = recipeY + 25 * yy;
                this.renderExpectedIngredientInput(renderStack, renderX, renderY, z, 1.1F, recipeIndex * 20, this.recipe.getInputs().getIngredient(recipeIndex));
            }
        }
    }
    this.renderExpectedRelayInputs(renderStack, x, y, z + 150, this.recipe);
}
Also used : AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType)

Example 2 with AltarType

use of hellfirepvp.astralsorcery.common.block.tile.altar.AltarType in project AstralSorcery by HellFirePvP.

the class RenderPageRecipeTemplate method addAltarRecipeTooltip.

protected void addAltarRecipeTooltip(SimpleAltarRecipe altarRecipe, List<ITextProperties> toolTip) {
    if (altarRecipe.getStarlightRequirement() > 0) {
        AltarType highestPossible = null;
        ProgressionTier reached = ResearchHelper.getClientProgress().getTierReached();
        for (AltarType type : AltarType.values()) {
            if ((highestPossible == null || !type.isThisLEThan(highestPossible)) && reached.isThisLaterOrEqual(type.getAssociatedTier().getRequiredProgress())) {
                highestPossible = type;
            }
        }
        if (highestPossible != null) {
            long indexSel = (ClientScheduler.getClientTick() / 30) % (highestPossible.ordinal() + 1);
            AltarType typeSelected = AltarType.values()[((int) indexSel)];
            ITextProperties itemName = typeSelected.getAltarItemRepresentation().getDisplayName();
            ITextProperties starlightRequired = getAltarStarlightAmountDescription(itemName, altarRecipe.getStarlightRequirement(), typeSelected.getStarlightCapacity());
            ITextProperties starlightRequirementDescription = new TranslationTextComponent("astralsorcery.journal.recipe.altar.starlight.desc");
            toolTip.add(starlightRequirementDescription);
            toolTip.add(starlightRequired);
        }
    }
    if (altarRecipe instanceof AltarUpgradeRecipe) {
        toolTip.add(new TranslationTextComponent("astralsorcery.journal.recipe.altar.upgrade"));
    }
}
Also used : AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType) ITextProperties(net.minecraft.util.text.ITextProperties) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) AltarUpgradeRecipe(hellfirepvp.astralsorcery.common.crafting.recipe.altar.AltarUpgradeRecipe) ProgressionTier(hellfirepvp.astralsorcery.common.data.research.ProgressionTier)

Example 3 with AltarType

use of hellfirepvp.astralsorcery.common.block.tile.altar.AltarType in project AstralSorcery by HellFirePvP.

the class SimpleAltarRecipeBuilder method validateAndGet.

@Nonnull
@Override
protected T validateAndGet() {
    AltarType type = this.recipe.getAltarType();
    this.recipe.getInputs().validate(type);
    if (!type.isThisGEThan(AltarType.RADIANCE)) {
        if (this.recipe.getRelayInputs().size() > 0) {
            throw new IllegalArgumentException("Cannot make a altar recipe require relay inputs, if the recipe isn't for a T4 altar or higher.");
        }
        if (this.recipe.getFocusConstellation() != null) {
            throw new IllegalArgumentException("Cannot make a altar recipe require a constellation focus, if the recipe isn't for a T4 altar or higher.");
        }
    }
    if (this.recipe.getDuration() <= 0) {
        throw new IllegalArgumentException("Cannot make a altar recipe with 0 or less ticks duration!");
    }
    if (this.recipe.getStarlightRequirement() > type.getStarlightCapacity()) {
        throw new IllegalArgumentException("Cannot make a recipe require more starlight than the capacity of the corresponding altar allows for.");
    }
    return this.recipe;
}
Also used : AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType) Nonnull(javax.annotation.Nonnull)

Example 4 with AltarType

use of hellfirepvp.astralsorcery.common.block.tile.altar.AltarType in project AstralSorcery by HellFirePvP.

the class IntegrationCraftTweaker method onCommandCollection.

public static void onCommandCollection(CTCommandCollectionEvent event) {
    event.registerDump("astralConstellations", "Lists the different Astral Sorcery Constellations", commandContext -> {
        CraftTweakerAPI.logDump("List of all known Astral Sorcery Constellations: ");
        RegistriesAS.REGISTRY_CONSTELLATIONS.getKeys().forEach(resourceLocation -> {
            IConstellation constellation = RegistriesAS.REGISTRY_CONSTELLATIONS.getValue(resourceLocation);
            CraftTweakerAPI.logDump("%s\tis weak: %s, is major: %s", resourceLocation.toString(), constellation instanceof IWeakConstellation, constellation instanceof IMajorConstellation);
        });
        final StringTextComponent message = new StringTextComponent(TextFormatting.GREEN + "Constellations written to the log" + TextFormatting.RESET);
        commandContext.getSource().sendFeedback(message, true);
        return 0;
    });
    event.registerDump("astralAltarTypes", "Lists the different Astral Sorcery Altar Types", commandContext -> {
        CraftTweakerAPI.logDump("List of all known Astral Sorcery Altar Types: ");
        for (AltarType value : AltarType.values()) {
            CraftTweakerAPI.logDump(value.name());
        }
        final StringTextComponent message = new StringTextComponent(TextFormatting.GREEN + "Altar Types written to the log" + TextFormatting.RESET);
        commandContext.getSource().sendFeedback(message, true);
        return 0;
    });
}
Also used : AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType)

Example 5 with AltarType

use of hellfirepvp.astralsorcery.common.block.tile.altar.AltarType in project AstralSorcery by HellFirePvP.

the class TieredAltarRecipeTransferHandler method transferRecipe.

@Nullable
@Override
public IRecipeTransferError transferRecipe(C container, IRecipeLayout recipeLayout, PlayerEntity player, boolean maxTransfer, boolean doTransfer) {
    if (!ServerInfo.isJeiOnServer()) {
        String tooltipMessage = Translator.translateToLocal("jei.tooltip.error.recipe.transfer.no.server");
        return handlerHelper.createUserErrorWithTooltip(tooltipMessage);
    }
    if (!containerClass.isAssignableFrom(container.getClass())) {
        return handlerHelper.createInternalError();
    }
    IRecipeCategory<?> category = recipeLayout.getRecipeCategory();
    if (!(category instanceof CategoryAltar)) {
        return handlerHelper.createInternalError();
    }
    AltarType recipeTier = ((CategoryAltar) category).getAltarType();
    AltarType altarTier = container.getTileEntity().getAltarType();
    Map<Integer, Slot> inventorySlots = new HashMap<>();
    for (Slot slot : container.inventorySlots.subList(0, 36)) {
        inventorySlots.put(slot.slotNumber, slot);
    }
    Map<Integer, Slot> craftingSlots = new HashMap<>();
    for (Slot slot : container.inventorySlots.subList(36, 36 + maxListSize)) {
        craftingSlots.put(slot.slotNumber, slot);
    }
    int inputCount = 0;
    IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();
    // Remove relay inputs from the input grid.
    Map<Integer, IGuiIngredient<ItemStack>> itemStacks = new HashMap<>();
    for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> entry : itemStackGroup.getGuiIngredients().entrySet()) {
        if (entry.getKey() < 25) {
            itemStacks.put(entry.getKey(), entry.getValue());
        }
    }
    for (IGuiIngredient<ItemStack> ingredient : itemStacks.values()) {
        if (ingredient.isInput() && !ingredient.getAllIngredients().isEmpty()) {
            inputCount++;
        }
    }
    if (inputCount > craftingSlots.size()) {
        LOGGER.error("Recipe Transfer does not work for container {}", container.getClass());
        return handlerHelper.createInternalError();
    }
    Map<Integer, ItemStack> availableItemStacks = new HashMap<>();
    int filledCraftSlotCount = 0;
    int emptySlotCount = 0;
    for (Slot slot : craftingSlots.values()) {
        final ItemStack stack = slot.getStack();
        if (!stack.isEmpty()) {
            if (!slot.canTakeStack(player)) {
                LOGGER.error("Recipe Transfer does not work for container {}. Player can't move item out of Crafting Slot number {}", container.getClass(), slot.slotNumber);
                return handlerHelper.createInternalError();
            }
            filledCraftSlotCount++;
            availableItemStacks.put(slot.slotNumber, stack.copy());
        }
    }
    for (Slot slot : inventorySlots.values()) {
        final ItemStack stack = slot.getStack();
        if (!stack.isEmpty()) {
            availableItemStacks.put(slot.slotNumber, stack.copy());
        } else {
            emptySlotCount++;
        }
    }
    // check if we have enough inventory space to shuffle items around to their final locations
    if (filledCraftSlotCount - inputCount > emptySlotCount) {
        String message = Translator.translateToLocal("jei.tooltip.error.recipe.transfer.inventory.full");
        return handlerHelper.createUserErrorWithTooltip(message);
    }
    RecipeTransferUtil.MatchingItemsResult matchingItemsResult = RecipeTransferUtil.getMatchingItems(stackHelper, availableItemStacks, itemStacks);
    if (matchingItemsResult.missingItems.size() > 0) {
        String message = Translator.translateToLocal("jei.tooltip.error.recipe.transfer.missing");
        return handlerHelper.createUserErrorForSlots(message, matchingItemsResult.missingItems);
    }
    List<Integer> craftingSlotIndexes = new ArrayList<>(craftingSlots.keySet());
    Collections.sort(craftingSlotIndexes);
    List<Integer> inventorySlotIndexes = new ArrayList<>(inventorySlots.keySet());
    Collections.sort(inventorySlotIndexes);
    Map<Integer, Integer> matchIndices = MapStream.of(matchingItemsResult.matchingItems).mapKey(container::translateIndex).toMap();
    // check that the slots exist and can be altered
    for (Map.Entry<Integer, Integer> entry : matchIndices.entrySet()) {
        int craftNumber = entry.getKey();
        int slotNumber = craftingSlotIndexes.get(craftNumber);
        if (slotNumber < 0 || slotNumber >= container.inventorySlots.size()) {
            LOGGER.error("Recipes Transfer references slot {} outside of the inventory's size {}", slotNumber, container.inventorySlots.size());
            return handlerHelper.createInternalError();
        }
    }
    if (doTransfer) {
        PacketRecipeTransfer packet = new PacketRecipeTransfer(matchIndices, craftingSlotIndexes, inventorySlotIndexes, maxTransfer, true);
        Network.sendPacketToServer(packet);
    }
    return null;
}
Also used : IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup) AltarType(hellfirepvp.astralsorcery.common.block.tile.altar.AltarType) RecipeTransferUtil(mezz.jei.transfer.RecipeTransferUtil) IGuiIngredient(mezz.jei.api.gui.ingredient.IGuiIngredient) PacketRecipeTransfer(mezz.jei.network.packets.PacketRecipeTransfer) Slot(net.minecraft.inventory.container.Slot) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Aggregations

AltarType (hellfirepvp.astralsorcery.common.block.tile.altar.AltarType)9 ItemStack (net.minecraft.item.ItemStack)3 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)2 SimpleAltarRecipe (hellfirepvp.astralsorcery.common.crafting.recipe.SimpleAltarRecipe)2 ActiveSimpleAltarRecipe (hellfirepvp.astralsorcery.common.crafting.recipe.altar.ActiveSimpleAltarRecipe)2 AltarRecipeGrid (hellfirepvp.astralsorcery.common.crafting.recipe.altar.AltarRecipeGrid)2 AltarRecipeEffect (hellfirepvp.astralsorcery.common.crafting.recipe.altar.effect.AltarRecipeEffect)2 ByteBufUtils (hellfirepvp.astralsorcery.common.util.data.ByteBufUtils)2 Nonnull (javax.annotation.Nonnull)2 Nullable (javax.annotation.Nullable)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 PositionedLoopSound (hellfirepvp.astralsorcery.client.util.sound.PositionedLoopSound)1 SkyHandler (hellfirepvp.astralsorcery.common.constellation.SkyHandler)1 DayTimeHelper (hellfirepvp.astralsorcery.common.constellation.world.DayTimeHelper)1 WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)1 SimpleAltarRecipeContext (hellfirepvp.astralsorcery.common.crafting.recipe.SimpleAltarRecipeContext)1