-
-
Save algj/b32e459ad1737ef6e478c0cc305990ed to your computer and use it in GitHub Desktop.
Spigot Mob Spawner head for resource packs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// don't forget to add craftbukkit.jar of your server version. seriously. | |
Location loc = player.getLocation(); | |
World world = player.getWorld(); | |
Block block = world.getBlockAt(loc); | |
BlockState state = block.getState(); | |
state.setType(Material.SPAWNER); | |
state.update(true); | |
CreatureSpawner data = (CreatureSpawner) block.getState(); | |
data.setRequiredPlayerRange(0); | |
data.setSpawnRange(0); | |
data.setSpawnCount(0); | |
data.setSpawnedType(EntityType.ARMOR_STAND); | |
data.update(); | |
block.setBlockData(data.getBlockData()); | |
BlockPosition blockPos = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getZ()); | |
TileEntityMobSpawner spawner = (TileEntityMobSpawner) ((CraftWorld) world).getHandle().getTileEntity(blockPos); | |
NBTTagCompound spawnerTag = spawner.b(); | |
spawnerTag.setShort("SpawnRange", (short) 0); | |
spawnerTag.setShort("MaxNearbyEntities", (short) 0); | |
NBTTagList handList = new NBTTagList(); | |
NBTTagList armorList = new NBTTagList(); | |
NBTTagCompound mainHand = new NBTTagCompound(); | |
NBTTagCompound offHand = new NBTTagCompound(); | |
handList.add(mainHand); | |
handList.add(offHand); | |
NBTTagCompound helmet = new NBTTagCompound(); | |
NBTTagCompound chestplate = new NBTTagCompound(); | |
NBTTagCompound leggings = new NBTTagCompound(); | |
NBTTagCompound boots = new NBTTagCompound(); | |
helmet.setString("id", "minecraft:bread"); | |
helmet.setShort("Count", (short) 1); | |
NBTTagCompound tag = new NBTTagCompound(); | |
tag.setShort("CustomModelData", (short) 2); | |
helmet.set("tag", tag); | |
armorList.add(boots); | |
armorList.add(leggings); | |
armorList.add(chestplate); | |
armorList.add(helmet); | |
NBTTagCompound spawnData = new NBTTagCompound(); | |
spawnData.setString("id", "armor_stand"); | |
spawnData.set("HandItems", handList); | |
spawnData.set("ArmorItems", armorList); | |
spawnerTag.set("SpawnData", spawnData); | |
spawner.load(spawnerTag); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment