Jump to content

[1.16] TileEnity has no "read" functiom.


KidKoderMod033109

Recommended Posts

Hi,

I working on making my Tile Entity store data, but when I tried to override the read function, there was no such thing. Here is my code:

public class CopperCoreTileEntity extends TileEntity implements ITickableTileEntity {
    public int x, y, z;
    private int power = 0;
    private int tick;
    private boolean inited;

    public CopperCoreTileEntity(TileEntityType<?> tileEntityTypeIn) {
        super(tileEntityTypeIn);
    }
    public CopperCoreTileEntity() {
        this(ModTileEntityTypes.COPPER_CORE.get());
    }

    public void tick() {
        if(!inited) init();
        tick++;
        if(tick==6000 && power > 0) {
            power--;
        }
    }

    private void init() {
        inited  = true;
        x = this.pos.getX() - 1;
        y = this.pos.getY() - 1;
        z = this.pos.getZ() - 1;
        tick = 0;
    }

    @Override
    public CompoundNBT write(CompoundNBT compound) {
        compound.put("initvalue", NBTHelper.toNBT(this));
        return  super.write(compound);
    }

}

How do I override the read function?

Thanks in advance,

Kid Koder

Link to comment
Share on other sites

There is actually a read function it just isn't named. 

read(@Nonnull CompoundNBT nbt) → func_230337_a_(BlockState p_230337_1_, CompoundNBT nbt)

 

When you override the function let your IDE complete it for you. It will define the BlockState is an input that you will have to use.

I was able to find this list of functions through this website. You will need to know what they

are named when you start creating your GUIs.

[removed link to website with illegal forge rehosting - diesieben07]

Edited by diesieben07
Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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