Jump to content

Darki

Members
  • Posts

    161
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    http://dasdarki.de/
  • Location
    Cologne
  • Personal Text
    I am working on something interesting

Recent Profile Visitors

2114 profile views

Darki's Achievements

Creeper Killer

Creeper Killer (4/8)

-5

Reputation

  1. Anyone? What I tried so far: - Using the Entity#move Method - Using the EntityCreature#getNavigator#tryMoveToXYZ Nothing of it works. Do I have to write an own Pathfinder or Method?
  2. What....Oh ok. I am completely new in coding mods....I can code plugins....and java it selfs....But coding mods is so much diffrent to coding plugins. So does that mean as long as I do nothing completely wrong with the proxies....it should work? Or are there any other things I need to watch out for?
  3. Ok. For now I'll leave it like this because its working on the Client....Server-Side I did not test anything in my Mod....Maybe I have to re code some code so that my mod can be played in MP. But for now its just find. And at the moment my mod has other "problems"
  4. Its a simple and dumb answer: Because Mojang does it in the same Way. @Nullable public EntityLivingBase getOwner() { try { UUID uuid = this.getOwnerId(); return uuid == null ? null : this.world.getPlayerEntityByUUID(uuid); } catch (IllegalArgumentException var2) { return null; } } This is the Code of EntityTameable#getOwner
  5. And this would be the Problem^^ I am storing the UUID of the User in the NBT Tags of an Entity. To explain a little bit more: I have a custom Entity which is not tamable but kind of....The Owner gets set by the mod itsselfs....
  6. Hi, I'd like to know if there is a Method or something else to force a Entity (Living) and / or other Players to move to a specified Location. I don't want to teleport the Entities I want to move them...like when the would be controlled by a Player. Thanks in advanced.
  7. Would this work? public static EntityPlayer findPlayer(World world, UUID uuid) { return !DeathNote.getInstance().getProxy().isServer() ? world.getPlayerEntityByUUID(uuid) : FMLServerHandler.instance().getServer().getPlayerList().getPlayerByUUID(uuid); }
  8. Hi, I have a simple Question but I cant figure out how to solve it. I want to get the Player by the given UUID when the Mod is running on the Client not on the Server. To show you what I want here my current code: public static EntityPlayer findPlayer(World world, UUID uuid) { return !world.isRemote ? Minecraft.getMinecraft().player : // The Getter when the Player is on a Server } I have a Static Method which returns an EntityPlayer Object. I check via world.IsRemote if the Player is on the Server or not, when not it returns the Minecraft Player because there is only one Player but when he is playing on a Server I want to return the Player from the given UUID. I hope I could show you what I want^^ Thanks in advanced. Darki
  9. Hey, Its really simple but i am too dumb to solve it. I have a ClientConnectedToServerEvent and I ask how can I get the UUID in this Event from the current Player. When I use Minecraft#player I get a NP Exception. So how^^.
  10. Thanks. Cause of your tips I could improve it. But that wasnt the probleme. I figured it out and honestly i am an idiot . I forgot to call markDirty() after generating my data^^
  11. Or is there another way to save data which is associated to a world?
  12. I debugged a little bit. Everytime i load the data, its null so that its creating a new data. And i find out that when i save the world an exception will thrown. But not in my code i think: [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: java.lang.IllegalArgumentException: Name and ID cannot both be blank [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at com.mojang.authlib.GameProfile.<init>(GameProfile.java:25) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.management.PlayerProfileCache.lookupProfile(PlayerProfileCache.java:100) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.management.PlayerProfileCache.getGameProfileForUsername(PlayerProfileCache.java:183) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.village.Village.writeVillageDataToNBT(Village.java:552) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.village.VillageCollection.writeToNBT(VillageCollection.java:300) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.world.storage.MapStorage.saveData(MapStorage.java:134) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.world.storage.MapStorage.saveAllData(MapStorage.java:114) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.world.WorldServer.saveLevel(WorldServer.java:1116) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1057) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:415) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:238) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:141) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:537) [16:46:14] [Server thread/INFO] [STDERR]: [net.minecraft.world.storage.MapStorage:saveData:142]: at java.lang.Thread.run(Unknown Source) Maybe I call the method at the wrong time in the wrong place. The load method will be called when an entity joins the world especially the player. Where else should i call the method? If you need the code where I call the method: @SubscribeEvent public void onJoinWorld(EntityJoinWorldEvent e) { Diseases.instance.combinationManager.load(e.getWorld()); }
  13. Nope still not working: public static class CombinationData extends WorldSavedData { private static final String DATA_NAME = Diseases.MOD_ID + "_combinationData"; private List<Combination> combinations; public CombinationData() { super(DATA_NAME); } public CombinationData(String name) { super(name); } public static CombinationData get(World world) { MapStorage storage = world.getMapStorage(); CombinationData data = (CombinationData)storage.getOrLoadData(CombinationData.class, DATA_NAME); if (data == null) { generate(); data = new CombinationData(); data.combinations = CombinationManager.combinations; storage.setData(DATA_NAME, data); } return data; } @Override public void readFromNBT(NBTTagCompound nbt) { for (EnumDisease disease : EnumDisease.values()) { if (nbt.hasKey(disease.getTag())) combinations.add(new Combination(disease, EnumAtom.valueOf(nbt.getString(disease.getTag())), EnumCapsid.valueOf(nbt.getString(disease.getTag())), EnumNucleicAcid.valueOf(nbt.getString(disease.getTag())))); } } public void setCombinations(List<Combination> combinations) { this.combinations = combinations; } public List<Combination> getCombinations() { return combinations; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { for (Combination combination : combinations) { compound.setString(combination.disease.getTag(), combination.atom.toString() + ";" + combination.capsid.toString() + ";" + combination.nucleicAcid.toString()); } return compound; } }
  14. Hi, I am just working on my mod. I made an algorithm that generates random recipes for something. I want save this recipes in the world data. I searched for it and found WorldSavedData. I tried it with it but every time the world gets loaded the recipes aren't the same. Here my Code: public static List<Combination> combinations; private boolean loaded; public CombinationManager() { combinations = new ArrayList<CombinationManager.Combination>(); loaded = false; } private static void generate() { List<CacheCombination> cacheCombinations = new ArrayList<CombinationManager.CacheCombination>(); for (EnumDisease disease : EnumDisease.values()) { CacheCombination cacheCombination = generateCombination(); while (cacheCombinations.contains(cacheCombination)) { cacheCombination = generateCombination(); } combinations.add(new Combination(disease, cacheCombination.atom, cacheCombination.capsid, cacheCombination.nucleicAcid)); } } public void load(World world) { if (!loaded) { combinations = CombinationData.get(world).combinations; for (Combination combination : combinations) { System.out.println("COMBI: " + combination.disease.getName() + " = " + combination.atom.toString() + " + " + combination.capsid.toString() + " + " + combination.nucleicAcid.toString()); } loaded = true; } } private static CacheCombination generateCombination() { return new CacheCombination(EnumCapsid.values()[new Random().nextInt(EnumCapsid.values().length)], EnumAtom.values()[new Random().nextInt(EnumAtom.values().length)], EnumNucleicAcid.values()[new Random().nextInt(EnumNucleicAcid.values().length)]); } public static class CombinationData extends WorldSavedData { private static final String DATA_NAME = Diseases.MOD_ID + "_combinationData"; private List<Combination> combinations; public CombinationData() { super(DATA_NAME); } public CombinationData(String name) { super(name); } public static CombinationData get(World world) { CombinationData data = (CombinationData)world.loadItemData(CombinationData.class, DATA_NAME); if (data == null) { generate(); data = new CombinationData(); data.combinations = CombinationManager.combinations; world.setItemData(DATA_NAME, data); } return data; } @Override public void readFromNBT(NBTTagCompound nbt) { for (EnumDisease disease : EnumDisease.values()) { if (nbt.hasKey(disease.getTag())) combinations.add(new Combination(disease, EnumAtom.valueOf(nbt.getString(disease.getTag())), EnumCapsid.valueOf(nbt.getString(disease.getTag())), EnumNucleicAcid.valueOf(nbt.getString(disease.getTag())))); } } public void setCombinations(List<Combination> combinations) { this.combinations = combinations; } public List<Combination> getCombinations() { return combinations; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { for (Combination combination : combinations) { compound.setString(combination.disease.getTag(), combination.atom.toString() + ";" + combination.capsid.toString() + ";" + combination.nucleicAcid.toString()); } return compound; } }
  15. Thank you very much. Its working^^ Normally i code spigot plugins its in some points alot easier
×
×
  • Create New...

Important Information

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