Search in sources :

Example 1 with MerchantOfferAccessor

use of org.spongepowered.common.accessor.world.item.trading.MerchantOfferAccessor in project SpongeCommon by SpongePowered.

the class SpongeTradeOfferBuilder method build.

@SuppressWarnings("ConstantConditions")
@Override
public TradeOffer build() throws IllegalStateException {
    checkState(this.firstItem != null, "Trading item has not been set");
    checkState(this.sellingItem != null, "Selling item has not been set");
    checkState(this.useCount <= this.maxUses, "Usage count cannot be greater than the max usage count (%s)", this.maxUses);
    final ItemStack first = this.firstItem.createStack();
    final ItemStack second = this.secondItem == null ? null : this.secondItem.createStack();
    final ItemStack selling = this.sellingItem.createStack();
    final MerchantOffer merchantOffer = new MerchantOffer(ItemStackUtil.toNative(first), ItemStackUtil.toNative(second), ItemStackUtil.toNative(selling), this.useCount, this.maxUses, this.merchantExperienceGranted, (float) this.priceGrowthMultiplier);
    ((MerchantOfferAccessor) merchantOffer).accessor$rewardExp(this.allowsExperience);
    ((MerchantOfferAccessor) merchantOffer).accessor$demand(this.demandBonus);
    return (TradeOffer) merchantOffer;
}
Also used : MerchantOffer(net.minecraft.world.item.trading.MerchantOffer) ItemStack(org.spongepowered.api.item.inventory.ItemStack) MerchantOfferAccessor(org.spongepowered.common.accessor.world.item.trading.MerchantOfferAccessor) TradeOffer(org.spongepowered.api.item.merchant.TradeOffer)

Aggregations

MerchantOffer (net.minecraft.world.item.trading.MerchantOffer)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 TradeOffer (org.spongepowered.api.item.merchant.TradeOffer)1 MerchantOfferAccessor (org.spongepowered.common.accessor.world.item.trading.MerchantOfferAccessor)1