Last active
July 18, 2017 22:42
-
-
Save GenbuHase/92f97f3eaae72a68d0ca9af85253551a to your computer and use it in GitHub Desktop.
ScriptMod Codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let KstrCollection = []; | |
const KstrRenderType = (function () { | |
let renderer = Renderer.createHumanoidRenderer(); | |
let model = renderer.getModel(); | |
let head = model.getPart("head").clear(); | |
let body = model.getPart("body").clear(); | |
let leftArm = model.getPart("leftArm").clear(); | |
let rightArm = model.getPart("rightArm").clear(); | |
let leftLeg = model.getPart("leftLeg").clear(); | |
let rightLeg = model.getPart("rightLeg").clear(); | |
body.setTextureSize(32, 16); | |
body.setTextureOffset(0, 0, true); | |
body.addBox(-4, -4, -4, 8, 8, 8); | |
return renderer; | |
})(); | |
const spawnKstr = function (x, y, z) { | |
let Kstr = Entity.spawnMob(x + 0.5, y + 1.0, z + 0.5, EntityType.SLIME, "mob/Kstr.png"); | |
Entity.setNameTag(Kstr, "Kstr"); | |
Entity.setRenderType(Kstr, KstrRenderType.renderType); | |
KstrCollection.push(Kstr); | |
}; | |
function useItem (x, y, z, id) { | |
if (id == 280) spawnKstr(x, y, z); | |
}; | |
function entityAddedHook (ent){ | |
if (Entity.getNameTag(ent) == "Kstr") { | |
Entity.setRenderType(ent, KstrRenderType.renderType); | |
Entity.setMobSkin(ent, "mob/Kstr.png"); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetFileDataFromTexturePack(Path) { | |
return new Java.lang.String(ModPE.getBytesFromTexturePack(Path), "UTF-8"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code Importer Sample - 1 | |
//https://gist.github.com/GenbuHase/92f97f3eaae72a68d0ca9af85253551a/raw/Code Importer.js | |
Hello = function () { | |
print("Hello"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Import(URI) { | |
var Th = new java.lang.Thread( | |
new java.lang.Runnable({ | |
run: function () { | |
var Code = new java.io.BufferedReader(new java.io.InputStreamReader(new java.net.URL(URI).openStream())); | |
var CodeDatas = ""; | |
var AddCodes = ""; | |
while (CodeDatas != null) { | |
AddCodes += CodeDatas + "\n"; | |
CodeDatas = Code.readLine(); | |
} | |
print (AddCodes); | |
eval (AddCodes); | |
} | |
}) | |
); | |
Th.start(); | |
while (Th.getState() != java.lang.Thread.State.TERMINATED) { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.getClassName = function () { | |
return Object.prototype.toString.call(this).slice(8, -1); | |
}, Object.defineProperty(Object.prototype, "getClassName", { | |
enumerable: false | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const JsReader = (function () { | |
function JsReader (file) { | |
return Object.create(new java.io.BufferedReader(new java.io.FileReader(file)), { | |
run: { | |
value () { | |
let mem = "", | |
res = ""; | |
while ((mem = this.readLine()) != null) { | |
res += mem; | |
} | |
eval(res); | |
} | |
} | |
}); | |
}; | |
return JsReader; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
*【ローカライズファイルの書式】 | |
*{ | |
* "ja_JP": { | |
* "item.Hoge.name": "ほげ" | |
* }, | |
* | |
* "en_US": { | |
* "item.Hoge.name": "Hoge" | |
* } | |
*} | |
/*/ | |
const LangLoader = (function () { | |
function LangLoader (path) { | |
try { | |
return Object.create(new BufferedReader(new InputStreamReader(ModPE.openInputStreamFromTexturePack(path))), { | |
toObject: { | |
value () { | |
let mem = "", | |
res = ""; | |
while ((mem = this.readLine()) != null) { | |
res += mem + "\n"; | |
} | |
return(JSON.parse(res)); | |
} | |
}, | |
apply: { | |
value () { | |
let langData = this.toObject(); | |
for (let Key in langData[ModPE.getLanguage()]) { | |
ModPE.langEdit(Key, langData[ModPE.getLanguage()][Key]); | |
} | |
} | |
} | |
}); | |
} catch (Err) { | |
clientMessage(Err); | |
} | |
}; | |
return LangLoader; | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
*Player.GetItemAmount(ID, Damage) | |
* | |
*<<概要>> | |
* 引数のIDとダメージ値のアイテムの個数を返します | |
* | |
*<<引数>> | |
* ID(int型):数えるアイテムのID | |
* Damage(int型):数えるアイテムのダメージ値 | |
/*/ | |
Player.GetItemAmount = function (ID, Damage) { | |
var Result = 0; | |
for (var i = 9; i < 36; I++) { | |
if (Player.getInventorySlot(I) == ID && Player.getInventorySlotData(i) == Damage) { | |
Result += Player.getInventorySlotCount(i); | |
} | |
} | |
return Result; | |
} | |
/*/ | |
*Level.ViewArea(StartPos, EndPos, ParticleID) | |
* | |
*<<概要>> | |
* 指定された範囲をパーティクルで囲みます | |
* | |
*<<引数>> | |
* StartPos(Array型) | |
* =>[0](int型):開始地点のX座標 | |
* =>[1](int型):開始地点のY座標 | |
* =>[2](int型):開始地点のZ座標 | |
* | |
* EndPos(Array型) | |
* =>[0](int型):終了地点のX座標 | |
* =>[1](int型):終了地点のY座標 | |
* =>[2](int型):終了地点のZ座標 | |
* | |
* ParticleID(int型<省略可能>):表示するパーティクルのID | |
/*/ | |
Level.ViewArea = function (StartPos, EndPos, ParticleID) { | |
var XMax = Math.max(StartPos[0], EndPos[0]), XMin = Math.min(StartPos[0], EndPos[0]), | |
YMax = Math.max(StartPos[1], EndPos[1]), YMin = Math.min(StartPos[1], EndPos[1]), | |
ZMax = Math.max(StartPos[2], EndPos[2]), ZMin = Math.min(StartPos[2], EndPos[2]); | |
if (ParticleID == undefined) { | |
ParticleID = ParticleType.flame; | |
} | |
for (var Y = 0; Y <= YMax - YMin; Y++) { | |
for (var X = 0; X <= XMax - XMin; X++) { | |
for (var Z = 0; Z <= ZMax - ZMin; Z++) { | |
for (var Xs = 0; Xs < 2; Xs++) { | |
for (var ZCon = 0; ZCon < 1; ZCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y, ZMin + Z + ZCon, 0, 0, 0, 1); | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y + 1, ZMin + Z + ZCon, 0, 0, 0, 1); | |
} | |
} | |
for (var Zs = 0; Zs < 2; Zs++) { | |
for (var XCon = 0; XCon < 1; XCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + XCon, YMin + Y, ZMin + Z + Zs, 0, 0, 0, 1); | |
Level.addParticle(ParticleID, XMin + X + XCon, YMin + Y + 1, ZMin + Z + Zs, 0, 0, 0, 1); | |
} | |
} | |
for (var Xs = 0; Xs < 2; Xs++) { | |
for (var Zs = 0; Zs < 2; Zs++) { | |
for (var YCon = 0; YCon < 1; YCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y + YCon, ZMin + Z + Zs, 0, 0, 0, 1); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
/*/ | |
*ModPE.PostData(URL, Data) | |
* | |
*<<概要>> | |
* 指定されたURLにDataを送信します | |
* | |
*<<引数>> | |
* URL(String型):送信先のURL | |
* Data(String型):{{Key}}={{Data}}の書式 | |
/*/ | |
ModPE.PostData = function (URL, Data) { | |
try{ | |
var Connecter = new java.net.URL(URL).openConnection(); | |
Connecter.setRequestMethod("POST"); | |
Connecter.setDoOutput(true); //POSTを可能にする | |
var Printer = new java.io.PrintStream(Connecter.getOutputStream()); | |
Printer.print(post_string); | |
Printer.close(); | |
var Reader = new java.io.BufferedReader(new java.io.InputStreamReader(Connecter.getInputStream())); | |
var Result = new java.lang.StringBuffer(); | |
var Memory = null; | |
// InputStreamからのデータを文字列として取得する | |
while ((Memory = Reader.readLine()) != null) { | |
Result.append(Memory); | |
} | |
return Result.toString(); | |
} catch (Error) { | |
clientMessage(Error); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GetPartFromImage = function (Path, X1, Y1, X2, Y2) { | |
var Image = android.graphics.BitmapFactory.decodeFile(Path); | |
return android.graphics.Bitmap.createBitmap(Image, X1, Y1, X2 - X1, Y2 - Y1, null, true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*/ | |
*Level.ViewArea(StartPos, EndPos, ParticleID) | |
* | |
*<<概要>> | |
* 指定された範囲をパーティクルで囲みます | |
* | |
*<<引数>> | |
* StartPos(Array型) | |
* =>[0](int型):開始地点のX座標 | |
* =>[1](int型):開始地点のY座標 | |
* =>[2](int型):開始地点のZ座標 | |
* | |
* EndPos(Array型) | |
* =>[0](int型):終了地点のX座標 | |
* =>[1](int型):終了地点のY座標 | |
* =>[2](int型):終了地点のZ座標 | |
* | |
* ParticleID(int型<省略可能>):表示するパーティクルのID | |
/*/ | |
Level.ViewArea = function (StartPos, EndPos, ParticleID) { | |
var XMax = Math.max(StartPos[0], EndPos[0]), XMin = Math.min(StartPos[0], EndPos[0]), | |
YMax = Math.max(StartPos[1], EndPos[1]), YMin = Math.min(StartPos[1], EndPos[1]), | |
ZMax = Math.max(StartPos[2], EndPos[2]), ZMin = Math.min(StartPos[2], EndPos[2]); | |
if (ParticleID == undefined) { | |
ParticleID = ParticleType.flame; | |
} | |
for (var Y = 0; Y <= YMax - YMin; Y++) { | |
for (var X = 0; X <= XMax - XMin; X++) { | |
for (var Z = 0; Z <= ZMax - ZMin; Z++) { | |
for (var Xs = 0; Xs < 2; Xs++) { | |
for (var ZCon = 0; ZCon < 1; ZCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y, ZMin + Z + ZCon, 0, 0, 0, 1); | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y + 1, ZMin + Z + ZCon, 0, 0, 0, 1); | |
} | |
} | |
for (var Zs = 0; Zs < 2; Zs++) { | |
for (var XCon = 0; XCon < 1; XCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + XCon, YMin + Y, ZMin + Z + Zs, 0, 0, 0, 1); | |
Level.addParticle(ParticleID, XMin + X + XCon, YMin + Y + 1, ZMin + Z + Zs, 0, 0, 0, 1); | |
} | |
} | |
for (var Xs = 0; Xs < 2; Xs++) { | |
for (var Zs = 0; Zs < 2; Zs++) { | |
for (var YCon = 0; YCon < 1; YCon += 0.1) { | |
Level.addParticle(ParticleID, XMin + X + Xs, YMin + Y + YCon, ZMin + Z + Zs, 0, 0, 0, 1); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
var Pos1 = [null, null, null], | |
Pos2 = [null, null, null]; | |
var Counter = 0; | |
function newLevel() { | |
ModPE.setItem(501, "blaze_rod", 0, "選択ツール(開始地点)", 1); | |
ModPE.setItem(502, "blaze_rod", 0, "選択ツール(終了地点)", 1); | |
Player.addItemCreativeInv(501, 1, 0); | |
Player.addItemCreativeInv(502, 1, 0); | |
Item.setCategory(501, ItemCategory.TOOL); | |
Item.setCategory(502, ItemCategory.TOOL); | |
} | |
function useItem(X, Y, Z, ItemID, BlockID, Side, ItemDamage, BlockDamage) { | |
switch (ItemID) { | |
case 501: | |
Pos1 = [X, Y, Z]; | |
clientMessage("開始地点を[" + X + ", " + Y + ", " + Z + "]に設定しました"); | |
break; | |
case 502: | |
Pos2 = [X, Y, Z]; | |
clientMessage("終了地点を[" + X + ", " + Y + ", " + Z + "]に設定しました"); | |
break; | |
} | |
} | |
function modTick() { | |
if (Counter == 30) { | |
if (Pos1[0] != null && Pos1[1] != null && Pos1[2] != null && Pos2[0] != null && Pos2[1] != null && Pos2[2] != null) { | |
Level.ViewArea(Pos1, Pos2); | |
} | |
Counter = 0; | |
} | |
Counter++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment