Search in sources :

Example 1 with MerchantEntity

use of net.minecraft.entity.passive.MerchantEntity in project MasaGadget by plusls.

the class MixinRenderUtils method renderTradeOfferList.

@Inject(method = "renderInventoryOverlay", at = @At(value = "RETURN"))
private static void renderTradeOfferList(MinecraftClient mc, MatrixStack matrixStack, CallbackInfo ci) {
    if (!Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_TRADE_OFFER_LIST.getBooleanValue()) {
        return;
    }
    Entity entity = TraceUtil.getTraceEntity();
    if (!(entity instanceof MerchantEntity)) {
        return;
    }
    SimpleInventory simpleInventory = new SimpleInventory(MAX_TRADE_OFFER_SIZE);
    for (TradeOffer tradeOffer : ((MerchantEntity) entity).getOffers()) {
        for (int i = 0; i < simpleInventory.size(); ++i) {
            ItemStack itemStack = simpleInventory.getStack(i);
            if (itemStack.isEmpty()) {
                simpleInventory.setStack(i, tradeOffer.getSellItem().copy());
                break;
            }
        }
    }
    int x = GuiUtils.getScaledWindowWidth() / 2 - 88;
    int y = GuiUtils.getScaledWindowHeight() / 2 - 5;
    int slotOffsetX = 8;
    int slotOffsetY = 8;
    InventoryOverlay.InventoryRenderType type = InventoryOverlay.InventoryRenderType.GENERIC;
    DyeColor dye = DyeColor.GREEN;
    float[] colors = dye.getColorComponents();
    fi.dy.masa.malilib.render.RenderUtils.color(colors[0], colors[1], colors[2], 1.0F);
    InventoryOverlay.renderInventoryBackground(type, x, y, MAX_TRADE_OFFER_SIZE, MAX_TRADE_OFFER_SIZE, MinecraftClient.getInstance());
    InventoryOverlay.renderInventoryStacks(type, simpleInventory, x + slotOffsetX, y + slotOffsetY, MAX_TRADE_OFFER_SIZE, 0, MAX_TRADE_OFFER_SIZE, mc);
    fi.dy.masa.malilib.render.RenderUtils.color(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : Entity(net.minecraft.entity.Entity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) InventoryOverlay(fi.dy.masa.malilib.render.InventoryOverlay) ItemStack(net.minecraft.item.ItemStack) DyeColor(net.minecraft.util.DyeColor) SimpleInventory(net.minecraft.inventory.SimpleInventory) TradeOffer(net.minecraft.village.TradeOffer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

InventoryOverlay (fi.dy.masa.malilib.render.InventoryOverlay)1 Entity (net.minecraft.entity.Entity)1 MerchantEntity (net.minecraft.entity.passive.MerchantEntity)1 SimpleInventory (net.minecraft.inventory.SimpleInventory)1 ItemStack (net.minecraft.item.ItemStack)1 DyeColor (net.minecraft.util.DyeColor)1 TradeOffer (net.minecraft.village.TradeOffer)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1