mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-29 11:07:59 +01:00
Add API to send game events (#6444)
This commit is contained in:
parent
ebb3c9b96a
commit
b3c84b4e7d
2 changed files with 32 additions and 0 deletions
patches
|
@ -109,6 +109,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ */
|
+ */
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ Collection<Material> getInfiniburn();
|
+ Collection<Material> getInfiniburn();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Posts a specified game event at a location
|
||||||
|
+ *
|
||||||
|
+ * @param sourceEntity optional source entity
|
||||||
|
+ * @param gameEvent the game event to post
|
||||||
|
+ * @param position the position in the world where to post the event to listeners
|
||||||
|
+ */
|
||||||
|
+ void sendGameEvent(@Nullable Entity sourceEntity, @NotNull GameEvent gameEvent, @NotNull Vector position);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
// Spigot start
|
// Spigot start
|
||||||
|
|
|
@ -64,8 +64,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public Collection<org.bukkit.Material> getInfiniburn() {
|
+ public Collection<org.bukkit.Material> getInfiniburn() {
|
||||||
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().infiniburn().getValues().iterator(), CraftMagicNumbers::getMaterial));
|
+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(getHandle().dimensionType().infiniburn().getValues().iterator(), CraftMagicNumbers::getMaterial));
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) {
|
||||||
|
+ getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.Registry.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position));
|
||||||
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
public Raid locateNearestRaid(Location location, int radius) {
|
public Raid locateNearestRaid(Location location, int radius) {
|
||||||
Validate.notNull(location, "Location cannot be null");
|
Validate.notNull(location, "Location cannot be null");
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java b/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java
|
||||||
|
@@ -0,0 +0,0 @@ public final class CraftVector {
|
||||||
|
public static net.minecraft.world.phys.Vec3 toNMS(org.bukkit.util.Vector bukkit) {
|
||||||
|
return new net.minecraft.world.phys.Vec3(bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
||||||
|
}
|
||||||
|
+ // Paper start
|
||||||
|
+ public static org.bukkit.util.Vector toBukkit(net.minecraft.core.BlockPos blockPosition) {
|
||||||
|
+ return new org.bukkit.util.Vector(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static net.minecraft.core.BlockPos toBlockPos(org.bukkit.util.Vector bukkit) {
|
||||||
|
+ return new net.minecraft.core.BlockPos(bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue