cleaner
This commit is contained in:
1 parent
6f28425eaf
commit
cd892f95bc
3 files changed
+11
-10
No files matched your search
@@ -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
|
the item they are holding. The event is invoked after receiving a packet from the client, before anything happens server side
|
||||||
with that interaction.
|
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
|
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.
|
changes and merchant updates its trade-uses counter.
|
||||||
The parameter `entity` can be `null` if the merchant is not an entity.
|
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.screen.slot.TradeOutputSlot;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.village.Merchant;
|
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.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -20,14 +20,15 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_TRADES;
|
|||||||
public abstract class TradeOutputSlot_scarpetEventMixin {
|
public abstract class TradeOutputSlot_scarpetEventMixin {
|
||||||
@Shadow @Final private Merchant merchant;
|
@Shadow @Final private Merchant merchant;
|
||||||
|
|
||||||
|
@Shadow @Final private MerchantInventory merchantInventory;
|
||||||
|
|
||||||
@Inject(method = "onTakeItem", at = @At(value = "INVOKE",
|
@Inject(method = "onTakeItem", at = @At(value = "INVOKE",
|
||||||
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V"),
|
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V")
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
|
||||||
)
|
)
|
||||||
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())
|
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);
|
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('');
|
||||||
print('__on_player_trades(player, item)');
|
print('__on_player_trades(player, item)');
|
||||||
print('player trades:');
|
print('player trades:');
|
||||||
print(' - player: '+player);
|
print(' - player: '+player);
|
||||||
print(' - entity: '+ entity);
|
print(' - entity: '+ entity);
|
||||||
print(' - buy: '+ buy);
|
print(' - buy_left: '+ buy_left);
|
||||||
print(' - buyB: '+ buyB);
|
print(' - buy_right: '+ buy_right);
|
||||||
print(' - sell: '+ sell);
|
print(' - sell: '+ sell)
|
||||||
);
|
);
|
||||||
Reference in new issue
Block a user