mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-28 23:49:41 +02:00
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 70d24eb8 SPIGOT-6587: Update documentation/error of drop chance API CraftBukkit Changes: 470050ad SPIGOT-6587: Update documentation/error of drop chance API 1c39efa3 Fix Inventory#getViewers on the player inventory not returning the player first time their inventory is opened d161627d Fix PrepareItemCraftEvent#isRepair aa1fae73 SPIGOT-6586: EntityChangeBlockEvent for falling block does not cancel properly 8a04072e SPIGOT-6583: Throwing eggs doesn't make sounds Spigot Changes: f773da84 Remove redundant patch cd367234 Rebuild patches
94 lines
5.0 KiB
Diff
94 lines
5.0 KiB
Diff
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..6271586368c65250c887739d04c5fccf95fdb2d8
|
|
--- /dev/null
|
|
+++ b/src/main/java/io/papermc/paper/CraftEntityTag.java
|
|
@@ -0,0 +1,28 @@
|
|
+package io.papermc.paper;
|
|
+
|
|
+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;
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.tags.TagCollection;
|
|
+
|
|
+public class CraftEntityTag extends CraftTag<net.minecraft.world.entity.EntityType<?>, EntityType> {
|
|
+
|
|
+ public CraftEntityTag(TagCollection<net.minecraft.world.entity.EntityType<?>> registry, ResourceLocation tag) {
|
|
+ super(registry, tag);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isTagged(EntityType item) {
|
|
+ return getHandle().contains(CraftMagicNumbers.getEntityTypes(item));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Set<EntityType> getValues() {
|
|
+ return Collections.unmodifiableSet(getHandle().getValues().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 5412c537fa3c3c1e4613a3b3b0ebfdf983a6902a..811cd39d8ce944abe0eff5d5d3e9af5b1fb0edf7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2217,6 +2217,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(FluidTags.getAllTags(), 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(net.minecraft.tags.EntityTypeTags.getAllTags(), 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 9cbe97686394a5c4ae7b401d846b1a3525602d46..75240802d17ff6b032c8708700cb2407cca3e56f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -116,8 +116,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, net.minecraft.world.level.material.Fluid> MATERIAL_FLUID = new HashMap<>();
|
|
+ // Paper start
|
|
+ private static final Map<org.bukkit.entity.EntityType, net.minecraft.world.entity.EntityType<?>> ENTITY_TYPE_ENTITY_TYPES = new HashMap<>();
|
|
+ private static final Map<net.minecraft.world.entity.EntityType<?>, 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.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())));
|
|
+ ENTITY_TYPES_ENTITY_TYPE.put(net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey())), type);
|
|
+ }
|
|
+ // Paper end
|
|
for (Block block : net.minecraft.core.Registry.BLOCK) {
|
|
BLOCK_MATERIAL.put(block, Material.getMaterial(net.minecraft.core.Registry.BLOCK.getKey(block).getPath().toUpperCase(Locale.ROOT)));
|
|
}
|
|
@@ -183,6 +192,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
public static ResourceLocation key(Material mat) {
|
|
return CraftNamespacedKey.toMinecraft(mat.getKey());
|
|
}
|
|
+ // Paper start
|
|
+ public static net.minecraft.world.entity.EntityType<?> getEntityTypes(org.bukkit.entity.EntityType type) {
|
|
+ return ENTITY_TYPE_ENTITY_TYPES.get(type);
|
|
+ }
|
|
+ public static org.bukkit.entity.EntityType getEntityType(net.minecraft.world.entity.EntityType<?> entityTypes) {
|
|
+ return ENTITY_TYPES_ENTITY_TYPE.get(entityTypes);
|
|
+ }
|
|
+ // Paper end
|
|
// ========================================================================
|
|
// Paper start
|
|
@Override
|