PrincessRTFM Posted December 11, 2015 Share Posted December 11, 2015 I have an ItemStack object, and I know that's it's going to be inside either an EntityLiving's inventory, or an IInventory TileEntity. I want to get the location in the world of the container, regardless of which one it is. I can use different code for each scenario if I need to, but I haven't found any way to do this yet. Is it even possible, or am I out of luck? Quote Link to comment Share on other sites More sharing options...
larsgerrits Posted December 11, 2015 Share Posted December 11, 2015 ItemStacks themself don't have a reference to the inventory they are in, so you have to find another way. Where do you get the ItemStack from? Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/ Link to comment Share on other sites More sharing options...
PrincessRTFM Posted December 11, 2015 Author Share Posted December 11, 2015 I've got an item that implements the RF API, and I'm working with the receiveEnergy() and extractEnergy() methods. All I get is the ItemStack, an int specifying the maximum amount of energy that's trying to be moved around, and a boolean indicating whether this is just a simulation. Quote Link to comment Share on other sites More sharing options...
shadowfacts Posted December 11, 2015 Share Posted December 11, 2015 Why do you need to know which inventory contains the stack? Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods Link to comment Share on other sites More sharing options...
IceMetalPunk Posted December 11, 2015 Share Posted December 11, 2015 Why do you need to know which inventory contains the stack? As he said, because the item is being used as an RF container, and it's supposed to do different things depending on whether it's in the player's inventory or in a tile entity's inventory (I assume if it's in a tile entity, it charges that entity up, but if it's in a player's inventory, it instead charges the items in his inventory; that's the usual battery design). ItemStacks have NBT data stored in their stackTagCompound member. One thing you could do is override the useItemRightClick() method; whenever a player right-clicks the item, it "activates" it, which in reality just stores that player's UUID in the NBT tags for later use. As for clearing that tag when the item is put into a TileEntity's inventory...I'm not sure about that. If they were all your own tile entities, you could just make a custom slot class that extends slot but overrides the putStack() method to clear the tag. But since they're likely other people's containers...I'm not sure where to go from there. Quote Whatever Minecraft needs, it is most likely not yet another tool tier. Link to comment Share on other sites More sharing options...
PrincessRTFM Posted December 11, 2015 Author Share Posted December 11, 2015 Why do you need to know which inventory contains the stack? As he said, because the item is being used as an RF container, and it's supposed to do different things depending on whether it's in the player's inventory or in a tile entity's inventory (I assume if it's in a tile entity, it charges that entity up, but if it's in a player's inventory, it instead charges the items in his inventory; that's the usual battery design). ItemStacks have NBT data stored in their stackTagCompound member. One thing you could do is override the useItemRightClick() method; whenever a player right-clicks the item, it "activates" it, which in reality just stores that player's UUID in the NBT tags for later use. As for clearing that tag when the item is put into a TileEntity's inventory...I'm not sure about that. If they were all your own tile entities, you could just make a custom slot class that extends slot but overrides the putStack() method to clear the tag. But since they're likely other people's containers...I'm not sure where to go from there. Actually, I'm making a "raw" version of the capacitor (because the final one is OP) and I want the raw one to need to be charged to finish it, like it's being "infused" with RF. Think Draconic Evolution's charged draconium blocks. But I want to require that the player do this in a block, instead of having (for example) an EnderIO wireless charge in their house that crafts it in their inventory. If I can't do that, I guess I could just up the power required to craft it or something. Also I'm not a he. Quote Link to comment Share on other sites More sharing options...
shadowfacts Posted December 12, 2015 Share Posted December 12, 2015 You don't need special inventory detection code. Just use the normal IEnergyContainerItem and it should work with things like the Wireless Charger and Energetic Infuser. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods Link to comment Share on other sites More sharing options...
PrincessRTFM Posted December 12, 2015 Author Share Posted December 12, 2015 You don't need special inventory detection code. Just use the normal IEnergyContainerItem and it should work with things like the Wireless Charger and Energetic Infuser. But I don't want it to work with the Wireless Charger. I wanted it to only charge up in a charging block, not a player's inventory. Can't find a way to make that happen, so I've just put it on my todo list with a low priority. Quote Link to comment Share on other sites More sharing options...
ovikk Posted December 12, 2015 Share Posted December 12, 2015 Do you have access to the charger recipes? If so you could just add a charger recipe. Quote I might be terribly wrong.. Like really, really wrong. But I'm just trying to help. Link to comment Share on other sites More sharing options...
PrincessRTFM Posted December 12, 2015 Author Share Posted December 12, 2015 Do you have access to the charger recipes? If so you could just add a charger recipe. I could probably use IMC for that, I think Thermal Expansion allows that sort of thing, but then it would only work in one specific block. I guess I can't make it work the way I was hoping to, but thanks to everyone who responded for the help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.