feat: TU19 (Dec 2014) Features & Content (#155)

* try to resolve merge conflict

* feat: TU19 (Dec 2014) Features & Content (#32)

* December 2014 files

* Working release build

* Fix compilation issues

* Add sound to Windows64Media

* Add DLC content and force Tutorial DLC

* Revert "Add DLC content and force Tutorial DLC"

This reverts commit 97a4399472.

* Disable broken light packing

* Disable breakpoint during DLC texture map load

Allows DLC loading but the DLC textures are still broken

* Fix post build not working

* ...

* fix vs2022 build

* fix cmake build

---------

Co-authored-by: Loki <lokirautio@gmail.com>
This commit is contained in:
daoge
2026-03-03 03:04:10 +08:00
committed by GitHub
parent 84c31a2331
commit b3feddfef3
2069 changed files with 264842 additions and 139522 deletions

View File

@@ -3,6 +3,7 @@
#include "TileRenderer.h"
#include "Tesselator.h"
#include "Textures.h"
#include "TextureAtlas.h"
#include "EntityRenderer.h"
#include "PlayerRenderer.h"
#include "EntityRenderDispatcher.h"
@@ -17,10 +18,15 @@
#include "..\Minecraft.World\net.minecraft.world.level.h"
#include "..\Minecraft.World\net.minecraft.world.h"
int ItemInHandRenderer::list = -1;
ResourceLocation ItemInHandRenderer::ENCHANT_GLINT_LOCATION = ResourceLocation(TN__BLUR__MISC_GLINT);
ResourceLocation ItemInHandRenderer::MAP_BACKGROUND_LOCATION = ResourceLocation(TN_MISC_MAPBG);
ResourceLocation ItemInHandRenderer::UNDERWATER_LOCATION = ResourceLocation(TN_MISC_WATER);
int ItemInHandRenderer::listItem = -1;
int ItemInHandRenderer::listTerrain = -1;
int ItemInHandRenderer::listGlint = -1;
ItemInHandRenderer::ItemInHandRenderer(Minecraft *mc, bool optimisedMinimap)
ItemInHandRenderer::ItemInHandRenderer(Minecraft *minecraft, bool optimisedMinimap)
{
// 4J - added
height = 0;
@@ -29,18 +35,18 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft *mc, bool optimisedMinimap)
tileRenderer = new TileRenderer();
lastSlot = -1;
this->mc = mc;
minimap = new Minimap(mc->font, mc->options, mc->textures, optimisedMinimap);
this->minecraft = minecraft;
minimap = new Minimap(minecraft->font, minecraft->options, minecraft->textures, optimisedMinimap);
// 4J - replaced mesh that is used to render held items with individual cubes, so we can make it all join up properly without seams. This
// has a lot more quads in it than the original, so is now precompiled with a UV matrix offset to put it in the final place for the
// current icon. Compile it on demand for the first ItemInHandRenderer (list is static)
if( list == -1 )
if( listItem == -1 )
{
list = MemoryTracker::genLists(1);
listItem = MemoryTracker::genLists(1);
float dd = 1 / 16.0f;
glNewList(list, GL_COMPILE);
glNewList(listItem, GL_COMPILE);
Tesselator *t = Tesselator::getInstance();
t->begin();
for( int yp = 0; yp < 16; yp++ )
@@ -92,6 +98,64 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft *mc, bool optimisedMinimap)
glEndList();
}
// Terrain texture is a different layout from the item texture
if( listTerrain == -1 )
{
listTerrain = MemoryTracker::genLists(1);
float dd = 1 / 16.0f;
glNewList(listTerrain, GL_COMPILE);
Tesselator *t = Tesselator::getInstance();
t->begin();
for( int yp = 0; yp < 16; yp++ )
for( int xp = 0; xp < 16; xp++ )
{
float u = (15-xp) / 256.0f;
float v = (15-yp) / 512.0f;
u += 0.5f / 256.0f;
v += 0.5f / 512.0f;
float x0 = xp / 16.0f;
float x1 = x0 + 1.0f/16.0f;
float y0 = yp / 16.0f;
float y1 = y0 + 1.0f/16.0f;
float z0 = 0.0f;
float z1 = -dd;
t->normal(0, 0, 1);
t->vertexUV(x0, y0, z0, u, v);
t->vertexUV(x1, y0, z0, u, v);
t->vertexUV(x1, y1, z0, u, v);
t->vertexUV(x0, y1, z0, u, v);
t->normal(0, 0, -1);
t->vertexUV(x0, y1, z1, u, v);
t->vertexUV(x1, y1, z1, u, v);
t->vertexUV(x1, y0, z1, u, v);
t->vertexUV(x0, y0, z1, u, v);
t->normal(-1, 0, 0);
t->vertexUV(x0, y0, z1, u, v);
t->vertexUV(x0, y0, z0, u, v);
t->vertexUV(x0, y1, z0, u, v);
t->vertexUV(x0, y1, z1, u, v);
t->normal(1, 0, 0);
t->vertexUV(x1, y1, z1, u, v);
t->vertexUV(x1, y1, z0, u, v);
t->vertexUV(x1, y0, z0, u, v);
t->vertexUV(x1, y0, z1, u, v);
t->normal(0, 1, 0);
t->vertexUV(x1, y0, z0, u, v);
t->vertexUV(x0, y0, z0, u, v);
t->vertexUV(x0, y0, z1, u, v);
t->vertexUV(x1, y0, z1, u, v);
t->normal(0, -1, 0);
t->vertexUV(x1, y1, z1, u, v);
t->vertexUV(x0, y1, z1, u, v);
t->vertexUV(x0, y1, z0, u, v);
t->vertexUV(x1, y1, z0, u, v);
}
t->end();
glEndList();
}
// Also create special object for glint overlays - this is the same as the previous one, with a different UV scalings, and depth test set to equal
if( listGlint == -1 )
{
@@ -158,7 +222,7 @@ ItemInHandRenderer::ItemInHandRenderer(Minecraft *mc, bool optimisedMinimap)
}
void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance> item, int layer, bool setColor/* = true*/)
void ItemInHandRenderer::renderItem(shared_ptr<LivingEntity> mob, shared_ptr<ItemInstance> item, int layer, bool setColor/* = true*/)
{
// 4J - code borrowed from render method below, although not factoring in brightness as that should already be being taken into account
// by texture lighting. This is for colourising things held in 3rd person view.
@@ -177,9 +241,9 @@ void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance
if (item->getIconType() == Icon::TYPE_TERRAIN && tile != NULL && TileRenderer::canRender(tile->getRenderShape()))
{
MemSect(31);
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
minecraft->textures->bindTexture(minecraft->textures->getTextureLocation(Icon::TYPE_TERRAIN));
MemSect(0);
tileRenderer->renderTile(tile, item->getAuxValue(), SharedConstants::TEXTURE_LIGHTING ? 1.0f : mob->getBrightness(1)); // 4J - change brought forward from 1.8.2
tileRenderer->renderTile(Tile::tiles[item->id], item->getAuxValue(), SharedConstants::TEXTURE_LIGHTING ? 1.0f : mob->getBrightness(1)); // 4J - change brought forward from 1.8.2
}
else
{
@@ -192,14 +256,9 @@ void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance
return;
}
if (item->getIconType() == Icon::TYPE_TERRAIN)
{
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
}
else
{
mc->textures->bindTexture(TN_GUI_ITEMS); // 4J was L"/gui/items.png"
}
bool bIsTerrain = item->getIconType() == Icon::TYPE_TERRAIN;
minecraft->textures->bindTexture(minecraft->textures->getTextureLocation(item->getIconType()));
MemSect(0);
Tesselator *t = Tesselator::getInstance();
@@ -238,13 +297,13 @@ void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance
glTranslatef(-15 / 16.0f, -1 / 16.0f, 0);
float dd = 1 / 16.0f;
renderItem3D(t, u0, v0, u1, v1, icon->getSourceWidth(), icon->getSourceHeight(), 1 / 16.0f, false);
renderItem3D(t, u0, v0, u1, v1, icon->getSourceWidth(), icon->getSourceHeight(), 1 / 16.0f, false, bIsTerrain);
if (item != NULL && item->isFoil() && layer == 0)
{
glDepthFunc(GL_EQUAL);
glDisable(GL_LIGHTING);
mc->textures->bind(mc->textures->loadTexture(TN__BLUR__MISC_GLINT)); // 4J was L"%blur%/misc/glint.png"
minecraft->textures->bindTexture(&ENCHANT_GLINT_LOCATION);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE);
float br = 0.76f;
@@ -257,14 +316,14 @@ void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance
glTranslatef(sx, 0, 0);
glRotatef(-50, 0, 0, 1);
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true);
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true, bIsTerrain);
glPopMatrix();
glPushMatrix();
glScalef(ss, ss, ss);
sx = System::currentTimeMillis() % (3000 + 1873) / (3000 + 1873.0f) * 8;
glTranslatef(-sx, 0, 0);
glRotatef(10, 0, 0, 1);
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true);
renderItem3D(t, 0, 0, 1, 1, 256, 256, 1 / 16.0f, true, bIsTerrain);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glDisable(GL_BLEND);
@@ -280,7 +339,7 @@ void ItemInHandRenderer::renderItem(shared_ptr<Mob> mob, shared_ptr<ItemInstance
}
// 4J added useList parameter
void ItemInHandRenderer::renderItem3D(Tesselator *t, float u0, float v0, float u1, float v1, int width, int height, float depth, bool isGlint)
void ItemInHandRenderer::renderItem3D(Tesselator *t, float u0, float v0, float u1, float v1, int width, int height, float depth, bool isGlint, bool isTerrain)
{
float r = 1.0f;
@@ -301,7 +360,7 @@ void ItemInHandRenderer::renderItem3D(Tesselator *t, float u0, float v0, float u
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(u0, v0, 0);
glCallList(list);
glCallList(isTerrain? listTerrain : listItem);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
}
@@ -312,7 +371,7 @@ void ItemInHandRenderer::renderItem3D(Tesselator *t, float u0, float v0, float u
void ItemInHandRenderer::render(float a)
{
float h = oHeight + (height - oHeight) * a;
shared_ptr<Player> player = mc->player;
shared_ptr<Player> player = minecraft->player;
// 4J - added so we can adjust the position of the hands for horizontal & vertical split screens
float fudgeX = 0.0f;
@@ -355,12 +414,12 @@ void ItemInHandRenderer::render(float a)
shared_ptr<ItemInstance> item = selectedItem;
float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
float br = minecraft->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
// 4J - change brought forward from 1.8.2
if (SharedConstants::TEXTURE_LIGHTING)
{
br = 1;
int col = mc->level->getLightColor(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z), 0);
int col = minecraft->level->getLightColor(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z), 0);
int u = col % 65536;
int v = col / 65536;
glMultiTexCoord2f(GL_TEXTURE1, u / 1.0f, v / 1.0f);
@@ -413,9 +472,9 @@ void ItemInHandRenderer::render(float a)
{
// 4J-PB - if we've got a player texture, use that
//glBindTexture(GL_TEXTURE_2D, mc->textures->loadHttpTexture(mc->player->customTextureUrl, mc->player->getTexture()));
glBindTexture(GL_TEXTURE_2D, mc->textures->loadMemTexture(mc->player->customTextureUrl, mc->player->getTexture()));
mc->textures->clearLastBoundId();
//glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadHttpTexture(minecraft->player->customTextureUrl, minecraft->player->getTexture()));
glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadMemTexture(minecraft->player->customTextureUrl, minecraft->player->getTexture()));
minecraft->textures->clearLastBoundId();
for (int i = 0; i < 2; i++)
{
int flip = i * 2 - 1;
@@ -427,7 +486,7 @@ void ItemInHandRenderer::render(float a)
glRotatef(59, 0, 0, 1);
glRotatef((float)(-65 * flip), 0, 1, 0);
EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(mc->player);
EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(minecraft->player);
PlayerRenderer *playerRenderer = (PlayerRenderer *) er;
float ss = 1;
glScalef(ss, ss, ss);
@@ -463,7 +522,7 @@ void ItemInHandRenderer::render(float a)
glScalef(s, s, s);
MemSect(31);
mc->textures->bindTexture(TN_MISC_MAPBG); // 4J was L"/misc/mapbg.png"
minecraft->textures->bindTexture(&MAP_BACKGROUND_LOCATION); // 4J was L"/misc/mapbg.png"
MemSect(0);
Tesselator *t = Tesselator::getInstance();
@@ -477,9 +536,9 @@ void ItemInHandRenderer::render(float a)
t->vertexUV((float)(0 - vo), (float)( 0 - vo), (float)( 0), (float)( 0), (float)( 0));
t->end();
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(item, mc->level);
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(item, minecraft->level);
PIXBeginNamedEvent(0,"Minimap render");
if(data != NULL) minimap->render(mc->player, mc->textures, data, mc->player->entityId);
if(data != NULL) minimap->render(minecraft->player, minecraft->textures, data, minecraft->player->entityId);
PIXEndNamedEvent();
glPopMatrix();
@@ -633,12 +692,12 @@ void ItemInHandRenderer::render(float a)
// 4J-PB - if we've got a player texture, use that
//glBindTexture(GL_TEXTURE_2D, mc->textures->loadHttpTexture(mc->player->customTextureUrl, mc->player->getTexture()));
//glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadHttpTexture(minecraft->player->customTextureUrl, minecraft->player->getTexture()));
MemSect(31);
glBindTexture(GL_TEXTURE_2D, mc->textures->loadMemTexture(mc->player->customTextureUrl, mc->player->getTexture()));
glBindTexture(GL_TEXTURE_2D, minecraft->textures->loadMemTexture(minecraft->player->customTextureUrl, minecraft->player->getTexture()));
MemSect(0);
mc->textures->clearLastBoundId();
minecraft->textures->clearLastBoundId();
glTranslatef(-1.0f, +3.6f, +3.5f);
glRotatef(120, 0, 0, 1);
glRotatef(180 + 20, 1, 0, 0);
@@ -646,7 +705,7 @@ void ItemInHandRenderer::render(float a)
glScalef(1.5f / 24.0f * 16, 1.5f / 24.0f * 16, 1.5f / 24.0f * 16);
glTranslatef(5.6f, 0, 0);
EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(mc->player);
EntityRenderer *er = EntityRenderDispatcher::instance->getRenderer(minecraft->player);
PlayerRenderer *playerRenderer = (PlayerRenderer *) er;
float ss = 1;
glScalef(ss, ss, ss);
@@ -670,26 +729,19 @@ void ItemInHandRenderer::render(float a)
void ItemInHandRenderer::renderScreenEffect(float a)
{
glDisable(GL_ALPHA_TEST);
if (mc->player->isOnFire())
if (minecraft->player->isOnFire())
{
MemSect(31);
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
MemSect(0);
renderFire(a);
}
if (mc->player->isInWall()) // Inside a tile
if (minecraft->player->isInWall()) // Inside a tile
{
int x = Mth::floor(mc->player->x);
int y = Mth::floor(mc->player->y);
int z = Mth::floor(mc->player->z);
int x = Mth::floor(minecraft->player->x);
int y = Mth::floor(minecraft->player->y);
int z = Mth::floor(minecraft->player->z);
MemSect(31);
mc->textures->bindTexture(TN_TERRAIN); // 4J was L"/terrain.png"
MemSect(0);
int tile = mc->level->getTile(x, y, z);
if (mc->level->isSolidBlockingTile(x, y, z))
int tile = minecraft->level->getTile(x, y, z);
if (minecraft->level->isSolidBlockingTile(x, y, z))
{
renderTex(a, Tile::tiles[tile]->getTexture(2));
}
@@ -697,15 +749,15 @@ void ItemInHandRenderer::renderScreenEffect(float a)
{
for (int i = 0; i < 8; i++)
{
float xo = ((i >> 0) % 2 - 0.5f) * mc->player->bbWidth * 0.9f;
float yo = ((i >> 1) % 2 - 0.5f) * mc->player->bbHeight * 0.2f;
float zo = ((i >> 2) % 2 - 0.5f) * mc->player->bbWidth * 0.9f;
float xo = ((i >> 0) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f;
float yo = ((i >> 1) % 2 - 0.5f) * minecraft->player->bbHeight * 0.2f;
float zo = ((i >> 2) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f;
int xt = Mth::floor(x + xo);
int yt = Mth::floor(y + yo);
int zt = Mth::floor(z + zo);
if (mc->level->isSolidBlockingTile(xt, yt, zt))
if (minecraft->level->isSolidBlockingTile(xt, yt, zt))
{
tile = mc->level->getTile(xt, yt, zt);
tile = minecraft->level->getTile(xt, yt, zt);
}
}
}
@@ -713,10 +765,10 @@ void ItemInHandRenderer::renderScreenEffect(float a)
if (Tile::tiles[tile] != NULL) renderTex(a, Tile::tiles[tile]->getTexture(2));
}
if (mc->player->isUnderLiquid(Material::water))
if (minecraft->player->isUnderLiquid(Material::water))
{
MemSect(31);
mc->textures->bindTexture(TN_MISC_WATER); // 4J was L"/misc/water.png"
minecraft->textures->bindTexture(&UNDERWATER_LOCATION); // 4J was L"/misc/water.png"
MemSect(0);
renderWater(a);
}
@@ -726,6 +778,8 @@ void ItemInHandRenderer::renderScreenEffect(float a)
void ItemInHandRenderer::renderTex(float a, Icon *slot)
{
minecraft->textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: get this data from Icon
Tesselator *t = Tesselator::getInstance();
float br = 0.1f;
@@ -760,9 +814,11 @@ void ItemInHandRenderer::renderTex(float a, Icon *slot)
void ItemInHandRenderer::renderWater(float a)
{
minecraft->textures->bindTexture(&UNDERWATER_LOCATION);
Tesselator *t = Tesselator::getInstance();
float br = mc->player->getBrightness(a);
float br = minecraft->player->getBrightness(a);
glColor4f(br, br, br, 0.5f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -777,8 +833,8 @@ void ItemInHandRenderer::renderWater(float a)
float y1 = +1;
float z0 = -0.5f;
float uo = -mc->player->yRot / 64.0f;
float vo = +mc->player->xRot / 64.0f;
float uo = -minecraft->player->yRot / 64.0f;
float vo = +minecraft->player->xRot / 64.0f;
t->begin();
t->vertexUV((float)(x0), (float)( y0), (float)( z0), (float)( size + uo), (float)( size + vo));
@@ -796,7 +852,14 @@ void ItemInHandRenderer::renderWater(float a)
void ItemInHandRenderer::renderFire(float a)
{
Tesselator *t = Tesselator::getInstance();
glColor4f(1, 1, 1, 0.9f);
unsigned int col = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Fire_Overlay );
float aCol = ( (col>>24)&0xFF )/255.0f;
float rCol = ( (col>>16)&0xFF )/255.0f;
float gCol = ( (col>>8)&0xFF )/255.0;
float bCol = ( col&0xFF )/255.0;
glColor4f(rCol, gCol, bCol, aCol);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -805,6 +868,7 @@ void ItemInHandRenderer::renderFire(float a)
{
glPushMatrix();
Icon *slot = Tile::fire->getTextureLayer(1);
minecraft->textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); // TODO: Get this from Icon
float u0 = slot->getU0(true);
float u1 = slot->getU1(true);
@@ -837,7 +901,7 @@ void ItemInHandRenderer::tick()
oHeight = height;
shared_ptr<Player> player = mc->player;
shared_ptr<Player> player = minecraft->player;
shared_ptr<ItemInstance> nextTile = player->inventory->getSelected();
bool matches = lastSlot == player->inventory->selected && nextTile == selectedItem;