This commit is contained in:
starseed12345 2026-03-14 00:34:22 +01:00
commit 7afd983c4d
46 changed files with 196 additions and 76 deletions

View file

@ -7,6 +7,6 @@ private:
static ResourceLocation ARROW_LOCATION;
public:
virtual void render(shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -10,7 +10,7 @@ class BatRenderer : public MobRenderer
public:
BatRenderer();
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected:
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);

View file

@ -10,6 +10,6 @@ private:
public:
BlazeRenderer();
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -11,6 +11,6 @@ protected:
public:
BoatRenderer();
virtual void render(shared_ptr<Entity> boat, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> boat, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -8,7 +8,7 @@ private:
public:
ChickenRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
protected:

View file

@ -9,6 +9,6 @@ private:
public:
CowRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -4,6 +4,6 @@
class DefaultRenderer : public EntityRenderer
{
public:
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob) { return nullptr; };
};

View file

@ -13,6 +13,6 @@ private:
public:
EnderCrystalRenderer();
virtual void render(shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _crystal, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -25,7 +25,7 @@ protected:
virtual void renderModel(shared_ptr<LivingEntity> _mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale);
public:
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
protected:

View file

@ -15,7 +15,7 @@ private:
public:
EndermanRenderer();
void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
void additionalRendering(shared_ptr<LivingEntity> _mob, float a);

View file

@ -295,6 +295,11 @@ void EntityRenderDispatcher::render(shared_ptr<Entity> entity, double x, double
}
}
void EntityRenderDispatcher::beginFrame()
{
shadowTileCache.clear();
}
double EntityRenderDispatcher::distanceToSqr(double x, double y, double z)
{
double xd = x - xPlayer;

View file

@ -17,6 +17,29 @@ private:
public:
static EntityRenderDispatcher *instance;
struct ShadowTileKey
{
int x, y, z;
bool operator==(const ShadowTileKey &o) const
{
return x == o.x && y == o.y && z == o.z;
}
};
struct ShadowTileKeyHash
{
size_t operator()(const ShadowTileKey &k) const
{
return ((size_t)k.x * 73856093) ^ ((size_t)k.y * 19349663) ^ ((size_t)k.z * 83492791);
}
};
struct ShadowTileValue
{
int tileid;
int brightness;
};
private:
Font *font;
@ -39,11 +62,13 @@ private:
EntityRenderDispatcher();
public:
unordered_map<ShadowTileKey, ShadowTileValue, ShadowTileKeyHash> shadowTileCache;
void beginFrame();
EntityRenderer *getRenderer(eINSTANCEOF e);
EntityRenderer *getRenderer(shared_ptr<Entity> e);
void prepare(Level *level, Textures *textures, Font *font, shared_ptr<LivingEntity> player, shared_ptr<LivingEntity> crosshairPickMob, Options *options, float a);
void render(shared_ptr<Entity> entity, float a);
void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a, bool bItemFrame = false, bool bRenderPlayerShadow = true);
void render(const shared_ptr<Entity> entity, float a);
void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a, bool bItemFrame = false, bool bRenderPlayerShadow = true);
void setLevel(Level *level);
double distanceToSqr(double x, double y, double z);
Font *getFont();

View file

@ -202,18 +202,26 @@ void EntityRenderer::renderShadow(shared_ptr<Entity> e, double x, double y, doub
double xo = x - ex;
double yo = y - ey;
double zo = z - ez;
auto &cache = entityRenderDispatcher->shadowTileCache;
Tesselator *tt = Tesselator::getInstance();
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)
{
EntityRenderDispatcher::ShadowTileKey key = { xt, yt, zt };
auto it = cache.find(key);
if (it == cache.end())
{
renderTileShadow(Tile::tiles[t], x, y + e->getShadowHeightOffs() + fYLocalPlayerShadowOffset, z, xt, yt , zt, pow, r, xo, yo + e->getShadowHeightOffs() + fYLocalPlayerShadowOffset, zo);
}
EntityRenderDispatcher::ShadowTileValue val;
val.tileid = level->getTile(xt, yt - 1, zt);
val.brightness = (val.tileid > 0) ? level->getRawBrightness(xt, yt, zt) : 0;
it = cache.emplace(key, val).first;
}
if (it->second.tileid > 0 && it->second.brightness > 3)
{
renderTileShadow(Tile::tiles[it->second.tileid], x, y + e->getShadowHeightOffs() + fYLocalPlayerShadowOffset, z, xt, yt, zt, pow, r, xo, yo + e->getShadowHeightOffs() + fYLocalPlayerShadowOffset, zo);
}
}
tt->end();

