feat: slime block

This commit is contained in:
Fireblade 2026-05-21 23:21:47 -04:00
parent 67d6b2692f
commit 05c14bc0fe
38 changed files with 449 additions and 33 deletions

View file

@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: LegacyEvolved Community Discord
- name: neoLegacy Community Discord
url: https://discord.gg/D6hEPNYeyn
about: If you need help, please ask for it in our Discord! You will get assistance much faster there, including help getting the project to compile.

View file

@ -416,6 +416,10 @@ void Chunk::rebuild()
if (renderLayer > currentLayer)
{
if (currentLayer == 1 && tile == Tile::slimeBlock)
{
rendered |= tileRenderer->tesselateSlimeInnerInWorld(tile, x, y, z);
}
renderNextLayer = true;
}
else if (renderLayer == currentLayer)

View file

@ -90,6 +90,7 @@ void IUIScene_CreativeMenu::staticCtor()
ITEM_AUX(Tile::prismarine_Id, PrismarineTile::TYPE_DEFAULT)
ITEM_AUX(Tile::prismarine_Id, PrismarineTile::TYPE_BRICKS)
ITEM_AUX(Tile::prismarine_Id, PrismarineTile::TYPE_DARK)
ITEM(Tile::slime_Id)
ITEM(Tile::fence_Id)
// TU25

View file

@ -54,7 +54,18 @@ void PistonPieceRenderer::render(shared_ptr<TileEntity> _entity, double x, doubl
}
else
{
tileRenderer->tesselateInWorldNoCulling(tile, entity->x, entity->y, entity->z, entity->getData(), entity);
if (tile == Tile::slimeBlock)
{
tileRenderer->setFixedTexture(tile->getTexture(0, entity->getData()));
tileRenderer->fixedTextureAlpha = 0.35f;
tileRenderer->tesselateInWorldNoCulling(Tile::glass, entity->x, entity->y, entity->z, entity->getData(), entity);
tileRenderer->fixedTextureAlpha = 1.0f;
tileRenderer->clearFixedTexture();
}
else
{
tileRenderer->tesselateInWorldNoCulling(tile, entity->x, entity->y, entity->z, entity->getData(), entity);
}
}
t->offset(0, 0, 0);
t->end();

View file

