zhuowei / MCPELauncher

Source code for BlockLauncher, a launcher that patches Minecraft for Android
Apache License 2.0
680 stars 189 forks source link

Current Javascript that comes in BlockLauncher #1423

Closed ghost closed 7 years ago

ghost commented 7 years ago

I am currently working on a new mod and I've got a little problem. I use Java in my code and currently I'm trying to make the mod transfer a font .ttf file to local storage to use with GUI in my mod. The problem is that I cannot make it transfer since there are no typed arrays (byte arrays) in particular Int8Array which I had wanted to use for transfer. I'd like somebody to suggest another(possible and automatic) way to do what I'm trying to do. Or to suggest a way for Typed arrays in the mod. Thank you for reading my issue. Please so help!

tarik02 commented 7 years ago

Try to use java reflect.

ghost commented 7 years ago

I use Java in JS mods, I use ModPE.openInputStreamFromTexturePack(fontFromAssets);

I have a custom texture pack with the custom font in the pack.

This works with images but for fonts I need to save them to another folder and then use them with TypeFace.createFromFile(...)

My problem is that I can't read the contents of the ttf to a byteArray because there is none implemented in the version of JS that is in BL that I know of.

What I want to know is that are there any other ways of reading and writing from an InflaterInputStream to a FileOutputStream. I've already tried creating my own byteArray with a few methods because I know the return types but for some reason the file created has 15kB of nothingness.

I hope people understand now.

CtrlAltCuteness commented 7 years ago

This should be closed as default Android-accessible Android classes should be accessible by their fully qualified name.

ghost commented 7 years ago

I am closing this issue as a not relevant because I have figured out another way. Note that I am still using JavaScript, Int8Arrays, if you want to you can look them up. Since they aren't in the latest version I suspect that BlockLauncher isn't using the latest version of JavaScript. I will close this issue because of no answers.

CtrlAltCuteness commented 7 years ago

Typos... but if you look at some ModPE mods using buttons & stuff, Minecraft is accessible by its package name, and the functions / methods / classes as extended from there.

Note: Multiple declarations for compiled methods using the same name, if using the same amount of arguments, may have issues. I would assume using the native Java types it expects for all arguments of that function would make it more reliable, but I cannot be sure.

Javascript only has one number type. Java has various for integers (whole numbers of different minimum & maximum values; unsigned ALWAYS have a minimum of zero), floating point values (allows decimal values while being less reliable in exact values; also of different sizes), and even some seemingly strange ones as well (if you were not that good in math class, or got past the complex stuff such as actually being able to understand the ability to divide by zero... which I learned in high school, and forgot how to do without a computer).

CtrlAltCuteness commented 7 years ago

Sorry for that late reply after you closed it due to RL and long message on a programmer-friendly (especially terminal apps needing stuff like the Tab & Ctrl keys) keyboard IME.

Look up on the official site for Android reference (dev.android.something?) as well as elsewhere for Java built-in objects for integers, etc.

Okay, I'm done.

ghost commented 7 years ago

I've been doing Android for more than a year now with Java being even longer. Of course I know this stuff. It's just that I couldn't make a byte array in JavaScript, from Java and JavaScript's Int8Array which is basically a byte array in JavaScript was not included in BlockLauncher's version. I'm done as well now. I knew that they were accessible but there is no source that I can find that give the method's names. Of course Native Mods could be used but I'm simply not bothered learning them.