I'm trying to use the following code to check what a jukebox is playing, but it returns gold record even if its playing a green record. BlockState b=player.getTargetBlock(null, 100).getState(); and then ((Jukebox)b.getData()).getPlaying() But as far as I can tell, both the code and the minecraft wiki incorrectly assume that the jukebox stores the record in the data value. From what I've seen, the data value just says 1 if theres a disc in it. Which is why the code always outputs gold record. Anyway, is there some other way to check which record is inside a jukebox?
I think you could try to raise a flag when a player "inserts" the disc in the jukebox, containing the disc that was inserted. Then you could check if the jukebox is playing, and check that variable, then do your code Code:java BlockState b = player.getTargetBlock(null, 100).getState();if (((Jukebox)b.getData()).getPlaying() && theVarIToldYou == 1) { //1=green, 2=gold, for example do.something();} Edit: i didn't test this.
Experimental, you will need CraftBukkit: Code:java Location l = player.getLocation();TileEntityRecordPlayer recordplayer =(TileEntityRecordPlayer) ((CraftWorld) player.getWorld()).getHandle().getTileEntity(l.getBlockX(), l.getBlockY(), l.getBlockZ());int typeOfRecord = recordplayer.a; BTW, 0 means no disk.