Jump to content

TileEntity unbinds from block so NBTTag is worthless


jh62

Recommended Posts

Hi.

 

I've followed the tutorial from the forge's tutorial page about NBT, but here's what happens:

 

I have a block with a tile entity. I save to that entity some data, but everytime the world reloads the entity get's overwritten by:

 

@Override
public TileEntity createTileEntity(World world, int metadata){
           return new BlockTileEntity();
}

 

... inside the block.

 

I see through console prints that the TileEntity is loading saving the current values properly, but the block in question is not bound anymore to that TileEntity.

 

What am I missing?

Link to comment
Share on other sites

Did you register the tile entity? That could be your problem :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Did you register the tile entity? That could be your problem :P

 

Yes. Everything is registred.

 

As I said: on every world reload, the block creates a new TileEntity, so the previous one is obviously overwritten. I don't know how to retrieve the old one, if that's possible...

Link to comment
Share on other sites

My magical code viewing machine is not working at the moment, sorry... So could you please post your code for me to browse for problems?

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Sorry if some code is messed up. I don't have the *.java files right now. Im using JD-GUI to view the classes I have uploaded.

 

Mod class:

 

@Mod(modid="pablisMod", name="Pablis Mods", version="0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class PablisMod
{
  private static int id = 3096;

  @Mod.Instance("PablisMod")
  public static PablisMod instance;

  @SidedProxy(clientSide="pablisMod.ClientProxy", serverSide="pablisMod.CommonProxy")
  public static CommonProxy proxy;

  @Mod.PreInit
  public void preInit(FMLPreInitializationEvent event)
  {
  }

  @Mod.Init
  public void load(FMLInitializationEvent event)
  {
    --> This is a static method in every block to register itself : It's in the block class. <---
    BigClockBlock.registerBlock(getNextID());

    proxy.registerRenderers();
  }
  @Mod.PostInit
  public void postInit(FMLPostInitializationEvent event) {
  }

  private static int getNextID() {
    return id++;
  }
}

 

Client Proxy:

 

public class ClientProxy extends CommonProxy
{
  public void registerRenderers()
  {    
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClock.png");
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClockIcon.png");
    ClientRegistry.bindTileEntitySpecialRenderer(BigClockEntity.class, new BigClockRenderer());
  }
}

 

The Block:

 

(I wiped out the unninportant part)

 

public class BigClockBlock extends akb
{

  public static int id;

  public BigClockBlock(int id) {
    super(id, agi.d);
    id = id;
    b("Big Clock");
    a(tj.c);
    a(amq.e);
    setTextureFile("/pablisMod/textures/BigClockIcon.png");
    c(0.5F);

    r();
  }

  public TileEntity createTileEntity(World world, int metadata)
  {
    return new BigClockEntity();
  }

public boolean hasTileEntity(){
return true;
}

  public void OnBlockPlacedBy(yc par1World, int par2, int par3, int par4, md par5EntityLiving)
  {
   BigClockEntity entity = par1World.getBlockTileEntity( par2, par3, par4);
   entity.somedata = par2;
  }

  public static Block registerBlock(int id)
  {
    Block m_fieldName = new BigClockBlock(id);

    LanguageRegistry.addName(m_fieldName, "Big Clock");
    GameRegistry.registerBlock(m_fieldName, BigClockItem.class, "BigClockItem");

    GameRegistry.addRecipe(new ItemStack(m_fieldName), new Object[] { "yyy", "xzx", "xxx", Character.valueOf('x'), new ur(amq.M, 1, 1), Character.valueOf('y'), new ur(amq.bR, 1, 1), Character.valueOf('z'), new ur(up.aQ, 1, 0) });

    GameRegistry.registerTileEntity(BigClockEntity.class, "BigClockEntity");

    return m_fieldName;
  }
}

 

TileEntity:

 

public class BigClockEntity extends TileEntity{

  public int somedata = 0;

@Override
public void writeToNBT(NBTTagCompound par1)
{
   super.writeToNBT(par1);
   par1.setInteger("somedata ", somedata );
}

@Override
public void readFromNBT(NBTTagCompound par1)
{
   super.readFromNBT(par1);
   this.somedata = par1.getInteger("somedata ");
}

}

 

 

Link to comment
Share on other sites

@Mod.Instance("PablisMod")

 

Firstly, that should match your mod id. So you might want to change it to pablisMod.

 

public class ClientProxy extends CommonProxy
{
  public void registerRenderers()
  {    
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClock.png");
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClockIcon.png");
    ClientRegistry.bindTileEntitySpecialRenderer(BigClockEntity.class, new BigClockRenderer());
  }
}

 

Another thing, get rid of those preloadTexture lines. That method isn't used anymore.

 

 

 

Sorry if some code is messed up. I don't have the *.java files right now. Im using JD-GUI to view the classes I have uploaded.

 

Mod class:

 

@Mod(modid="pablisMod", name="Pablis Mods", version="0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class PablisMod
{
  private static int id = 3096;

  @Mod.Instance("PablisMod")
  public static PablisMod instance;

  @SidedProxy(clientSide="pablisMod.ClientProxy", serverSide="pablisMod.CommonProxy")
  public static CommonProxy proxy;

  @Mod.PreInit
  public void preInit(FMLPreInitializationEvent event)
  {
  }

  @Mod.Init
  public void load(FMLInitializationEvent event)
  {
    --> This is a static method in every block to register itself : It's in the block class. <---
    BigClockBlock.registerBlock(getNextID());

    proxy.registerRenderers();
  }
  @Mod.PostInit
  public void postInit(FMLPostInitializationEvent event) {
  }

  private static int getNextID() {
    return id++;
  }
}

 

Client Proxy:

 

public class ClientProxy extends CommonProxy
{
  public void registerRenderers()
  {    
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClock.png");
    MinecraftForgeClient.preloadTexture("/pablisMod/textures/BigClockIcon.png");
    ClientRegistry.bindTileEntitySpecialRenderer(BigClockEntity.class, new BigClockRenderer());
  }
}

 

The Block:

 

(I wiped out the unninportant part)

 

public class BigClockBlock extends akb
{

  public static int id;

  public BigClockBlock(int id) {
    super(id, agi.d);
    id = id;
    b("Big Clock");
    a(tj.c);
    a(amq.e);
    setTextureFile("/pablisMod/textures/BigClockIcon.png");
    c(0.5F);

    r();
  }

  public TileEntity createTileEntity(World world, int metadata)
  {
    return new BigClockEntity();
  }

public boolean hasTileEntity(){
return true;
}

  public void OnBlockPlacedBy(yc par1World, int par2, int par3, int par4, md par5EntityLiving)
  {
   BigClockEntity entity = par1World.getBlockTileEntity( par2, par3, par4);
   entity.somedata = par2;
  }

  public static Block registerBlock(int id)
  {
    Block m_fieldName = new BigClockBlock(id);

    LanguageRegistry.addName(m_fieldName, "Big Clock");
    GameRegistry.registerBlock(m_fieldName, BigClockItem.class, "BigClockItem");

    GameRegistry.addRecipe(new ItemStack(m_fieldName), new Object[] { "yyy", "xzx", "xxx", Character.valueOf('x'), new ur(amq.M, 1, 1), Character.valueOf('y'), new ur(amq.bR, 1, 1), Character.valueOf('z'), new ur(up.aQ, 1, 0) });

    GameRegistry.registerTileEntity(BigClockEntity.class, "BigClockEntity");

    return m_fieldName;
  }
}

 

TileEntity:

 

public class BigClockEntity extends TileEntity{

  public int somedata = 0;

@Override
public void writeToNBT(NBTTagCompound par1)
{
   super.writeToNBT(par1);
   par1.setInteger("somedata ", somedata );
}

@Override
public void readFromNBT(NBTTagCompound par1)
{
   super.readFromNBT(par1);
   this.somedata = par1.getInteger("somedata ");
}

}

 

 

 

Ill just point out that you seem to be using much, MUCH older methods and such than 1.6.2? Are you in 1.6.2 yet? Or are you still using the same methods?

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Ill just point out that you seem to be using much, MUCH older methods and such than 1.6.2? Are you in 1.6.2 yet? Or are you still using the same methods?

 

Sorry, I forgot to mention: I'm using 1.4.7 beacuse some mods i have are not compatible with 1.6.2.

Link to comment
Share on other sites

Haha, ok. That makes more sense. Let me pull up what I know about 1.4.7... :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

well for 1 you are not overriding the right method in your block

you are suppose to override:

public boolean hasTileEntity(int metadata)

not

public boolean hasTileEntity()

 

2, dont blame the TE if you have a problem, the TE obviously work because chest, furnace, beacon, sign load correctly and TE are VANILLA class, not forge

 

3

your block class name... its ressemble insanelly a song by macklemore "waddup i got a BigClock(Block)" *irrelevant*

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

well for 1 you are not overriding the right method in your block

you are suppose to override:

public boolean hasTileEntity(int metadata)

not

public boolean hasTileEntity()

 

2, dont blame the TE if you have a problem, the TE obviously work because chest, furnace, beacon, sign load correctly and TE are VANILLA class, not forge

 

3

your block class name... its ressemble insanelly a song by macklemore "waddup i got a BigClock(Block)" *irrelevant*

 

And Im not blaming the TE in general. Obviously they work. Im blaming my Block and my TE and some of the tutorials that you find in the internet.

 

Okey, after overriding the hasTileEntity(int metadata) instead of the other it seems to work now.

 

What is the pourpose of the other method then???

 

 

Link to comment
Share on other sites

Just a thing. Does the super class of your block implements ITileEntityProvider? You should always annotate overriden methods with @Override, so people reading your code can make better sense of it. (And also, because the compiler will complain if you add @Override to a method that doesn't exist on your super class or any of your implemented interfaces or if the method is private. This way you can check if everything works as you expect or if you're just creating a new method that minecraft can't ever know about)

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa OLXTOTO telah menetapkan standar baru dalam dunia perjudian dengan menjadi platform terbesar untuk pengalaman gaming yang penuh kemenangan dan kegacoran, sepanjang masa. Dengan fokus yang kuat pada menyediakan permainan yang menghadirkan kesenangan tanpa batas dan peluang kemenangan besar, OLXTOTO telah menjadi pilihan utama bagi para pencinta judi berani di Indonesia. Maxwin: Mengejar Kemenangan Terbesar Maxwin bukan sekadar kata-kata kosong di OLXTOTO. Ini adalah konsep yang ditanamkan dalam setiap aspek permainan yang mereka tawarkan. Dari permainan slot yang menghadirkan jackpot besar hingga berbagai opsi permainan togel dengan hadiah fantastis, para pemain dapat memperoleh peluang nyata untuk mencapai kemenangan terbesar dalam setiap taruhan yang mereka lakukan. OLXTOTO tidak hanya menawarkan kesempatan untuk menang, tetapi juga menjadi wadah bagi para pemain untuk meraih impian mereka dalam perjudian yang berani. Gacor: Keberuntungan yang Tak Tertandingi Keberuntungan seringkali menjadi faktor penting dalam perjudian, dan OLXTOTO memahami betul akan hal ini. Dengan berbagai strategi dan analisis yang disediakan, pemain dapat menemukan peluang gacor yang tidak tertandingi dalam setiap taruhan. Dari hasil togel yang tepat hingga putaran slot yang menguntungkan, OLXTOTO memastikan bahwa setiap taruhan memiliki potensi untuk menjadi momen yang mengubah hidup. Inovasi dan Kualitas Tanpa Batas Tidak puas dengan prestasi masa lalu, OLXTOTO terus berinovasi untuk memberikan pengalaman gaming terbaik kepada para pengguna. Dengan menggabungkan teknologi terbaru dengan desain yang ramah pengguna, platform ini menyajikan antarmuka yang mudah digunakan tanpa mengorbankan kualitas. Setiap pembaruan dan peningkatan dilakukan dengan tujuan tunggal: memberikan pengalaman gaming yang tanpa kompromi kepada setiap pengguna. Komitmen Terhadap Kepuasan Pelanggan Di balik kesuksesan OLXTOTO adalah komitmen mereka terhadap kepuasan pelanggan. Tim dukungan pelanggan yang profesional siap membantu para pemain dalam setiap langkah perjalanan gaming mereka. Dari pertanyaan teknis hingga bantuan dengan transaksi keuangan, OLXTOTO selalu siap memberikan pelayanan terbaik kepada para pengguna mereka. Penutup: Mengukir Sejarah dalam Dunia Perjudian Daring OLXTOTO bukan sekadar platform perjudian berani biasa. Ini adalah ikon dalam dunia perjudian daring Indonesia, sebuah destinasi yang menyatukan kemenangan dan keberuntungan dalam satu tempat yang mengasyikkan. Dengan komitmen mereka terhadap kualitas, inovasi, dan kepuasan pelanggan, OLXTOTO terus mengukir sejarah dalam dunia perjudian berani, menjadi nama yang tak terpisahkan dari pengalaman gaming terbaik. Bersiaplah untuk mengalami sensasi kemenangan terbesar dan keberuntungan tak terduga di OLXTOTO - platform maxwin dan gacor terbesar sepanjang masa.
    • OLXTOTO - Bandar Togel Online Dan Slot Terbesar Di Indonesia OLXTOTO telah lama dikenal sebagai salah satu bandar online terkemuka di Indonesia, terutama dalam pasar togel dan slot. Dengan reputasi yang solid dan pengalaman bertahun-tahun, OLXTOTO menawarkan platform yang aman dan andal bagi para penggemar perjudian daring. DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI Beragam Permainan Togel Sebagai bandar online terbesar di Indonesia, OLXTOTO menawarkan berbagai macam permainan togel. Mulai dari togel Singapura, togel Hongkong, hingga togel Sidney, pemain memiliki banyak pilihan untuk mencoba keberuntungan mereka. Dengan sistem yang transparan dan hasil yang adil, OLXTOTO memastikan bahwa setiap taruhan diproses dengan cepat dan tanpa keadaan. Slot Online Berkualitas Selain togel, OLXTOTO juga menawarkan berbagai permainan slot online yang menarik. Dari slot klasik hingga slot video modern, pemain dapat menemukan berbagai opsi permainan yang sesuai dengan preferensi mereka. Dengan grafis yang memukau dan fitur bonus yang menggiurkan, pengalaman bermain slot di OLXTOTO tidak akan pernah membosankan. Keamanan dan Kepuasan Pelanggan Terjamin Keamanan dan kepuasan pelanggan merupakan prioritas utama di OLXTOTO. Mereka menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan para pemain. Tim dukungan pelanggan yang ramah dan responsif siap membantu pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Promosi dan Bonus Menarik OLXTOTO sering menawarkan promosi dan bonus menarik kepada para pemainnya. Mulai dari bonus selamat datang hingga bonus deposit, pemain memiliki kesempatan untuk meningkatkan kemenangan mereka dengan memanfaatkan berbagai penawaran yang tersedia. Penutup Dengan reputasi yang solid, beragam permainan berkualitas, dan komitmen terhadap keamanan dan kepuasan pelanggan, OLXTOTO tetap menjadi salah satu pilihan utama bagi para pecinta judi online di Indonesia. Jika Anda mencari pengalaman berjudi yang menyenangkan dan terpercaya, OLXTOTO layak dipertimbangkan.
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
    • I have no idea how a UI mod crashed a whole world but HUGE props to you man, just saved me +2 months of progress!  
  • Topics

×
×
  • Create New...

Important Information

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