View file

@ -42,7 +42,7 @@ public:
EntityRenderer(); // 4J - added
virtual ~EntityRenderer();
public:
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a) = 0;
virtual void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a) = 0;
protected:
virtual void bindTexture(shared_ptr<Entity> entity);
virtual void bindTexture(ResourceLocation *location);
@ -61,7 +61,7 @@ public:
static void renderFlat(AABB *bb);
static void renderFlat(float x0, float y0, float z0, float x1, float y1, float z1);
virtual void init(EntityRenderDispatcher *entityRenderDispatcher);
virtual void postRender(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a, bool bRenderPlayerShadow);
virtual void postRender(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a, bool bRenderPlayerShadow);
virtual Font *getFont();
virtual void registerTerrainTextures(IconRegister *iconRegister);

View file

@ -9,7 +9,7 @@ private:
public:
ExperienceOrbRenderer();
virtual void render(shared_ptr<Entity> _orb, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _orb, double x, double y, double z, float rot, float a);
void blit(int x, int y, int sx, int sy, int w, int h);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);

View file

@ -9,6 +9,6 @@ private:
public:
FallingTileRenderer();
virtual void render(shared_ptr<Entity> _tile, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _tile, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -9,7 +9,7 @@ private:
public:
FireballRenderer(float scale);
virtual void render(shared_ptr<Entity> _fireball, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _fireball, double x, double y, double z, float rot, float a);
private:
// 4J Added override

View file

@ -7,6 +7,6 @@ private:
static ResourceLocation PARTICLE_LOCATION;
public:
virtual void render(shared_ptr<Entity> _hook, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _hook, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -30,7 +30,7 @@ public:
protected:
virtual void createArmorParts();
virtual int prepareArmor(shared_ptr<LivingEntity> _mob, int layer, float a);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
virtual void prepareCarriedItem(shared_ptr<Entity> mob, shared_ptr<ItemInstance> item);
virtual void additionalRendering(shared_ptr<LivingEntity> mob, float a);

View file

@ -9,7 +9,7 @@ private:
public:
void registerTerrainTextures(IconRegister *iconRegister);
virtual void render(shared_ptr<Entity> _itemframe, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _itemframe, double x, double y, double z, float rot, float a);
private:
void drawFrame(shared_ptr<ItemFrame> itemFrame);

View file

@ -11,7 +11,7 @@ private:
public:
ItemSpriteRenderer(Item *sourceItem, int sourceItemAuxValue = 0);
//ItemSpriteRenderer(Item *icon);
virtual void render(shared_ptr<Entity> e, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> e, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
private:

View file

@ -12,7 +12,7 @@ private:
public:
LeashKnotRenderer();
~LeashKnotRenderer();
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
protected:
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);

View file

@ -540,6 +540,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a)
TileEntityRenderDispatcher::xOff = (player->xOld + (player->x - player->xOld) * a);
TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a);
TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a);
EntityRenderDispatcher::instance->beginFrame();
mc->gameRenderer->turnOnLightLayer(a); // 4J - brought forward from 1.8.2

View file

@ -4,5 +4,5 @@
class LightningBoltRenderer : public EntityRenderer
{
public:
virtual void render(shared_ptr<Entity> bolt, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> bolt, double x, double y, double z, float rot, float a);
};

View file

@ -20,7 +20,7 @@ protected:
public:
LivingEntityRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void setArmor(Model *armor);
private:

View file

