Jump to content

AstroEngiSci

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by AstroEngiSci

  1. Thank you both! I modified the system so that written punch cards have different metadata than unwritten (I want them to have different names and have distinct icons). The call for server-only fixed the persistence issue; however, I have to call my teleport code client-side for it to work. The teleport code just calls player.setPosition(). Is there some other way I should be doing this so that it works from server-side?
  2. I'm building a mod that, among other things, contains teleporters. The location of target teleporters is stored in punch cards. On right-click on a teleporter with a blank punch card, the blank card is replaced with a written card. Then, the location of the target teleporter is written to the written card's NBT. All of that works just fine. The problem comes when reloading the world; for whatever reason, written punch cards don't persist in inventories through a world reload. I suspect the problem lies in my implementation of NBT. I don't totally understand NBT; it makes a convenient scapegoat. The code that replaces punch cards: public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { //Get the tile entity of this teleporter TeleporterTileEntity t = (TeleporterTileEntity) worldIn.getTileEntity(pos); //Check if they're holding a blank punch card ItemStack item = playerIn.getCurrentEquippedItem(); if(item != null && item.getItem() == EnderScience.blankPunch) { //Replace with written card ItemStack card = new ItemStack(EnderScience.writtenPunch, 1); int slot = playerIn.inventory.currentItem; playerIn.replaceItemInInventory(slot, card); //Store this teleporter's coordinates in the new punch card NBTTagCompound tag = new NBTTagCompound(); tag.setString("teleporter", pos.getX() + " " + pos.getY() + " " + pos.getZ()); card.setTagCompound(tag); if(playerIn.getCurrentEquippedItem().getTagCompound() == null) System.out.println("[Ender Science]: Failed to write card's NBT."); System.out.println("[Ender Science]: Teleporter coordinates: " + tag.getString("teleporter")); return true; } else if (item != null && item.getItem() == EnderScience.writtenPunch){ //TODO: Fix teleport call t.teleport(playerIn, worldIn, item.getTagCompound().getString("teleporter")); return true; } return true; } And the base class for the written punch card: public class WrittenPunchCard extends Item { public WrittenPunchCard() { setMaxStackSize(1); setUnlocalizedName("writtenpunch"); setCreativeTab(EnderScience.tab); } @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { tooltip.add("Coordinates: " + stack.getTagCompound().getString("teleporter")); } } The problem persists when I comment out the code that writes the teleporter coordinates to the punch card.
  3. From the Minecraft Forge wiki (http://www.minecraftforge.net/wiki/Basic_Modding) What this means is that if clientSideRequired = true, then the computer running Minecraft needs the mod in order for the mod to work. This of course, should almost always be the case. If serverSideRequired, and you try to join a server, then that server must have the mod installed, too. This should be false.
  4. I'm not sure how to use ChunkEvent.Load, can you please explain?
  5. That doesn't appear to be helping any. Somehow my getBlockTileEntity call is returning null, so either it's a problem with that, or that code just isn't loading the chunk. I've tried changing worldObj to world (since I pass the world in my function call) and that sill didn't work. I'm at a loss.
  6. In my mod, I've noticed a problem where I am trying to update information in a TileEntity that has been unloaded. There isn't really a way to get around this except loading the chunk the block is in, just long enough to update the data I need. However, I have no idea how to load/unload a chunk, because I am a total n00b. Any help is appreciated. My code: https://gist.github.com/anonymous/7295390
×
×
  • Create New...

Important Information

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