Welcome to the tutorial on how to add a Graphical UI (GUI) for your mod
What it's explained in this tutorial:
- Simple Popup (with Linear Layout and Scroll)
- Popup with "OK" and "Cancel" (with Linear Layout and Scroll)
- Toast message
- Open URL
- Button
- Text
P.S.: At the end of every element I added the link to the official Android Reference.
I will add soon screenshots for these elements
Simple Popup:
var currentActivity = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();<br>//You can add this code at the top of your script
Now inside a function we have to initialize the Linear Layout and the Scroll of the Popup that we are going to create:
var layout = new android.widget.LinearLayout(currentActivity);<br>//We have initialized the Linear Layout<br>//P.S.: after creating the Popup we will add the visual elements (buttons, switches, images, text) to the Layout<br><br>layout.setOrientation(android.widget.LinearLayout.VERTICAL);<br>//We have set the Layout to VERTICAL but we can also set it to HORIZONTAL<br><br>var scroll = new android.widget.ScrollView(currentActivity);<br>//We have initialized the Scroll (you can also have a Popup without the scroll but if you add something that goes out the maximum space you can't see it)<br><br>scroll.addView(layout);<br>//We have added the Linear Layout to the Scroll
Now we can initialize the Popup:
var popup = new android.app.Dialog(currentActivity);<br>//We have initialized the Popup<br><br>popup.setContentView(scroll);<br>// We have added the Scroll (do you remember that the Scroll contains the Linear Layout and the Linear Layout contains the visual element that we are going to add?)<br><br>popupInfo.setTitle("Title");<br>//Set the title of the Popup
Now we have a Popup that is ready to be shown (but it is blank because we haven't added any visual element), to show it use this code:
popup.show();
Official Android reference for the Popup: http://developer.and...app/Dialog.html
Popup with "OK" and "Cancel":
var popup = new android.app.AlertDialog.Builder(currentActivity);<br>//With the Simple Popup we used android.app.Dialog now we have to use android.app.AlertDialog
Now we can add to the Alert Dialog (the popup) the OK button and the Cancel button:
popup.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener(){<br>//You can write also different things in the button, instead of "OK" you can write "Done" for example<br>onClick: function(viewarg)<br>//The onClick method is called when the user press OK<br>{<br>//Add your code here when the user press "OK"<br>}});<br><br>popup.setNegativeButton("Cancel", new android.content.DialogInterface.OnClickListener(){<br>onClick: function(viewarg)<br>{<br>//Add your code here when the user press "Cancel"<br>}});
Official Android reference for the Popup with "OK" and "Cancel" (Alert Dialog): http://developer.and...lertDialog.html
Toast Message:
To create a toast message you can use this code:
android.widget.Toast.makeText(currentActivity, "Message", 0).show();<br>//Write what you want instead of "Message"
Official Android reference for Toast messages: http://developer.and...dget/Toast.html
Open URL:
var intentBrowser = new android.content.Intent(currentActivity);<br>//We have initialized an Intent with the name "intentBrowser"<br><br>intentBrowser.setAction(android.content.Intent.ACTION_VIEW);<br>//This set the action that the intent will perform, ACTION_VIEW it's the default action<br><br>intentBrowser.setData(android.net.Uri.parse("http://google.com"));<br>//We have set that the intent will open the URL "http://google.com"
Now we can start the Intent:
currentActivity.startActivity(intentBrowser);
Official Android reference for Intent: http://developer.and...ent/Intent.html
Official Android reference for Uri: http://developer.and...id/net/Uri.html
Button:
var button = new android.widget.Button(currentActivity);
Now we can set the text of the button and what will happen if the user press the button:
button.setText("Text");<br>//Write what you want instead of "Text"<br><br>button.setOnClickListener(new android.view.View.OnClickListener()<br>{<br>onClick: function()<br>{<br>//here you can add you code<br>}<br>});
Now the latest thing (but maybe the most important thing), add the visual element that we have just created in the Layout:
layout.addView(button);
Official Android reference for Button: http://developer.and...get/Button.html
Text:
var text = new android.widget.TextView(currentActivity);
Now we can set the text that is displayed (we can set also the color)
text.setText("Text");<br>//This set the text of the TextView element, you can change it and write what you want<br><br>text.setTextColor(android.graphics.Color.RED);<br>//This set the color of the text, you can also not write this line in your script if you want the text white
Now the latest thing (but maybe the most important thing), add the visual element that we have just created in the Layout:
layout.addView(text);
Official Android reference for TextView: http://developer.and...t/TextView.html
Example for every element of this tutorial:
(Open the Simple Popup by typing in chat /simple-popup or open the Popup with "OK" and "Cancel" by typing /popup-ok)
You can also look at the code here: GitHub
If this tutorial is useful for someone I will add switch, image and input text tutorials.
Please, if you like this tutorial press the green button ("vote this post up") here below.
And sorry for my bad English.
1
All of my Mods, updated and tested for MCPE 0.11.x !!!
Here it all is. I will have more screenshots soon. Use the texture pack and the newest BlockLauncher. Enjoy!
Please post here with bugs or questions or comments! Thanks!
------------------------
*** Texture Pack ***
Install the texture pack! It only has "extra" mod items and armour.... doesn't change normal MCPE textures!
http://adf.ly/1KMZQc
----------
TreePlanter 2.1
http://adf.ly/1KMZc6
Craft with Metalurgic resources (see below). Place the Planter block and place a Chest on top. Put saplings or plants in the first slot of the chest and tap the Planter Block.
Teleporter 1.1
http://adf.ly/1KMZrc
Craft the Teleporter Base, and then one of each Teleporters (1a and 1b). Place Teleporter 1a and 1b wherever you want to go between. Craft a Teleporter Link and use it to tap teleporter 1a, then 1b. Tap the teleporter with anything else to be transported between the two locations. More location/bases to come soon!
Solar Furnace 2.1
http://adf.ly/1KMZyU
Craft a Solar Panel with Metalurgic resources (see below). Place the Solar Panel on top of a Furnace (tap the block behind the furnace to place
). If the light level is bright enough, the Furnace below the Panel will run as long as there is an item to be cooked in it. Turns off when it gets dark.
SmokeCraft 4.3
http://adf.ly/1KMa6U
Cannabis in MCPE. Craft a hand Pipe with cobblestone and one Iron Ingot, or use a piece of paper to roll a joint. Use bonemeal on grass to get Cannabis. Trim cannabis with Shears to get more. Also small chance of cannabis when using shears on tall grass/ferns. Craft a Joint or a full Pipe in the crafting menu. Add a torch to light it. Also light the full pipe or joint by tapping it on a torch. Please play responsibly. *To smoke the Lit Joint or Lit Pipe, just tap it on the ground!* Effect lasts for a minute and a half.
Vertical Quarry 2.2
http://adf.ly/1KMaaG
Craft the Quarry Block with Metalurgical resources (see below). Place the Quarry block anywhere and tap it. The Quarry will dig straight down until bedrock (or air) and then move one block over, in the positive + X direction. All mined blocks will shoot out the top of the Quarry. No chest needed. Use the Item Magnet (see below) to help collect items as they shoot out the quarry.
Nether Dungeons 2.2
http://adf.ly/1KMaty
Tap Obsidian with Flint and Steel. Nether Portal will appear, and a Nether Dungeon will generate on the same map, with unique and randomized terrain. Walk into the portal to be teleported to the Nether. Watch out for Zombie Pigmen and also bonus Loot chests and Nether Quartz ore!
More Blocks, Drops, & Crafts 4.3
http://adf.ly/1KMb30
Adds: Redstone Lamps, Enchanting Table(no function), Hide/Wool Armor, Podzol and Grass recipes, Block of Coal from Charcoals, Single Diamond from 9 Coal Blocks, Gold Carrot, Carrot on a stick, Boiled Egg, Sunflower Seeds, Roasted Seeds, Cobweb recipe from slime and string, ... Slimes drop slimeballs, Endermen drop End Pearls, zombie Pigmen drop gold Nuggets... yeah.
Mob Health tag 2.0
http://adf.ly/1KMbPB
Any mob you hit will have a nametag displaying its remainng health.
Metalurgical Gem Alchemy 7.2
http://adf.ly/1KMbYC
Adds 7 new ores! Copper, Aluminum, Silver, Magnesium, Ruby, Sapphire, Amethyst! Combine the new metals to make more Gold or Iron. Mine for rare gems and collect Ore Dusts to smelt ingots for new items (many of my other mods require Metalurgic ingredients now!) The new Ores generate randomly below level 40, usually as single veins. Not too hard to find. My ore generation works well in normal worlds, but it will replace air blocks on a flat map or anything that is "open" near the bottom of the map.
LightSabers 1.1 !!!
http://adf.ly/1KZ91v
How does it work? Craft your Lightsaber with Iron Ingots, Glowstone dust, a Glass block, and then either an Emerald, Lapis, or Redstone dust to set the color of your Blade! Recipes are for 3 different colors. To use it, tap the Lightsaber anywhere, and the blade will turn ON. Tap again to turn the blade OFF. When the blade is On, the Lightsaber deals 8-10 damage per hit! When the blade is Off, nothing special happens. When you hit a mob, it will also emit "sparks" of whatever color the Blade is! How is it like The Force? Uhmmmmmmmm....... you have to concentrate to use it. If you accidently tap a block instead of a Mob, that will turn off your blade. So you have to focus your intention, and concentrate on not hitting anything but your target. Yeah............. ?
Item Magnet 1.3
http://adf.ly/1KMboX
Inspired by PC, but way more basic. Craft the Magnet with Metalurgic resources (see above). As long as you have the Magnet SOMEWHERE in your inventory, you will 'suck' or pull newly dropped Items and Blocks towards you. It has a small radius, slightly larger than the pick/interact range. Will be improved soon!
InsTent 1.5
http://adf.ly/1KMbww
Craft a tent with Wool and Sticks in the crafting menu. Tap the ground with the Tent item to set up/place the tent. Use it for basic shelter. Tap the 'set tent' block on the corner to instantly pack it up. Reusable.
GuideBook, Clock, GPS 5.1
http://adf.ly/1KMcFK
Craft the 'MineCrafter's Guide to the Blockiverse' in the crafting menu. Tap that book on any block or Mob for a bunch of info on XYZ, render type, age, health, light level, velocity..... Or tap a normal Clock to get time in ticks converted to a 12-hour format (am-pm)in chat. Tap a compass for your XYZ location in chat.
GlutenFree- craft 3.6
http://adf.ly/1KMcU9
Craft Gluten-Free food in the crafting menu. Collect Tree-Nuts by breaking leaves. Make GF Bread, Cookies, Cake, Milk.
EmeraldCraft 2.8
http://adf.ly/1KMcnY
Emerald Tools with magic Powers, and new Emerald Armor that *DOESN'T* just replace chain. Also new Emerald Blocks (Fence, Wall, Glass, Bookcase, Torch, and Emerald Slab and Carpet). Trade with Villagers by tapping them with the right item(s).... see chart! Also earn Emeralds when you battle new Emerald Mobs with more health! Randomly spawned Emerald Mobs have magical Green Eyes and drop Emeralds!
Biome Overlay XYZ 1.1
http://adf.ly/1KMd3L
Tap a piece of Paper on anything. An overlay with the Biome Name and your XYZ location will be displayed until you tap the paper on something again. Simple debug screen.
---Screenshot---
http://www.mediafire.com/view/wkhr4096649i306/Screenshot_2015-07-05-22-25-47.png
Item Magnet, Quarry Block, Biome Overlay, Metalurgic Gem Alchemy, Mob Health tag, and Teleporter! (all in one screen shot haha!)
1
Yeah, my mods too. But with my name on them. Its fine as far as I can tell (more downloads :-D ) but also kinda weird. And flattering....? There are many weird sites that I find my mods hosted on, some without credit.... meh. Information wants to be free.
4
Mods by NateKrell a.k.a. Etan_Llerk a.k.a NateOK
For Android, MCPE 0.9.5
*Pictures are BELOW this, in posts #2 and #3. And yes, I use adf.ly links now. Thanks for understanding, and waiting the extra 5 seconds to support my work!
[size=medium]
Emerald Tools/Armor, *GlutenFree-Craft, *SmokeCraft, *Tent-mod, and *ElementCraft all use one Texture Pack. Download: [size=medium]http://adf.ly/ssSyk[/size]
[size=small]If you don't use that Texture Pack, the new items and tools will look wrong. Otherwise, it is pretty standard MC Textures...[/size]
Emerald Tools and Armor
New Updated mod and link! May 12 2015! - http://www.minecraftforum.net/forums/minecraft-pocket-edition/mcpe-mods-tools/2424892-new-emeraldcraft-2-0-tools-armor-trading-and
Emerald tools are in the Crafting menu. They are enchanted with special powers:
-em Pickaxe: Fortune II increases the number of dropped items for many blocks, including Diamond, Lapis, Emerald, Redstone, and Coal Ores, and also Crops, Melons, and more!
-em. Shovel: Silk Touch drops the block you break, instead of the usual drop.
-em. Axe: TreeCapitator drops all Logs above the Log you break.
-em. Sword: Explode and Throw Mobs a short distance. Boom.
-em. Hoe: Randomly plant a crop, melon, pumpkin, or reeds... and water too!
----------
Gluten Free -Craft
http://adf.ly/ssRVE
Get Almonds from Leaf blocks, and use them to craft GF food in workbench.
-Almond Milk, GF Bread, GF Cake, and now GF cookies!
----------
SmokeCraft
http://adf.ly/ssS2N
Use Cannabis in MineCraft! The Mod adds a Joint, Pipe, & Full Pipe as items, and a Lit Joint & Lit Pipe as foods.
-Roll a Joint at the workbench, with Paper and Tall Grass (or Fern)
-Craft a Pipe, with Cobblestone and an Iron Ingot.
-Pack the bowl, and use a torch to light it! Use the Lit Joint/Pipe like a food item (eat it when your hearts are low).
Now with Slow-Speed and Vision- effects!!! (Lasts a short time).
----------
ElementCraft
http://adf.ly/ssQl3
Adds new Ores to Minecraft and generates them (once only!) as you move around and load new chunks.
-Found below level Y40, there is now Silver, Aluminum, Magnesium, Amethyst, Ruby and Sapphire!
-This keeps all the old ore blocks, and increases the number of ores from 7 to 13 (or 14, including Nether Quartz).
-So far you can Smelt the metals into Ingots and craft those into dust, as well as collect the gemstones from their ores.
***Also adds 1-in-200 chance of spawning an Emerald Cave! Full of Emerald Ore. Its like an Emerald Dungeon! More to come later!***
----------
Tent mod
http://adf.ly/ssSP7
This adds a camping tent that can be placed down or packed up with just one click!
It can provide some protection from Mobs, etc, when you are adventuring far from your home.
-The Tent can be Crafted from Wool and Sticks in the Crafting Table.
-Tap the Tent anywhere to set it up (3x3x3 space needed).
-Tap the darker "corner" Block of the tent to take it down again. Re-usable.
-The tent is big enough for one Bed to be placed inside (not included - bring your own Bed) and one Player.
-(Note: the only "custom texture" on this mod is the Item icon for the Tent itself. It would still place a wool Tent down just fine without the Texture Pack, if you need)
------------
Tree-Planter Machine!
http://adf.ly/ssSqC
One of my personal favorite Mods I have done, actually. It adds a Block that will plant Trees (or anything else!) over a 4 Chunk area (32x32 blocks square), but only on Grass Blocks!
-Craft the Tree Planter with Cobble, Plank Slabs, a trapdoor, redsrone dust, and a Sapling, in the Crafting menu.
-Place the Tree Planter down in the center of the area you want planted.
-Place a normal Chest *On Top* of the Planter. Put up to 64 saplings (or whatever) into the *first* space of the Chest.
-Tap the Planter Block to turn it on, and it will randomly check all Blocks around to see if they are Grass. If it is a Grass Block, it plants one item and checks another.
-The machine emits Redstone Smoke when it is on, and also makes a fast puff of green above itself, and also at the planted location, each time it finds an acceptable Block!
-It has chat messages to let you know when to refill the Chest on top. Plants any kind of Block!
---------
[size=small] [size=medium](no texture pack):[/size]
Emerald Trades (my version)
http://adf.ly/ssRF0
Tap any Villager to trade for Emeralds and more! You must be holding the right number and type of Item when you tap the Villager. Each type of Villager only takes certain trades (the same as PC, but less choices):
----------
GuideBook, GPS and Clock Time
http://adf.ly/ssRfm
-Craft the GuideBook in the workbench, tap it on any block/mob for info on ID, age, damage, etc...
-Tap a compass to get your x,y,z location.
-Tap a clock to have game-time converted to 12 hour am-pm format
----------
Skeleton drops Bow
http://adf.ly/ssRrt
Adds a 12% chance that Skeletons will drop a bow along with its arrows and bones.
----------
SkySpace
http://adf.ly/ssRwg
Tap Redstone Dust anywhere to blast yourself into Outer Space!!! You will float in the darkness, surrounded by stars, for a few seconds, then fall back to where you started, all safe. Just for fun.
----------
De-Crafting (my version)
http://adf.ly/ssPH9
Adds a De-crafting Table, for complex de-crafting, as well as simple de-crafting recipes in the normal Crafting Table.
-Get your resources back from many things, including 4 Planks from a Crafting Table, 8 from a Chest...
-Get 6 Gold Ingots plus a Stick and Redstone Dust from a set of Powered Rails, Even get your Diamonds back after crafting a Nether Reactor Core!
-Just tap the Decrafting Table with the item you want to revert back to its base ingredients. Many things can be Decrafted, but many can not yet! Let me know what you want new Decrafting recipes for! Comment.in this thread!
------------
Emerald Everything!
http://adf.ly/ssQsj
This adds several new Emerald Blocks to craft and use. Also works in Creative. Adds: Emerald Carpet, Emerald Slabs, Emerald Posts ans Pillars (like fences and wall pillars), Emerald Bookcases, and more! Uses new, un-used IDs for new Blocks. Kind of a weird one... enjoy.
-----------
MoreBlox (my version)
http://adf.ly/ssRmW
Adds a bunch of Blocks and Items from the PC version. It includes things like Nether Quartz Ore, and a method to make it drop the right item, Zombie Pigmen drop Gold Nuggets (craftable), Endermen drop Ender Pearls (do not work, but do in other people's mods), and more. Also has new recipes to craft Podzol, and Grass, from standard ingredients in Survival! Another fun one...
----------------
Solar Powered Furnace
http://adf.ly/ssSGi
This is the same Solar Furnace I had out a few months back... the 0.9.5 update broke it then, and now it is fixed.
-Craft the Solar Panel in the Crafting table. Place it "on top" of a single furnace.
-(To place it on top, you need to tap a wall behind or beside the Furnace, one block above it).
-Tap the Solar Panel after you place it on top of a Furnace. This will turn it On if the Light Level is bright enough (14 or 15). The Solar Panel will "power" the Furnace by keeping it full of -Coal as long as the surrounding Light is bright enough. If the light level gets to dark, or if you Tap the Solar Panel again, it will turn Off, and all Coal will be removed from the Furnace.
-Only one Solar Panel can be used at a time.
----------------
I hope you enjoy these.
Please post here to with bugs, questions, or ideas to make these better![size=small]
3
[p]http://adf.ly/1GzO9J[/p]
[p]------[/p] [p]
[p]
[p]Its a big mod, so check out my old page (in my signature line) for full info, but download THIS VERSION! [/p] [p]Basic info:[/p] [p]-Emerald Sword explodes mobs. Emerald Axe has treecapitator. Emerald Shovel has Silk Touch (get any block you break).[/p] [p]Emerald hoe plants a random food crop.[/p] [p]Emerald Pickaxe has *Fortune II* Enchantment! This is *not* faster, but it gives you more item drops-per-block for things like: Coal, Diamond, Redstone, Lapis, Emeralds, Gravel, crops.... I repeat: more items, not faster breaks![/p] [p]-Emerald Armor is the same level as Chainmail. Normal recipes with Emeralds.[/p]
[p]
[p]Emerald Trades: Tap a villager while holding the correct item(s) to trade, and the Villager will drop an Emerald. Different villagers trade different items (based on PC trading) so check my old page for more info.[/p]
[p]Comment on THIS PAGE with bugs or comments. Thanks![/p]
1
Nether "Dungeons"... every one is unique!
--------------------------
http://adf.ly/1GMPhz
**May 5 Bugfix! New link!**
This mod adds THE NETHER, in mini form! Tap Obsidian with Flint and Steel to make the Portal. Walk into the purple portal block, and you will be teleported to the Nether Dungeon! Watch out for Zombie Pigmen and random Loot Chests too!
-Real Dungeon, on the SAME MAP! No reloading a new map!
-Procedurally Generated, so all Dungeons are totally different! Like a real "Mini-Biome!"
-Mobs and loot! And Nether Quartz to mine!
-Works with more than 1 dungeon on the map!
-No texture pack needed!
Please comment with bugs or problems on THIS THREAD.
Thanks, and good luck in the Nether!
1
..... I use extended craft with many other mods and sometimes random errors just happen. Break the block(s), exit the game, delete that .txt file, reload your level.
Good luck!
1
PS- new mods out soon. Quarry, and Nether caves with random, unique terrain generation. Woo... maybe in a few days!
1
So, Happy holidays and have fun!!!
1
1
Otherwise, too bad because the maps were cool.