diff --git a/Spigot-API-Patches/Mob-Spawner-API-Enhancements.patch b/Spigot-API-Patches/Mob-Spawner-API-Enhancements.patch index 8c1e532b74..5aa9cb0654 100644 --- a/Spigot-API-Patches/Mob-Spawner-API-Enhancements.patch +++ b/Spigot-API-Patches/Mob-Spawner-API-Enhancements.patch @@ -25,5 +25,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Resets the spawn delay timer within the min/max range + */ + public void resetTimer(); ++ ++ /** ++ * Sets the {@link EntityType} to {@link EntityType#DROPPED_ITEM} and sets the data to the given ++ * {@link org.bukkit.inventory.ItemStack ItemStack}. ++ * <p> ++ * {@link #setSpawnCount(int)} does not dictate the amount of items in the stack spawned, but rather how many ++ * stacks should be spawned. ++ * ++ * @param itemStack The item to spawn. Must not {@link org.bukkit.Material#isAir be air}. ++ * @see #setSpawnedType(EntityType) ++ */ ++ void setSpawnedItem(@NotNull org.bukkit.inventory.ItemStack itemStack); + // Paper end } diff --git a/Spigot-Server-Patches/Mob-Spawner-API-Enhancements.patch b/Spigot-Server-Patches/Mob-Spawner-API-Enhancements.patch index 44a6cbfcac..e1473d9deb 100644 --- a/Spigot-Server-Patches/Mob-Spawner-API-Enhancements.patch +++ b/Spigot-Server-Patches/Mob-Spawner-API-Enhancements.patch @@ -85,6 +85,21 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +@@ -0,0 +0,0 @@ import org.bukkit.Material; + import org.bukkit.block.Block; + import org.bukkit.block.CreatureSpawner; + import org.bukkit.entity.EntityType; ++// Paper start ++import net.minecraft.server.IRegistry; ++import net.minecraft.server.MobSpawnerData; ++import net.minecraft.server.NBTTagCompound; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; ++import org.bukkit.inventory.ItemStack; ++// Paper end + + public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpawner> implements CreatureSpawner { + @@ -0,0 +0,0 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa public void setSpawnRange(int spawnRange) { this.getSnapshot().getSpawner().spawnRange = spawnRange; @@ -100,5 +115,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void resetTimer() { + this.getSnapshot().getSpawner().resetTimer(); + } ++ ++ @Override ++ public void setSpawnedItem(ItemStack itemStack) { ++ Preconditions.checkArgument(itemStack != null && !itemStack.getType().isAir(), "spawners cannot spawn air"); ++ net.minecraft.server.ItemStack item = CraftItemStack.asNMSCopy(itemStack); ++ NBTTagCompound compound = new NBTTagCompound(); ++ NBTTagCompound entity = new NBTTagCompound(); ++ entity.setString("id", IRegistry.ENTITY_TYPE.getKey(EntityTypes.ITEM).toString()); ++ entity.set("Item", item.save(new NBTTagCompound())); ++ compound.set("Entity", entity); ++ compound.setInt("Weight", this.getSnapshotNBT().hasKeyOfType("Weight", CraftMagicNumbers.NBT.TAG_ANY_NUMBER) ? this.getSnapshotNBT().getInt("Weight") : 1); ++ this.getSnapshot().getSpawner().setSpawnData(new MobSpawnerData(compound)); ++ this.getSnapshot().getSpawner().mobs.clear(); ++ } + // Paper end }