A bit big of a commit but

Added 3 Fog Choices (Pocket) (Java) (Unknown that was unused)

Restored Java Beta Sky Color code that was unused that depends on biome temperature (choosable using Java fog)

Tile Shadows and Entity Shadows that appear beneath them have been restored and fixed from the unused code, toggleable by turning fancy graphics on or off

Entities will now render flames on themselves when on fire, including the player

Added option to use Java Style Item Count text and position in tweaks

- fileshredder
This commit is contained in:
Shredder
2026-04-06 01:52:27 +05:00
parent 378dfe8e22
commit 055f00be49
26 changed files with 1574 additions and 1300 deletions

View File

@@ -40,18 +40,18 @@ EntityRenderDispatcher::EntityRenderDispatcher()
{
//@note: The Models (model/armor) will be deleted by resp. MobRenderer
assign( ER_ITEM_RENDERER, new ItemRenderer());
assign( ER_HUMANOID_RENDERER, new HumanoidMobRenderer(new HumanoidModel(), 0));
assign( ER_PIG_RENDERER, new PigRenderer(new PigModel(), NULL/*new PigModel(0.5f)*/, 0));
assign( ER_COW_RENDERER, new MobRenderer(new CowModel(), 0));
assign( ER_CHICKEN_RENDERER, new ChickenRenderer( new ChickenModel(), 0));
assign( ER_SHEEP_RENDERER, new SheepRenderer(new SheepModel(), new SheepFurModel(), 0));
assign( ER_HUMANOID_RENDERER, new HumanoidMobRenderer(new HumanoidModel(), 0.5));
assign( ER_PIG_RENDERER, new PigRenderer(new PigModel(0.5), NULL/*new PigModel(0.5f)*/, 0.7));
assign( ER_COW_RENDERER, new MobRenderer(new CowModel(), 0.7));
assign( ER_CHICKEN_RENDERER, new ChickenRenderer( new ChickenModel(), 0.3));
assign( ER_SHEEP_RENDERER, new SheepRenderer(new SheepModel(), new SheepFurModel(), 0.7));
assign( ER_SKELETON_RENDERER, new HumanoidMobRenderer(new SkeletonModel(), 0.5f));
assign( ER_ZOMBIE_RENDERER, new HumanoidMobRenderer(new ZombieModel(), 0.5f));
assign( ER_CREEPER_RENDERER, new CreeperRenderer());
assign( ER_SPIDER_RENDERER, new SpiderRenderer());
assign( ER_TNT_RENDERER, new TntRenderer());
assign( ER_ARROW_RENDERER, new ArrowRenderer());
assign( ER_PLAYER_RENDERER, new PlayerRenderer(new HumanoidModel(0, 0, 64, 64), 0));
assign( ER_PLAYER_RENDERER, new PlayerRenderer(new HumanoidModel(0, 0, 64, 64), 0.5));
assign( ER_THROWNEGG_RENDERER, new ItemSpriteRenderer(Item::egg->getIcon(0)));
assign( ER_SNOWBALL_RENDERER, new ItemSpriteRenderer(Item::snowBall->getIcon(0)));
assign( ER_PAINTING_RENDERER, new PaintingRenderer());
@@ -133,7 +133,7 @@ void EntityRenderDispatcher::render( Entity* entity, float x, float y, float z,
EntityRenderer* renderer = getRenderer(entity);
if (renderer != NULL) {
renderer->render(entity, x, y, z, rot, a);
//renderer->postRender(entity, x, y, z, rot, a);
renderer->postRender(entity, x, y, z, rot, a);
}
}

View File

@@ -5,11 +5,17 @@
#include "../gles.h"
#include "../../../world/phys/AABB.h"
#include "EntityRenderDispatcher.h"
#include "../../../util/Mth.h"
#include "../../../world/level/Level.h"
#include "../../../world/level/tile/Tile.h"
#include "../../Minecraft.h"
#include "../../Option.h"
EntityRenderDispatcher* EntityRenderer::entityRenderDispatcher = NULL;
EntityRenderer::EntityRenderer()
: shadowRadius(0),
: shadowRadius(0),
shadowStrength(1.0f)
{}
@@ -36,37 +42,37 @@ void EntityRenderer::render(const AABB& bb, float xo, float yo, float zo) {
glColor4f2(1, 1, 1, 1);
t.begin();
t.offset(xo, yo, zo);
//t.normal(0, 0, -1);
t.normal(0, 0, -1);
t.vertex(bb.x0, bb.y1, bb.z0);
t.vertex(bb.x1, bb.y1, bb.z0);
t.vertex(bb.x1, bb.y0, bb.z0);
t.vertex(bb.x0, bb.y0, bb.z0);
//t.normal(0, 0, 1);
t.normal(0, 0, 1);
t.vertex(bb.x0, bb.y0, bb.z1);
t.vertex(bb.x1, bb.y0, bb.z1);
t.vertex(bb.x1, bb.y1, bb.z1);
t.vertex(bb.x0, bb.y1, bb.z1);
//t.normal(0, -1, 0);
t.normal(0, -1, 0);
t.vertex(bb.x0, bb.y0, bb.z0);
t.vertex(bb.x1, bb.y0, bb.z0);
t.vertex(bb.x1, bb.y0, bb.z1);
t.vertex(bb.x0, bb.y0, bb.z1);
//t.normal(0, 1, 0);
t.normal(0, 1, 0);
t.vertex(bb.x0, bb.y1, bb.z1);
t.vertex(bb.x1, bb.y1, bb.z1);
t.vertex(bb.x1, bb.y1, bb.z0);
t.vertex(bb.x0, bb.y1, bb.z0);
//t.normal(-1, 0, 0);
t.normal(-1, 0, 0);
t.vertex(bb.x0, bb.y0, bb.z1);
t.vertex(bb.x0, bb.y1, bb.z1);
t.vertex(bb.x0, bb.y1, bb.z0);
t.vertex(bb.x0, bb.y0, bb.z0);
//t.normal(1, 0, 0);
t.normal(1, 0, 0);
t.vertex(bb.x1, bb.y0, bb.z0);
t.vertex(bb.x1, bb.y1, bb.z0);
t.vertex(bb.x1, bb.y1, bb.z1);
@@ -116,134 +122,139 @@ Font* EntityRenderer::getFont() {
return entityRenderDispatcher->getFont();
}
//void postRender(Entity entity, float x, float y, float z, float rot, float a) {
// if (entityRenderDispatcher.options.fancyGraphics && shadowRadius > 0) {
// float dist = entityRenderDispatcher.distanceToSqr(entity.x, entity.y, entity.z);
// float pow = (float) ((1 - dist / (16.0f * 16.0f)) * shadowStrength);
// if (pow > 0) {
// renderShadow(entity, x, y, z, pow, a);
// }
// }
// if (entity.isOnFire()) renderFlame(entity, x, y, z, a);
//}
void EntityRenderer::postRender(Entity* entity, float x, float y, float z, float rot, float a) {
if (/*entityRenderDispatcher.options.fancyGraphics &&*/entityRenderDispatcher->minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS) && shadowRadius > 0) {
float dist = entityRenderDispatcher->distanceToSqr(entity->x, entity->y, entity->z);
float pow = (float) ((1 - dist / (16.0f * 16.0f)) * shadowStrength);
if (pow > 0) {
renderShadow(entity, x, y, z, pow, a);
}
//}
if (entity->isOnFire()) renderFlame(entity, x, y, z, a);
}
}
void EntityRenderer::renderFlame(Entity* e, float x, float y, float z, float a) {
//void renderFlame(Entity e, float x, float y, float z, float a) {
// glDisable2(GL_LIGHTING);
// int tex = Tile.fire.tex;
int tex = ((Tile*)Tile::fire)->tex;
// int xt = (tex & 0xf) << 4;
// int yt = tex & 0xf0;
int xt = (tex & 0xf) << 4;
int yt = tex & 0xf0;
// float u0 = (xt) / 256.0f;
// float u1 = (xt + 15.99f) / 256.0f;
// float v0 = (yt) / 256.0f;
// float v1 = (yt + 15.99f) / 256.0f;
float u0 = (xt) / 256.0f;
float u1 = (xt + 15.99f) / 256.0f;
float v0 = (yt) / 256.0f;
float v1 = (yt + 15.99f) / 256.0f;
// glPushMatrix2();
// glTranslatef2((float) x, (float) y, (float) z);
glPushMatrix2();
glTranslatef2((float) x, (float) y, (float) z);
// float s = e.bbWidth * 1.4f;
// glScalef2(s, s, s);
// bindTexture("terrain.png");
// Tesselator t = Tesselator.instance;
float s = e->bbWidth * 1.4f;
glScalef2(s, s, s);
bindTexture("terrain.png");
Tesselator& t = Tesselator::instance;
// float r = 1.0f;
// float xo = 0.5f;
// float yo = 0.0f;
float r = 1.0f;
float xo = 0.5f;
float yo = 0.0f;
// float h = e.bbHeight / e.bbWidth;
float h = e->bbHeight / e->bbWidth;
// glRotatef2(-entityRenderDispatcher.playerRotY, 0, 1, 0);
// glTranslatef2(0, 0, -0.4f + ((int) h) * 0.02f);
// glColor4f2(1, 1, 1, 1);
// // glRotatef2(-playerRotX, 1, 0, 0);
// t.begin();
// while (h > 0) {
// t.vertexUV(r - xo, 0 - yo, 0, u1, v1);
// t.vertexUV(0 - xo, 0 - yo, 0, u0, v1);
// t.vertexUV(0 - xo, 1.4f - yo, 0, u0, v0);
// t.vertexUV(r - xo, 1.4f - yo, 0, u1, v0);
// h -= 1;
// yo -= 1;
// r *= 0.9f;
// glTranslatef2(0, 0, -0.04f);
// }
// t.end();
// glPopMatrix2();
// glEnable2(GL_LIGHTING);
//}
glRotatef2(-entityRenderDispatcher->playerRotY, 0, 1, 0);
glTranslatef2(0, 0, -0.4f + ((int) h) * 0.02f);
glColor4f2(1, 1, 1, 1);
// glRotatef2(-playerRotX, 1, 0, 0);
t.begin();
while (h > 0) {
t.vertexUV(r - xo, 0 - yo, 0, u1, v1);
t.vertexUV(0 - xo, 0 - yo, 0, u0, v1);
t.vertexUV(0 - xo, 1.4f - yo, 0, u0, v0);
t.vertexUV(r - xo, 1.4f - yo, 0, u1, v0);
h -= 1;
yo -= 1;
r *= 0.9f;
glTranslatef2(0, 0, -0.04f);
}
t.draw();
glPopMatrix2();
// glEnable2(GL_LIGHTING);
}
//void renderShadow(Entity e, float x, float y, float z, float pow, float a) {
// glEnable2(GL_BLEND);
// glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float pow, float a) { //
glEnable2(GL_BLEND);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Textures textures = entityRenderDispatcher.textures;
// textures.bind(textures.loadTexture("%clamp%/misc/shadow.png"));
//Textures* textures = entityRenderDispatcher->textures;
//textures->bind(textures->loadTexture("%clamp%/environment/shadow.png"));
Textures* textures = entityRenderDispatcher->textures;
textures->bind(textures->loadTexture("/misc/shadow.png"));
// Level level = getLevel();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// glDepthMask(false);
// float r = shadowRadius;
Level* level = getLevel();
// float ex = e.xOld + (e.x - e.xOld) * a;
// float ey = e.yOld + (e.y - e.yOld) * a + e.getShadowHeightOffs();
// float ez = e.zOld + (e.z - e.zOld) * a;
glDepthMask(false);
float r = shadowRadius;
// int x0 = Mth.floor(ex - r);
// int x1 = Mth.floor(ex + r);
// int y0 = Mth.floor(ey - r);
// int y1 = Mth.floor(ey);
// int z0 = Mth.floor(ez - r);
// int z1 = Mth.floor(ez + r);
float ex = e->xOld + (e->x - e->xOld) * a;
float ey = e->yOld + (e->y - e->yOld) * a + e->getShadowHeightOffs();
float ez = e->zOld + (e->z - e->zOld) * a;
// float xo = x - ex;
// float yo = y - ey;
// float zo = z - ez;
int x0 = Mth::floor(ex - r);
int x1 = Mth::floor(ex + r);
int y0 = Mth::floor(ey - r);
int y1 = Mth::floor(ey);
int z0 = Mth::floor(ez - r);
int z1 = Mth::floor(ez + r);
// Tesselator tt = Tesselator.instance;
// tt.begin();
// for (int xt = x0; xt <= x1; xt++)
// for (int yt = y0; yt <= y1; yt++)
// for (int zt = z0; zt <= z1; zt++) {
// int t = level.getTile(xt, yt - 1, zt);
// if (t > 0 && level.getRawBrightness(xt, yt, zt) > 3) {
// renderTileShadow(Tile.tiles[t], x, y + e.getShadowHeightOffs(), z, xt, yt, zt, pow, r, xo, yo + e.getShadowHeightOffs(), zo);
// }
// }
// tt.end();
float xo = x - ex;
float yo = y - ey;
float zo = z - ez;
// glColor4f2(1, 1, 1, 1);
// glDisable2(GL_BLEND);
// glDepthMask(true);
//}
Tesselator& tt = Tesselator::instance;
tt.begin();
for (int xt = x0; xt <= x1; xt++)
for (int yt = y0; yt <= y1; yt++)
for (int zt = z0; zt <= z1; zt++) {
int t = level->getTile(xt, yt - 1, zt);
if (t > 0 && level->getRawBrightness(xt, yt, zt) > 3) {
renderTileShadow(Tile::tiles[t], x, y + e->getShadowHeightOffs(), z, xt, yt, zt, pow, r, xo, yo + e->getShadowHeightOffs(), zo);
}
}
tt.draw();
//Level* getLevel() {
// return entityRenderDispatcher.level;
//}
glColor4f2(1, 1, 1, 1);
glDisable2(GL_BLEND);
glDepthMask(true);
}
//void renderTileShadow(Tile tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo) {
// Tesselator t = Tesselator.instance;
// if (!tt.isCubeShaped()) return;
Level* EntityRenderer::getLevel() {
return entityRenderDispatcher->level;
}
// float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel().getBrightness(xt, yt, zt);
// if (a < 0) return;
// if (a > 1) a = 1;
// t.color(1, 1, 1, (float) a);
// // glColor4f2(1, 1, 1, (float) a);
void EntityRenderer::renderTileShadow(Tile* tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo) {
Tesselator& t = Tesselator::instance;
if (!tt->isCubeShaped()) return;
// float x0 = xt + tt.xx0 + xo;
// float x1 = xt + tt.xx1 + xo;
// float y0 = yt + tt.yy0 + yo + 1.0 / 64.0f;
// float z0 = zt + tt.zz0 + zo;
// float z1 = zt + tt.zz1 + zo;
float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel()->getBrightness(xt, yt, zt);
if (a < 0) return;
if (a > 1) a = 1;
// t.color(1, 1, 1, (float) a);
glColor4f2(1, 1, 1, (float) a);
// float u0 = (float) ((x - (x0)) / 2 / r + 0.5f);
// float u1 = (float) ((x - (x1)) / 2 / r + 0.5f);
// float v0 = (float) ((z - (z0)) / 2 / r + 0.5f);
// float v1 = (float) ((z - (z1)) / 2 / r + 0.5f);
float x0 = xt + tt->xx0 + xo;
float x1 = xt + tt->xx1 + xo;
float y0 = yt + tt->yy0 + yo + 1.0 / 64.0f;
float z0 = zt + tt->zz0 + zo;
float z1 = zt + tt->zz1 + zo;
// t.vertexUV(x0, y0, z0, u0, v0);
// t.vertexUV(x0, y0, z1, u0, v1);
// t.vertexUV(x1, y0, z1, u1, v1);
// t.vertexUV(x1, y0, z0, u1, v0);
//}
float u0 = (float) ((x - (x0)) / 2 / r + 0.5f);
float u1 = (float) ((x - (x1)) / 2 / r + 0.5f);
float v0 = (float) ((z - (z0)) / 2 / r + 0.5f);
float v1 = (float) ((z - (z1)) / 2 / r + 0.5f);
t.vertexUV(x0, y0, z0, u0, v0);
t.vertexUV(x0, y0, z1, u0, v1);
t.vertexUV(x1, y0, z1, u1, v1);
t.vertexUV(x1, y0, z0, u1, v0);
}