@ -17,6 +17,14 @@ bool TileRenderer::fancy = true;
const float smallUV = ( 1.0f / 16.0f );
static inline void tessColor(Tesselator* t, float r, float g, float b, float a)
{
if (a >= 0.999f)
t->color(r, g, b);
else
t->color(r, g, b, a);
}
void TileRenderer::_init()
{
fixedTexture = nullptr;
@ -41,6 +49,8 @@ void TileRenderer::_init()
smoothShapeLighting = false;
minecraft = Minecraft::GetInstance();
fixedTextureAlpha = 1.0f;
xMin = 0;
yMin = 0;
zMin = 0;
@ -336,6 +346,9 @@ bool TileRenderer::tesselateInWorld( Tile* tt, int x, int y, int z, int forceDat
case Tile::SHAPE_CACTUS:
retVal = tesselateCactusInWorld( tt, x, y, z );
break;
case Tile::SHAPE_SLIME:
retVal = tesselateSlimeBlockInWorld( tt, x, y, z );
break;
case Tile::SHAPE_CROSS_TEXTURE:
retVal = tesselateCrossInWorld( tt, x, y, z );
break;
@ -6279,6 +6292,50 @@ bool TileRenderer::tesselateBlockInWorld( Tile* tt, int x, int y, int z, float r
}
bool TileRenderer::tesselateSlimeBlockInWorld(Tile *tt, int x, int y, int z)
{
setFixedTexture(getTexture(Tile::slimeBlock));
setShape(0, 0, 0, 1, 1, 1);
this->fixedTextureAlpha = 0.35f;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glDepthMask(false);
tesselateBlockInWorld(tt, x, y, z);
glDepthMask(true);
glEnable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
this->fixedTextureAlpha = 1.0f;
clearFixedTexture();
return true;
}
bool TileRenderer::tesselateSlimeInnerInWorld(Tile *tt, int x, int y, int z)
{
const float innerSizeStart = 3.0f / 16.0f;
const float innerSizeFinish = 13.0f / 16.0f;
setFixedTexture(getTexture(Tile::slimeBlock));
setShape(innerSizeStart, innerSizeStart, innerSizeStart, innerSizeFinish, innerSizeFinish, innerSizeFinish);
this->fixedTextureAlpha = 0.18f;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glDepthMask(false);
bool result = tesselateBlockInWorld(tt, x, y, z);
glDepthMask(true);
glEnable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
this->fixedTextureAlpha = 1.0f;
clearFixedTexture();
return result;
}
bool TileRenderer::tesselateBeaconInWorld(Tile *tt, int x, int y, int z)
{
float obsHeight = 3.0f / 16.0f;
@ -6299,7 +6356,7 @@ bool TileRenderer::tesselateBeaconInWorld(Tile *tt, int x, int y, int z)
noCulling = false;
clearFixedTexture();
return true;
}
@ -7285,16 +7342,16 @@ void TileRenderer::renderFaceDown( Tile* tt, double x, double y, double z, Icon
}
#endif
t->color( c1r, c1g, c1b );
tessColor(t, c1r, c1g, c1b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z1), static_cast<float>(u10), static_cast<float>(v10) );
t->color( c2r, c2g, c2b );
tessColor(t, c2r, c2g, c2b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z0), ( float )( u00 ), ( float )( v00 ) );
t->color( c3r, c3g, c3b );
tessColor(t, c3r, c3g, c3b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y0), static_cast<float>(z0), static_cast<float>(u01), static_cast<float>(v01) );
t->color( c4r, c4g, c4b );
tessColor(t, c4r, c4g, c4b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y0), static_cast<float>(z1), ( float )( u11 ), ( float )( v11 ) );
}
@ -7397,16 +7454,16 @@ void TileRenderer::renderFaceUp( Tile* tt, double x, double y, double z, Icon *t
}
#endif
t->color( c1r, c1g, c1b );
tessColor(t, c1r, c1g, c1b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y1), static_cast<float>(z1), ( float )( u11 ), ( float )( v11 ) );
t->color( c2r, c2g, c2b );
tessColor(t, c2r, c2g, c2b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y1), static_cast<float>(z0), ( float )( u01 ), ( float )( v01 ) );
t->color( c3r, c3g, c3b );
tessColor(t, c3r, c3g, c3b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z0), ( float )( u00 ), ( float )( v00 ) );
t->color( c4r, c4g, c4b );
tessColor(t, c4r, c4g, c4b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z1), ( float )( u10 ), ( float )( v10 ) );
}
@ -7516,16 +7573,16 @@ void TileRenderer::renderNorth( Tile* tt, double x, double y, double z, Icon *te
}
#endif
t->color( c1r, c1g, c1b );
tessColor(t, c1r, c1g, c1b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z0), static_cast<float>(u01), static_cast<float>(v01) );
t->color( c2r, c2g, c2b );
tessColor(t, c2r, c2g, c2b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y1), static_cast<float>(z0), static_cast<float>(u00), static_cast<float>(v00) );
t->color( c3r, c3g, c3b );
tessColor(t, c3r, c3g, c3b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y0), static_cast<float>(z0), static_cast<float>(u10), static_cast<float>(v10) );
t->color( c4r, c4g, c4b );
tessColor(t, c4r, c4g, c4b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z0), static_cast<float>(u11), static_cast<float>(v11) );
}
@ -7635,16 +7692,16 @@ void TileRenderer::renderSouth( Tile* tt, double x, double y, double z, Icon *te
}
#endif
t->color( c1r, c1g, c1b );
tessColor(t, c1r, c1g, c1b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z1), static_cast<float>(u00), static_cast<float>(v00) );
t->color( c2r, c2g, c2b );
tessColor(t, c2r, c2g, c2b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z1), static_cast<float>(u10), static_cast<float>(v10) );
t->color( c3r, c3g, c3b );
tessColor(t, c3r, c3g, c3b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y0), static_cast<float>(z1), static_cast<float>(u11), static_cast<float>(v11) );
t->color( c4r, c4g, c4b );
tessColor(t, c4r, c4g, c4b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
t->vertexUV( static_cast<float>(x1), static_cast<float>(y1), static_cast<float>(z1), static_cast<float>(u01), static_cast<float>(v01) );
}
@ -7753,16 +7810,16 @@ void TileRenderer::renderWest( Tile* tt, double x, double y, double z, Icon *tex
}
#endif
t->color( c1r, c1g, c1b );
tessColor(t, c1r, c1g, c1b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc1 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z1), static_cast<float>(u01), static_cast<float>(v01) );
t->color( c2r, c2g, c2b );
tessColor(t, c2r, c2g, c2b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc2 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(z0), static_cast<float>(u00), static_cast<float>(v00) );
t->color( c3r, c3g, c3b );
tessColor(t, c3r, c3g, c3b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc3 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z0), static_cast<float>(u10), static_cast<float>(v10) );
t->color( c4r, c4g, c4b );
tessColor(t, c4r, c4g, c4b, this->fixedTextureAlpha);
if ( SharedConstants::TEXTURE_LIGHTING ) t->tex2( tc4 );
t->vertexUV( static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(z1), static_cast<float>(u11), static_cast<float>(v11) );
}
@ -8106,6 +8163,56 @@ void TileRenderer::renderTile( Tile* tile, int data, float brightness, float fAl
tile->updateDefaultShape();
t->end();
}
else if (shape == Tile::SHAPE_SLIME)
{
tile->updateDefaultShape();
glTranslatef(-0.5f, -0.5f, -0.5f);
bool hadFixedTexture = hasFixedTexture();
Icon *savedFixedTexture = fixedTexture;
setFixedTexture(getTexture(Tile::slimeBlock));
setShape(3.0f / 16.0f, 3.0f / 16.0f, 3.0f / 16.0f, 13.0f / 16.0f, 13.0f / 16.0f, 13.0f / 16.0f);
t->begin();
t->normal(0.0f, -1.0f, 0.0f);
renderFaceDown(tile, 0, 0, 0, getTexture(tile, 0, data));
t->normal(0.0f, 1.0f, 0.0f);
renderFaceUp(tile, 0, 0, 0, getTexture(tile, 1, data));
t->normal(0.0f, 0.0f, -1.0f);
renderNorth(tile, 0, 0, 0, getTexture(tile, 2, data));
t->normal(0.0f, 0.0f, 1.0f);
renderSouth(tile, 0, 0, 0, getTexture(tile, 3, data));
t->normal(-1.0f, 0.0f, 0.0f);
renderWest(tile, 0, 0, 0, getTexture(tile, 4, data));
t->normal(1.0f, 0.0f, 0.0f);
renderEast(tile, 0, 0, 0, getTexture(tile, 5, data));
t->end();
setFixedTexture(getTexture(Tile::slimeBlock));
setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
glColor4f(brightness, brightness, brightness, fAlpha * 0.5f);
t->begin();
t->normal(0.0f, -1.0f, 0.0f);
renderFaceDown(tile, 0, 0, 0, getTexture(tile, 0, data));
t->normal(0.0f, 1.0f, 0.0f);
renderFaceUp(tile, 0, 0, 0, getTexture(tile, 1, data));
t->normal(0.0f, 0.0f, -1.0f);
renderNorth(tile, 0, 0, 0, getTexture(tile, 2, data));
t->normal(0.0f, 0.0f, 1.0f);
renderSouth(tile, 0, 0, 0, getTexture(tile, 3, data));
t->normal(-1.0f, 0.0f, 0.0f);
renderWest(tile, 0, 0, 0, getTexture(tile, 4, data));
t->normal(1.0f, 0.0f, 0.0f);
renderEast(tile, 0, 0, 0, getTexture(tile, 5, data));
t->end();
if (hadFixedTexture)
setFixedTexture(savedFixedTexture);
else
clearFixedTexture();
glColor4f(brightness, brightness, brightness, fAlpha);
}
else if ( shape == Tile::SHAPE_CACTUS )
{
tile->updateDefaultShape();
@ -8557,6 +8664,7 @@ bool TileRenderer::canRender( int renderShape )
if ( renderShape == Tile::SHAPE_BLOCK ) return true;
if ( renderShape == Tile::SHAPE_TREE ) return true;
if ( renderShape == Tile::SHAPE_QUARTZ) return true;
if ( renderShape == Tile::SHAPE_SLIME ) return true;
if ( renderShape == Tile::SHAPE_CACTUS ) return true;
if ( renderShape == Tile::SHAPE_STAIRS ) return true;
if ( renderShape == Tile::SHAPE_FENCE ) return true;

View file

@ -12,6 +12,7 @@ class FenceGateTile;
class BrewingStandTile;
class CauldronTile;
class EggTile;
class SlimeTile;
class TheEndPortalFrameTile;
class RepeaterTile;
class ComparatorTile;
@ -39,6 +40,7 @@ class TileRenderer
public :
static bool fancy;
bool setColor;
float fixedTextureAlpha;
float tileShapeX0;
float tileShapeX1;
@ -87,11 +89,14 @@ public:
bool tesselateInWorld( Tile* tt, int x, int y, int z, int forceData = -1, shared_ptr< TileEntity > forceEntity =
shared_ptr< TileEntity >() ); // 4J added forceData, forceEntity param
bool tesselateSlimeInnerInWorld(Tile *tt, int x, int y, int z);
private:
bool tesselateAirPortalFrameInWorld(TheEndPortalFrameTile *tt, int x, int y, int z);
bool tesselateBedInWorld( Tile* tt, int x, int y, int z );
bool tesselateBrewingStandInWorld(BrewingStandTile *tt, int x, int y, int z);
bool tesselateCauldronInWorld(CauldronTile *tt, int x, int y, int z);
bool tesselateSlimeBlockInWorld(Tile *tt, int x, int y, int z);
bool tesselateFlowerPotInWorld(FlowerPotTile *tt, int x, int y, int z);
bool tesselateAnvilInWorld(AnvilTile *tt, int x, int y, int z);

View file

@ -1301,6 +1301,10 @@ Can also be used for low-level lighting.</value>
<value>Can be mined with a pickaxe to collect cobblestone.</value>
</data>
<data name="IDS_DESC_SLIME_BLOCK">
<value>Causes players and mobs to bounce when they jump on it.</value>
</data>
<data name="IDS_DESC_DIRT">
<value>Collected using a shovel. Can be used for construction.</value>
</data>
@ -2949,6 +2953,10 @@ Can also be used for low-level lighting.</value>
<value>Stone</value>
</data>
<data name="IDS_TILE_SLIME_BLOCK">
<value>Slime Block</value>
</data>
<data name="IDS_TILE_GRASS">
<value>Grass Block</value>
</data>

View file

@ -3,6 +3,7 @@
BarrierTile::BarrierTile(int id, Material *material, bool allowSame) : HalfTransparentTile(id, L"barrier", material, allowSame)
{
setLightBlock(0);
}
int BarrierTile::getResourceCount(Random *random)

View file

@ -6,6 +6,7 @@
BaseEntityTile::BaseEntityTile(int id, Material *material, bool isSolidRender /*= true*/) : Tile(id, material, isSolidRender)
{
setLightBlock(0);
_isEntityTile = true;
}

View file

@ -11,6 +11,7 @@ BasePressurePlateTile::BasePressurePlateTile(int id, const wstring &tex, Materia
{
texture = tex;
setTicking(true);
setLightBlock(0);
// 4J Stu - Move this to derived classes
//updateShape(getDataForSignal(Redstone::SIGNAL_MAX));

View file

@ -11,6 +11,7 @@ ButtonTile::ButtonTile(int id, bool sensitive) : Tile(id, Material::decoration,
{
this->setTicking(true);
this->sensitive = sensitive;
setLightBlock(0);
}
Icon *ButtonTile::getTexture(int face, int data)

View file

@ -14,6 +14,7 @@ const wstring CauldronTile::TEXTURE_BOTTOM = L"cauldron_bottom";
CauldronTile::CauldronTile(int id) : Tile(id, Material::metal, isSolidRender())
{
setLightBlock(0);
iconInner = nullptr;
iconTop = nullptr;
iconBottom = nullptr;

View file

@ -4,6 +4,7 @@
DirectionalTile::DirectionalTile(int id, Material *material, bool isSolidRender) : Tile(id, material, isSolidRender)
{
setLightBlock(0);
}
int DirectionalTile::getDirection(int data)

View file

@ -20,6 +20,7 @@ static std::map<wstring, int> doorItemMap = {
DoorTile::DoorTile(int id, Material *material, const wstring& doorType) : Tile(id, material,isSolidRender())
{
setLightBlock(0);
this->doorType = doorType;
float r = 0.5f;

View file

@ -892,7 +892,7 @@ void Entity::move(double xa, double ya, double za, bool noEntityCubes) // 4J -
checkFallDamage(ya, onGround);
if (xaOrg != xa) xd = 0;
if (yaOrg != ya) yd = 0;
if (yaOrg != ya && yd < 0) yd = 0; // ONE LINE OF CODE??? REALLY?? THIS TOOK ME 4 HOURS YOUVE GOT TO BE KIDDING ME - A VERY ANGRY FIREBLADE
if (zaOrg != za) zd = 0;
double xm = x - xo;

View file

@ -7,6 +7,7 @@
FenceTile::FenceTile(int id, const wstring &texture, Material *material) : Tile( id, material, isSolidRender())
{
setLightBlock(0);
this->texture = texture;
}

View file

@ -7,6 +7,7 @@
FlowerPotTile::FlowerPotTile(int id) : Tile(id, Material::decoration, isSolidRender() )
{
setLightBlock(0);
updateDefaultShape();
sendTileData();
}

View file

@ -14,11 +14,15 @@ HalfSlabTile::HalfSlabTile(int id, Material *material)
void HalfSlabTile::DerivedInit()
{
if (!isFullSize())
{
setLightBlock(0);
setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f);
}
else
{
Tile::solid[id] = true;
}
}
void HalfSlabTile::updateDefaultShape()

View file

@ -7,6 +7,7 @@ HalfTransparentTile::HalfTransparentTile(int id, const wstring &tex, Material *m
{
this->allowSame = allowSame;
this->texture = tex;
setLightBlock(0);
}
bool HalfTransparentTile::isSolidRender(bool isServerLevel)

View file

@ -181,7 +181,8 @@ void LivingEntity::checkFallDamage(double ya, bool onGround)
if (t > 0)
{
Tile::tiles[t]->fallOn(level, xt, yt, zt, shared_from_this(), fallDistance);
auto ent = shared_from_this();
Tile::tiles[t]->fallOn(level, xt, yt, zt, ent, fallDistance);
}
}

View file

@ -45,6 +45,7 @@ public:
static const int PUSH_NORMAL = 0;
static const int PUSH_DESTROY = 1;
static const int PUSH_BLOCK = 2; // not pushable
static const int PUSH_SLIME = 3; // slime block
static void staticCtor();

View file

@ -5,6 +5,7 @@
#include "PistonExtensionTile.h"
#include "Facing.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.phys.h"
#include "../Minecraft.Client/Minecraft.h"
#include "../Minecraft.Client/MultiPlayerLevel.h"
#include "net.minecraft.world.h"
@ -342,7 +343,7 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
PIXBeginNamedEvent(0,"Contract sticky phase C\n");
if (!pistonPiece && block > 0 && (isPushable(block, level, twoX, twoY, twoZ, false))
&& (Tile::tiles[block]->getPistonPushReaction() == Material::PUSH_NORMAL || block == Tile::pistonBase_Id || block == Tile::pistonStickyBase_Id))
&& (Tile::tiles[block]->getPistonPushReaction() == Material::PUSH_NORMAL || Tile::tiles[block]->getPistonPushReaction() == Material::PUSH_SLIME || block == Tile::pistonBase_Id || block == Tile::pistonStickyBase_Id))
{
stopSharingIfServer(level, twoX, twoY, twoZ); // 4J added
@ -356,7 +357,42 @@ bool PistonBaseTile::triggerEvent(Level *level, int x, int y, int z, int param1,
ignoreUpdate(false);
level->removeTile(twoX, twoY, twoZ);
ignoreUpdate(true);
}
if (block == Tile::slimeBlock->id)
{
for (int face = 0; face < 6; face++)
{
int adjX = twoX + Facing::STEP_X[face];
int adjY = twoY + Facing::STEP_Y[face];
int adjZ = twoZ + Facing::STEP_Z[face];
int adjBlock = level->getTile(adjX, adjY, adjZ);
if (adjBlock == 0)
{
continue;
}
if (!isPushable(adjBlock, level, adjX, adjY, adjZ, false))
{
continue;
}
int adjData = level->getData(adjX, adjY, adjZ);
int destX = adjX - Facing::STEP_X[facing];
int destY = adjY - Facing::STEP_Y[facing];
int destZ = adjZ - Facing::STEP_Z[facing];
stopSharingIfServer(level, destX, destY, destZ);
level->setTileAndData(destX, destY, destZ, Tile::pistonMovingPiece_Id, adjData, Tile::UPDATE_NONE);
level->setTileEntity(destX, destY, destZ, PistonMovingPiece::newMovingPieceEntity(adjBlock, adjData, facing, false, false));
ignoreUpdate(false);
level->removeTile(adjX, adjY, adjZ);
ignoreUpdate(true);
level->updateNeighborsAt(adjX, adjY, adjZ, adjBlock);
}
}
}
else if (!pistonPiece)
{
stopSharingIfServer(level, x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); // 4J added
@ -647,6 +683,26 @@ bool PistonBaseTile::createPush(Level *level, int sx, int sy, int sz, int facing
int ez = cz;
int count = 0;
int tiles[MAX_PUSH_DEPTH + 1];
struct MoveBlock
{
int x;
int y;
int z;
int block;
int data;
};
vector<MoveBlock> movedBlocks;
auto alreadyMoved = [&movedBlocks](int x, int y, int z)
{
for (const auto &move : movedBlocks)
{
if (move.x == x && move.y == y && move.z == z)
{
return true;
}
}
return false;
};
while (cx != sx || cy != sy || cz != sz)
{
@ -670,6 +726,12 @@ bool PistonBaseTile::createPush(Level *level, int sx, int sy, int sz, int facing
level->setTileAndData(cx, cy, cz, Tile::pistonMovingPiece_Id, data, Tile::UPDATE_NONE);
level->setTileEntity(cx, cy, cz, PistonMovingPiece::newMovingPieceEntity(block, data, facing, true, false));
}
if (block == Tile::slimeBlock->id)
{
AABB *bb = AABB::newTemp(nx, ny, nz, nx + 1, ny + 2, nz + 1);
auto entities = level->getEntities(nullptr, bb);
}
movedBlocks.push_back({ nx, ny, nz, block, data });
tiles[count++] = block;
cx = nx;
@ -677,6 +739,49 @@ bool PistonBaseTile::createPush(Level *level, int sx, int sy, int sz, int facing
cz = nz;
}
for (size_t i = 0; i < movedBlocks.size(); i++)
{
if (movedBlocks[i].block != Tile::slimeBlock->id)
{
continue;
}
for (int face = 0; face < 6; face++)
{
int nx = movedBlocks[i].x + Facing::STEP_X[face];
int ny = movedBlocks[i].y + Facing::STEP_Y[face];
int nz = movedBlocks[i].z + Facing::STEP_Z[face];
if (alreadyMoved(nx, ny, nz))
{
continue;
}
int block = level->getTile(nx, ny, nz);
if (block == 0)
{
continue;
}
if (!isPushable(block, level, nx, ny, nz, false))
{
continue;
}
int data = level->getData(nx, ny, nz);
int dx = nx + Facing::STEP_X[facing];
int dy = ny + Facing::STEP_Y[facing];
int dz = nz + Facing::STEP_Z[facing];
stopSharingIfServer(level, dx, dy, dz);
level->setTileAndData(dx, dy, dz, Tile::pistonMovingPiece_Id, data, Tile::UPDATE_NONE);
level->setTileEntity(dx, dy, dz, PistonMovingPiece::newMovingPieceEntity(block, data, facing, true, false));
level->removeTile(nx, ny, nz);
level->updateNeighborsAt(nx, ny, nz, block);
movedBlocks.push_back({ nx, ny, nz, block, data });
}
}
cx = ex;
cy = ey;
cz = ez;

View file

@ -2,6 +2,7 @@
#include "com.mojang.nbt.h"
#include "PistonPieceEntity.h"
#include "PistonMovingPiece.h"
#include "net.minecraft.world.phys.h"
#include "net.minecraft.world.level.h"
#include "Facing.h"
#include "Tile.h"
@ -119,7 +120,13 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount)
AABB *aabb = Tile::pistonMovingPiece->getAABB(level, x, y, z, id, progress, facing);
if (aabb != nullptr)
{
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, aabb);
AABB *queryBox = aabb;
if (id == Tile::slimeBlock->id && Facing::STEP_Y[facing] > 0)
{
queryBox = AABB::newTemp(aabb->x0, aabb->y0, aabb->z0, aabb->x1, aabb->y1 + 1.0f, aabb->z1);
}
vector<shared_ptr<Entity> > *entities = level->getEntities(nullptr, queryBox);
if (!entities->empty())
{
vector< shared_ptr<Entity> > collisionHolder;
@ -133,6 +140,17 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount)
it->move(amount * Facing::STEP_X[facing],
amount * Facing::STEP_Y[facing],
amount * Facing::STEP_Z[facing]);
if (id == Tile::slimeBlock->id && Facing::STEP_Y[facing] > 0)
{
if (it->yd < amount)
{
it->yd = amount;
}
it->onGround = false;
it->fallDistance = 0.0f;
it->hasImpulse = true;
}
}
}
}

View file

@ -22,7 +22,8 @@ const wstring RedStoneDustTile::TEXTURE_LINE_OVERLAY = L"_line_overlay";
RedStoneDustTile::RedStoneDustTile(int id) : Tile(id, Material::decoration,isSolidRender())
{
shouldSignal = true;
setLightBlock(0);
updateDefaultShape();
iconCross = nullptr;

View file

@ -0,0 +1,93 @@
#include "stdafx.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.dimension.h"
#include "net.minecraft.world.item.enchantment.h"
#include "net.minecraft.world.food.h"
#include "net.minecraft.stats.h"
#include "SlimeTile.h"
#include "Entity.h"
SlimeTile::SlimeTile(int id) : HalfTransparentTile(id, L"slime", Material::clay, false)
{
friction = 0.8f;
setLightBlock(0);
}
int SlimeTile::getRenderLayer()
{
return 2;
}
int SlimeTile::getRenderShape()
{
return Tile::SHAPE_SLIME;
}
bool SlimeTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
return true;
}
int SlimeTile::getResourceCount(Random *random)
{
return 0;
}
bool SlimeTile::isSolidRender()
{
return false;
}
int SlimeTile::getPistonPushReaction()
{
return Material::PUSH_SLIME;
}
void SlimeTile::fallOn(Level *level, int x, int y, int z,
shared_ptr<Entity> entity, float distance)
{
HalfTransparentTile::fallOn(level, x, y, z, entity, distance);
if (entity == nullptr)
return;
if (entity->isSneaking())
return;
if (std::abs(entity->yd) < 0.1f)
return;
if (entity->yd < 0.0f)
{
entity->yd = -entity->yd;
if (!(entity->instanceof(eTYPE_LIVINGENTITY)))
{
entity->yd *= 0.8f;
}
}
entity->fallDistance = 0.0f;
entity->onGround = false;
}
void SlimeTile::stepOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity)
{
if (entity != nullptr &&
std::abs(entity->yd) < 0.1f &&
!entity->isSneaking())
{
double d0 = 0.4 + std::abs(entity->yd) * 0.2;
entity->xd *= d0;
entity->zd *= d0;
level->playSound(x + 0.5, y + 0.5, z + 0.5, eSoundType_MOB_SLIME_SMALL, 0.4f, 0.8f + level->random->nextFloat() * 0.4f);
}
HalfTransparentTile::stepOn(level, x, y, z, entity);
}
void SlimeTile::updateEntityAfterFallOn(Level* level, shared_ptr<Entity> entity)
{
// stub
}

View file

@ -0,0 +1,21 @@
#pragma once
#include "HalfTransparentTile.h"
class Random;
class SlimeTile : public HalfTransparentTile
{
public:
SlimeTile(int id);
virtual int getRenderLayer();
virtual bool shouldRenderFace(LevelSource *level, int x, int y, int z, int face);
virtual int getRenderShape();
virtual bool isSolidRender();
virtual int getResourceCount(Random *random);
virtual int getPistonPushReaction();
// slime block logic
virtual void fallOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity, float fallDistance);
virtual void updateEntityAfterFallOn(Level *level, shared_ptr<Entity> entity);
virtual void stepOn(Level *level, int x, int y, int z, shared_ptr<Entity> entity);
};

View file

@ -5,6 +5,7 @@
ThinFenceTile::ThinFenceTile(int id, const wstring &tex, const wstring &edgeTex, Material *material, bool dropsResources) : Tile(id, material,isSolidRender())
{
setLightBlock(0);
iconSide = nullptr;
edgeTexture = edgeTex;
this->dropsResources = dropsResources;

View file

@ -34,6 +34,7 @@ Tile::SoundType *Tile::SOUND_WOOD = nullptr;
Tile::SoundType *Tile::SOUND_GRAVEL = nullptr;
Tile::SoundType *Tile::SOUND_GRASS = nullptr;
Tile::SoundType *Tile::SOUND_STONE = nullptr;
Tile::SoundType *Tile::SOUND_SLIME = nullptr;
Tile::SoundType *Tile::SOUND_METAL = nullptr;
Tile::SoundType *Tile::SOUND_GLASS = nullptr;
Tile::SoundType *Tile::SOUND_CLOTH = nullptr;
@ -68,6 +69,7 @@ Tile *Tile::sand = nullptr;
Tile *Tile::gravel = nullptr;
Tile *Tile::goldOre = nullptr;
Tile *Tile::ironOre = nullptr;
Tile *Tile::slimeBlock = nullptr;
Tile *Tile::coalOre = nullptr;
Tile *Tile::treeTrunk = nullptr;
LeafTile *Tile::leaves = nullptr;
@ -313,6 +315,7 @@ void Tile::staticCtor()
Tile::SOUND_GRAVEL = new Tile::SoundType(eMaterialSoundType_GRAVEL, 1, 1);
Tile::SOUND_GRASS = new Tile::SoundType(eMaterialSoundType_GRASS, 1, 1);
Tile::SOUND_STONE = new Tile::SoundType(eMaterialSoundType_STONE, 1, 1);
Tile::SOUND_SLIME = new Tile::SoundType(eMaterialSoundType_STONE, 1, 1, eSoundType_MOB_SLIME_BIG, eSoundType_MOB_SLIME_BIG);
Tile::SOUND_METAL = new Tile::SoundType(eMaterialSoundType_STONE, 1, 1.5f);
Tile::SOUND_GLASS = new Tile::SoundType(eMaterialSoundType_STONE, 1, 1, eSoundType_RANDOM_GLASS,eSoundType_STEP_STONE);
Tile::SOUND_CLOTH = new Tile::SoundType(eMaterialSoundType_CLOTH, 1, 1);
@ -518,6 +521,7 @@ void Tile::staticCtor()
Tile::tree2Trunk = (new TreeTile2(162))->setDestroyTime(2.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"log")->setDescriptionId(IDS_TILE_LOG)->sendTileData()->setUseDescriptionId(IDS_DESC_LOG);
Tile::woodStairsAcacia = (new StairTile(163, Tile::wood, TreeTile::ACACIA_TRUNK))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_acaciawood)->setIconName(L"stairsWoodAcacia")->setDescriptionId(IDS_TILE_STAIRS_ACACIAWOOD)->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::woodStairsDark = (new StairTile(164, Tile::wood, TreeTile::DARK_TRUNK))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_darkwood)->setIconName(L"stairsWoodDark")->setDescriptionId(IDS_TILE_STAIRS_DARKWOOD)->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS);
Tile::slimeBlock = (new SlimeTile(165))->setSoundType(SOUND_SLIME)->setIconName(L"slime")->setDescriptionId(IDS_TILE_SLIME_BLOCK)->setUseDescriptionId(IDS_DESC_SLIME_BLOCK)->disableMipmap();
Tile::barrier = (new BarrierTile(166, Material::stone, false)) ->setIndestructible()->setExplodeable(6000000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"barrier")->setDescriptionId(IDS_TILE_BARRIER)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_BARRIER);
Tile::iron_trapdoor = (new TrapDoorTile(167, Material::metal))->setBaseItemTypeAndMaterial(Item::eBaseItemType_door, Item::eMaterial_trap)->setDestroyTime(5.0f)->setSoundType(Tile::SOUND_METAL)->setIconName(L"iron_trapdoor")->setDescriptionId(IDS_TILE_IRON_TRAPDOOR)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_TRAPDOOR);
@ -1560,6 +1564,12 @@ void Tile::registerIcons(IconRegister *iconRegister)
icon = iconRegister->registerIcon(getIconName());
}
void Tile::updateEntityAfterFallOn(Level *level, shared_ptr<Entity> entity)
{
if (!entity) return;
entity->fallDistance = 0.0f;
}
wstring Tile::getTileItemIconName()
{
return L"";
@ -1846,4 +1856,5 @@ const int Tile::stairs_quartz_Id;
const int Tile::woolCarpet_Id;
const int Tile::stairs_acaciawood_Id;
const int Tile::stairs_darkwood_Id;
const int Tile::slime_Id;
#endif

View file

@ -125,6 +125,7 @@ public:
static SoundType *SOUND_GRAVEL;
static SoundType *SOUND_GRASS;
static SoundType *SOUND_STONE;
static SoundType *SOUND_SLIME;
static SoundType *SOUND_METAL;
static SoundType *SOUND_GLASS;
static SoundType *SOUND_CLOTH;
@ -175,8 +176,9 @@ public:
static const int SHAPE_HOPPER = 38;
static const int SHAPE_QUARTZ = 39;
static const int SHAPE_THIN_PANE = 40;
static const int SHAPE_SLIME = 41;
static const int SHAPE_COUNT = 41;
static const int SHAPE_COUNT = 42;
static Tile **tiles;
@ -373,7 +375,7 @@ public:
static const int stairs_acaciawood_Id = 163;
static const int stairs_darkwood_Id = 164;
//165 slimeblock
static const int slime_Id = 165;
static const int barrier_Id = 166;
static const int iron_trapdoor_Id = 167;
static const int prismarine_Id = 168;
@ -498,6 +500,7 @@ public:
static Tile *rail;
static Tile *stairs_stone;
static Tile *wallSign;
static Tile *slimeBlock;
static Tile *lever;
static Tile *pressurePlate_stone;
static Tile *door_iron;
@ -820,6 +823,7 @@ protected:
public:
virtual void registerIcons(IconRegister *iconRegister);
virtual void updateEntityAfterFallOn(Level *level, shared_ptr<Entity> entity);
virtual wstring getTileItemIconName();
// AP - added this function so we can generate the faceFlags for a block in a single fast function

View file

@ -6,6 +6,7 @@
TorchTile::TorchTile(int id) : Tile(id, Material::decoration,isSolidRender())
{
setLightBlock(0);
this->setTicking(true);
}

View file

@ -5,6 +5,7 @@
TransparentTile::TransparentTile(int id, Material *material, bool allowSame, bool isSolidRender) : Tile(id, material,isSolidRender)
{
this->allowSame = allowSame;
setLightBlock(1);
}
bool TransparentTile::isSolidRender(bool isServerLevel)

View file

@ -10,6 +10,7 @@ TrapDoorTile::TrapDoorTile(int id, Material *material) : Tile(id, material,isSol
{
float r = 0.5f;
float h = 1.0f;
setLightBlock(0);
setShape(0.5f - r, 0, 0.5f - r, 0.5f + r, h, 0.5f + r);
}

View file

@ -17,6 +17,7 @@ const unsigned int WallTile::COBBLE_NAMES[2] = { IDS_TILE_COBBLESTONE_WALL,
WallTile::WallTile(int id, Tile *baseTile) : Tile(id, baseTile->material, isSolidRender())
{
setLightBlock(0);
setDestroyTime(baseTile->destroySpeed);
setExplodeable(baseTile->explosionResistance / 3);
setSoundType(baseTile->soundType);

View file

@ -5,6 +5,7 @@
WebTile::WebTile(int id) : Tile(id, Material::web)
{
setLightBlock(0);
}

View file

@ -6,6 +6,7 @@
WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, isSolidRender() )
{
setLightBlock(0);
setShape(0, 0, 0, 1, 1 / 16.0f, 1);
setTicking(true);
updateShape(0);

View file

@ -1955,6 +1955,8 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_TILE
"${CMAKE_CURRENT_SOURCE_DIR}/SignTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/SkullTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SkullTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/SlimeTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SlimeTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/SmoothStoneBrickTile.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/SmoothStoneBrickTile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/SnowTile.cpp"

View file

@ -97,6 +97,7 @@
#include "SignTile.h"
#include "SkullTile.h"
#include "SlimeTile.h"
#include "SmoothStoneBrickTile.h"
#include "SnowTile.h"
#include "SoulSandTile.h"

View file

@ -261,7 +261,7 @@ LAUNCHER
BUILD_DIR="$SOURCE_DIR/build/windows64-clang"
mkdir -p "$BUILD_DIR"
info "LegacyEvolved LCE v$VERSION build script"
info "neoLegacy v$VERSION build script"
info "Source: $SOURCE_DIR | Type: $BUILD_TYPE"
echo ""
check_deps