3D Items!
This commit is contained in:
parent
b11cc95e50
commit
3d8525a321
@ -46,6 +46,7 @@
|
|||||||
* `Hide Block Outline When GUI Is Hidden` (Enabled By Default)
|
* `Hide Block Outline When GUI Is Hidden` (Enabled By Default)
|
||||||
* `Fix Crash When Generating Certain Seeds` (Enabled By Default)
|
* `Fix Crash When Generating Certain Seeds` (Enabled By Default)
|
||||||
* `Click Buttons On Mouse Down` (Enabled By Default)
|
* `Click Buttons On Mouse Down` (Enabled By Default)
|
||||||
|
* `3D Dropped Items` (Enabled By Default)
|
||||||
* Existing Functionality (All Enabled By Default)
|
* Existing Functionality (All Enabled By Default)
|
||||||
* `Fix Screen Rendering When Hiding HUD`
|
* `Fix Screen Rendering When Hiding HUD`
|
||||||
* `Sanitize Usernames`
|
* `Sanitize Usernames`
|
||||||
|
@ -108,4 +108,5 @@ TRUE Improved Classic Title Positioning
|
|||||||
TRUE Use Updated Title
|
TRUE Use Updated Title
|
||||||
TRUE Hide Block Outline When GUI Is Hidden
|
TRUE Hide Block Outline When GUI Is Hidden
|
||||||
TRUE Fix Crash When Generating Certain Seeds
|
TRUE Fix Crash When Generating Certain Seeds
|
||||||
TRUE Click Buttons On Mouse Down
|
TRUE Click Buttons On Mouse Down
|
||||||
|
TRUE 3D Dropped Items
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
@ -261,6 +263,81 @@ static ContainerMenu *ContainerMenu_destructor_injection(ContainerMenu_destructo
|
|||||||
return original(container_menu);
|
return original(container_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3D Dropped Items
|
||||||
|
static bool disable_hand_positioning = false;
|
||||||
|
static void ItemInHandRenderer_renderItem_glTranslatef_injection(const float x, const float y, const float z) {
|
||||||
|
if (disable_hand_positioning) {
|
||||||
|
glPopMatrix();
|
||||||
|
glPushMatrix();
|
||||||
|
} else {
|
||||||
|
glTranslatef(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void ItemRenderer_render_injection(ItemRenderer_render_t original, ItemRenderer *self, Entity *entity, const float x, const float y, const float z, const float a, const float b) {
|
||||||
|
// Get Item
|
||||||
|
const ItemEntity *item_entity = (ItemEntity *) entity;
|
||||||
|
ItemInstance item = item_entity->item;
|
||||||
|
// Check If Item Is Tile
|
||||||
|
if (item.id < 256 && TileRenderer::canRender(Tile::tiles[item.id]->getRenderShape())) {
|
||||||
|
// Call Original Method
|
||||||
|
original(self, entity, x, y, z, a, b);
|
||||||
|
} else {
|
||||||
|
// 3D Item
|
||||||
|
self->random.setSeed(187);
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
// Count
|
||||||
|
int count;
|
||||||
|
if (item.count < 2) {
|
||||||
|
count = 1;
|
||||||
|
} else if (item.count < 16) {
|
||||||
|
count = 2;
|
||||||
|
} else if (item.count < 32) {
|
||||||
|
count = 3;
|
||||||
|
} else {
|
||||||
|
count = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bob
|
||||||
|
const float age = float(item_entity->age) + b;
|
||||||
|
const float bob = (Mth::sin((age / 10.0f) + item_entity->bob_offset) * 0.1f) + 0.1f;
|
||||||
|
glTranslatef(x, y + bob, z);
|
||||||
|
|
||||||
|
// Scale
|
||||||
|
glScalef(0.5f, 0.5f, 0.5f);
|
||||||
|
|
||||||
|
// Spin
|
||||||
|
const float spin = ((age / 20.0f) + item_entity->bob_offset) * float(180.0f / M_PI);
|
||||||
|
glRotatef(spin, 0, 1, 0);
|
||||||
|
|
||||||
|
// Position
|
||||||
|
constexpr float xo = 0.5f;
|
||||||
|
constexpr float yo = 0.25f;
|
||||||
|
constexpr float width = 1 / 16.0f;
|
||||||
|
constexpr float margin = 0.35f / 16.0f;
|
||||||
|
constexpr float zo = width + margin;
|
||||||
|
glTranslatef(-xo, -yo, -((zo * float(count)) / 2));
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
disable_hand_positioning = true;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
glTranslatef(0, 0, zo);
|
||||||
|
glPushMatrix();
|
||||||
|
if (i > 0) {
|
||||||
|
const float c = (self->random.nextFloat() * 2 - 1) * 0.15f;
|
||||||
|
const float d = (self->random.nextFloat() * 2 - 1) * 0.15f;
|
||||||
|
glTranslatef(c, d, 0.0f);
|
||||||
|
}
|
||||||
|
EntityRenderer::entityRenderDispatcher->item_renderer->renderItem(nullptr, &item);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
disable_hand_positioning = false;
|
||||||
|
|
||||||
|
// Finish
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
void _init_misc_graphics() {
|
void _init_misc_graphics() {
|
||||||
// Disable V-Sync
|
// Disable V-Sync
|
||||||
@ -351,6 +428,12 @@ void _init_misc_graphics() {
|
|||||||
overwrite_calls(ChestTileEntity_shouldSave, ChestTileEntity_shouldSave_injection);
|
overwrite_calls(ChestTileEntity_shouldSave, ChestTileEntity_shouldSave_injection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3D Dropped Items
|
||||||
|
if (feature_has("3D Dropped Items", server_disabled)) {
|
||||||
|
overwrite_calls(ItemRenderer_render, ItemRenderer_render_injection);
|
||||||
|
overwrite_call((void *) 0x4bf34, (void *) ItemInHandRenderer_renderItem_glTranslatef_injection);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't Render Game In Headless Mode
|
// Don't Render Game In Headless Mode
|
||||||
if (reborn_is_headless()) {
|
if (reborn_is_headless()) {
|
||||||
overwrite_calls(GameRenderer_render, nop<GameRenderer_render_t, GameRenderer *, float>);
|
overwrite_calls(GameRenderer_render, nop<GameRenderer_render_t, GameRenderer *, float>);
|
||||||
|
@ -216,11 +216,7 @@ static DynamicTexture *create_fire_texture(const int a2) {
|
|||||||
texture->super()->vtable = get_fire_texture_vtable();
|
texture->super()->vtable = get_fire_texture_vtable();
|
||||||
// Setup Random
|
// Setup Random
|
||||||
texture->data.m_random = Random::allocate();
|
texture->data.m_random = Random::allocate();
|
||||||
const int seed = Common::getTimeMs();
|
texture->data.m_random->constructor();
|
||||||
texture->data.m_random->seed = seed;
|
|
||||||
texture->data.m_random->param_1 = 0x271;
|
|
||||||
texture->data.m_random->param_2 = false;
|
|
||||||
texture->data.m_random->param_3 = 0;
|
|
||||||
for (int i = 0; i < 320; i++) {
|
for (int i = 0; i < 320; i++) {
|
||||||
texture->data.m_data1[i] = 0.0f;
|
texture->data.m_data1[i] = 0.0f;
|
||||||
texture->data.m_data2[i] = 0.0f;
|
texture->data.m_data2[i] = 0.0f;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
vtable 0x1075a8;
|
||||||
|
|
||||||
virtual-method void render(Entity *entity, float param_2, float param_3, float param_4, float param_5, float param_6) = 0x8;
|
virtual-method void render(Entity *entity, float param_2, float param_3, float param_4, float param_5, float param_6) = 0x8;
|
||||||
|
|
||||||
// Can be called without an EntityRenderer, just do EntityRenderer_bindTexture(NULL, &file);
|
// Can be called without an EntityRenderer, just do EntityRenderer_bindTexture->get(false)(NULL, &file);
|
||||||
method void bindTexture(const std::string &file) = 0x62540;
|
method void bindTexture(const std::string &file) = 0x62540;
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
|
@ -5,3 +5,4 @@ constructor (Level *level, float x, float y, float z, const ItemInstance &item)
|
|||||||
|
|
||||||
property ItemInstance item = 0xd0;
|
property ItemInstance item = 0xd0;
|
||||||
property int age = 0xdc;
|
property int age = 0xdc;
|
||||||
|
property float bob_offset = 0xe4;
|
@ -1,3 +1,7 @@
|
|||||||
|
extends EntityRenderer;
|
||||||
|
|
||||||
|
vtable 0x107970;
|
||||||
|
|
||||||
static-method void renderGuiItem_one(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, bool param_3) = 0x63e58;
|
static-method void renderGuiItem_one(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, bool param_3) = 0x63e58;
|
||||||
static-method void renderGuiItem_two(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) = 0x63be0;
|
static-method void renderGuiItem_two(Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) = 0x63be0;
|
||||||
static-method void renderGuiItemCorrect(Font *font, Textures *textures, const ItemInstance *item_instance, int x, int y) = 0x639a0;
|
static-method void renderGuiItemCorrect(Font *font, Textures *textures, const ItemInstance *item_instance, int x, int y) = 0x639a0;
|
||||||
@ -7,3 +11,5 @@ static-method void blit(float x, float y, float texture_x, float texture_y, floa
|
|||||||
// This doesn't include things that it doesn't need for item rendering (like the level)
|
// This doesn't include things that it doesn't need for item rendering (like the level)
|
||||||
// So if you are (ab)using it for something else, be sure to set what you need
|
// So if you are (ab)using it for something else, be sure to set what you need
|
||||||
static-property TileRenderer *tileRenderer = 0x137c18;
|
static-property TileRenderer *tileRenderer = 0x137c18;
|
||||||
|
|
||||||
|
property Random random = 0xc;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
method void tick() = 0x4da1c;
|
method void tick() = 0x4da1c;
|
||||||
method int render(Mob *mob, int param_1, float delta) = 0x4f710;
|
method int render(Mob *mob, int param_1, float delta) = 0x4f710;
|
||||||
|
method void render_AABB(const AABB &box) = 0x4d740;
|
||||||
method void renderDebug(const AABB &aabb, float delta) = 0x4d310;
|
method void renderDebug(const AABB &aabb, float delta) = 0x4d310;
|
||||||
method void generateSky() = 0x4d0d4;
|
method void generateSky() = 0x4d0d4;
|
||||||
method void renderHitSelect(Player *player, const HitResult &hit_result, int i, void *vp, float f) = 0x4e318;
|
method void renderHitSelect(Player *player, const HitResult &hit_result, int i, void *vp, float f) = 0x4e318;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
size 0x9d0;
|
size 0x9d0;
|
||||||
|
|
||||||
|
constructor () = 0xb7490;
|
||||||
|
|
||||||
method float nextFloat() = 0x42cf8;
|
method float nextFloat() = 0x42cf8;
|
||||||
method uint genrand_int32() = 0x50e14;
|
method uint genrand_int32() = 0x50e14;
|
||||||
method void init_genrand(uint seed) = 0x27d38;
|
method void init_genrand(uint seed) = 0x27d38;
|
||||||
|
method void setSeed(int seed) = 0xaf884;
|
||||||
|
|
||||||
property uint seed = 0x0;
|
property uint seed = 0x0;
|
||||||
property int param_1 = 0x9c4; // Set To 0x271
|
property int param_1 = 0x9c4; // Set To 0x271
|
||||||
|
Loading…
Reference in New Issue
Block a user