mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
CPU Overhead Optimization,Pathfinding and Entity Optimizations
- Cache shared_from_this() in serverAiStep - Reduce shared_ptr overhead in entities - Add shadow tile cache to optimize entity shadow rendering
This commit is contained in:
parent
bda3b1078a
commit
41b734ebdb
|
|
@ -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);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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; };
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue