* Add semi transparent glass as patch.

This commit is contained in:
iProgramInCpp
2023-08-22 22:48:41 +03:00
parent 282ecf85d4
commit d8f900edbd
6 changed files with 32 additions and 9 deletions

1
.gitignore vendored
View File

@@ -435,3 +435,4 @@ xcuserdata/
# Ignore options.txt - where your configuration will be saved
/game/options.txt
/game/assetsO

View File

@@ -1,11 +1,12 @@
#Texture patch data for Minecraft PE. The # at the start denotes a comment, removing it makes it a command.
# Commands you can use:
# - terrain|x|y|filename -- Patches terrain.png
# - items|x|y|filename -- Patches gui/items.png
# - frame|itemid|x|y -- Sets the base texture frame of the tile or itemID.
# - vegetation_tint|bool -- Enables default vegetation tint. (grass and leaves)
# - metal_block_sides|int -- Makes metal blocks have separate side textures, and allows specification of their Y offset. -1 to disable.
# - stop_now -- Stops processing at that line. All further commands will be ignored.
# - terrain|x|y|filename -- Patches terrain.png
# - items|x|y|filename -- Patches gui/items.png
# - frame|itemid|x|y -- Sets the base texture frame of the tile or itemID.
# - vegetation_tint|bool -- Enables default vegetation tint. (grass and leaves)
# - metal_block_sides|int -- Makes metal blocks have separate side textures, and allows specification of their Y offset. -1 to disable.
# - semi_transparent_glass|bool -- Makes glass render on the alpha layer (as opposed to the opaque layer). Allows it to be semi transparent like ice.
# - stop_now -- Stops processing at that line. All further commands will be ignored.
# * The filename parameter will be a PNG file that can be found relative to this directory. For example, '../quiver.png' will load it from assets/, 'chain.png' will load it from assets/patches/.
# * The X and Y destination coordinates will be multiplied by 16.

View File

@@ -19,6 +19,7 @@ PatchManager* GetPatchManager()
PatchManager::PatchManager()
{
m_bGrassTinted = true;
m_bGlassSemiTransparent = false;
m_nMetalSideYOffset = -1;
}
@@ -130,8 +131,11 @@ void PatchManager::LoadPatchData(const std::string& patchData)
ReadBool(lineStream, m_bGrassTinted);
continue;
}
// features -- TODO un-hardcode this
if (command == "semi_transparent_glass")
{
ReadBool(lineStream, m_bGlassSemiTransparent);
continue;
}
if (command == "metal_block_sides")
{
ReadInt(lineStream, m_nMetalSideYOffset);
@@ -208,6 +212,11 @@ int PatchManager::GetMetalSideYOffset()
return m_nMetalSideYOffset;
}
bool PatchManager::IsGlassSemiTransparent()
{
return m_bGlassSemiTransparent;
}
void PatchManager::ReadBool(std::istream& is, bool& b)
{
std::string flag;

View File

@@ -79,6 +79,7 @@ public:
// Features
bool IsGrassTinted();
int GetMetalSideYOffset();
bool IsGlassSemiTransparent();
private:
void ReadBool(std::istream& is, bool& b);
@@ -86,6 +87,7 @@ private:
private:
bool m_bGrassTinted;
bool m_bGlassSemiTransparent;
int m_nMetalSideYOffset;
std::vector<PatchData> m_patchData;
};

View File

@@ -8,6 +8,7 @@
#include "GlassTile.hpp"
#include "world/level/Level.hpp"
#include "client/renderer/PatchManager.hpp"
GlassTile::GlassTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c)
{
@@ -16,4 +17,12 @@ GlassTile::GlassTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c)
int GlassTile::getResourceCount(Random* pRandom)
{
return 0;
}
}
int GlassTile::getRenderLayer()
{
if (GetPatchManager()->IsGlassSemiTransparent())
return LAYER_ALPHA;
return LAYER_OPAQUE;
}

View File

@@ -16,4 +16,5 @@ public:
GlassTile(int ID, int texture, Material*);
int getResourceCount(Random*) override;
int getRenderLayer() override;
};