RSDuck / RandomPeripherals

A minecraft mod that adds some peripherals for the computercraft mod
2 stars 0 forks source link

[Suggestion] Item/Block Texture Exporter #10

Open mura3277 opened 8 years ago

mura3277 commented 8 years ago

So first off I'll explain why I would want such a feature:

I am currently working a system that uses the ME Bridge from Peripherals++ to get a list of things in your AE system. I then send that data to a mysql database and display the contents of the AE system on a website. The reason I want this feature is because I have made a way to convert an image in the current computers id folder to a base 64 string. This allows me to send this string to a php script to reconstruct the string into an image and store it on the web server.

So if I had method, that when you supply an item id it exports the texture to the current computers ID folder I can then send that to the site and have images for the items.

Ok so I know there wouldn't be a lot of uses for such a feature, but it's really the only way of making my project possible other than manually collecting and uploading item images to my site. I would extremely appreciate if you could look into how easy/hard this would be to implement and I'd be happy to outline more details of how I would like it to work.

Again, there isn't a lot of uses this has other than this but I thought I would see what your thoughts were.

Thanks for reading!

mura3277 commented 8 years ago

I forgot to mention one other thing: Would block textures (as in the 3D block that is rendered in game) be possible to export as an image? This would even be hard to re-create on a site even with the textures in the mods assets folder, which would make you even more of a hero :p

RSDuck commented 8 years ago

Exporting flat images only is easy to do. Rendering 3D dimensional blocks as in inventories is hard and probably only possible with major hacks or stuff like render to texture

mura3277 commented 8 years ago

So I found this mod a while ago when I was searching for a mod to export textures: https://github.com/Flow86/Advanced-Recipe-Generator-Mod

It exports the recipes like this: advancedamplifabricatoriv

Possibly this would let you know the process?

RSDuck commented 8 years ago

Ok, based of the method used to render the blocks in the other mod, I managed to dump 3D Icons while loading Minecraft.

Probably I'm going to add a readonly mountable disk, which contains all(or a part of) the item icons.

What do you think about this?

mura3277 commented 8 years ago

Wow I really appreciate you for taking the time to work on this!

So when I send the base64 string of the image to a php script, I need to have a reference to the mod the item belongs to, its id and meta. So I would need to have access to that on the lua side.

As long as I can do this, then it will work for my application.

Again, thanks!

mura3277 commented 8 years ago

Have you had anymore time to tinker with this?

Thanks.

RSDuck commented 8 years ago

At the moment I have plenty of time(holidays!). The last days I worked on a highly experimental Minecraft mod which makes Minecraft compatible with Google Cardboard.

Good that you reminded me

mura3277 commented 8 years ago

Thanks :)

RSDuck commented 8 years ago

I just fixed(well really it isn't really fixed, it's more a workaround) one major issue. If it wasn't there I finished the work on this feature a week ago.

For some reasons the Forge loadingscreen(with loadingbars ect.) somehow redraws asynchrounly. Thats the reason why clearing the window didn't work, instead I got the loading bar image or the loading bar image with the blocks drawn onto it or variations of this.

Currently I disabled the loadingbar, I'm going to see if I can temporary disable the redrawing of the loadingbar for a short moment, otherwise this feature will only work with loading bar disabled.

mura3277 commented 8 years ago

Not having the loading bar really isn't a problem for me!

Thanks for the update :)

RSDuck commented 8 years ago

I moved the image creation to before the world gets loaded. This fixes the loading screen and some blocks that need some stuff to be setup.

Also, is it enough if it creates several textures and files on server side(which got sended by clients, when they connect, because the server doesn't load models and textures), which contains several images with icons and a file(XML, JSON or something like this) which contains informations where which block is located. You could use CSS sprites to display the subset of an icon map. That way ComputerCraft isn't involved in getting the items icons, but I think it would be stupid to make some kind of peripheral. I think the best idea is to make a rom mount which every Computer/Turtle can access where the files can be accessed.

mura3277 commented 8 years ago

Sorry for not being around to reply to this!

Whatever you think is the best process for accessing the images. The only thing I'd say is a sprite sheet would not be the easiest thing to use since I'm not sure how you wold match an item ID to a location on the sheet.

A rom mount sounds like a good idea, but again, it kind of needs to be individual files since paring a location with an item ID would not be a easy process.

RSDuck commented 8 years ago

no, problem, it's already done. The old interface is indeed awkward to use.

To access the files craft an Interdimensional File Synchroninator and use it as disk

mura3277 commented 8 years ago

Bug report :D

So it could possibly be because I am running GT (Which adds lots of items), but when the textures are generated on world login, I get the error "A fatal error has occurred, this connection is terminated". My log file is also complaining about stack overflows and not being able to find images.

Errors start at about [03:40:08] here http://mura.ws/latest.log

Quite a lot of the images have been generated however and other than the errors it seems to be working really well!

mura3277 commented 8 years ago

Oh and also, is it at all possible to keep the transparency of the images?

RSDuck commented 8 years ago

Try this, I think the problem occurs because of a malformed path(where / gets used in a block id), try this build: RandomPeripherals-1.5 Beta 4.jar.zip

And don't forget to delete the .zip ending, for some reason files need to have an .jar ending, otherwise only some features don't work and it crashes and Github doesn't allow to upload .jar in issues

mura3277 commented 8 years ago

It still seems to throw that error. it only seems to happen when I first join a world. Look at this for a better example of what happens: http://i.imgur.com/7YQ4LmC.gifv

Log file: http://mura.ws/latest-beta4.log

mura3277 commented 8 years ago

Hmm so I just launched my instance and I didn't get the error this time. It seems to have generated all of images (16k files :D). Weird.

RSDuck commented 8 years ago

thats indeed weired. First I thought this problem is happenend because all packets weren't received in the same order the were sended, but then I read that the network library Minecraft is using(Netty), is guaranteing that all packets will be received in the same order they were sended.

But when I looked into the Forge source code, from which I use some functions there which send the packets using Netty, were function calls to functions named flush. Maybe the packets get still received in the wrong order.