From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: feat: TU19 (Dec 2014) Features & Content (#155) * try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki --- Minecraft.World/FallingTile.cpp | 57 +++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) (limited to 'Minecraft.World/FallingTile.cpp') diff --git a/Minecraft.World/FallingTile.cpp b/Minecraft.World/FallingTile.cpp index 254631ff..28248014 100644 --- a/Minecraft.World/FallingTile.cpp +++ b/Minecraft.World/FallingTile.cpp @@ -24,6 +24,7 @@ void FallingTile::_init() hurtEntities = false; fallDamageMax = 40; fallDamageAmount = 2; + tileData = NULL; // 4J Added so that client-side falling tiles can fall through blocks // This fixes a bug on the host where the tile update from the server comes in before the client-side falling tile @@ -62,6 +63,11 @@ FallingTile::FallingTile(Level *level, double x, double y, double z, int tile, i zOld = z; } +FallingTile::~FallingTile() +{ + delete tileData; +} + bool FallingTile::makeStepSound() { return false; @@ -105,7 +111,7 @@ void FallingTile::tick() { if (level->getTile(xt, yt, zt) == tile) { - level->setTile(xt, yt, zt, 0); + level->removeTile(xt, yt, zt); } else { @@ -120,17 +126,36 @@ void FallingTile::tick() zd *= 0.7f; yd *= -0.5f; - // if (HeavyTile.isFree(level, xt, yt, zt)) { if (level->getTile(xt, yt, zt) != Tile::pistonMovingPiece_Id) { remove(); - if (!cancelDrop && level->mayPlace(tile, xt, yt, zt, true, 1, nullptr) && !HeavyTile::isFree(level, xt, yt - 1, zt) && level->setTileAndData(xt, yt, zt, tile, data)) + if (!cancelDrop && level->mayPlace(tile, xt, yt, zt, true, 1, nullptr, nullptr) && !HeavyTile::isFree(level, xt, yt - 1, zt) && level->setTileAndData(xt, yt, zt, tile, data, Tile::UPDATE_ALL)) { HeavyTile *hv = dynamic_cast(Tile::tiles[tile]); if (hv) { hv->onLand(level, xt, yt, zt, data); } + if (tileData != NULL && Tile::tiles[tile]->isEntityTile()) + { + shared_ptr tileEntity = level->getTileEntity(xt, yt, zt); + + if (tileEntity != NULL) + { + CompoundTag *swap = new CompoundTag(); + tileEntity->save(swap); + vector *allTags = tileData->getAllTags(); + for(AUTO_VAR(it, allTags->begin()); it != allTags->end(); ++it) + { + Tag *tag = *it; + if (tag->getName().compare(L"x") == 0 || tag->getName().compare(L"y") == 0 || tag->getName().compare(L"z") == 0) continue; + swap->put(tag->getName(), tag->copy()); + } + delete allTags; + tileEntity->load(swap); + tileEntity->setChanged(); + } + } } else { @@ -140,7 +165,7 @@ void FallingTile::tick() } else if ( (time > 20 * 5 && !level->isClientSide && (yt < 1 || yt > Level::maxBuildHeight)) || (time > 20 * 30)) { - if(dropItem) spawnAtLocation(tile, 1); + if(dropItem) spawnAtLocation( shared_ptr( new ItemInstance(tile, 1, Tile::tiles[tile]->getSpawnResourcesAuxValue(data) )), 0); remove(); } } @@ -153,14 +178,16 @@ void FallingTile::causeFallDamage(float distance) int dmg = Mth::ceil(distance - 1); if (dmg > 0) { - vector > *entities = level->getEntities(shared_from_this(), bb); + // 4J: Copy vector since it might be modified when we hurt the entities (invalidating our iterator) + vector > *entities = new vector >(*level->getEntities(shared_from_this(), bb)); DamageSource *source = tile == Tile::anvil_Id ? DamageSource::anvil : DamageSource::fallingBlock; - //for (Entity entity : entities) - for(AUTO_VAR(it,entities->begin()); it != entities->end(); ++it) + for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) { (*it)->hurt(source, min(Mth::floor(dmg * fallDamageAmount), fallDamageMax)); } + delete entities; + if (tile == Tile::anvil_Id && random->nextFloat() < 0.05f + (dmg * 0.05)) { int damage = data >> 2; @@ -182,17 +209,26 @@ void FallingTile::causeFallDamage(float distance) void FallingTile::addAdditonalSaveData(CompoundTag *tag) { tag->putByte(L"Tile", (byte) tile); + tag->putInt(L"TileID", tile); tag->putByte(L"Data", (byte) data); tag->putByte(L"Time", (byte) time); tag->putBoolean(L"DropItem", dropItem); tag->putBoolean(L"HurtEntities", hurtEntities); tag->putFloat(L"FallHurtAmount", fallDamageAmount); tag->putInt(L"FallHurtMax", fallDamageMax); + if (tileData != NULL) tag->putCompound(L"TileEntityData", tileData); } void FallingTile::readAdditionalSaveData(CompoundTag *tag) { - tile = tag->getByte(L"Tile") & 0xff; + if (tag->contains(L"TileID")) + { + tile = tag->getInt(L"TileID"); + } + else + { + tile = tag->getByte(L"Tile") & 0xff; + } data = tag->getByte(L"Data") & 0xff; time = tag->getByte(L"Time") & 0xff; @@ -212,6 +248,11 @@ void FallingTile::readAdditionalSaveData(CompoundTag *tag) dropItem = tag->getBoolean(L"DropItem"); } + if (tag->contains(L"TileEntityData")) + { + tileData = tag->getCompound(L"TileEntityData"); + } + if (tile == 0) { tile = Tile::sand_Id; -- cgit v1.2.3