mcpejs研究吧 关注:233贴子:3,591
  • 3回复贴,共1
var ctx=com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
functionnewLevel()
{
print("欢迎使用月牙的孩子气js");
}
ctx.runOnUiThread(new java.lang.Runnable({run:function(){
//位置①
var win=new android.widget.PopupWindow();
//位置②
var layout=new android.widget.LinearLayout(ctx);
//位置③
var button=new android.widget.Button(ctx);
button.setText("帮助");
button.setOnClickListener(new android.view.View.OnClickListener(){onClick:function(v){
clientMessage("欢迎使用月牙的孩子气JS,输入/4399领取4399专用物品");
}});
//位置④
layout.addView(button);
//位置⑤
win.setContentView(layout);
win.setWidth(100);
win.setHeight(80);
win.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.argb(0,0,0,0)))
win.showAtLocation(ctx.getWindow().getDecorView(),android.view.Gravity.RIGHT | android.view.Gravity.BOTTOM,0,0);}}));
ModPE.setItem(998,"black",0,"黑色记忆",1);
ModPE.setItem(997,"life",0,"生命",1);
ModPE.setItem(965,"happy",0,"快乐之星",1);
Player.addItemCreativeInv(998,1,0);
ModPE.addCraftRecipe(998,1,0,[[42,3,0],[49,1,0],[347,1,0]]);
Player.getCarriedItem();
Entity.getEntityTypeId();
if(getCarriedItem()==998)
{
Entity.addEffect(32,2,2,2,false,true);
}
function procCmd(cmd/*4399*/) {
Player.addItemInventory(965,1,0);
}
function attackHook(a,v)
{
if(getCarriedItem()==997)
{
Entity.setHealth(v,Entity.getHealth(v)+6)
}
}
无法写入


IP属地:四川来自Android客户端1楼2016-02-27 16:27回复
    膜拜大神


    IP属地:陕西来自Android客户端2楼2016-02-27 21:36
    收起回复
      在ui线程上运行需要结尾处有catch(err){print(err)}


      IP属地:河南来自Android客户端3楼2016-04-03 06:37
      回复