@ -14,7 +14,7 @@ protected:
public:
MinecartRenderer();
virtual void render(shared_ptr<Entity> _cart, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _cart, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
protected:

View file

@ -13,7 +13,7 @@ class MobRenderer : public LivingEntityRenderer
{
public:
MobRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
protected:
virtual bool shouldShowName(shared_ptr<LivingEntity> mob);

View file

@ -9,7 +9,7 @@ private:
public:
MushroomCowRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected:
virtual void additionalRendering(shared_ptr<LivingEntity> _mob, float a);

View file

@ -11,7 +11,7 @@ private:
public:
OcelotRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected:
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);

View file

@ -12,7 +12,7 @@ private:
public:
PaintingRenderer(); // 4J -added
virtual void render(shared_ptr<Entity> _painting, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _painting, double x, double y, double z, float rot, float a);
private:
void renderPainting(shared_ptr<Painting> painting, int w, int h, int uo, int vo);

View file

@ -14,6 +14,6 @@ protected:
virtual int prepareArmor(shared_ptr<LivingEntity> _pig, int layer, float a);
public:
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -30,7 +30,7 @@ protected:
virtual void prepareSecondPassArmor(shared_ptr<LivingEntity> mob, int layer, float a);
public:
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
protected:
virtual void additionalRendering(shared_ptr<LivingEntity> _mob, float a);

View file

@ -14,6 +14,6 @@ protected:
virtual int prepareArmor(shared_ptr<LivingEntity> _sheep, int layer, float a);
public:
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -16,7 +16,7 @@ protected:
float getFlipDegrees(shared_ptr<LivingEntity> spider);
public:
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
protected:

View file

@ -8,7 +8,7 @@ private:
public:
SquidRenderer(Model *model, float shadow);
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
protected:
virtual void setupRotations(shared_ptr<LivingEntity> _mob, float bob, float bodyRot, float a);

View file

@ -8,6 +8,6 @@ private:
public:
TntRenderer();
virtual void render(shared_ptr<Entity> _tnt, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _tnt, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
};

View file

@ -12,7 +12,7 @@ private:
public:
VillagerGolemRenderer();
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> mob);
protected:

View file

@ -18,7 +18,7 @@ protected:
public:
VillagerRenderer();
virtual void render(shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> _mob);
protected:

View file

@ -11,7 +11,7 @@ private:
public:
WitchRenderer();
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
protected:
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);

View file

@ -14,7 +14,7 @@ private:
public:
WitherBossRenderer();
virtual void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);
protected:

View file

@ -13,7 +13,7 @@ private:
public:
WitherSkullRenderer();
void render(shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
void render(const shared_ptr<Entity> entity, double x, double y, double z, float rot, float a);
ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);
private:

View file

