Skip to content

Commit

Permalink
Support for Minecraft PE 1.2.0b25
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Sep 5, 2017
1 parent 8228f5a commit bbc949e
Show file tree
Hide file tree
Showing 28 changed files with 542 additions and 200 deletions.
2 changes: 1 addition & 1 deletion jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

APP_ABI := armeabi-v7a #x86
APP_ABI := armeabi-v7a x86
APP_PLATFORM := android-14
APP_CFLAGS := -O2 -std=gnu99 -Wall
APP_CPPFLAGS += -std=c++14 -Wno-invalid-offsetof -Wno-pmf-conversions
Expand Down
7 changes: 5 additions & 2 deletions jni/fakeassets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static bool prefix(const char *pre, const char *str)
static const char kResourcePackPrefix[] = "resource_packs/vanilla/";
static const char kResourcePackDirPrefix[] = "resource_packs/vanilla";
AAsset* bl_AAssetManager_open_hook(AAssetManager *mgr, const char *filename, int mode) {
BL_LOG("Asset: open %s", filename);
//BL_LOG("Asset: open %s", filename);

// zero length filename or an absolute path (on the filesystem) definitely won't be in the assets.
if (strlen(filename) == 0 || filename[0] == '/') return nullptr;
Expand All @@ -25,6 +25,9 @@ AAsset* bl_AAssetManager_open_hook(AAssetManager *mgr, const char *filename, int
AAsset *in = AAssetManager_open(mgr, newFilename.c_str(), mode);
if (in) return in;
if (prefix("resource_packs/skins", filename)) return in;
if (prefix("resource_packs/vanilla_loading_screens", filename)) return in;
if (prefix("resource_packs/vanilla_base", filename)) return in;
//BL_LOG("Asset: open %s", filename);
if (true||prefix(kResourcePackPrefix, filename)) {
JNIEnv *env;
int attachStatus = bl_JavaVM->GetEnv((void**) &env, JNI_VERSION_1_2);
Expand All @@ -43,7 +46,7 @@ AAsset* bl_AAssetManager_open_hook(AAssetManager *mgr, const char *filename, int
bl_JavaVM->DetachCurrentThread();
}
//if (exists) BL_LOG("Assets: exists %s", filename);
if (exists) filename = "startup.images"; // known to exist.
if (exists) filename = "resource_packs/vanilla/manifest.json"; // known to exist.
}
return AAssetManager_open(mgr, filename, mode);
};
Expand Down
17 changes: 11 additions & 6 deletions jni/link_stubs.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// reexport C2/D2 versions of functions as C1/D1

extern void _ZN16ResourceLocationD2Ev(void* a);
void _ZN16ResourceLocationD1Ev(void* a) {
_ZN16ResourceLocationD2Ev(a);
extern void* _ZN16ResourceLocationD2Ev(void* a);
void* _ZN16ResourceLocationD1Ev(void* a) {
return _ZN16ResourceLocationD2Ev(a);
}

extern void _ZN4Json6ReaderD2Ev(void* a);
void _ZN4Json6ReaderD1Ev(void* a) {
_ZN4Json6ReaderD2Ev(a);
extern void* _ZN4Json6ReaderD2Ev(void* a);
void* _ZN4Json6ReaderD1Ev(void* a) {
return _ZN4Json6ReaderD2Ev(a);
}

extern void* _ZN12ItemInstanceD2Ev(void* a);
void* _ZN12ItemInstanceD1Ev(void* a) {
return _ZN12ItemInstanceD2Ev(a);
}
5 changes: 5 additions & 0 deletions jni/mcpe/commandorigin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ class DevConsoleCommandOrigin : public CommandOrigin {
char filler[184-4]; // 4 from DevConsoleCommandOrigin::clone()
};
static_assert(sizeof(DevConsoleCommandOrigin) == 184, "dev console command size");

class CommandVersion {
public:
static int CurrentVersion;
};
11 changes: 9 additions & 2 deletions jni/mcpe/entitydamagesource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ class EntityDamageSource {
int source;
virtual ~EntityDamageSource();
virtual bool isEntitySource() const;
virtual Entity* getEntity() const;
virtual bool isChildEntitySource() const;
virtual Entity* getChildEntity() const;
virtual bool isBlockSource() const;
virtual std::string getDeathMessage(std::string, Entity*) const;
virtual bool getIsCreative() const;
virtual bool getIsWorldBuilder() const;
virtual EntityUniqueID getEntityUniqueID() const;
virtual int getEntityType() const;
virtual int getEntityCategories() const;
virtual bool getDamagingEntityIsCreative() const;
virtual EntityUniqueID getDamagingEntityUniqueID() const;
virtual int getDamagingEntityType() const;
virtual int getDamagingEntityCategories() const;
};

class EntityDamageByEntitySource : public EntityDamageSource {
Expand Down
7 changes: 4 additions & 3 deletions jni/mcpe/gameconnectioninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class GameConnectionInfo {
// see GameConnectionInfo copy constructor
short connectionType; // 0
std::string host; // 4
int port; // 8
std::string rakNetGuid; // 12
char thirdPartyInfo[13]; // 16
char filler[4]; // 8
int port; // 12
std::string rakNetGuid; // 16
char thirdPartyInfo[37]; // 20
};
}; // namespace GameConnectionInfo
5 changes: 4 additions & 1 deletion jni/mcpe/gamemode.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class ItemUseCallback;
class Player;
class GameMode {
public:
Player* player;
virtual ~GameMode();
Player* player; // 4
void _destroyBlockInternal(BlockPos const&, signed char);
float getDestroyProgress();
void useItemOn(ItemInstance&, BlockPos const&, signed char, Vec3 const&, ItemUseCallback*);
void destroyBlock(BlockPos const&, signed char);
};
static_assert(offsetof(GameMode, player) == 4, "GameMode player");
3 changes: 3 additions & 0 deletions jni/mcpe/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <string>
#include <vector>

class ResourcePackManager;
class SkinRepository;

class Localization {
public:
std::map<std::string, std::string>& _getStrings() const;
Expand Down
12 changes: 9 additions & 3 deletions jni/mcpe/inventoryitemrenderer.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#pragma once
class UIControl;
class ClientInstance;

class MinecraftUIRenderContext;
class RectangleArea;

class InventoryItemRenderer {
public:
char filler[48]; // 0
int itemId; // 48; from render
char filler2[80-52]; // 52
char filler[52]; // 0
int itemId; // 52; from render
char filler2[80-56]; // 56
std::string atlasName; // 80 from update
void update(ClientInstance&, UIControl&);
void render(MinecraftUIRenderContext&, ClientInstance&, UIControl&, int, RectangleArea&);
};
static_assert(offsetof(InventoryItemRenderer, itemId) == 52, "itemId offset");
10 changes: 6 additions & 4 deletions jni/mcpe/itemrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class ItemGraphics {
ItemGraphics() {
}
};
static_assert(sizeof(ItemGraphics) == 24, "itemGraphics size");
class ItemRenderer {
public:
std::vector<ItemGraphics> itemGraphics; // 0
char filler[204];
std::vector<ItemGraphics> itemGraphics; // 204
void _loadItemGraphics();
void* getAtlasPos(ItemInstance const&);

static mce::TexturePtr const& getGraphics(ItemInstance const&);
static mce::TexturePtr const& getGraphics(Item const&);
static std::vector<ItemGraphics> mItemGraphics;
static ItemRenderer instance;
};
static_assert(offsetof(ItemRenderer, itemGraphics) == 0, "itemrenderer offset wrong");
static_assert(offsetof(ItemRenderer, itemGraphics) == 204, "itemrenderer offset wrong");
10 changes: 5 additions & 5 deletions jni/mcpe/mce/textureptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class TexturePtr {
public:
char filler[0x4]; // 0
Texture* texture; // 4
std::string textureName; // 8
std::string something; // 12
char filler2[4]; // 16
void* something8; // 8
std::string textureName; // 12
char filler2[24-16]; // 16
TexturePtr();
TexturePtr(TextureGroup&, ResourceLocation, bool a=false);
TexturePtr(TexturePtr&&);
Expand All @@ -30,10 +30,10 @@ class TexturePtr {
static TexturePtr NONE;
};

static_assert(sizeof(TexturePtr) == 20, "textureptr size");
static_assert(sizeof(TexturePtr) == 24, "textureptr size");
class TextureGroup {
public:
TexturePtr getTexture(std::string const&);
TexturePtr getTexture(ResourceLocation, bool);
void loadTexture(ResourceLocation const&, bool);
static bool mCanLoadTextures;
};
Expand Down
6 changes: 5 additions & 1 deletion jni/mcpe/minecraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Level;
class Timer;
namespace mce {
class TextureGroup;
class Texture;
} // namespace mce
class Mob;
class Options;
Expand All @@ -17,6 +18,7 @@ class ClientInstance;
class EntityRenderDispatcher;
class ItemRenderer;
class UIProfanityContext;
class ServerNetworkHandler;

enum GameType {
};
Expand All @@ -36,6 +38,7 @@ class MinecraftGame {
ClientInstance* getPrimaryClientInstance();
Level* getLocalServerLevel() const;
void updateFoliageColors();
ServerNetworkHandler* getServerNetworkHandler();
};

class ClientInstance {
Expand All @@ -53,10 +56,11 @@ class ClientInstance {
void onResourcesLoaded();
LevelRenderer* getLevelRenderer() const;
void play(std::string const&, Vec3 const&, float, float);
void startLeaveGame(bool);
void _startLeaveGame();
Level* getLevel();
EntityRenderDispatcher& getEntityRenderDispatcher();
ItemRenderer* getItemRenderer();
UIProfanityContext const& getUIProfanityContext() const;
mce::Texture const& getUITexture();
};
#define MinecraftClient ClientInstance
6 changes: 3 additions & 3 deletions jni/mcpe/resourcelocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ class ResourceLocation {
public:
std::string str1; // 0
int position; // 4
std::string something; // 8
/*ResourceLocation(std::string const& _str1) : ResourceLocation() {
*((void**)(&str1)) = *((void**)&_str1);
position = 0;
}*/
ResourceLocation(std::string const& _str1, int _position=0, std::string _something="AAAAAAAAAA") : str1(_str1), position(_position), something(_something) {
ResourceLocation(std::string const& _str1, int _position=0) : str1(_str1), position(_position) {
}
ResourceLocation();
~ResourceLocation();
};

// GuiData::getAtlasTex
static_assert(sizeof(ResourceLocation) == 8, "ResourceLocation size");
1 change: 1 addition & 0 deletions jni/mcpe/screenchooser.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

class AbstractScene;
class ScreenChooser {
public:
Expand Down
Loading

0 comments on commit bbc949e

Please sign in to comment.