Jump to content

Recommended Posts

Posted

good days 
this is a kind of cursed block intended to to be set in some dungeons and give lot as a chest 


The problem is it saves the items only when it feels like  the gold and the emeralds just get loss after reload the world the block entity just goes back to the last saved state data the one whit 
the carbono armor item in the chest slot 

 

i made some experiments i made a custome itemhandler whit system outs to see whats happening 

  Reveal hidden contents

 

the important part is this  here this system out must only print when a change afects the itemhandler in the server side and here i manually force the block entity to save that custom itemhandler to the Block entity nbt and then save the BlockEnt to the world 

	    // ########## ########## ########## ##########
    public void save() {
        if (this.container == null) {
            System.out.println("\n#this.container is Null at save()#\n");
        }
	        if (this.container != null) {
            Level warudo = this.container.getLevel();
            if(!warudo.isClientSide()) {
                System.out.println("\n#this.container is saving()#\n");
                CompoundTag nbt = this.container.serializeNBT();
                nbt.put("inventory", this.serializeNBT());
                this.container.load(nbt);
                warudo.setBlockEntity(this.container);
            }
            return;
        }
        //this.container.saveAdditional( this.serializeNBT() );
    }
	

 

in the console i see this every time i take or move some item from the gui

	#this.container is saving()#
	 
	#this.container is saving()#
	 
	#this.container is saving()#
	 
	#this.container is saving()#
	 
	#this.container is saving()#
	

####################################################

this means the menu is working and sending the changes to the server side but this blockentity nbt data is not getting save to the world   

warudo.setBlockEntity(this.container);

is doing nothing 

i have more block entities and those entities has the same problem i just no notice it until know  

 

my guest is

coze this happends before in 1.19 and that time whats coze i dont register the blockentities to the bus 

but this time im doing it 
 

  Reveal hidden contents

 

 

the thing is that i think this is not valid for 1.20.4 coze i get it from a 1.20.1 tutorial an probably the way of declaring it has change again 

    public static final RegistryObject<BlockEntityType<BlockEntityBodyBlock>> BLOCKENTITYMOBBLOCK =
            BLOCK_ENTITIES.register( "blockentitymobblock", () ->
                    BlockEntityType.Builder.of( BlockEntityBodyBlock::new,
                            BlockInit.DEAD_BODY.get() ).build(null)  );

 

############################################################################################

what i think i need is an example a working code gits whit block entities register soo i could fix the mines according to 1.20.4 

 

 

thanks for reading the long post 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.