Search in sources :

Example 1 with CapeItem

use of com.gildedgames.aether.common.item.accessories.cape.CapeItem in project CustomizableElytra by Hidoni.

the class CustomizableElytraLayer method getTextureWithCape.

private ResourceLocation getTextureWithCape(T entitylivingbaseIn, CompoundNBT customizationTag, boolean capeHidden) {
    ResourceLocation elytraTexture = null;
    boolean isTextureGrayscale = ElytraCustomizationUtil.getData(customizationTag).type != ElytraCustomizationData.CustomizationType.None;
    if (!capeHidden) {
        if (entitylivingbaseIn instanceof AbstractClientPlayerEntity) {
            AbstractClientPlayerEntity abstractclientplayerentity = (AbstractClientPlayerEntity) entitylivingbaseIn;
            if (abstractclientplayerentity.isPlayerInfoSet() && abstractclientplayerentity.getLocationElytra() != null) {
                elytraTexture = abstractclientplayerentity.getLocationElytra();
            } else if (abstractclientplayerentity.hasPlayerInfo() && abstractclientplayerentity.getLocationCape() != null && abstractclientplayerentity.isWearing(PlayerModelPart.CAPE)) {
                elytraTexture = abstractclientplayerentity.getLocationCape();
            }
        }
        if (elytraTexture == null && CustomizableElytra.aetherLoaded) {
            Optional<ImmutableTriple<String, Integer, ItemStack>> curiosHelper = CuriosApi.getCuriosHelper().findEquippedCurio((item) -> item.getItem() instanceof CapeItem, entitylivingbaseIn);
            Optional<ICuriosItemHandler> curiosHandler = CuriosApi.getCuriosHelper().getCuriosHandler(entitylivingbaseIn).resolve();
            if (curiosHelper.isPresent() && curiosHandler.isPresent()) {
                Optional<ICurioStacksHandler> stacksHandler = curiosHandler.get().getStacksHandler(curiosHelper.get().getLeft());
                if (stacksHandler.isPresent()) {
                    CapeItem cape = (CapeItem) curiosHelper.get().getRight().getItem();
                    if (cape.getCapeTexture() != null && stacksHandler.get().getRenders().get(curiosHelper.get().getMiddle())) {
                        elytraTexture = cape.getCapeTexture();
                    }
                }
            }
        }
    }
    if (elytraTexture == null) {
        elytraTexture = getElytraTexture(isTextureGrayscale);
    } else if (isTextureGrayscale) {
        elytraTexture = ElytraTextureUtil.getGrayscale(elytraTexture);
    }
    return elytraTexture;
}
Also used : ICurioStacksHandler(top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler) ICuriosItemHandler(top.theillusivec4.curios.api.type.capability.ICuriosItemHandler) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) CapeItem(com.gildedgames.aether.common.item.accessories.cape.CapeItem)

Example 2 with CapeItem

use of com.gildedgames.aether.common.item.accessories.cape.CapeItem in project The-Aether by Gilded-Games.

the class AetherMixinHooks method elytraLayerMixin.

public static <T extends LivingEntity> ResourceLocation elytraLayerMixin(ItemStack stack, T entity) {
    Optional<SlotResult> slotResult = CuriosApi.getCuriosHelper().findFirstCurio(entity, (item) -> item.getItem() instanceof CapeItem);
    if (slotResult.isPresent()) {
        String identifier = slotResult.get().slotContext().identifier();
        int id = slotResult.get().slotContext().index();
        LazyOptional<ICuriosItemHandler> itemHandler = CuriosApi.getCuriosHelper().getCuriosHandler(entity);
        if (itemHandler.resolve().isPresent()) {
            Optional<ICurioStacksHandler> stacksHandler = itemHandler.resolve().get().getStacksHandler(identifier);
            CapeItem cape = (CapeItem) slotResult.get().stack().getItem();
            boolean isCapeVisible = stacksHandler.get().getRenders().get(id);
            if (cape.getCapeTexture() != null && isCapeVisible) {
                return cape.getCapeTexture();
            }
        }
    }
    return null;
}
Also used : ICurioStacksHandler(top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler) ICuriosItemHandler(top.theillusivec4.curios.api.type.capability.ICuriosItemHandler) CapeItem(com.gildedgames.aether.common.item.accessories.cape.CapeItem) SlotResult(top.theillusivec4.curios.api.SlotResult)

Aggregations

CapeItem (com.gildedgames.aether.common.item.accessories.cape.CapeItem)2 ICuriosItemHandler (top.theillusivec4.curios.api.type.capability.ICuriosItemHandler)2 ICurioStacksHandler (top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler)2 AbstractClientPlayerEntity (net.minecraft.client.entity.player.AbstractClientPlayerEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ImmutableTriple (org.apache.commons.lang3.tuple.ImmutableTriple)1 SlotResult (top.theillusivec4.curios.api.SlotResult)1