mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
fixup loom pattern select event patch
This commit is contained in:
parent
e66d823dc3
commit
e5628d4fc7
@ -16,27 +16,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- this.setupResultSlot((Holder) this.selectablePatterns.get(id));
|
- this.setupResultSlot((Holder) this.selectablePatterns.get(id));
|
||||||
+ // Paper start - Add PlayerLoomPatternSelectEvent
|
+ // Paper start - Add PlayerLoomPatternSelectEvent
|
||||||
+ int selectablePatternIndex = id;
|
+ int selectablePatternIndex = id;
|
||||||
+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(this.selectablePatterns.get(selectablePatternIndex).value().getHashname()));
|
+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.craftbukkit.block.banner.CraftPatternType.minecraftHolderToBukkit((this.selectablePatterns.get(selectablePatternIndex))));
|
||||||
+ if (!event.callEvent()) {
|
+ if (!event.callEvent()) {
|
||||||
+ player.containerMenu.sendAllDataToRemote();
|
+ player.containerMenu.sendAllDataToRemote();
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
|
+ final Holder<BannerPattern> eventPattern = org.bukkit.craftbukkit.block.banner.CraftPatternType.bukkitToMinecraftHolder(event.getPatternType());
|
||||||
+ Holder<BannerPattern> selectedPattern = null;
|
+ Holder<BannerPattern> selectedPattern = null;
|
||||||
+ for (int i = 0; i < this.selectablePatterns.size(); i++) {
|
+ for (int i = 0; i < this.selectablePatterns.size(); i++) {
|
||||||
+ final Holder<BannerPattern> holder = this.selectablePatterns.get(i);
|
+ final Holder<BannerPattern> holder = this.selectablePatterns.get(i);
|
||||||
+ if (event.getPatternType().getIdentifier().equals(holder.value().getHashname())) {
|
+ if (eventPattern.equals(holder)) {
|
||||||
+ selectablePatternIndex = i;
|
+ selectablePatternIndex = i;
|
||||||
+ selectedPattern = holder;
|
+ selectedPattern = holder;
|
||||||
+ break;
|
+ break;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ if (selectedPattern == null) {
|
+ if (selectedPattern == null) {
|
||||||
+ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) {
|
+ selectedPattern = eventPattern;
|
||||||
+ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) {
|
|
||||||
+ selectedPattern = BuiltInRegistries.BANNER_PATTERN.wrapAsHolder(pattern);
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ selectablePatternIndex = -1;
|
+ selectablePatternIndex = -1;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
Loading…
Reference in New Issue
Block a user