View File

@@ -12,6 +12,8 @@ class EntityRenderDispatcher;
class Entity;
class AABB;
class Font;
class Tile;
class Level;
class EntityRenderer
{
@@ -24,6 +26,11 @@ public:
virtual void render(Entity* entity, float x, float y, float z, float rot, float a) = 0;
static void render(const AABB& bb, float xo, float yo, float zo);
static void renderFlat(const AABB& bb);
void renderShadow(Entity* e, float x, float y, float z, float pow, float a);
void renderTileShadow(Tile* tt, float x, float y, float z, int xt, int yt, int zt, float pow, float r, float xo, float yo, float zo);
void renderFlame(Entity* e, float x, float y, float z, float a);
void postRender(Entity* entity, float x, float y, float z, float rot, float a);
Level* getLevel();
Font* getFont();

View File

@@ -226,7 +226,40 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, const ItemInsta
t.draw();
}
void ItemRenderer::renderGuiItemDecorations(const ItemInstance* item, float x, float y) {
void ItemRenderer::renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y){ // this is normally unused in the header but i ported it from java beta - shredder
if (item != NULL) {
if (item->count > 1) {
std::string countStr = std::to_string(item->count);
// glDisable(GL_LIGHTING);
// glDisable(GL_DEPTH_TEST);
font->drawShadow(countStr, x + 19 - 2 - font->width(countStr),
y + 6 + 3, 0xFFFFFF);
// glEnable(GL_LIGHTING);
// glEnable(GL_DEPTH_TEST);
}
if (item->isDamaged()) {
float p = std::floor(13.5f - (float) item->getDamageValue() * 13.0f / (float) item->getMaxDamage() + 0.5);
int cc = (int) std::floor(255.5f - (float) item->getDamageValue() * 255.0f / (float) item->getMaxDamage() + 0.5);
// glDisable(GL_LIGHTING);
// glDisable(GL_DEPTH_TEST);
// glDisable(GL_TEXTURE_2D);
// auto var8 = ::net::minecraft::client::renderer::Tesselator::instance();
Tesselator& t = Tesselator::instance;
int ca = 255 - cc << 16 | cc << 8;
int cb = (255 - cc) / 4 << 16 | 16128;
fillRect(t, x + 2, y + 13, 13, 2, 0);
fillRect(t, x + 2, y + 13, 12, 1, cb);
fillRect(t, x + 2, y + 13, p, 1, ca);
// glEnable(GL_TEXTURE_2D);
// glEnable(GL_LIGHTING);
// glEnable(GL_DEPTH_TEST);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
void ItemRenderer::renderGuiItemDecorations(const ItemInstance* item, float x, float y) { // nothing changed here this is the normal pocket edition one.
if (!item) return;
if (item->count > 0 && item->isDamaged()) {
float p = std::floor(13.5f - (float) item->getDamageValue() * 13.0f / (float) item->getMaxDamage());

View File

@@ -22,7 +22,7 @@ public:
static void renderGuiItem(Font* font, Textures* textures, const ItemInstance* item, float x, float y, bool fancy);
static void renderGuiItem(Font* font, Textures* textures, const ItemInstance* item, float x, float y, float w, float h, bool fancy);
static void renderGuiItemCorrect(Font* font, Textures* textures, const ItemInstance* item, int x, int y);
//void renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y);
static void renderGuiItemDecorations(Font* font, Textures* textures, ItemInstance* item, int x, int y);
static void renderGuiItemDecorations(const ItemInstance* item, float x, float y);
static void blit(float x, float y, float sx, float sy, float w, float h);

View File

@@ -135,7 +135,7 @@ void MobRenderer::render(Entity* e, float x, float y, float z, float rot, float
//glEnable2(GL_DEPTH_TEST);
glPopMatrix2();
postRender(mob, x, y, z, rot, a);
renderName(mob, x, y, z);
}