This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Bomb Bloke's profile picture

[MC1.8+] Banner Editor

Started by Bomb Bloke, 05 April 2016 - 01:29 AM
Bomb Bloke #1
Posted 05 April 2016 - 03:29 AM
pastebin get YxLzGY53 banedit

As so often happens, I set out to do one thing, got sidetracked, and did something else… in this case I was going to add NBT reading/writing support to WorldPorter, but made this instead.

Banners are a Minecraft 1.8 thing. You craft them together with various bits and bobs to put patterns on them. This script lets you set those patterns directly, using a Command Computer. Should be fairly simple to use; you plonk a chest on top of the computer, fill it with banners, create your masterpiece with the script and then "export" it to the banners in the chest.



Worth noting that this is hardly the first banner editor out there - eg Planet Minecraft has a web-based one - but what the heck. It does open up an easy avenue for allowing non-server OPs to fully customise their banners (they can usually only define up to six layers). With any luck it might lead to some more colourful servers?

Version History2016/04/05
1.0.0
Initial release.

2018/03/28
1.0.1
Compatibility tweak for later Minecraft versions.
Edited on 28 March 2018 - 08:50 AM
Selim #2
Posted 05 April 2016 - 01:58 PM
That is actually really cool.
LDDestroier #3
Posted 22 April 2016 - 01:45 AM
Does this use the NFP format for exporting?
Edited on 22 April 2016 - 02:28 AM
Bomb Bloke #4
Posted 22 April 2016 - 03:59 AM
No, it doesn't write files at all.
LDDestroier #5
Posted 22 April 2016 - 04:28 AM
No, it doesn't write files at all.

I mean importing! Does it import NFP files to be put onto banners?
Bomb Bloke #6
Posted 22 April 2016 - 05:10 AM
No, that'd be a bit complex.

As the links above describe, Minecraft banners are made up of layers, each containing a pre-defined image. Those images are all built into the game (you don't get to change them, outside of resource packs or whatever), and so you can't just load any abstract image directly onto a banner.

One could theoretically build a script which tries to figure out the best combination of layers that most closely resembles a given image file, but there are a lot of possible layer combinations, and even so the "best match" is still unlikely to be a "good match". You'll tend to get better results manually arranging the layers into something that at least looks decent, even if it's not altogether accurate.
Luca_S #7
Posted 24 April 2016 - 02:28 PM
It would be cool if you could save the banners as a file.
Bomb Bloke #8
Posted 24 April 2016 - 03:03 PM
What sort of file, and what would you do with it?
Lupus590 #9
Posted 24 April 2016 - 07:33 PM
Share it across MC servers?
Bomb Bloke #10
Posted 25 April 2016 - 02:46 AM
The main problem with saving files is that files need names, and this script is mostly useful for users who aren't OPs… meaning that they need to access the script through an external monitor, where filename entry is… cumbersome. But let's say I added some form of on-screen keyboard and rigged the script to save / load using an external disk drive… such users are still going to have to use the pastebin script or something to transfer the files.

So it seems to me that it'd be a whole lot easier to just take a screenshot of the banner in the editor, and copy the layout into another server from there, if ever need be.

On the other hand, if you're talking about saving to a more conventional image file of some sort, there are problems there too - for one thing the editor won't be able to load them, for another if you want to draw regular images you'd be better off using a regular image editor.
vico #11
Posted 31 May 2016 - 08:06 AM
I wonder if is possible to add optional support for Et Futurum banners (exacly same structure, its a backport mod) for 1.7.10.

I think its just a matter to replace all "minecraft:banner" references to a variable and, upon verifying (presuming the user have the mod) if minecraft version is 1.7.10, use in the var "etfuturum:banner" (dont know the id exacly) instead.

I don't have enough time to see it now, if i was, i would try to convert myself.
Bomb Bloke #12
Posted 31 May 2016 - 09:27 AM
There are two difficulties in taking this particular script back to MC 1.7.10.

One is the lack of MC 1.8's "blockdata" command, upon which I rely to read and write to the external chest's inventory. Without that, exporting banners becomes clunkier, and importing becomes pretty much impossible. If a peripheral mod existed that allowed reading (and ideally writing!) directly to a tile entity's NBT data it wouldn't be a problem, but as far as I'm aware, no such mod exists yet.

The above isn't such a big deal, but the other is that ComputerCraft 1.76's graphical capabilities are used for the preview pane (via BLittle), and CC 1.76 also requires MC 1.8. Ditching the new techniques would make it next to impossible to display a banner with any degree of accuracy on a regular ComputerCraft display.
Forgotten_Boy #13
Posted 24 September 2016 - 07:26 AM
Can't seem to get this to work :(/> The import/export functions won't work for me - they do nothing when clicked. I've arranged the chest with banners as you demonstrate in the video. Using Minecraft 1.8.9 in Creative mode. Another Command computer I have to set the time works so presumably it's not permissions.

Where should I look?
Bomb Bloke #14
Posted 24 September 2016 - 09:29 AM
If you turtle.inspect() your chest, is it a "minecraft:chest", or has a mod overridden it?
Forgotten_Boy #15
Posted 24 September 2016 - 06:05 PM
The only mod I have installed is ComputerCraft, but it's the ComputerCraftEDU version (file: ComputerCraftPlusComputerCraftEdu1.79.jar).

I can check that chest, but it should be vanilla. Maybe it is my mod jar?
Bomb Bloke #16
Posted 25 September 2016 - 01:17 PM
Nah, probably not a mod issue in that case.

But if it's not the type of chest, then I'll need some more info. If you run this line through the system's Lua console it should hopefully generate a debug.txt with some clues:

_, input = commands.blockdata("~ ~1 ~ {}") out = fs.open("debug.txt", "w") out.writeLine(input) out.close()
Forgotten_Boy #17
Posted 25 September 2016 - 07:11 PM
The debug.txt contents:

{1.0=The data tag did not change: {x:-401,y:69,z:280,Items:[0:{Slot:0b,id:"minecraft:banner",Count:1b,tag:{BlockEntityTag:{Patterns:[0:{Pattern:"flo",Color:0}],Base:15}},Damage:15s},1:{Slot:1b,id:"minecraft:banner",Count:1b,tag:{BlockEntityTag:{Base:10}},Damage:10s}],id:"Chest",Lock:""}}

This was after attempting an "Export" into a chest with a single white banner in its first slot.

Other data:
- per your previous request about the chest, if I go to the lua prompt and type "turtle" it prints "nil". Command Computers are not turtles?
- your WorldPorter program works great so it's specific to this situation.
Edited on 25 September 2016 - 05:12 PM
Bomb Bloke #18
Posted 26 September 2016 - 01:27 AM
The debug.txt contents:

This was after attempting an "Export" into a chest with a single white banner in its first slot.

Odd, that string indicates there were two banners in the chest at the time you ran the command. In any case no problems are revealed there.

per your previous request about the chest, if I go to the lua prompt and type "turtle" it prints "nil". Command Computers are not turtles?

Well it's a good thing I wrote this, then, isn't it? :lol:/>

Or you could, I dunno, maybe just place a turtle in front of a chest? Whatever you find easier. ;)/>
Forgotten_Boy #19
Posted 26 September 2016 - 02:48 AM
I've tried a variety of banner combos in the chest; it could be I didn't save the debug.txt for the right attempt.

