Home Commands Examples Getting Started With Scripts Global Keywords 1.21 Migration Guide
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

Merchant

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.entity.type.villager.Merchant;

Members

Getter
Checks if the merchant can restock.
script.zs
// Merchant.canRestock as bool
myMerchant.canRestock

Return Type: bool

canRestock() as bool
Checks if the merchant can restock.

Returns: true if the merchant can restock.

script.zs
// Merchant.canRestock() as bool;
myMerchant.canRestock();

Return Type: bool

Getter
Checks if the merchant is on the client side.
script.zs
// Merchant.isClientSide as bool
myMerchant.isClientSide

Return Type: bool

isClientSide() as bool
Checks if the merchant is on the client side.

Returns: true if the merchant is on the client side.

script.zs
// Merchant.isClientSide() as bool;
myMerchant.isClientSide();

Return Type: bool

notifyTrade(offer as MerchantOffer)
Notifies the merchant that a trade has occurred.
script.zs
// Merchant.notifyTrade(offer as MerchantOffer);
myMerchant.notifyTrade(myMerchantOffer);

Parameters:

offer Type: MerchantOffer - The MerchantOffer that occurred.
Getter
Gets the notify trade sound of the merchant.
script.zs
// Merchant.notifyTradeSound as SoundEvent
myMerchant.notifyTradeSound

Return Type: SoundEvent

notifyTradeSound() as SoundEvent
Gets the notify trade sound of the merchant.

Returns: The notify trade sound of the merchant.

script.zs
// Merchant.notifyTradeSound() as SoundEvent;
myMerchant.notifyTradeSound();

Return Type: SoundEvent

notifyTradeUpdated(stack as ItemStack)
Notifies the merchant that the trade has been updated.
script.zs
// Merchant.notifyTradeUpdated(stack as ItemStack);
myMerchant.notifyTradeUpdated(myItemStack);

Parameters:

stack Type: ItemStack - The ItemStack that was traded.
Getter
Gets the MerchantOffers of the merchant.
script.zs
// Merchant.offers as MerchantOffers
myMerchant.offers

Return Type: MerchantOffers

offers() as MerchantOffers
Gets the MerchantOffers of the merchant.

Returns: The MerchantOffers of the merchant.

script.zs
// Merchant.offers() as MerchantOffers;
myMerchant.offers();

Return Type: MerchantOffers

openTradingScreen(player as Player, displayName as Component, level as int)
Opens the trading screen for the merchant.
script.zs
// Merchant.openTradingScreen(player as Player, displayName as Component, level as int);
myMerchant.openTradingScreen(myPlayer, myComponent, myInt);

Parameters:

player Type: Player - The player to open the trading screen for.
displayName Type: Component - The display name of the merchant.
level Type: int - The level of the merchant.
Getter
Gets if the merchant should show the progress bar.
script.zs
// Merchant.showProgressBar as bool
myMerchant.showProgressBar

Return Type: bool

showProgressBar() as bool
Gets if the merchant should show the progress bar.

Returns: If the merchant should show the progress bar.

script.zs
// Merchant.showProgressBar() as bool;
myMerchant.showProgressBar();

Return Type: bool

Getter
Gets the trading player of the merchant.
script.zs
// Merchant.tradingPlayer as Player
myMerchant.tradingPlayer

Return Type: Player

Setter
Sets the trading player of the merchant.
script.zs
// Merchant.tradingPlayer = (player as Player);
myMerchant.tradingPlayer = myPlayer;

Parameters:

player Type: Player - The player to set as the trading player.
tradingPlayer(player as Player)
Sets the trading player of the merchant.
script.zs
// Merchant.tradingPlayer(player as Player);
myMerchant.tradingPlayer(myPlayer);

Parameters:

player Type: Player - The player to set as the trading player.
tradingPlayer() as Player
Gets the trading player of the merchant.

Returns: The trading player of the merchant.

script.zs
// Merchant.tradingPlayer() as Player;
myMerchant.tradingPlayer();

Return Type: Player

Getter
Gets the villager XP of the merchant.
script.zs
// Merchant.villagerXp as int
myMerchant.villagerXp

Return Type: int

villagerXp() as int
Gets the villager XP of the merchant.

Returns: The villager XP of the merchant.

script.zs
// Merchant.villagerXp() as int;
myMerchant.villagerXp();

Return Type: int