This commit is contained in:
gnembon committed 2020-12-14 02:36:53 -04:00
1 parent 6f28425eaf
commit cd892f95bc
3 files changed
+11 -10

No files matched your search

+1 -1
View File
@@ -116,7 +116,7 @@ Triggered when player right clicks (interacts) with an entity, even if the entit
the item they are holding. The event is invoked after receiving a packet from the client, before anything happens server side
with that interaction.
### `__on_player_trades(player, entity, buy, buyB, sell)`
### `__on_player_trades(player, entity, buy_left, buy_right, sell)`
Triggered when player trades with a merchant. The event is invoked after the server allow the trade, but before the inventory
changes and merchant updates its trade-uses counter.
The parameter `entity` can be `null` if the merchant is not an entity.
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.TradeOutputSlot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.village.Merchant;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.MerchantInventory;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -20,14 +20,15 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_TRADES;
public abstract class TradeOutputSlot_scarpetEventMixin {
@Shadow @Final private Merchant merchant;
@Shadow @Final private MerchantInventory merchantInventory;
@Inject(method = "onTakeItem", at = @At(value = "INVOKE",
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V"),
locals = LocalCapture.CAPTURE_FAILHARD
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V")
)
private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfoReturnable cir, TradeOffer tradeOffer) {
private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
if(PLAYER_TRADES.isNeeded() && !this.merchant.getMerchantWorld().isClient())
{
PLAYER_TRADES.onTrade((ServerPlayerEntity) player, merchant, tradeOffer);
PLAYER_TRADES.onTrade((ServerPlayerEntity) player, merchant, merchantInventory.getTradeOffer());
}
}
}
@@ -292,14 +292,14 @@ __on_player_picks_up_item(player, item) ->
print(' Player '+player+' injects '+item);
);
__on_player_trades(player, entity, buy, buyB, sell) ->
__on_player_trades(player, entity, buy_left, buy_right, sell) ->
(
print('');
print('__on_player_trades(player, item)');
print('player trades:');
print(' - player: '+player);
print(' - entity: '+ entity);
print(' - buy: '+ buy);
print(' - buyB: '+ buyB);
print(' - sell: '+ sell);
print(' - buy_left: '+ buy_left);
print(' - buy_right: '+ buy_right);
print(' - sell: '+ sell)
);