What should I try next?
Bomb Bloke #20
Posted 26 September 2016 - 12:27 PM
Here's a version which'll write a rather more informative debug.txt.
Forgotten_Boy #21
Posted 26 September 2016 - 11:57 PM
As you correctly guessed, it was the chest :/
A trapped chest, to be exact. Changed it out and am happily placing banners. Thanks!
JacobF #22
Posted 13 March 2018 - 01:16 AM
Hello I can't export the banner. I have the banner in a chest it is a real chest (I checked with a turtle). When I click export it says:
banedit.lua:633: attempt to index ? (a number value)
Bomb Bloke #23
Posted 13 March 2018 - 01:09 PM
Huh, I'm honestly uncertain what would lead to that. Could you tell me which versions of Minecraft and ComputerCraft you're trying to use the script with?

I've made an edit to the script which may or may not resolve the issue, please try redownloading it and exporting again.
JacobF #24
Posted 15 March 2018 - 12:34 AM
Huh, I'm honestly uncertain what would lead to that. Could you tell me which versions of Minecraft and ComputerCraft you're trying to use the script with?

I've made an edit to the script which may or may not resolve the issue, please try redownloading it and exporting again.

Ok, I've updated the code and instead of throwing an error code on export it does nothing and before you ask I used a turtle to turtle.inspect() to confirm it is indeed a minecraft:chest (with a metadata of 5 if that's relevant). The version of Minecraft is 1.12.2 and the version of ComputerCraft is 1.80pr1.
Bomb Bloke #25
Posted 15 March 2018 - 01:39 AM
Ok, the NBT format must've changed enough since MC 1.8 that the script can't alter the chest contents anymore. I'm pretty sure I remember testing it in MC 1.11, but later in the weekend I should be able to do a full review and get it going again in all builds.
Bomb Bloke #26
Posted 28 March 2018 - 10:48 AM
Sorry, I forgot about this - it should be all fixed up now. :)/>
JacobF #27
Posted 29 March 2018 - 03:39 AM
Sorry, I forgot about this - it should be all fixed up now. :)/>

It is working for me. Thank you!