@ -31,7 +31,7 @@ protected:
virtual int prepareArmor(shared_ptr<LivingEntity> _mob, int layer, float a);
public:
virtual void render(shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual void render(const shared_ptr<Entity> _mob, double x, double y, double z, float rot, float a);
virtual ResourceLocation *getTextureLocation(shared_ptr<Entity> entity);
protected:

View file

@ -46,11 +46,13 @@ bool ButtonTile::isCubeShaped()
bool ButtonTile::mayPlace(Level *level, int x, int y, int z, int face)
{
if (face == 0 && level->isSolidBlockingTile(x, y + 1, z)) return true; // STARSEED- support for ceiling button placement
if (face == 1 && level->isSolidBlockingTile(x, y - 1, z)) return true; // STARSEED- support for floor button placement
if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) return true;
if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) return true;
if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) return true;
if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) return true;
return false;
return false;
}
bool ButtonTile::mayPlace(Level *level, int x, int y, int z)
@ -71,23 +73,67 @@ bool ButtonTile::mayPlace(Level *level, int x, int y, int z)
{
return true;
}
if (level->isSolidBlockingTile(x, y - 1, z))
{
return true; // STARSEED- floor
}
if (level->isSolidBlockingTile(x, y + 1, z))
{
return true; // STARSEED- ceiling
}
return false;
}
shared_ptr<Player> ButtonTile::lastPlayer;
int ButtonTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue)
{
int dir = level->getData(x, y, z);
int dir = level->getData(x, y, z);
int oldFlip = dir & 8;
dir &= 7;
int oldFlip = dir & 8;
dir &= 7;
if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) dir = 4;
else if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) dir = 3;
else if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) dir = 2;
else if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) dir = 1;
else dir = findFace(level, x, y, z);
if (face == 0 && level->isSolidBlockingTile(x, y + 1, z))
{
int rot = 0;
return dir + oldFlip;
if (lastPlayer)
{
rot = (int)(lastPlayer->yRot * 4.0f / 360.0f + 0.5f) & 3;
}
if (rot == 0 || rot == 2)
{
dir = 0; // ceiling northsouth
}
else
{
dir = 7; // ceiling eastwest
}
}
else if (face == 1 && level->isSolidBlockingTile(x, y - 1, z))
{
int rot = 0;
if (lastPlayer)
{
rot = (int)(lastPlayer->yRot * 4.0f / 360.0f + 0.5f) & 3;
}
if (rot == 0 || rot == 2)
{
dir = 5; // floor northsouth
}
else
{
dir = 6; // floor eastwest
}
}
else if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) dir = 4;
else if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) dir = 3;
else if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) dir = 2;
else if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) dir = 1;
else dir = findFace(level, x, y, z);
return dir + oldFlip;
}
int ButtonTile::findFace(Level *level, int x, int y, int z)
@ -108,6 +154,14 @@ int ButtonTile::findFace(Level *level, int x, int y, int z)
{
return 4;
}
if (level->isSolidBlockingTile(x, y - 1, z)) //STARSEED- floor/ceiling
{
return 5;
}
if (level->isSolidBlockingTile(x, y + 1, z)) // STARSEED- floor/ceiling
{
return 0;
}
return 1;
}
@ -122,6 +176,9 @@ void ButtonTile::neighborChanged(Level *level, int x, int y, int z, int type)
if (!level->isSolidBlockingTile(x + 1, y, z) && dir == 2) replace = true;
if (!level->isSolidBlockingTile(x, y, z - 1) && dir == 3) replace = true;
if (!level->isSolidBlockingTile(x, y, z + 1) && dir == 4) replace = true;
if (!level->isSolidBlockingTile(x, y - 1, z) && dir == 5) replace = true; // STARSEED- support for floor/ceiling
if (!level->isSolidBlockingTile(x, y + 1, z) && dir == 0) replace = true; // STARSEED- support for floor/ceiling
if (replace)
{
@ -175,6 +232,22 @@ void ButtonTile::updateShape(int data)
{
setShape(0.5f - r, h0, 1 - d, 0.5f + r, h1, 1);
}
else if (dir == 5) // STARSEED- bounding box for floor and correct shape
{
setShape(0.5f - r, 0, 0.5f - (h1 - h0) / 2, 0.5f + r, d, 0.5f + (h1 - h0) / 2);
}
else if (dir == 6) // STARSEED- rotated floor
{
setShape(0.5f - (h1 - h0) / 2, 0, 0.5f - r, 0.5f + (h1 - h0) / 2, d, 0.5f + r);
}
else if (dir == 0) // STARSEED- bounding box for ceiling and correct shape
{
setShape(0.5f - r, 1 - d, 0.5f - (h1 - h0) / 2, 0.5f + r, 1, 0.5f + (h1 - h0) / 2);
}
else if (dir == 7) // STARSEED- rotated ceiling
{
setShape(0.5f - (h1 - h0) / 2, 1 - d, 0.5f - r, 0.5f + (h1 - h0) / 2, 1, 0.5f + r);
}
}
void ButtonTile::attack(Level *level, int x, int y, int z, shared_ptr<Player> player)
@ -240,6 +313,8 @@ int ButtonTile::getDirectSignal(LevelSource *level, int x, int y, int z, int dir
if (myDir == 3 && dir == 3) return Redstone::SIGNAL_MAX;
if (myDir == 2 && dir == 4) return Redstone::SIGNAL_MAX;
if (myDir == 1 && dir == 5) return Redstone::SIGNAL_MAX;
if (myDir == 5 && dir == 0) return Redstone::SIGNAL_MAX; // STARSEED- floor
if (myDir == 0 && dir == 1) return Redstone::SIGNAL_MAX; // STARSEED- ceiling
return false;
}
@ -350,10 +425,14 @@ void ButtonTile::updateNeighbours(Level *level, int x, int y, int z, int dir)
{
level->updateNeighborsAt(x, y, z + 1, id);
}
else
{
level->updateNeighborsAt(x, y - 1, z, id);
}
else if (dir == 5) // STARSEED- floor
{
level->updateNeighborsAt(x, y - 1, z, id);
}
else if (dir == 0) // STARSEED- ceiling
{
level->updateNeighborsAt(x, y + 1, z, id);
}
}
bool ButtonTile::shouldTileTick(Level *level, int x,int y,int z)

View file

@ -17,6 +17,7 @@ protected:
ButtonTile(int id, bool sensitive);
public:
static shared_ptr<Player> lastPlayer;
Icon *getTexture(int face, int data);
virtual AABB *getAABB(Level *level, int x, int y, int z);
virtual int getTickDelay(Level *level);

View file

@ -40,6 +40,7 @@ PathfinderMob::~PathfinderMob()
void PathfinderMob::serverAiStep()
{
auto self = shared_from_this();
if (fleeTime > 0)
{
if (--fleeTime == 0)
@ -56,14 +57,14 @@ void PathfinderMob::serverAiStep()
attackTarget = findAttackTarget();
if (attackTarget != nullptr)
{
setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true)); // 4J - changed to setPath from path =
setPath(level->findPath(self, attackTarget, maxDist, true, false, false, true)); // 4J - changed to setPath from path =
}
}
else
{
if (attackTarget->isAlive())
{
float d = attackTarget->distanceTo(shared_from_this());
float d = attackTarget->distanceTo(self);
if (canSee(attackTarget))
{
checkHurtTarget(attackTarget, d);
@ -86,7 +87,7 @@ void PathfinderMob::serverAiStep()
if (!holdGround && (attackTarget != nullptr && (path == nullptr || random->nextInt(20) == 0)))
{
setPath(level->findPath(shared_from_this(), attackTarget, maxDist, true, false, false, true));// 4J - changed to setPath from path =
setPath(level->findPath(self, attackTarget, maxDist, true, false, false, true));// 4J - changed to setPath from path =
}
else if (!holdGround && ((path == nullptr && (random->nextInt(180) == 0) || fleeTime > 0) || (random->nextInt(120) == 0 || fleeTime > 0)))
{
@ -111,18 +112,17 @@ void PathfinderMob::serverAiStep()
considerForExtraWandering( isDespawnProtected() );
int yFloor = Mth::floor(bb->y0 + 0.5f);
xRot = 0;
if (path == nullptr || random->nextInt(100) == 0)
{
this->Mob::serverAiStep();
setPath(nullptr); // 4J - changed to setPath from path =
return;
}
bool inWater = isInWater();
bool inLava = isInLava();
xRot = 0;
if (path == nullptr || random->nextInt(100) == 0)
{
this->Mob::serverAiStep();
setPath(nullptr);// 4J - changed to setPath from path =
return;
}
Vec3 *target = path->currentPos(shared_from_this());
Vec3 *target = path->currentPos(self);
double r = bbWidth * 2;
while (target != nullptr && target->distanceToSqr(x, target->y, z) < r * r)
{
@ -132,7 +132,7 @@ void PathfinderMob::serverAiStep()
target = nullptr;
setPath(nullptr); // 4J - changed to setPath from path =
}
else target = path->currentPos(shared_from_this());
else target = path->currentPos(self);
}
jumping = false;
@ -221,7 +221,7 @@ void PathfinderMob::findRandomStrollLocation(int quadrant/*=-1*/) // 4J - added
}
if (hasBest)
{
setPath(level->findPath(shared_from_this(), xBest, yBest, zBest, 10, true, false, false, true)); // 4J - changed to setPath from path =
setPath(level->findPath(shared_from_this(), xBest, yBest, zBest, 10, true, false, false, true)); // 4J - changed to setPath from path =
}
}

View file

@ -82,6 +82,7 @@ bool TileItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> playe
Tile *tile = Tile::tiles[tileId];
// 4J - Adding this from 1.6
int itemValue = getLevelDataForAuxValue(instance->getAuxValue());
ButtonTile::lastPlayer = player; // STARSEED- used for retrieving player rotation
int dataValue = Tile::tiles[tileId]->getPlacedOnFaceDataValue(level, x, y, z, face, clickX, clickY, clickZ, itemValue);
if (level->setTileAndData(x, y, z, tileId, dataValue, Tile::UPDATE_ALL))
{