Jump to content

Gaprosys

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Gaprosys

  1. Sorry, I have thinked, the embed tag where the right been for code. That is then a mistake from me.
  2. Hi, thanks for the reply. My current code looks like so: IndustriousMageWorldSaveData: [embed=425,349] package de.gaprosys.industriousmage.handler_network; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.io.IOException; import java.util.Map; import java.util.Set; import de.gaprosys.industriousmage.IndustriousMage; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraft.world.storage.MapStorage; public class IndustriousMageWorldSaveData extends WorldSavedData { final static String key = "IndustriousMageSaveData"; public IndustriousMageWorldSaveData(String key) { super(key); } public IndustriousMageWorldSaveData() { super(key); } public static IndustriousMageWorldSaveData get(World world) { MapStorage storage = world.mapStorage; IndustriousMageWorldSaveData result; try { result = (IndustriousMageWorldSaveData)storage.loadData(IndustriousMageWorldSaveData.class, key); } catch(NullPointerException ex) { result = new IndustriousMageWorldSaveData(); storage.setData(key, result); } return result; } public static void saveData(World world) { try { world.mapStorage.loadData(IndustriousMageWorldSaveData.class, key).setDirty(true); } catch(Exception ex) {} } @Override public void readFromNBT(NBTTagCompound nbt) { long maxIMP; long currentIMP; int id; String s; NBTTagList tagList = nbt.getTagList("Player", 10); for(int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); s = tag.getString("playerName"); id = tag.getInteger("playerID"); currentIMP = tag.getLong("playerCurrentIMP"); maxIMP = tag.getLong("playerMaxIMP"); IndustriousMage.impTransfer.addPlayerToNetworks(s); IndustriousMage.impTransfer.setPlayerIMPNetworkId(s, id); IndustriousMage.impTransfer.addMaxIMPtoPlayer(s, maxIMP); IndustriousMage.impTransfer.addCurrentIMPtoPlayer(s, currentIMP); System.out.println(); System.out.println(s); System.out.println(id); System.out.println(currentIMP); System.out.println(maxIMP); } } @Override public void writeToNBT(NBTTagCompound nbt) { NBTTagList tagList = new NBTTagList(); ArrayList<String> network = new ArrayList<String>(); network = IndustriousMage.impTransfer.getPlayerIds(); String s; for(int i = 0; i <= network.size(); i++) { s = (String)network.get(i); NBTTagCompound tag = new NBTTagCompound(); tag.setString("playerName", s); tag.setInteger("playerID", i); tag.setLong("playerCurrentIMP", IndustriousMage.impTransfer.getPlayerCurrentIMPNetwork(s)); tag.setLong("playerMaxIMP", IndustriousMage.impTransfer.getPlayerMaxIMPNetwork(s)); System.out.println(); System.out.println(s); System.out.println(i); System.out.println(IndustriousMage.impTransfer.getPlayerCurrentIMPNetwork(s)); System.out.println(IndustriousMage.impTransfer.getPlayerMaxIMPNetwork(s)); tagList.appendTag(tag); } nbt.setTag("Player", tagList); } } [/embed] the System.out.println is for me, To look, what they read. I use just a try to initialize the WorldSavedData Class from me, because, they throw often an NullPointerException by loading a world. The used Events to load and save the datas: [embed=425,349] @SubscribeEvent public void LoadPlayerList(WorldEvent.Load event) { if(!event.world.isRemote) { IndustriousMageWorldSaveData worldsave; worldsave = IndustriousMageWorldSaveData.get(event.world); } } @SubscribeEvent public void UnloadPlayerList(WorldEvent.Unload event) { if(!event.world.isRemote) { IndustriousMageWorldSaveData.saveData(event.world); } } @SubscribeEvent public void SavePlayerList(WorldEvent.Save event) { if(!event.world.isRemote) { IndustriousMageWorldSaveData.saveData(event.world); } } [/embed] with the LoadPlayer- function I try to load the player list. what they actually not do. With the UnloadPlayerList and SavePlayerList I saved the lists. - Gaprosys
  3. Hi, How can I save costum informations per world? I founded WorldSavedData, but it looks like, they load not the datas. I loaded the datas per WorldEvent.Load, .Unload and .Save. I hope anybody can help. - Gaprosys
  4. Hi, how can I override the world type event. I brought this because if I start the a provider from me, by they I change the world provider from nether and overworld, the default is after the use from my world type the same as my world type.They shouldn't so work. I hope everyone has an idea. Sorry for my bad english, - Gaprosys
  5. Hi, I brought help with my Mod. how can I add a world generator how start in the nether. I want, that someone can access the world generator to, as example, "Netherworld" and they start then in Nether and can then go to the End. I hope, everyone understand that and can help. - Gaprosys
  6. Thanks for this reply and answer. There is then no more questions. I closed it then here.
  7. Hi, I make a mod and try to make a crusher, who give me 1/4 of a dust(1 Dust = 1 Ingot)of Iron or Gold if I put 32 Cobblestone in it. A friend of me mean, that thas is overpowerd. Is this right or not? Is there a site in the web, who list the standard for this? Sorry for my bad english, I live in Germany. Have a nice saturday. - Gaprosys
×
×
  • Create New...

Important Information

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