add back optimizing hopper searches (#5839)
This commit is contained in:
parent
a0056c36f1
commit
3846367c2d
333 changed files with 147 additions and 132 deletions
40
patches/server/0566-added-PlayerTradeEvent.patch
Normal file
40
patches/server/0566-added-PlayerTradeEvent.patch
Normal file
|
@ -0,0 +1,40 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 2 Jul 2020 16:12:10 -0700
|
||||
Subject: [PATCH] added PlayerTradeEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
index 4a7b657265cbbc91ae85409abb3db29cfc555a2c..e59a77c80a1bbe62aaa61bd4792d21b12c895a5c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
@@ -140,13 +140,24 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
|
||||
|
||||
@Override
|
||||
public void notifyTrade(MerchantOffer offer) {
|
||||
- offer.increaseUses();
|
||||
- this.ambientSoundTime = -this.getAmbientSoundInterval();
|
||||
- this.rewardTradeXp(offer);
|
||||
+ // Paper - moved down
|
||||
+ // Paper start
|
||||
if (this.tradingPlayer instanceof ServerPlayer) {
|
||||
- CriteriaTriggers.TRADE.trigger((ServerPlayer) this.tradingPlayer, this, offer.getResult());
|
||||
+ io.papermc.paper.event.player.PlayerTradeEvent event = new io.papermc.paper.event.player.PlayerTradeEvent(((ServerPlayer) this.tradingPlayer).getBukkitEntity(), (org.bukkit.entity.AbstractVillager) this.getBukkitEntity(), offer.asBukkit(), true, true);
|
||||
+ event.callEvent();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ MerchantOffer recipe = CraftMerchantRecipe.fromBukkit(event.getTrade()).toMinecraft();
|
||||
+ if (event.willIncreaseTradeUses()) recipe.increaseUses();
|
||||
+ this.ambientSoundTime = -this.getAmbientSoundInterval();
|
||||
+ if (event.isRewardingExp()) this.rewardTradeXp(recipe);
|
||||
+ CriteriaTriggers.TRADE.trigger((ServerPlayer) this.tradingPlayer, this, recipe.getResult());
|
||||
+ }
|
||||
+ } else {
|
||||
+ offer.increaseUses();
|
||||
+ this.ambientSoundTime = -getAmbientSoundInterval();
|
||||
+ this.rewardTradeXp(offer);
|
||||
}
|
||||
-
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
protected abstract void rewardTradeXp(MerchantOffer offer);
|
Loading…
Add table
Add a link
Reference in a new issue