Jump to content

Recommended Posts

Posted

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);

}

 

Posted

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?

Posted

CompressedStreamTools allow you to read/write NBT to file.

 

Note that this operation still needs to act only on server. Client cannot manipulate data.

1.7.10 is no longer supported by forge, you are on your own.

Posted

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.

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.