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;
}
Aggregations