Jump to content

Recommended Posts

Posted

I have what appears to be a simple question but it turns out to be way not simple if actually attempted. I am trying to spawn a jukebox, with a record in it and get the jukebox to play that record.

 

So far I can spawn the actual jukebox. That's simple. I can assign it to a TileEntityJukebox variable and get it to put a record in it but I can't get it to actually play the stupid record for anything. I've lost track of all the different things I've tried but here's what I have right now:

 

 this.world.setBlockState(new BlockPos(this.posX - 1, this.posY, this.posZ), Blocks.JUKEBOX.getDefaultState()); //spawn the jukebox block
            TileEntityJukebox jukebox1 = (TileEntityJukebox)this.world.getTileEntity(new BlockPos(this.posX - 1, this.posY, this.posZ));//assign it to a TileEntityJukebox
            ItemStack recordWhatever = new ItemStack(com.xeraster.supertnt.init.Items.RECORDSONG, 1);//create the item stack with the record to go into the jukebox
            jukebox1.setRecord(recordWhatever.copy());//Put the record in the jukebox. Doesn't matter if I do it with or without that ".copy()" part at the end. It won't play the record either way.
            this.world.setBlockState(new BlockPos(this.posX - 1, this.posY, this.posZ), Blocks.JUKEBOX.getDefaultState().withProperty(PropertyBool.create("has_record"), Boolean.valueOf(true)));//I saw this in the BlockJukebox class so I tried slapping it in but lo and behold it still doesn't work. Shocker. /s
this.world.playRecord(new BlockPos(this.posX - 1, this.posY, this.posZ), SoundHandler.RECORDSONG);//tried this too because I saw it on line 86 of BlockJukebox. Doesn't work either. Yeah yeah yeah ik it was in the "dropRecord" function but I'm out of things to try at this point

 

It must be noted that my custom record DOES work when I insert it manually. If I right-click on the spawned jukebox, it spits out the record that it's not playing and if I manually put it back in, it will play.

So what am I missing? How to I spawn a Jukebox with a record in it and make it play it?

Posted

What record is inserted is handled by the Jukebox TileEntity.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

The one called "RECORDSONG". It's a custom added record, not a base game one. It gets inserted when I execute jukebox1.setrecord.(recordWhatever.copy()). I can observe that the record does in fact insert because after the jukebox spawns, I can right-click on it or destroy it and the record pops out.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.