Jump to content

vemacs

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by vemacs

  1. Here's my class: public void setOfflineInventory(String username, ItemStack[] contents, ItemStack[] armor) { SaveHandler saveHandler = (SaveHandler)DimensionManager.getWorld(0).getSaveHandler(); NBTTagCompound playerNbt = saveHandler.getPlayerData(username); InventoryPlayer inventory = new InventoryPlayer(null); inventory.readFromNBT(playerNbt.getTagList("Inventory")); inventory.armorInventory = armor; inventory.mainInventory = contents; playerNbt.setTag("Inventory", inventory.writeToNBT(new NBTTagList())); try { File playersDirectory = new File(saveHandler.getSaveDirectory(), "players"); File temp = new File(playersDirectory, username + ".dat.tmp"); File playerFile = new File(playersDirectory, username + ".dat"); CompressedStreamTools.writeCompressed(playerNbt, new FileOutputStream(temp)); if (playerFile.exists()) { playerFile.delete(); } temp.renameTo(playerFile); } catch (Exception e) { logger.warning("Data failed to save for " + username); } } I've fixed some minor typos, but I can't seem to find those methods for NBTTagCompound and SaveHandlerMP, respectively. I'm trying setTag instead of setTagList for NBTTagCompound, I'm not sure about how it would work, but it doesn't report any errors. I've also removed getConfigurationManager() from the 1st line of the class, and used DimensionManager instead. For further stability, I probably should get the last logged in world of the player, and add another parameter to the method. As this is obviously going to be part of a SMP mod, should I use SaveHandlerMP instead of SaveHandler?
  2. vemacs

    XP Block

    You could try doing a spawnentity of type player, placing the spawned player where the block is, and then hiding the player.
  3. Erm, right. That was cobbled together from copypasted code. Could you provide a basic example for the loading and saving of the inventory? I can't seem to find any detailed documentation of that. I'm not overly familiar with the way forge works, but assuming I have the InventoryPlayer loaded, would I do: public void setOfflineInventory(String username, ItemStack[] contents, ItemStack[] armor) { //load username's inventory as an InventoryPlayer called inventory inventory.armorInventory = armor; inventory.mainInventory = contents; //save username's inventory and cleanup } Thanks in advance!
  4. You can use something like this: // modify playerNbt try { File playersDirectory = new File(saveHandler.getSaveDirectory(), "players"); File temp = new File(playersDirectory, username + ".dat.tmp"); File playerFile = new File(playersDirectory, username + ".dat"); CompressedStreamTools.writeCompressed(playerNbt, new FileOutputStream(temp)); if (playerFile.exists()) { playerFile.delete(); } temp.renameTo(playerFile); } catch (Exception e) { logger.warning("Failed to save player data for " + username); } Untested, but should work There is already an NBT library built in Vanilla Minecraft, obviously Thanks, but forgive my noobishness, would I use something like this (haven't had a chance to test it yet) : public void setOfflineInventory(String username, net.minecraft.entity.player.InventoryPlayer inventory) { SaveHandler saveHandler =(SaveHandler)MinecraftServer.getServer().getConfigurationManager().worldServers[0].getSaveHandler(); NBTTagCompound playerNbt = saveHandler.getPlayerData(username); //set inventory this.playerNBT.set("Inventory", ((CraftInventoryPlayer)inventory).getInventory().a(new NBTTagList())); try { File playersDirectory = new File(saveHandler.getSaveDirectory(), "players"); File temp = new File(playersDirectory, username + ".dat.tmp"); File playerFile = new File(playersDirectory, username + ".dat"); CompressedStreamTools.writeCompressed(playerNbt, new FileOutputStream(temp)); if (playerFile.exists()) { playerFile.delete(); } temp.renameTo(playerFile); } catch (Exception e) { logger.warning("Failed to save player data for " + username); } }
  5. Suppose I have 2 ItemStack[] s, and want to write them to the inventory of an offline player. How would I do that, given the player name? Specifically, something like: public void setOfflineInventory(String playername, ItemStack[] contents, ItemStack[] armor) { //do stuff here } Would I have to go into an NBT editor? And if so, are there any readily available NBT libraries for Forge? Thanks in advance.
  6. Thanks, I've PMed him, but I'm just patching some exploits related to the /lock function. I'm also patching some vulnerabilities in the login mod. I've PMed him my patches (which should fix the issues), and I'm going to ask him for the source. However, assuming that I did get the source, and the source is the exact same as the decompiled version, what would I be doing wrong if it isn't compiling?
  7. I've been trying to mod Fihgu's protection mod all morning (basically trying to change some strings), and so far, I have the deobfuscated source from BON and JD-Gui, and have modified a single class (EventHandler.java). However, I'm having serious issues compiling. I've added the deobfuscated and recompiled minecraft.jar from MCP, fihgu's core mod, Forge (both src+universal), all the imports in mcp /lib to the classpath, and for the life of me, still can't get it to compile (see http://www.minecraftforge.net/forum/index.php/topic,5536.0.html). Am I completely doing it wrong, and if so, how would I do it properly? I honestly don't think that reinventing the wheel is needed just to modify a single .class. Thanks in advance. (sorry for not providing more details, a generic answer would be preferred)
  8. I have a problem with my code, and it's quite frustrating. This line: player.mcServer.getConfigurationManager().transferPlayerToDimension(player, this.location.dimension); Returns: The method getConfigurationManager() is undefined for the type MinecraftServer, which definitely is wrong. When I hover over the mcServer part, however, I get: The type aa cannot be resolved. It is indirectly referenced from required .class files Am I using the wrong imports? This is the only thing preventing me from compiling.
  9. Okay, I've deobfuscated and decompiled the code using BON and JD-GUI, and made my patches. Now, when I'm trying to recompile the .java, I get a lot of symbol not found errors: EventHandler.java:217: error: cannot find symbol ChunkCoordinates spawn = player.worldObj.getSpawnPoint(); ^ symbol: class ChunkCoordinates location: class EventHandler EventHandler.java:227: error: cannot find symbol return EnumSet.of(TickType.SERVER); ^ symbol: variable TickType location: class EventHandler 75 errors How would I go about resolving that?
  10. I'm pretty sure you're incorrect on that part. I'm currently trying to use Bearded Octo Nemesis to deobfuscate the mod, and need support on that, but that goes into another thread.
  11. I've decided to change around some strings to a Forge mod (namely Fihgu's protection mod), so I've opened the ZIP file (not of the coremod) using JD-GUI, changed it around a bit, and saved it as the original .class name (EventHandler.java). However, when running: javac -classpath protection.zip EventHandler.java It outputs: EventHandler.java:3: error: '.' expected import aa; ^ EventHandler.java:3: error: ';' expected import aa; ^ EventHandler.java:4: error: class, interface, or enum expected import cpw.mods.fml.common.IPlayerTracker; ^ EventHandler.java:10: error: '.' expected import gm; ^ EventHandler.java:10: error: ';' expected import gm; ^ EventHandler.java:11: error: class, interface, or enum expected import iq; ^ EventHandler.java:17: error: '.' expected import qx; ^ EventHandler.java:17: error: ';' expected import qx; ^ EventHandler.java:18: error: class, interface, or enum expected import rp; ^ EventHandler.java:19: error: '.' expected import s; ^ EventHandler.java:19: error: ';' expected import s; ^ EventHandler.java:20: error: class, interface, or enum expected import ur; ^ EventHandler.java:21: error: '.' expected import y; ^ EventHandler.java:21: error: ';' expected import y; ^ EventHandler.java:22: error: class, interface, or enum expected import yc; ^ 15 errors Which means that the ClassPath is not being resolved. How would I go about recompiling a .class file from a forge mod (not a coremod)? Thanks in advance.
  12. Hello folks, New forge modder here, I just wanted to get some support for this question: Is there something similar to PlayerMoveEvent for Bukkit, in which you can cancel the event? EntityMoveHelper looks somewhatly related, but doesn't seem to be able to be cancelled. Of course, I could go with a hackish on TickEnd solution that gets the position of the player, see if it's changed, and then for cancelling, teleport the player to the last recorded location. However, it is very hackish, so I was wondering if there is a more elegant solution?
  13. Legit servers have a need for authentication plugins too (in case of insecure stuff on Mojang's part, linking multiple servers, and just having an additional authentication layer just in case. Besides, those plugins mainly use PlayerJoinEvent, AsyncPlayerChatEvent, PlayerLoginEvent, PlayerMoveEvent, etc..., so they provide a good subset of features that many other plugins use. While these plugins can be used for piracy, they're not "akin" to it. Additionally, supporting (not explicitly of course, but indirectly) these plugins will result in increased compatibility with other plugins that rely on these events, which would help advance the entire project goal.
  14. Really nice! Most of our core mods (Essentials, WorldEdit, etc...) are running fine! Also, Shortify has supported multiple URL substitution for 3 months or so now
×
×
  • Create New...

Important Information

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