I've been trying to get a GUI to pop up if the player is holding a custom item with the id of 504, and it would dismiss if the player is holding an other item, but everytime i switch to an item other then 504 an error pops up saying:
Error:
Error occurred in script: Industrialcraft.js
org.mozilla.javascript.WrappedException: Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. (Industrialcraft.js#116)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(Industrialcraft.js:116)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:233)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:302)
at dalvik.system.NativeStart.run(Native Method)
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4084)
at android.view.ViewRootImpl.die(ViewRootImpl.java:4071)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:336)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:286)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.widget.PopupWindow.dismiss(PopupWindow.java:1270)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
... 11 more
Code:
modTick(){
if (getCarriedItem()==504)
{
Test();
}
if(getCarriedItem()!=504&&TestGUI!=null){
TestGUI.dismiss();
}
}
function Test()
{
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); ctx.runOnUiThread(new java.lang.Runnable({ run: function() { try{
TestGUI = new android.widget.PopupWindow();
var Testuplayout = new android.widget.RelativeLayout(ctx);
var TestUp = new android.widget.Button(ctx);
TestUp.setText("△");
TestUp.setTextSize(40);
TestUp.setOnClickListener(new android.view.View.OnClickListener(
{ onClick: function(viewarg) {
setVelY( getPlayerEnt() ,1);
if(Player.getCarriedItemData() < 299){ Entity.setCarriedItem(getPlayerEnt(), 504, Player.getCarriedItemCount(), Player.getCarriedItemData() + 1);}
else { //Otherwise
Level.playSoundEnt(attacker, "random.break", 100, 100); //Play the break sound
Player.clearInventorySlot(Player.getSelectedSlotId()); //Remove the tool from the player's inventory
}
BeATz_UnKNoWN, you're good at GUIs, so you may know that. Good news - I'm now a master at making GUIs! I am working on an Android mod (adds Android phones, not a mod that works on Android, lol) that has WhatsApp
I realised the problem. Your TestGUI variable will ALWAYS have a value apart from null, therefore when the carried item is not 504 the script will try to dismiss the PopupWindow 20 times per second; even when it has already been dismissed. This should be your modTick() hook:
BeATz_UnKNoWN, you're good at GUIs, so you may know that. Good news - I'm now a master at making GUIs! I am working on an Android mod (adds Android phones, not a mod that works on Android, lol) that has WhatsApp
You're saying your a master and you are using more bits (computer term) than me. Please tell me how to change the CURRENT drawable of a ProgressBar. * You can't just say that I am good and you are a master without proof.
*I know how to and since you are a "master" you should as well.
Want to look at my current code? Added WhatsApp, Google Play and a Config menu with only a Phone Informations button that opens the Phone Informations menu, that only has this written on it:
Minedroid version: indev
And I am working on changing from dialogs to a window, so i can make a customization menu in Configurations that will have a Background Color option.
Three + the number of Android Developers across the world.
Also, I saw a twitter pic of your enchantments mod... Am I the only person who disliked the runes in Minecraft Enchanting
Error:
Error occurred in script: Industrialcraft.js
org.mozilla.javascript.WrappedException: Wrapped android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. (Industrialcraft.js#116)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script.modTick(Industrialcraft.js:116)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.callScriptMethod(ScriptManager.java:233)
at net.zhuoweizhang.mcpelauncher.ScriptManager.tickCallback(ScriptManager.java:302)
at dalvik.system.NativeStart.run(Native Method)
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4746)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:4084)
at android.view.ViewRootImpl.die(ViewRootImpl.java:4071)
at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:336)
at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:286)
at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:84)
at android.widget.PopupWindow.dismiss(PopupWindow.java:1270)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
... 11 more
Code:
modTick(){
if (getCarriedItem()==504)
{
Test();
}
if(getCarriedItem()!=504&&TestGUI!=null){
TestGUI.dismiss();
}
}
function Test()
{
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get(); ctx.runOnUiThread(new java.lang.Runnable({ run: function() { try{
TestGUI = new android.widget.PopupWindow();
var Testuplayout = new android.widget.RelativeLayout(ctx);
var TestUp = new android.widget.Button(ctx);
TestUp.setText("△");
TestUp.setTextSize(40);
TestUp.setOnClickListener(new android.view.View.OnClickListener(
{ onClick: function(viewarg) {
setVelY( getPlayerEnt() ,1);
if(Player.getCarriedItemData() < 299){ Entity.setCarriedItem(getPlayerEnt(), 504, Player.getCarriedItemCount(), Player.getCarriedItemData() + 1);}
else { //Otherwise
Level.playSoundEnt(attacker, "random.break", 100, 100); //Play the break sound
Player.clearInventorySlot(Player.getSelectedSlotId()); //Remove the tool from the player's inventory
}
} }));
Testuplayout.addView(TestUp);
TestGUI.setContentView(Testuplayout);
TestGUI.setWidth(80);
TestGUI.setHeight(80);
TestGUI.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
TestGUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 90); }
catch(err)
{ print("Error: "+err); } } })); }
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
BeATz_UnKNoWN, you're good at GUIs, so you may know that. Good news - I'm now a master at making GUIs! I am working on an Android mod (adds Android phones, not a mod that works on Android, lol) that has WhatsApp
Game dev and Minecraft modder.
Twitter: @jv110br_
Game dev and Minecraft modder.
Twitter: @jv110br_
var TestGUI; function modTick(){ if(getCarriedItem()==504 && TestGUI==null || getCarriedItem()==504 && TestGUI=="NaN"){ Test(); } if(getCarriedItem()!=504 && TestGUI!=null){ TestGUI.dismiss(); TestGUI = null; } }You're saying your a master and you are using more bits (computer term) than me. Please tell me how to change the CURRENT drawable of a ProgressBar. * You can't just say that I am good and you are a master without proof.
*I know how to and since you are a "master" you should as well.
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
Minedroid version: indev
And I am working on changing from dialogs to a window, so i can make a customization menu in Configurations that will have a Background Color option.
Game dev and Minecraft modder.
Twitter: @jv110br_
Game dev and Minecraft modder.
Twitter: @jv110br_
Game dev and Minecraft modder.
Twitter: @jv110br_
Three + the number of Android Developers across the world.
Also, I saw a twitter pic of your enchantments mod... Am I the only person who disliked the runes in Minecraft Enchanting
You limit yourselves to GUI's... I see that you a just an MCPE modder, not an Android Developer.*yourself
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
Game dev and Minecraft modder.
Twitter: @jv110br_