Jump to content

Recommended Posts

Posted (edited)

Hey Guys,

i'm trying to create a custom Jukebox which allows starting and stopping the current disc. I've added a play and stop button in my Menu Screen to controll the play state but for some reason nothing happens if i click my buttons.

Menu:

  Reveal hidden contents

MenuScreen:

  Reveal hidden contents

Packet:

  Reveal hidden contents

BlockEntity:

  Reveal hidden contents
Edited by Skyriis
Posted
  On 5/5/2022 at 8:02 PM, diesieben07 said:

These fields should not be in the packet. At most they allow the user to cheat. The server already knows this information.

Expand  

They where unused anyway. I've removed them from the Packet and updated the code above. My Problem still remains :(

Posted
  On 5/6/2022 at 7:22 AM, diesieben07 said:

I don't see anything that would even happen if the packet is received, except the server setting the block state. Is that all that you expected

Expand  

It should change "isPlaying" variable too. (in the play / stop method of the blockentity)

Posted
  On 5/6/2022 at 7:57 AM, diesieben07 said:

How have you checked whether it does or not?

Expand  

If i check it in the Packet (using the menu.isPlaying method) it'll show the correct value but if i check it in the menu screen it shows the old / default value.

Posted

i guess that thing get's invoked when i open my container but why?

container.addListener((handler, slot) -> {
            if (slot == 8) {
                stop();
            }
            setChanged();
        });

it should only get invoked if "onContentsChanged" get's called

Posted (edited)

Okay next problem. the blockentity doesn't play anything when i log out and log in again. I guess i have to run the 

level.levelEvent(PLAY_RECORD_EVENT, worldPosition, Item.getId(getRecord().getItem()));

when the blockentity gets loaded but is there a method for that?

Edited by Skyriis
Posted (edited)
  On 5/6/2022 at 10:28 AM, diesieben07 said:

You have to do it in your BlockEntity's ticker

Expand  

i should run

level.levelEvent(PLAY_RECORD_EVENT, worldPosition, Item.getId(getRecord().getItem()));

every tick? Wouldn't that cause the disc to go crasy?

Edited by Skyriis
Posted (edited)
  On 5/6/2022 at 11:54 AM, diesieben07 said:

You make a boolean.

Expand  

Okay i made a boolean and it started the disc but i can't stop it anymore. (i've updated the code above).

 

EDIT

nvm i forgot to update the boolean

Edited by Skyriis

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.