geforkt von Mirrors/Paper
Added Vanilla Entity Tags
Dieser Commit ist enthalten in:
Ursprung
fccac282aa
Commit
97d0c571b4
43
Spigot-API-Patches/0263-Added-Vanilla-Entity-Tags.patch
Normale Datei
43
Spigot-API-Patches/0263-Added-Vanilla-Entity-Tags.patch
Normale Datei
@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 20:03:40 -0800
|
||||
Subject: [PATCH] Added Vanilla Entity Tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
|
||||
index aacbfadc91f580cc667603c8165eacbadee38cca..cbefdacee2d7b29a705de20935e20380a4632e14 100644
|
||||
--- a/src/main/java/org/bukkit/Tag.java
|
||||
+++ b/src/main/java/org/bukkit/Tag.java
|
||||
@@ -421,6 +421,32 @@ public interface Tag<T extends Keyed> extends Keyed {
|
||||
* Vanilla fluid tag representing water and flowing water.
|
||||
*/
|
||||
Tag<Fluid> FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class);
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Key for the build in entity registry
|
||||
+ */
|
||||
+ String REGISTRY_ENTITIES = "entities";
|
||||
+ /**
|
||||
+ * Vanilla entity tag representing arrow entities.
|
||||
+ */
|
||||
+ Tag<org.bukkit.entity.EntityType> ARROWS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("arrows"), org.bukkit.entity.EntityType.class);
|
||||
+ /**
|
||||
+ * Vanilla entity tag representing entities that live in beehives
|
||||
+ */
|
||||
+ Tag<org.bukkit.entity.EntityType> BEEHIVE_INHABITORS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("beehive_inhabitors"), org.bukkit.entity.EntityType.class);
|
||||
+ /**
|
||||
+ * Vanilla entity tag representing projectiles that impact
|
||||
+ */
|
||||
+ Tag<org.bukkit.entity.EntityType> IMPACT_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("impact_projectiles"), org.bukkit.entity.EntityType.class);
|
||||
+ /**
|
||||
+ * Vanilla entity tag for village raiders
|
||||
+ */
|
||||
+ Tag<org.bukkit.entity.EntityType> RAIDERS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("raiders"), org.bukkit.entity.EntityType.class);
|
||||
+ /**
|
||||
+ * Vanilla entity tag for skeleton types
|
||||
+ */
|
||||
+ Tag<org.bukkit.entity.EntityType> SKELETONS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("skeletons"), org.bukkit.entity.EntityType.class);
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Returns whether or not this tag has an entry for the specified item.
|
95
Spigot-Server-Patches/0657-Added-Vanilla-Entity-Tags.patch
Normale Datei
95
Spigot-Server-Patches/0657-Added-Vanilla-Entity-Tags.patch
Normale Datei
@ -0,0 +1,95 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 20:03:35 -0800
|
||||
Subject: [PATCH] Added Vanilla Entity Tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/CraftEntityTag.java b/src/main/java/io/papermc/paper/CraftEntityTag.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4a689a2769ac343c2ffab49631c416014ce46d02
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/CraftEntityTag.java
|
||||
@@ -0,0 +1,30 @@
|
||||
+package io.papermc.paper;
|
||||
+
|
||||
+import net.minecraft.server.Entity;
|
||||
+import net.minecraft.server.EntityTypes;
|
||||
+import net.minecraft.server.MinecraftKey;
|
||||
+import net.minecraft.server.Tags;
|
||||
+import org.bukkit.craftbukkit.tag.CraftTag;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.Set;
|
||||
+import java.util.stream.Collectors;
|
||||
+
|
||||
+public class CraftEntityTag extends CraftTag<EntityTypes<?>, EntityType> {
|
||||
+
|
||||
+ public CraftEntityTag(Tags<EntityTypes<?>> registry, MinecraftKey tag) {
|
||||
+ super(registry, tag);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isTagged(EntityType item) {
|
||||
+ return getHandle().isTagged(CraftMagicNumbers.getEntityTypes(item));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Set<EntityType> getValues() {
|
||||
+ return Collections.unmodifiableSet(getHandle().getTagged().stream().map(CraftMagicNumbers::getEntityType).collect(Collectors.toSet()));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index dc7de2b59ec5ca3e5fba34dbb2aa2e6aed8f95cb..9ad6ea5ef331c3c057f39115d00f855ca57e219b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2169,6 +2169,11 @@ public final class CraftServer implements Server {
|
||||
Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type");
|
||||
|
||||
return (org.bukkit.Tag<T>) new CraftFluidTag(console.getTagRegistry().getFluidTags(), key);
|
||||
+ // Paper start
|
||||
+ case org.bukkit.Tag.REGISTRY_ENTITIES:
|
||||
+ Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity namespace must have entitytype type");
|
||||
+ return (org.bukkit.Tag<T>) new io.papermc.paper.CraftEntityTag(console.getTagRegistry().getEntityTags(), key);
|
||||
+ // Paper end
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 979f3504e6a6ca46993f3d9b0f408ab6744bdccd..ac5003dc827217bd1947c71044abcbcbd2210dcd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -91,8 +91,17 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
private static final Map<Material, Item> MATERIAL_ITEM = new HashMap<>();
|
||||
private static final Map<Material, Block> MATERIAL_BLOCK = new HashMap<>();
|
||||
private static final Map<Material, FluidType> MATERIAL_FLUID = new HashMap<>();
|
||||
+ // Paper start
|
||||
+ private static final Map<org.bukkit.entity.EntityType, net.minecraft.server.EntityTypes<?>> ENTITY_TYPE_ENTITY_TYPES = new HashMap<>();
|
||||
+ private static final Map<net.minecraft.server.EntityTypes<?>, org.bukkit.entity.EntityType> ENTITY_TYPES_ENTITY_TYPE = new HashMap<>();
|
||||
|
||||
static {
|
||||
+ for (org.bukkit.entity.EntityType type : org.bukkit.entity.EntityType.values()) {
|
||||
+ if (type == org.bukkit.entity.EntityType.UNKNOWN) continue;
|
||||
+ ENTITY_TYPE_ENTITY_TYPES.put(type, net.minecraft.server.IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())));
|
||||
+ ENTITY_TYPES_ENTITY_TYPE.put(net.minecraft.server.IRegistry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())), type);
|
||||
+ }
|
||||
+ // Paper end
|
||||
for (Block block : IRegistry.BLOCK) {
|
||||
BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getKey().toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
@@ -158,6 +167,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public static MinecraftKey key(Material mat) {
|
||||
return CraftNamespacedKey.toMinecraft(mat.getKey());
|
||||
}
|
||||
+ // Paper start
|
||||
+ public static net.minecraft.server.EntityTypes<?> getEntityTypes(org.bukkit.entity.EntityType type) {
|
||||
+ return ENTITY_TYPE_ENTITY_TYPES.get(type);
|
||||
+ }
|
||||
+ public static org.bukkit.entity.EntityType getEntityType(net.minecraft.server.EntityTypes<?> entityTypes) {
|
||||
+ return ENTITY_TYPES_ENTITY_TYPE.get(entityTypes);
|
||||
+ }
|
||||
+ // Paper end
|
||||
// ========================================================================
|
||||
// Paper start
|
||||
@Override
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren