aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0199-Allow-spawning-Item-entities-with-World.spawnEntity.patch
blob: b25c1ffce95ccf2387c0f74fa70f92a907557ac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 4 Jun 2018 20:39:20 -0400
Subject: [PATCH] Allow spawning Item entities with World.spawnEntity

This API has more capabilities than .dropItem with the Consumer function

Item can be set inside of the Consumer pre spawn function.

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
index c783fb9d3c2569c324877037913f286c325354ff..177d58dca134ee590af9cfd1fb427aa7eed7d4b3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
@@ -594,6 +594,10 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
                 entity = net.minecraft.world.entity.EntityType.BOAT.create(world);
             }
             entity.moveTo(x, y, z, yaw, pitch);
+            // Paper start
+        } else if (org.bukkit.entity.Item.class.isAssignableFrom(clazz)) {
+            entity = new net.minecraft.world.entity.item.ItemEntity(world, x, y, z, new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Item.byBlock(net.minecraft.world.level.block.Blocks.DIRT)));
+            // Paper end
         } else if (FallingBlock.class.isAssignableFrom(clazz)) {
             BlockPos pos = BlockPos.containing(x, y, z);
             entity = FallingBlockEntity.fall(world, pos, this.getHandle().getBlockState(pos));