Commits
Lukas A authored 6e887cd942b
45 45 | import org.bukkit.entity.minecart.ExplosiveMinecart; |
46 46 | import org.bukkit.entity.minecart.HopperMinecart; |
47 47 | import org.bukkit.entity.minecart.PoweredMinecart; |
48 48 | import org.bukkit.entity.minecart.SpawnerMinecart; |
49 49 | import org.bukkit.entity.minecart.StorageMinecart; |
50 50 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; |
51 51 | import org.bukkit.event.world.SpawnChangeEvent; |
52 52 | import org.bukkit.generator.BlockPopulator; |
53 53 | import org.bukkit.generator.ChunkGenerator; |
54 54 | import org.bukkit.inventory.ItemStack; |
55 + | import org.bukkit.material.MaterialData; |
55 56 | import org.bukkit.metadata.MetadataValue; |
56 57 | import org.bukkit.plugin.Plugin; |
57 58 | import org.bukkit.plugin.messaging.StandardMessenger; |
58 59 | import org.bukkit.potion.PotionData; |
59 60 | import org.bukkit.potion.PotionType; |
60 61 | import org.bukkit.util.Vector; |
61 62 | |
62 63 | public class CraftWorld implements World { |
63 64 | public static final int CUSTOM_DIMENSION_OFFSET = 10; |
64 65 | |
845 846 | if (distance <= radius) { |
846 847 | ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); |
847 848 | } |
848 849 | } |
849 850 | } |
850 851 | |
851 852 | public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException { |
852 853 | return spawn(location, clazz, SpawnReason.CUSTOM); |
853 854 | } |
854 855 | |
856 + | |
857 + | public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { |
858 + | Validate.notNull(data, "MaterialData cannot be null"); |
859 + | return spawnFallingBlock(location, data.getItemType(), data.getData()); |
860 + | } |
861 + | |
855 862 | public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException { |
856 863 | Validate.notNull(location, "Location cannot be null"); |
857 864 | Validate.notNull(material, "Material cannot be null"); |
858 865 | Validate.isTrue(material.isBlock(), "Material must be a block"); |
859 866 | |
860 867 | EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).fromLegacyData(data)); |
861 868 | entity.ticksLived = 1; |
862 869 | |
863 870 | world.addEntity(entity, SpawnReason.CUSTOM); |
864 871 | return (FallingBlock) entity.getBukkitEntity(); |