I am looking for a way to set the data for a block, just like the vanilla /blockdata command would do. Not the setData(byte) but the actual block properties (whether it is via json, or setting each property manually). How can I do that? Thank you, Victor
Take a look at Block#getState() (the BlockState class), you can also cast that to stuff like Chest to set a chest block's contents
I need to set a spawner to spawn withers with a certain nametag /blockdata x y z {EntityId:WitherBoss,SpawnData:{CustomName:"Name"}} I am looking for an analogy to do that with bukkit code. Casting BlockState to CreatureSpawner does not provide me that feature. is there a way to set a spawner to a certain entity (with it's characteristics)?
Actually, using some NMS it's pretty doable: Code (Text): TileEntityMobSpawner tile = ((CraftCreatureSpawner) <blockstate>).getTileEntity(); MobSpawnerAbstract spawner = tile.getSpawner(); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound properties = new NBTTagCompound(); properties.setString("CustomName", "Name"); tag.set("Properties", properties); MobSpawnerAbstract.a data = new MobSpawnerAbstract.a(tag, "WitherBoss"); spawner.a(data); <blockstate>.update(); I'm not sure if it will work, because I just looked this up in the spigot jar, but I think it should work fine.