Jump to content

[1.7.10]Item save format?


NextInima

Recommended Posts

It there a way i can save A custom item with ntb data in a file on the desktop or any other custom location?

 

 

 

 

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.ArathosRPG.ArathosRPGMod.ArathosRPG;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.effect.EntityLightningBolt;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.Vec3;

import net.minecraft.world.World;

 

public class RINCraftGood extends Item{

 

private String Rubrik,Lessezeichen;

 

public RINCraftGood(String RubrikString,String Lessezeichen1){

//this.setCreativeTab(ArathosRPG.KoRIN);

this.setMaxStackSize(15);

this.setCreativeTab(ArathosRPG.KoRIN7);

this.Rubrik = RubrikString;

this.Lessezeichen = Lessezeichen1;

}

public RINCraftGood(String RubrikString,boolean a){

//this.setCreativeTab(ArathosRPG.KoRIN);

this.setMaxStackSize(15);

this.Rubrik = RubrikString;

this.setFull3D();

}

 

 

@SideOnly(Side.CLIENT)

public void registerIcons (IIconRegister iconRegister) {

this.itemIcon = iconRegister.registerIcon(ArathosRPG.modid + ":" + this.Rubrik + "/" + this.getUnlocalizedName().substring(5));

}

 

@Override

public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer Entityplayer) {

Vec3 look = Entityplayer.getLookVec();

MovingObjectPosition Coord = Entityplayer.rayTrace(300, 1);

EntityLightningBolt Lightning = new EntityLightningBolt(world, 1, 1, 1);

Lightning.setPosition(Coord.blockX,Coord.blockY,Coord.blockZ);

world.spawnEntityInWorld(Lightning);

return itemStack;

}

 

public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)

{

list.add(Lessezeichen);

}

}

 

 

 

The NBT Data will add ingame through the player by doing stuff with this item.

 

Or the player can create it with NBT stuff like i add this to the item.

 

 

@Override

public void onCreated(ItemStack itemstack, World world,EntityPlayer entityplayer){

int resistanceArmor = 1;

itemstack.stackTagCompound = new NBTTagCompound();

itemstack.stackTagCompound.setInteger("armorr", resistanceArmor);

}

 

Link to comment
Share on other sites

i forgot the file writer i have

 

 

 

  FileWriter writer;

  File file2 = new File("KoRIN_ITEMS");

  file2.mkdir();

  File file = new File("KoRIN_ITEMS/"+CUSTOMID+".txt");

    try {

      writer = new FileWriter(file ,false);

     

      writer.write(exsample1);

      writer.write(System.getProperty("line.separator"));

      writer.write(exsample2);

     

      writer.close();

    } catch (IOException e) {

      e.printStackTrace();

   

    }

   

}

 

 

 

the question is how can i save the item and how i can read the item from this file?

Link to comment
Share on other sites

You need a bit more than just the CompressedStreamTools IIRC, but that's a good chunk of it.

 

Its been a while since I did NBT file work (I was rendering camera views, sending them to the server for saving, and retransmitting for viewing,

), but I think the CST won't do the file IO, you'll have to handle that yourself.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

first of all  really thank you for the answer,

 

I am new in this section and thats why i ask so mutch xD

 

I will try my best why these infomations and maybe i will get it alone.

Link to comment
Share on other sites

i have download this stuff and will try to understand how the PacketHandlerServer class work, i am happy toseen that i can reach my goal for now  :-[;D

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



×
×
  • Create New...

Important Information

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