Runix-Minecraft / Runix

Home of the forge based, Runecraft inspired Minecraft mod
3 stars 0 forks source link

Runes don't respect a TileEntity's inventory #28

Open 0xilly opened 10 years ago

0xilly commented 10 years ago

example: Make a RunecaftRune place a chest on the runecraft vehicle it will eject everything from that chest.

josiahseaman commented 10 years ago

I looked at some classic Runecraft code to see how the did it there. My eyes are still bleeding a little bit. All you need to do is copy the NBT into java, clear it from the block, delete the block, place new block, set NBT. It's just a matter of making the right lib/forge calls. Illyohs, I think you're most qualified to handle this. I'd like you to do it.

0xilly commented 10 years ago

NOT RUNECRAFT CODE!!! GOING INTO THAT IS LIKE GOING THROUGH MORDOR!

josiahseaman commented 10 years ago

Ya, that's what I concluded to. So just don't do that. Search around online for how to read and copy NBT data.

0xilly commented 9 years ago

I was thinking about this again today while I couldn't sleep. I believe that we could copy the TilesEntities meta values and load them into memory remove the entity from the world and paste the information to the corresponding tile's. This solves thing for FTP and Faith but could be really exspensive for things like Runecraft or we could keep it in memory till it deactivates.

josiahseaman commented 9 years ago

If it's possible to make a shallow copy, that would actually be better than a deep copy. If we can just get a reference to the inventory object, copy it and delete the original referencing object, that would be terrific, because it would mean there's no possibility of duplication. Doing a deep copy of the items creates the very real risk that the process gets interrupted in the middle of having two independent copies of items.

0xilly commented 9 years ago

Another issue comes from how are we going to handle things that aren't inventories like Thaumcraft aura nodes or ComputerCraft computers. I know that this can be done and is done in BloodMagic with the Teleposer. Also now that I think about it what about mods that don't want one of their blocks faithed or FTPd maybe have them send a IMC message with the block name?

josiahseaman commented 9 years ago

All the more reason to use a shallow copy strategy. As long as the coders didn't make a second internal copy of the XYZ coordinate, then we can just edit the vanilla block reference and it should work for all mods. The key here is just doing the minimum necessary and don't make assumptions about the internals of what you're moving. Can you find examples of other mods that do stuff like this?

0xilly commented 9 years ago

The only two mods that I can think of are MFFS using the ForceManipulator and Bloodmagics teleposers

On 01/06/2015 04:06 PM, Josiah Seaman wrote:

All the more reason to use a shallow copy strategy. As long as the coders didn't make a second internal copy of the XYZ coordinate, then we can just edit the vanilla block reference and it should work for all mods. The key here is just doing the minimum necessary and don't make assumptions about the internals of what you're moving. Can you find examples of other mods that do stuff like this?

— Reply to this email directly or view it on GitHub https://github.com/Runix-Minecraft/Runix/issues/28#issuecomment-68933665.

Anthony Anderson(Lord Illyohs)

0xilly commented 9 years ago

here is one implementation of block movement that respects tiles https://github.com/Vazkii/Botania/blob/5f1df8a774054fe4342b15182eceff30c194f323/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java#L110-L160

0xilly commented 9 years ago

More specifically

josiahseaman commented 9 years ago

I approve of copying this code wholesale. The real magic is actually a couple lines down.