mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
parent
4ca3d61623
commit
f3d98fefef
1 changed files with 45 additions and 43 deletions
|
@ -7,110 +7,109 @@ Adds a new event for all crafting stations that generate a result slot item
|
|||
|
||||
Anvil and Grindstone now extend this event
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java
|
||||
index 4effcc860f9b1cf9f13f4c6ae02a6b16df459259..268bedd042b651514aa94b735876de9c40bae56f 100644
|
||||
--- a/src/main/java/net/minecraft/server/Container.java
|
||||
+++ b/src/main/java/net/minecraft/server/Container.java
|
||||
@@ -126,6 +126,7 @@ public abstract class Container {
|
||||
return nonnulllist;
|
||||
}
|
||||
|
||||
+ public void notifyListeners() { this.c(); } // Paper - OBFHELPER
|
||||
public void c() {
|
||||
int i;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
index 24631b2bcb2a1d057c1fb6596ff401133c8b548a..a2eee6ed8f166d1ff42dc913ea34e80032d90e3a 100644
|
||||
index 24631b2bcb2a1d057c1fb6596ff401133c8b548a..fc2038df89f25c07f6f853f6df41fe9b203c3585 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
@@ -294,6 +294,8 @@ public class ContainerAnvil extends ContainerAnvilAbstract {
|
||||
@@ -294,6 +294,7 @@ public class ContainerAnvil extends ContainerAnvilAbstract {
|
||||
}
|
||||
|
||||
this.e();
|
||||
+
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java b/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java
|
||||
index 2029d4dd9a2abe693c34723c379009578ab52503..71f588be3dfd840f2cd3d5a4f19cf8ff24d3837b 100644
|
||||
index 2029d4dd9a2abe693c34723c379009578ab52503..ad9f234c4862d78b5a8e547aa8bb6528497de236 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerAnvilAbstract.java
|
||||
@@ -67,6 +67,7 @@ public abstract class ContainerAnvilAbstract extends Container {
|
||||
@@ -65,6 +65,7 @@ public abstract class ContainerAnvilAbstract extends Container {
|
||||
super.a(iinventory);
|
||||
if (iinventory == this.repairInventory) {
|
||||
this.e();
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerCartography.java b/src/main/java/net/minecraft/server/ContainerCartography.java
|
||||
index 91e1372952f07087f51b22f1c53f63d2cf2f40fc..1acc7f4eaede582f79f6e17c594d8553582c675d 100644
|
||||
index 91e1372952f07087f51b22f1c53f63d2cf2f40fc..79d328786f2e9ba386cb297bb8e7ec0ec3228a65 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerCartography.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerCartography.java
|
||||
@@ -154,6 +154,7 @@ public class ContainerCartography extends Container {
|
||||
this.a(itemstack, itemstack1, itemstack2);
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||
}
|
||||
|
||||
private void a(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2) {
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
index fe9a083b724a8657cac8462b3f44d3cc12a4db58..cd7914ea4cc606b980aa22662beae2d4d8f3e0e9 100644
|
||||
index fe9a083b724a8657cac8462b3f44d3cc12a4db58..39f809a37b58e008e7ef32c0759eeecbde26bc94 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
||||
@@ -10,6 +10,10 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||
import org.bukkit.entity.Player;
|
||||
// CraftBukkit end
|
||||
+// Paper start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent;
|
||||
+// Paper end
|
||||
|
||||
public class ContainerGrindstone extends Container {
|
||||
|
||||
@@ -144,6 +148,9 @@ public class ContainerGrindstone extends Container {
|
||||
@@ -144,6 +144,7 @@ public class ContainerGrindstone extends Container {
|
||||
super.a(iinventory);
|
||||
if (iinventory == this.craftInventory) {
|
||||
this.e();
|
||||
+ // Paper start
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper
|
||||
+ // Paper end
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerLoom.java b/src/main/java/net/minecraft/server/ContainerLoom.java
|
||||
index 9490f74ee426e162844432073b3d78a2b6cddb32..e309f71e56933f0e7d2d9fc72a7681d4916eea3d 100644
|
||||
index 9490f74ee426e162844432073b3d78a2b6cddb32..1fe21ca13a1eecb64cb2d3f4f18993e181d26ae2 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerLoom.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerLoom.java
|
||||
@@ -175,6 +175,8 @@ public class ContainerLoom extends Container {
|
||||
@@ -174,7 +174,8 @@ public class ContainerLoom extends Container {
|
||||
}
|
||||
|
||||
this.j();
|
||||
this.c();
|
||||
+
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 3); // Paper
|
||||
- this.c();
|
||||
+ //this.c(); // Paper - done below
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerSmithing.java b/src/main/java/net/minecraft/server/ContainerSmithing.java
|
||||
index 76a81b30fa9e53952202c61717231d68d7be8e71..5392d82b90abe0de907c238153f4c769e5d998fa 100644
|
||||
index 76a81b30fa9e53952202c61717231d68d7be8e71..80a98e10df3f880b77c4dc99c9b871a2362f50cd 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerSmithing.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerSmithing.java
|
||||
@@ -65,6 +65,7 @@ public class ContainerSmithing extends ContainerAnvilAbstract {
|
||||
this.resultInventory.setItem(0, itemstack);
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 2); // Paper
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 2); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerStonecutter.java b/src/main/java/net/minecraft/server/ContainerStonecutter.java
|
||||
index 270bf7f3e6ca15891419f1ce3e88d9aff094bee6..ce63c715e4920ad272e7c3dffb8f3279118d0fae 100644
|
||||
index 270bf7f3e6ca15891419f1ce3e88d9aff094bee6..a235f6406dc06ceafea6fbe429bf595da2fea07c 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerStonecutter.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerStonecutter.java
|
||||
@@ -133,6 +133,7 @@ public class ContainerStonecutter extends Container {
|
||||
this.a(iinventory, itemstack);
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(getBukkitView(), this.resultInventory.getItem(0), 1); // Paper
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 1); // Paper
|
||||
}
|
||||
|
||||
private void a(IInventory iinventory, ItemStack itemstack) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 6c5036b23a41769167fd53b8cc5454e5e747598e..3e51d78b5b6b6b78381c36ca45a5166cd474df75 100644
|
||||
index 6c5036b23a41769167fd53b8cc5454e5e747598e..dbc46fcda3f3e006d9e7b7a89ab942b46a05cd9f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1548,12 +1548,31 @@ public class CraftEventFactory {
|
||||
@@ -1548,12 +1548,33 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
|
@ -122,14 +121,17 @@ index 6c5036b23a41769167fd53b8cc5454e5e747598e..3e51d78b5b6b6b78381c36ca45a5166c
|
|||
+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
||||
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // disable event
|
||||
event.getInventory().setItem(2, event.getResult());
|
||||
- return event;
|
||||
+ //return event; // Paper
|
||||
+ }
|
||||
}
|
||||
+ // Paper end
|
||||
+
|
||||
+ // Paper start - support specific overrides for prepare result
|
||||
+ public static com.destroystokyo.paper.event.inventory.PrepareResultEvent callPrepareResultEvent(InventoryView view, ItemStack item, int resultSlot) {
|
||||
+ public static void callPrepareResultEvent(net.minecraft.server.Container container, int resultSlot) {
|
||||
+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event;
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(item).clone();
|
||||
+ InventoryView view = container.getBukkitView();
|
||||
+ org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot);
|
||||
+ CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null;
|
||||
+ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory) {
|
||||
+ event = new PrepareAnvilEvent(view, result);
|
||||
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.GrindstoneInventory) {
|
||||
|
@ -139,8 +141,8 @@ index 6c5036b23a41769167fd53b8cc5454e5e747598e..3e51d78b5b6b6b78381c36ca45a5166c
|
|||
+ }
|
||||
+ event.callEvent();
|
||||
+ event.getInventory().setItem(resultSlot, event.getResult());
|
||||
return event;
|
||||
}
|
||||
+ container.notifyListeners();
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue