Jump to content

spywhere

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Nope!

spywhere's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thank you. Problem now solved. In fact, I saw that "GuiScreenBook" have a method called "sendBookToServer" which required to send a packet to server. Instead of sending a packet to server. I set a global variable inside GUI class and use that data to save on server call which is works great.
  2. Thank you. Problem now solved. In fact, I saw that "GuiScreenBook" have a method called "sendBookToServer" which required to send a packet to server. Instead of sending a packet to server. I set a global variable inside GUI class and use that data to save on server call which is works great.
  3. That's what I just thinking about how it's work... Before posting this, I try to make it store data on server side and open GUI on client side but there's a problem which is when you first open GUI, the random value generated but didn't stored and when you try open it again, that's the time it's stored the value... Or simple is... it's start to store data on second time I open the GUI. Like this... Number is 53 Number is 14 Number is 14 Number is 14 Number is 14 I just don't know how to fix that so it's generate number only once... I'll try fix that again... And thanks for reply.
  4. That's what I just thinking about how it's work... Before posting this, I try to make it store data on server side and open GUI on client side but there's a problem which is when you first open GUI, the random value generated but didn't stored and when you try open it again, that's the time it's stored the value... Or simple is... it's start to store data on second time I open the GUI. Like this... Number is 53 Number is 14 Number is 14 Number is 14 Number is 14 I just don't know how to fix that so it's generate number only once... I'll try fix that again... And thanks for reply.
  5. I have a problem with store data on items... What I want to do is... When you sneak & right click, GUI will popup and ask player to enter some data. When click Done (or OK) ,data that player entered will be stored within items. And when they sneak & right click again, they can edit their entered data. Right click will use data stored in the item. Problems is... Data is stored but still being reset. This is what I tried to simplify it (So it easier to understand and helps me out)... When player right click, the number will be told. And when player sneak & right click, GUI will open and store edited data. Testing... Right click several times without sneak & right click. Expectation: A random number called X being told when right click and does not change when right click again. Reality: As screenshot showing... Source code for item private void useItem(ItemStack itemStack, World world, EntityPlayer player, boolean addMode) { data = new NBTData(itemStack); if(world.isRemote){ //Is client if(!data.hasKey("test")){ data.set("test", new Random().nextInt(100)); data.save(); } if(player.isSneaking()){ player.openGui(MyMod.instance, 1, world, (int) player.posX, (int) player.posY, (int) player.posZ); }else{ player.addChatMessage("Number is " + data.get("test", -1)); } } } public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(!player.capabilities.isCreativeMode){ itemStack.stackSize = 0; return itemStack; } //On air useItem(itemStack, world, player, false); return itemStack; } public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, int face, float par8, float par9, float par10) { if(!player.capabilities.isCreativeMode){ --itemStack.stackSize; return false; } //On block useItem(itemStack, world, player, true); return true; } Screenshot: http://s9.postimg.org/cu96dubjv/2013_04_25_02_32_20.jpg[/img] Notes: NBTData is my own wrapper of NBTTagCompound for easier use That "data" will be used with GUI. Store data will do the same (data.save()) on GUI class. data.save() will store all data on NBTTagCompound to ItemStack (using ItemStack.setTagCompound)
  6. I have a problem with store data on items... What I want to do is... When you sneak & right click, GUI will popup and ask player to enter some data. When click Done (or OK) ,data that player entered will be stored within items. And when they sneak & right click again, they can edit their entered data. Right click will use data stored in the item. Problems is... Data is stored but still being reset. This is what I tried to simplify it (So it easier to understand and helps me out)... When player right click, the number will be told. And when player sneak & right click, GUI will open and store edited data. Testing... Right click several times without sneak & right click. Expectation: A random number called X being told when right click and does not change when right click again. Reality: As screenshot showing... Source code for item private void useItem(ItemStack itemStack, World world, EntityPlayer player, boolean addMode) { data = new NBTData(itemStack); if(world.isRemote){ //Is client if(!data.hasKey("test")){ data.set("test", new Random().nextInt(100)); data.save(); } if(player.isSneaking()){ player.openGui(MyMod.instance, 1, world, (int) player.posX, (int) player.posY, (int) player.posZ); }else{ player.addChatMessage("Number is " + data.get("test", -1)); } } } public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { if(!player.capabilities.isCreativeMode){ itemStack.stackSize = 0; return itemStack; } //On air useItem(itemStack, world, player, false); return itemStack; } public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, int face, float par8, float par9, float par10) { if(!player.capabilities.isCreativeMode){ --itemStack.stackSize; return false; } //On block useItem(itemStack, world, player, true); return true; } Screenshot: http://s9.postimg.org/cu96dubjv/2013_04_25_02_32_20.jpg[/img] Notes: NBTData is my own wrapper of NBTTagCompound for easier use That "data" will be used with GUI. Store data will do the same (data.save()) on GUI class. data.save() will store all data on NBTTagCompound to ItemStack (using ItemStack.setTagCompound)
×
×
  • Create New...

Important Information

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