TU19: merge Minecraft.World/Blocks

This commit is contained in:
Tropical
2026-03-21 15:52:50 -05:00
parent f25cd66f4d
commit 9b6046cb83
242 changed files with 8083 additions and 4657 deletions

View File

@@ -2,6 +2,7 @@
#include "../Headers/net.minecraft.h"
#include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.level.redstone.h"
#include "TripWireSourceTile.h"
TripWireSourceTile::TripWireSourceTile(int id)
@@ -93,8 +94,8 @@ void TripWireSourceTile::neighborChanged(Level* level, int x, int y, int z,
replace = true;
if (replace) {
this->spawnResources(level, x, y, z, data, 0);
level->setTile(x, y, z, 0);
spawnResources(level, x, y, z, data, 0);
level->removeTile(x, y, z);
}
}
}
@@ -170,7 +171,7 @@ void TripWireSourceTile::calculateState(
int xx = x + stepX * receiverPos;
int zz = z + stepZ * receiverPos;
int opposite = Direction::DIRECTION_OPPOSITE[dir];
level->setData(xx, y, zz, opposite | state);
level->setData(xx, y, zz, opposite | state, Tile::UPDATE_ALL);
notifyNeighbors(level, xx, y, zz, opposite);
playSound(level, xx, y, zz, attached, powered, wasAttached, wasPowered);
@@ -180,7 +181,7 @@ void TripWireSourceTile::calculateState(
if (id > 0) // ie. it isn't being removed.
{
level->setData(x, y, z, data);
level->setData(x, y, z, data, Tile::UPDATE_ALL);
if (canUpdate) notifyNeighbors(level, x, y, z, dir);
}
@@ -197,7 +198,7 @@ void TripWireSourceTile::calculateState(
wireData &= ~TripWireTile::MASK_ATTACHED;
}
level->setData(xx, y, zz, wireData);
level->setData(xx, y, zz, wireData, Tile::UPDATE_ALL);
}
}
}
@@ -228,23 +229,23 @@ void TripWireSourceTile::playSound(Level* level, int x, int y, int z,
void TripWireSourceTile::notifyNeighbors(Level* level, int x, int y, int z,
int dir) {
level->updateNeighborsAt(x, y, z, this->id);
level->updateNeighborsAt(x, y, z, id);
if (dir == Direction::EAST) {
level->updateNeighborsAt(x - 1, y, z, this->id);
level->updateNeighborsAt(x - 1, y, z, id);
} else if (dir == Direction::WEST) {
level->updateNeighborsAt(x + 1, y, z, this->id);
level->updateNeighborsAt(x + 1, y, z, id);
} else if (dir == Direction::SOUTH) {
level->updateNeighborsAt(x, y, z - 1, this->id);
level->updateNeighborsAt(x, y, z - 1, id);
} else if (dir == Direction::NORTH) {
level->updateNeighborsAt(x, y, z + 1, this->id);
level->updateNeighborsAt(x, y, z + 1, id);
}
}
bool TripWireSourceTile::checkCanSurvive(Level* level, int x, int y, int z) {
if (!mayPlace(level, x, y, z)) {
this->spawnResources(level, x, y, z, level->getData(x, y, z), 0);
level->setTile(x, y, z, 0);
level->removeTile(x, y, z);
return false;
}
@@ -296,23 +297,29 @@ void TripWireSourceTile::onRemove(Level* level, int x, int y, int z, int id,
Tile::onRemove(level, x, y, z, id, data);
}
bool TripWireSourceTile::getSignal(LevelSource* level, int x, int y, int z,
int dir) {
return (level->getData(x, y, z) & MASK_POWERED) == MASK_POWERED;
int TripWireSourceTile::getSignal(LevelSource* level, int x, int y, int z,
int dir) {
return (level->getData(x, y, z) & MASK_POWERED) == MASK_POWERED
? Redstone::SIGNAL_MAX
: Redstone::SIGNAL_NONE;
}
bool TripWireSourceTile::getDirectSignal(Level* level, int x, int y, int z,
int dir) {
int TripWireSourceTile::getDirectSignal(LevelSource* level, int x, int y, int z,
int dir) {
int data = level->getData(x, y, z);
if ((data & MASK_POWERED) != MASK_POWERED) return false;
if ((data & MASK_POWERED) != MASK_POWERED) return Redstone::SIGNAL_NONE;
int myDir = data & MASK_DIR;
if (myDir == Direction::NORTH && dir == Facing::NORTH) return true;
if (myDir == Direction::SOUTH && dir == Facing::SOUTH) return true;
if (myDir == Direction::WEST && dir == Facing::WEST) return true;
if (myDir == Direction::EAST && dir == Facing::EAST) return true;
if (myDir == Direction::NORTH && dir == Facing::NORTH)
return Redstone::SIGNAL_MAX;
if (myDir == Direction::SOUTH && dir == Facing::SOUTH)
return Redstone::SIGNAL_MAX;
if (myDir == Direction::WEST && dir == Facing::WEST)
return Redstone::SIGNAL_MAX;
if (myDir == Direction::EAST && dir == Facing::EAST)
return Redstone::SIGNAL_MAX;
return false;
return Redstone::SIGNAL_NONE;
}
bool TripWireSourceTile::isSignalSource() { return true; }