mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 15:03:32 +00:00
Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -29,6 +29,7 @@ Mob::Mob(Level* level)
|
||||
invulnerableDuration(20),
|
||||
//hasHair(false),
|
||||
textureName("mob/char.png"),
|
||||
capeTextureName(""),
|
||||
allowAlpha(true),
|
||||
modelName(""),
|
||||
bobStrength(1),
|
||||
@@ -82,6 +83,15 @@ Mob::Mob(Level* level)
|
||||
yRot = (float) (Mth::random() * Mth::PI * 2);
|
||||
|
||||
this->footSize = 0.5f;
|
||||
|
||||
// Initialize cape inertia positions
|
||||
xCape = x;
|
||||
yCape = y;
|
||||
zCape = z;
|
||||
|
||||
xc = xCape;
|
||||
yc = yCape;
|
||||
zc = zCape;
|
||||
}
|
||||
|
||||
Mob::~Mob() {
|
||||
@@ -110,6 +120,21 @@ std::string Mob::getTexture()
|
||||
return textureName;
|
||||
}
|
||||
|
||||
void Mob::setTextureName(const std::string& name)
|
||||
{
|
||||
textureName = name;
|
||||
}
|
||||
|
||||
std::string Mob::getCapeTexture()
|
||||
{
|
||||
return capeTextureName;
|
||||
}
|
||||
|
||||
void Mob::setCapeTextureName(const std::string& name)
|
||||
{
|
||||
capeTextureName = name;
|
||||
}
|
||||
|
||||
bool Mob::isPickable()
|
||||
{
|
||||
return !removed;
|
||||
@@ -269,6 +294,10 @@ void Mob::superTick()
|
||||
|
||||
void Mob::tick()
|
||||
{
|
||||
xc = xCape;
|
||||
yc = yCape;
|
||||
zc = zCape;
|
||||
|
||||
super::tick();
|
||||
|
||||
if (arrowCount > 0) {
|
||||
@@ -373,6 +402,18 @@ void Mob::tick()
|
||||
while (xRot - xRotO >= 180)
|
||||
xRotO += 360;
|
||||
animStep += walkSpeed;
|
||||
|
||||
// Reduce jitter by using a smaller interpolation factor (more lag, smoother motion)
|
||||
double dxCape = x - xCape;
|
||||
double dyCape = y - yCape;
|
||||
double dzCape = z - zCape;
|
||||
|
||||
const double interp = 0.15; // small value for smoother cape motion
|
||||
const double interpY = 0.12; // extra smoothing on vertical movement
|
||||
|
||||
xCape += dxCape * interp;
|
||||
yCape += dyCape * interpY;
|
||||
zCape += dzCape * interp;
|
||||
}
|
||||
|
||||
void Mob::setSize( float w, float h )
|
||||
|
||||
@@ -42,10 +42,16 @@ public:
|
||||
|
||||
virtual void spawnAnim();
|
||||
virtual std::string getTexture();
|
||||
virtual void setTextureName(const std::string& name);
|
||||
|
||||
virtual bool isAlive();
|
||||
// Optional player cape texture (non-null on clients when available)
|
||||
virtual std::string getCapeTexture();
|
||||
virtual void setCapeTextureName(const std::string& name);
|
||||
|
||||
virtual bool isAlive();
|
||||
virtual bool isPickable();
|
||||
virtual bool isPushable();
|
||||
|
||||
virtual bool isShootable();
|
||||
|
||||
MoveControl* getMoveControl();
|
||||
@@ -212,7 +218,22 @@ protected:
|
||||
float walkingSpeed;
|
||||
float flyingSpeed;
|
||||
|
||||
// Cape inertia positions
|
||||
double xCape, yCape, zCape;
|
||||
double xc, yc, zc;
|
||||
|
||||
public:
|
||||
// Cape position accessors (for renderers)
|
||||
double getCapeX() const { return xCape; }
|
||||
double getCapeY() const { return yCape; }
|
||||
double getCapeZ() const { return zCape; }
|
||||
|
||||
double getCapePrevX() const { return xc; }
|
||||
double getCapePrevY() const { return yc; }
|
||||
double getCapePrevZ() const { return zc; }
|
||||
|
||||
std::string textureName;
|
||||
std::string capeTextureName;
|
||||
std::string modelName;
|
||||
int deathScore;
|
||||
float oRun, run;
|
||||
|
||||
@@ -255,16 +255,16 @@ void Inventory::setupDefault() {
|
||||
} else {
|
||||
#if defined(WIN32)
|
||||
// Survival
|
||||
addItem(new ItemInstance(Item::ironIngot, 64));
|
||||
addItem(new ItemInstance(Item::ironIngot, 34));
|
||||
addItem(new ItemInstance(Tile::stonecutterBench));
|
||||
addItem(new ItemInstance(Tile::workBench));
|
||||
addItem(new ItemInstance(Tile::furnace));
|
||||
addItem(new ItemInstance(Tile::wood, 54));
|
||||
addItem(new ItemInstance(Item::stick, 14));
|
||||
addItem(new ItemInstance(Item::coal, 31));
|
||||
addItem(new ItemInstance(Tile::sand, 6));
|
||||
addItem(new ItemInstance(Item::dye_powder, 23, DyePowderItem::PURPLE));
|
||||
// addItem(new ItemInstance(Item::ironIngot, 64));
|
||||
// addItem(new ItemInstance(Item::ironIngot, 34));
|
||||
// addItem(new ItemInstance(Tile::stonecutterBench));
|
||||
// addItem(new ItemInstance(Tile::workBench));
|
||||
// addItem(new ItemInstance(Tile::furnace));
|
||||
// addItem(new ItemInstance(Tile::wood, 54));
|
||||
// addItem(new ItemInstance(Item::stick, 14));
|
||||
// addItem(new ItemInstance(Item::coal, 31));
|
||||
// addItem(new ItemInstance(Tile::sand, 6));
|
||||
// addItem(new ItemInstance(Item::dye_powder, 23, DyePowderItem::PURPLE));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,13 +14,14 @@ namespace GameType {
|
||||
class LevelSettings
|
||||
{
|
||||
public:
|
||||
LevelSettings(long seed, int gameType)
|
||||
LevelSettings(long seed, int gameType, bool allowCheats = false)
|
||||
: seed(seed),
|
||||
gameType(gameType)
|
||||
gameType(gameType),
|
||||
allowCheats(allowCheats)
|
||||
{
|
||||
}
|
||||
static LevelSettings None() {
|
||||
return LevelSettings(-1,-1);
|
||||
return LevelSettings(-1,-1,false);
|
||||
}
|
||||
|
||||
long getSeed() const {
|
||||
@@ -31,6 +32,10 @@ public:
|
||||
return gameType;
|
||||
}
|
||||
|
||||
bool getAllowCheats() const {
|
||||
return allowCheats;
|
||||
}
|
||||
|
||||
//
|
||||
// Those two should actually not be here
|
||||
// @todo: Move out when we add LevelSettings.cpp :p
|
||||
@@ -53,6 +58,7 @@ public:
|
||||
private:
|
||||
const long seed;
|
||||
const int gameType;
|
||||
const bool allowCheats;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL__LevelSettings_H__*/
|
||||
|
||||
@@ -287,53 +287,58 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) {
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
// Coal: common, wide Y range, moderate vein size
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(128);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::coalOre->id, 16);
|
||||
feature.place(level, &random, x, y, z);
|
||||
OreFeature feature(Tile::coalOre->id, 14);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
// Iron: common, limited to upper underground
|
||||
for (int i = 0; i < 14; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(64);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::ironOre->id, 8);
|
||||
feature.place(level, &random, x, y, z);
|
||||
OreFeature feature(Tile::ironOre->id, 10);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
// Gold: rarer and deeper
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(32);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::goldOre->id, 8);
|
||||
feature.place(level, &random, x, y, z);
|
||||
OreFeature feature(Tile::goldOre->id, 9);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
// Redstone: somewhat common at low depths
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(16);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::redStoneOre->id, 7);
|
||||
feature.place(level, &random, x, y, z);
|
||||
OreFeature feature(Tile::redStoneOre->id, 8);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
// Emerald (diamond-equivalent): still rare but slightly more than vanilla
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(16);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::emeraldOre->id, 7);
|
||||
feature.place(level, &random, x, y, z);
|
||||
OreFeature feature(Tile::emeraldOre->id, 6);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
// lapis ore
|
||||
// Lapis: rare and not in very high Y
|
||||
for (int i = 0; i < 1; i++) {
|
||||
int x = xo + random.nextInt(16);
|
||||
int y = random.nextInt(16) + random.nextInt(16);
|
||||
int z = zo + random.nextInt(16);
|
||||
OreFeature feature(Tile::lapisOre->id, 6);
|
||||
feature.place(level, &random, x, y, z);
|
||||
feature.place(level, &random, x, y, z);
|
||||
}
|
||||
|
||||
const float ss = 0.5f;
|
||||
@@ -504,7 +509,8 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) {
|
||||
prepareHeights(xOffs, zOffs, blocks, 0, temperatures);//biomes, temperatures);
|
||||
buildSurfaces(xOffs, zOffs, blocks, biomes);
|
||||
|
||||
//caveFeature.apply(this, level, xOffs, zOffs, blocks, LevelChunk::ChunkBlockCount);
|
||||
// Carve caves into the chunk
|
||||
caveFeature.apply(this, level, xOffs, zOffs, blocks, LevelChunk::ChunkBlockCount);
|
||||
levelChunk->recalcHeightmap();
|
||||
|
||||
return levelChunk;
|
||||
|
||||
@@ -12,8 +12,8 @@ LevelData::LevelData()
|
||||
dimension(Dimension::NORMAL),
|
||||
playerDataVersion(-1),
|
||||
storageVersion(0),
|
||||
gameType(GameType::Default),
|
||||
loadedPlayerTag(NULL)
|
||||
gameType(GameType::Default), spawnMobs(false),
|
||||
allowCheats(false), loadedPlayerTag(NULL)
|
||||
{
|
||||
//LOGI("ctor 1: %p\n", this);
|
||||
spawnMobs = (gameType == GameType::Survival);
|
||||
@@ -21,8 +21,7 @@ LevelData::LevelData()
|
||||
|
||||
LevelData::LevelData( const LevelSettings& settings, const std::string& levelName, int generatorVersion /*= -1*/ )
|
||||
: seed(settings.getSeed()),
|
||||
gameType(settings.getGameType()),
|
||||
levelName(levelName),
|
||||
gameType(settings.getGameType()), allowCheats(settings.getAllowCheats()), levelName(levelName),
|
||||
xSpawn(128),
|
||||
ySpawn(64),
|
||||
zSpawn(128),
|
||||
@@ -62,6 +61,7 @@ LevelData::LevelData( const LevelData& rhs )
|
||||
playerDataVersion(rhs.playerDataVersion),
|
||||
generatorVersion(rhs.generatorVersion),
|
||||
spawnMobs(rhs.spawnMobs),
|
||||
allowCheats(rhs.allowCheats),
|
||||
loadedPlayerTag(NULL),
|
||||
playerData(rhs.playerData)
|
||||
{
|
||||
@@ -84,6 +84,7 @@ LevelData& LevelData::operator=( const LevelData& rhs )
|
||||
time = rhs.time;
|
||||
dimension = rhs.dimension;
|
||||
spawnMobs = rhs.spawnMobs;
|
||||
allowCheats = rhs.allowCheats;
|
||||
playerData = rhs.playerData;
|
||||
playerDataVersion = rhs.playerDataVersion;
|
||||
generatorVersion = rhs.generatorVersion;
|
||||
@@ -161,6 +162,7 @@ void LevelData::setTagData( CompoundTag* tag, CompoundTag* playerTag )
|
||||
if (!tag) return;
|
||||
tag->putLong("RandomSeed", seed);
|
||||
tag->putInt("GameType", gameType);
|
||||
tag->putBoolean("AllowCommands", allowCheats);
|
||||
tag->putInt("SpawnX", xSpawn);
|
||||
tag->putInt("SpawnY", ySpawn);
|
||||
tag->putInt("SpawnZ", zSpawn);
|
||||
@@ -181,6 +183,7 @@ void LevelData::getTagData( const CompoundTag* tag )
|
||||
if (!tag) return;
|
||||
seed = (long)tag->getLong("RandomSeed");
|
||||
gameType = tag->getInt("GameType");
|
||||
allowCheats = tag->getBoolean("AllowCommands");
|
||||
xSpawn = tag->getInt("SpawnX");
|
||||
ySpawn = tag->getInt("SpawnY");
|
||||
zSpawn = tag->getInt("SpawnZ");
|
||||
@@ -362,3 +365,13 @@ void LevelData::setSpawnMobs( bool doSpawn )
|
||||
{
|
||||
spawnMobs = doSpawn;
|
||||
}
|
||||
|
||||
bool LevelData::getAllowCheats() const
|
||||
{
|
||||
return allowCheats;
|
||||
}
|
||||
|
||||
void LevelData::setAllowCheats( bool allow )
|
||||
{
|
||||
allowCheats = allow;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
bool getSpawnMobs() const;
|
||||
void setSpawnMobs(bool doSpawn);
|
||||
|
||||
bool getAllowCheats() const;
|
||||
void setAllowCheats(bool allow);
|
||||
|
||||
public:
|
||||
PlayerData playerData;
|
||||
int playerDataVersion;
|
||||
@@ -89,6 +92,7 @@ private:
|
||||
int gameType;
|
||||
int storageVersion;
|
||||
bool spawnMobs;
|
||||
bool allowCheats;
|
||||
//@note: This version is never written or loaded to disk. The only purpose
|
||||
// is to use it in the level generator on server and clients.
|
||||
int generatorVersion;
|
||||
|
||||
@@ -165,7 +165,8 @@ void DoorTile::neighborChanged(Level* level, int x, int y, int z, int type) {
|
||||
}
|
||||
if (spawn) {
|
||||
if (!level->isClientSide) {
|
||||
spawnResources(level, x, y, z, data, 0);
|
||||
// use default chance (1.0) so the drop always occurs
|
||||
spawnResources(level, x, y, z, data);
|
||||
}
|
||||
} else {
|
||||
bool signal = level->hasNeighborSignal(x, y, z) || level->hasNeighborSignal(x, y + 1, z);
|
||||
@@ -174,13 +175,12 @@ void DoorTile::neighborChanged(Level* level, int x, int y, int z, int type) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// upper half: removal should not drop a second door. the
|
||||
// lower half neighbour handler takes care of spawning the item
|
||||
// whenever the door is broken from either end.
|
||||
if (level->getTile(x, y - 1, z) != id) {
|
||||
level->setTile(x, y, z, 0);
|
||||
if(material == Material::metal) {
|
||||
popResource(level, x, y, z, ItemInstance(Item::door_iron));
|
||||
} else {
|
||||
popResource(level, x, y, z, ItemInstance(Item::door_wood));
|
||||
}
|
||||
// no resource spawn here
|
||||
}
|
||||
if (type > 0 && type != id) {
|
||||
neighborChanged(level, x, y - 1, z, type);
|
||||
@@ -189,7 +189,11 @@ void DoorTile::neighborChanged(Level* level, int x, int y, int z, int type) {
|
||||
}
|
||||
|
||||
int DoorTile::getResource(int data, Random* random) {
|
||||
if ((data & 8) != 0) return 0;
|
||||
// only the lower half should return a resource ID; the upper half
|
||||
// itself never drops anything and playerDestroy suppresses spawning
|
||||
// from the top. This prevents duplicate drops if the bottom half is
|
||||
// mined.
|
||||
if ((data & UPPER_BIT) != 0) return 0;
|
||||
if (material == Material::metal) return Item::door_iron->id;
|
||||
return Item::door_wood->id;
|
||||
}
|
||||
@@ -199,6 +203,14 @@ HitResult DoorTile::clip(Level* level, int xt, int yt, int zt, const Vec3& a, co
|
||||
return super::clip(level, xt, yt, zt, a, b);
|
||||
}
|
||||
|
||||
// override to prevent double-dropping when top half is directly mined
|
||||
void DoorTile::playerDestroy(Level* level, Player* player, int x, int y, int z, int data) {
|
||||
if ((data & UPPER_BIT) == 0) {
|
||||
// only let the lower half handle the actual spawning
|
||||
super::playerDestroy(level, player, x, y, z, data);
|
||||
}
|
||||
}
|
||||
|
||||
int DoorTile::getDir(LevelSource* level, int x, int y, int z) {
|
||||
return getCompositeData(level, x, y, z) & C_DIR_MASK;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public:
|
||||
|
||||
int getResource(int data, Random* random);
|
||||
|
||||
// override to avoid duplicate drops when upper half is mined directly
|
||||
void playerDestroy(Level* level, Player* player, int x, int y, int z, int data) override;
|
||||
|
||||
HitResult clip(Level* level, int xt, int yt, int zt, const Vec3& a, const Vec3& b);
|
||||
|
||||
int getDir(LevelSource* level, int x, int y, int z);
|
||||
|
||||
Reference in New Issue
Block a user