Jump to content

Recommended Posts

Posted

I have created a Lantern TileEntity, but it does not save the values.

Here is the TileEntity class:

 

 

 

package itsamysterious.mods.reallifemod.core.blocks.tiles;

 

import itsamysterious.mods.reallifemod.core.tiles.RLMTileEntity;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.network.NetworkManager;

import net.minecraft.network.Packet;

import net.minecraft.network.play.server.S35PacketUpdateTileEntity;

 

public class TileEntity_Lantern extends RLMTileEntity{

public float rotation;

public boolean isActive;

 

public TileEntity_Lantern(int i) {

super("LanternTileentity");

this.rotation=i*90;

}

 

    public void writeToNBT(NBTTagCompound compound){

    NBTTagCompound tag=new NBTTagCompound();

    tag.setBoolean("IsActive", isActive);

    tag.setFloat("Rotation", rotation);

    compound.setTag("LanternTag", tag);

    super.writeToNBT(compound);

 

    }

   

    @Override

    public void readFromNBT(NBTTagCompound compound) {

    super.readFromNBT(compound);

    NBTTagCompound tag=compound.getCompoundTag("LanternTag");

    this.isActive=tag.getBoolean("IsActive");

    this.rotation=tag.getFloat("Rotation");

    }

 

    @Override

    public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)

    {

      NBTTagCompound tag = pkt.getNbtCompound();

      readFromNBT(tag);

    }

   

    public Packet getDescriptionPacket()

    {

      NBTTagCompound tag = new NBTTagCompound();

      writeToNBT(tag);

      return new S35PacketUpdateTileEntity(getPos(), 1, tag);

    }

}

 

 

 

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.