mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-31 12:56:29 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@9f004614 Update a whole lot of deprecated annotations PaperMC/Paper@72f13f8b [ci/skip] Mention API Checks for CONTRIBUTING.md (#12315) PaperMC/Paper@7cc6cb50 Check for trailing input in ItemFactory#createItemStack (#12312) PaperMC/Paper@f49d18df Add get/set customName to Skull block (#12302) PaperMC/Paper@894631f0 Make advancement ordering predictable (#12292) PaperMC/Paper@2aad131e Add config option for command spam whitelist PaperMC/Paper@bb3b7e69 Fix annotation mistakes PaperMC/Paper@058455e4 InventoryView QOL open method (#12282) PaperMC/Paper@f2258582 Fix firework entity not being removed when FireworkExplodeEvent is cancelled (#12268) PaperMC/Paper@7819df10 Add getHeight method to ChunkData (#12311) PaperMC/Paper@37b9ca1f Add flush parameter to World#save (#12330) PaperMC/Paper@515e12ca Check if BUNDLE_CONTENTS is present in InventoryClickEvent (#12321) PaperMC/Paper@5a6ab97b Add config to remove player as vehicle restriction in /ride (#12327) PaperMC/Paper@c467df95 Add ItemStack#copyDataFrom (#12224) Gale Changes: Dreeam-qwq/Gale@d5143ee0 Updated Upstream (Paper) Dreeam-qwq/Gale@63c396e7 Updated Upstream (Paper) Dreeam-qwq/Gale@5c2147b4 Updated Upstream (Paper) Dreeam-qwq/Gale@804ecea0 Rebuild patches
73 lines
2.8 KiB
Diff
73 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Sat, 22 Mar 2025 00:08:11 +0100
|
|
Subject: [PATCH] Optimize ContextMap.create
|
|
|
|
|
|
diff --git a/net/minecraft/util/context/ContextMap.java b/net/minecraft/util/context/ContextMap.java
|
|
index cc8d67df5e074beb8c41bb6ce4f519f963e59d0d..9b1152db265afd87f17f0b7d4b2d09f4913b2f9c 100644
|
|
--- a/net/minecraft/util/context/ContextMap.java
|
|
+++ b/net/minecraft/util/context/ContextMap.java
|
|
@@ -1,10 +1,8 @@
|
|
package net.minecraft.util.context;
|
|
|
|
import com.google.common.collect.Sets;
|
|
-import java.util.IdentityHashMap;
|
|
-import java.util.Map;
|
|
-import java.util.NoSuchElementException;
|
|
-import java.util.Set;
|
|
+
|
|
+import java.util.*;
|
|
import javax.annotation.Nullable;
|
|
import org.jetbrains.annotations.Contract;
|
|
|
|
@@ -72,17 +70,39 @@ public class ContextMap {
|
|
}
|
|
|
|
public ContextMap create(ContextKeySet contextKeySet) {
|
|
- Set<ContextKey<?>> set = Sets.difference(this.params.keySet(), contextKeySet.allowed());
|
|
- if (!set.isEmpty()) {
|
|
- throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + set);
|
|
- } else {
|
|
- Set<ContextKey<?>> set1 = Sets.difference(contextKeySet.required(), this.params.keySet());
|
|
- if (!set1.isEmpty()) {
|
|
- throw new IllegalArgumentException("Missing required parameters: " + set1);
|
|
- } else {
|
|
- return new ContextMap(this.params);
|
|
+ Set<ContextKey<?>> allowed = contextKeySet.allowed();
|
|
+ Set<ContextKey<?>> invalid = null;
|
|
+
|
|
+ // Check for any parameters that are not allowed
|
|
+ for (ContextKey<?> key : this.params.keySet()) {
|
|
+ if (!allowed.contains(key)) {
|
|
+ if (invalid == null) {
|
|
+ invalid = new HashSet<>();
|
|
+ }
|
|
+ invalid.add(key);
|
|
+ }
|
|
+ }
|
|
+ if (invalid != null) {
|
|
+ throw new IllegalArgumentException("Parameters not allowed in this parameter set: " + invalid);
|
|
+ }
|
|
+
|
|
+ Set<ContextKey<?>> required = contextKeySet.required();
|
|
+ Set<ContextKey<?>> missing = null;
|
|
+
|
|
+ // Check for any required parameters that are missing
|
|
+ for (ContextKey<?> reqKey : required) {
|
|
+ if (!this.params.containsKey(reqKey)) {
|
|
+ if (missing == null) {
|
|
+ missing = new HashSet<>();
|
|
+ }
|
|
+ missing.add(reqKey);
|
|
}
|
|
}
|
|
+ if (missing != null) {
|
|
+ throw new IllegalArgumentException("Missing required parameters: " + missing);
|
|
+ }
|
|
+
|
|
+ return new ContextMap(this.params);
|
|
}
|
|
}
|
|
}
|