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 97a4399472.

* 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 <lokirautio@gmail.com>
This commit is contained in:
daoge
2026-03-03 03:04:10 +08:00
committed by GitHub
parent 84c31a2331
commit b3feddfef3
2069 changed files with 264842 additions and 139522 deletions

View File

@@ -1,14 +1,13 @@
#include "stdafx.h"
#include "net.minecraft.h"
#include "net.minecraft.world.level.redstone.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.tile.h"
#include "net.minecraft.world.item.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.h"
#include "DiodeTile.h"
const double DiodeTile::DELAY_RENDER_OFFSETS[4] = { -1.0f / 16.0f, 1.0f / 16.0f, 3.0f / 16.0f, 5.0f / 16.0f };
const int DiodeTile::DELAYS[4] = { 1, 2, 3, 4 };
DiodeTile::DiodeTile(int id, bool on) : DirectionalTile(id, Material::decoration,isSolidRender())
{
this->on = on;
@@ -47,20 +46,22 @@ bool DiodeTile::canSurvive(Level *level, int x, int y, int z)
void DiodeTile::tick(Level *level, int x, int y, int z, Random *random)
{
int data = level->getData(x, y, z);
bool sourceOn = getSourceSignal(level, x, y, z, data);
if (on && !sourceOn)
if (!isLocked(level, x, y, z, data))
{
level->setTileAndData(x, y, z, Tile::diode_off_Id, data);
}
else if (!on)
{
// when off-diodes are ticked, they always turn on for one tick and
// then off again if necessary
level->setTileAndData(x, y, z, Tile::diode_on_Id, data);
if (!sourceOn)
bool sourceOn = shouldTurnOn(level, x, y, z, data);
if (on && !sourceOn)
{
int delay = (data & DELAY_MASK) >> DELAY_SHIFT;
level->addToTickNextTick(x, y, z, Tile::diode_on_Id, DELAYS[delay] * 2);
level->setTileAndData(x, y, z, getOffTile()->id, data, Tile::UPDATE_CLIENTS);
}
else if (!on)
{
// when off-diodes are ticked, they always turn on for one tick and
// then off again if necessary
level->setTileAndData(x, y, z, getOnTile()->id, data, Tile::UPDATE_CLIENTS);
if (!sourceOn)
{
level->addToTickNextTick(x, y, z, getOnTile()->id, getTurnOffDelay(data), -1);
}
}
}
}
@@ -72,9 +73,9 @@ Icon *DiodeTile::getTexture(int face, int data)
{
if (on)
{
return Tile::notGate_on->getTexture(face);
return Tile::redstoneTorch_on->getTexture(face);
}
return Tile::notGate_off->getTexture(face);
return Tile::redstoneTorch_off->getTexture(face);
}
if (face == Facing::UP)
{
@@ -84,11 +85,6 @@ Icon *DiodeTile::getTexture(int face, int data)
return Tile::stoneSlab->getTexture(Facing::UP);
}
void DiodeTile::registerIcons(IconRegister *iconRegister)
{
icon = iconRegister->registerIcon(on ? L"repeater_lit" : L"repeater");
}
bool DiodeTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
{
if (face == Facing::DOWN || face == Facing::UP)
@@ -104,26 +100,32 @@ int DiodeTile::getRenderShape()
return SHAPE_DIODE;
}
bool DiodeTile::getDirectSignal(Level *level, int x, int y, int z, int dir)
bool DiodeTile::isOn(int data)
{
return on;
}
int DiodeTile::getDirectSignal(LevelSource *level, int x, int y, int z, int dir)
{
return getSignal(level, x, y, z, dir);
}
bool DiodeTile::getSignal(LevelSource *level, int x, int y, int z, int facing)
int DiodeTile::getSignal(LevelSource *level, int x, int y, int z, int facing)
{
if (!on)
int data = level->getData(x, y, z);
if (!isOn(data))
{
return false;
return Redstone::SIGNAL_NONE;
}
int dir = getDirection(level->getData(x, y, z));
int dir = getDirection(data);
if (dir == Direction::SOUTH && facing == Facing::SOUTH) return true;
if (dir == Direction::WEST && facing == Facing::WEST) return true;
if (dir == Direction::NORTH && facing == Facing::NORTH) return true;
if (dir == Direction::EAST && facing == Facing::EAST) return true;
if (dir == Direction::SOUTH && facing == Facing::SOUTH) return getOutputSignal(level, x, y, z, data);
if (dir == Direction::WEST && facing == Facing::WEST) return getOutputSignal(level, x, y, z, data);
if (dir == Direction::NORTH && facing == Facing::NORTH) return getOutputSignal(level, x, y, z, data);
if (dir == Direction::EAST && facing == Facing::EAST) return getOutputSignal(level, x, y, z, data);
return false;
return Redstone::SIGNAL_NONE;
}
void DiodeTile::neighborChanged(Level *level, int x, int y, int z, int type)
@@ -131,7 +133,7 @@ void DiodeTile::neighborChanged(Level *level, int x, int y, int z, int type)
if (!canSurvive(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);
level->updateNeighborsAt(x + 1, y, z, id);
level->updateNeighborsAt(x - 1, y, z, id);
level->updateNeighborsAt(x, y, z + 1, id);
@@ -141,49 +143,91 @@ void DiodeTile::neighborChanged(Level *level, int x, int y, int z, int type)
return;
}
checkTickOnNeighbor(level, x, y, z, type);
}
void DiodeTile::checkTickOnNeighbor(Level *level, int x, int y, int z, int type)
{
int data = level->getData(x, y, z);
bool sourceOn = getSourceSignal(level, x, y, z, data);
int delay = (data & DELAY_MASK) >> DELAY_SHIFT;
if ( (on && !sourceOn) || (!on && sourceOn))
if (!isLocked(level, x, y, z, data))
{
level->addToTickNextTick(x, y, z, id, DELAYS[delay] * 2);
bool sourceOn = shouldTurnOn(level, x, y, z, data);
if ((on && !sourceOn || !on && sourceOn) && !level->isTileToBeTickedAt(x, y, z, id))
{
int prio = -1;
// if the tile in front is a repeater, we prioritize this update
if (shouldPrioritize(level, x, y, z, data))
{
prio = -3;
}
else if (on)
{
prio = -2;
}
level->addToTickNextTick(x, y, z, id, getTurnOnDelay(data), prio);
}
}
}
bool DiodeTile::getSourceSignal(Level *level, int x, int y, int z, int data)
bool DiodeTile::isLocked(LevelSource *level, int x, int y, int z, int data)
{
int dir = getDirection(data);
switch (dir)
{
case Direction::SOUTH:
return level->getSignal(x, y, z + 1, Facing::SOUTH) || (level->getTile(x, y, z + 1) == Tile::redStoneDust_Id && level->getData(x, y, z + 1) > 0);
case Direction::NORTH:
return level->getSignal(x, y, z - 1, Facing::NORTH) || (level->getTile(x, y, z - 1) == Tile::redStoneDust_Id && level->getData(x, y, z - 1) > 0);
case Direction::EAST:
return level->getSignal(x + 1, y, z, Facing::EAST) || (level->getTile(x + 1, y, z) == Tile::redStoneDust_Id && level->getData(x + 1, y, z) > 0);
case Direction::WEST:
return level->getSignal(x - 1, y, z, Facing::WEST) || (level->getTile(x - 1, y, z) == Tile::redStoneDust_Id && level->getData(x - 1, y, z) > 0);
}
return false;
}
// 4J-PB - Adding a TestUse for tooltip display
bool DiodeTile::TestUse()
bool DiodeTile::shouldTurnOn(Level *level, int x, int y, int z, int data)
{
return true;
return getInputSignal(level, x, y, z, data) > Redstone::SIGNAL_NONE;
}
bool DiodeTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
int DiodeTile::getInputSignal(Level *level, int x, int y, int z, int data)
{
if( soundOnly) return false;
int dir = getDirection(data);
int data = level->getData(x, y, z);
int delay = (data & DELAY_MASK) >> DELAY_SHIFT;
delay = ((delay + 1) << DELAY_SHIFT) & DELAY_MASK;
int xx = x + Direction::STEP_X[dir];
int zz = z + Direction::STEP_Z[dir];
int input = level->getSignal(xx, y, zz, Direction::DIRECTION_FACING[dir]);
level->setData(x, y, z, delay | (data & DIRECTION_MASK));
return true;
if (input >= Redstone::SIGNAL_MAX) return input;
return max(input, level->getTile(xx, y, zz) == Tile::redStoneDust_Id ? level->getData(xx, y, zz) : Redstone::SIGNAL_NONE);
}
int DiodeTile::getAlternateSignal(LevelSource *level, int x, int y, int z, int data)
{
int dir = getDirection(data);
switch (dir)
{
case Direction::SOUTH:
case Direction::NORTH:
return max(getAlternateSignalAt(level, x - 1, y, z, Facing::WEST), getAlternateSignalAt(level, x + 1, y, z, Facing::EAST));
case Direction::EAST:
case Direction::WEST:
return max(getAlternateSignalAt(level, x, y, z + 1, Facing::SOUTH), getAlternateSignalAt(level, x, y, z - 1, Facing::NORTH));
}
return Redstone::SIGNAL_NONE;
}
int DiodeTile::getAlternateSignalAt(LevelSource *level, int x, int y, int z, int facing)
{
int tile = level->getTile(x, y, z);
if (isAlternateInput(tile))
{
if (tile == Tile::redStoneDust_Id)
{
return level->getData(x, y, z);
}
else
{
return level->getDirectSignal(x, y, z, facing);
}
}
return Redstone::SIGNAL_NONE;
}
bool DiodeTile::isSignalSource()
@@ -191,12 +235,12 @@ bool DiodeTile::isSignalSource()
return true;
}
void DiodeTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Mob> by)
void DiodeTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
{
int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4;
level->setData(x, y, z, dir);
level->setData(x, y, z, dir, Tile::UPDATE_ALL);
bool sourceOn = getSourceSignal(level, x, y, z, dir);
bool sourceOn = shouldTurnOn(level, x, y, z, dir);
if (sourceOn)
{
level->addToTickNextTick(x, y, z, id, 1);
@@ -205,17 +249,37 @@ void DiodeTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<Mob> b
void DiodeTile::onPlace(Level *level, int x, int y, int z)
{
level->updateNeighborsAt(x + 1, y, z, id);
level->updateNeighborsAt(x - 1, y, z, id);
level->updateNeighborsAt(x, y, z + 1, id);
level->updateNeighborsAt(x, y, z - 1, id);
level->updateNeighborsAt(x, y - 1, z, id);
level->updateNeighborsAt(x, y + 1, z, id);
updateNeighborsInFront(level, x, y, z);
}
void DiodeTile::updateNeighborsInFront(Level *level, int x, int y, int z)
{
int dir = getDirection(level->getData(x, y, z));
if (dir == Direction::WEST)
{
level->neighborChanged(x + 1, y, z, id);
level->updateNeighborsAtExceptFromFacing(x + 1, y, z, id, Facing::WEST);
}
if (dir == Direction::EAST)
{
level->neighborChanged(x - 1, y, z, id);
level->updateNeighborsAtExceptFromFacing(x - 1, y, z, id, Facing::EAST);
}
if (dir == Direction::NORTH)
{
level->neighborChanged(x, y, z + 1, id);
level->updateNeighborsAtExceptFromFacing(x, y, z + 1, id, Facing::NORTH);
}
if (dir == Direction::SOUTH)
{
level->neighborChanged(x, y, z - 1, id);
level->updateNeighborsAtExceptFromFacing(x, y, z - 1, id, Facing::SOUTH);
}
}
void DiodeTile::destroy(Level *level, int x, int y, int z, int data)
{
if (on)
if (on)
{
level->updateNeighborsAt(x + 1, y, z, id);
level->updateNeighborsAt(x - 1, y, z, id);
@@ -224,7 +288,7 @@ void DiodeTile::destroy(Level *level, int x, int y, int z, int data)
level->updateNeighborsAt(x, y - 1, z, id);
level->updateNeighborsAt(x, y + 1, z, id);
}
Tile::destroy(level, x, y, z, data);
Tile::destroy(level, x, y, z, data);
}
bool DiodeTile::isSolidRender(bool isServerLevel)
@@ -232,68 +296,45 @@ bool DiodeTile::isSolidRender(bool isServerLevel)
return false;
}
int DiodeTile::getResource(int data, Random *random, int playerBonusLevel)
bool DiodeTile::isAlternateInput(int tile)
{
return Item::diode->id;
Tile *tt = Tile::tiles[tile];
return tt != NULL && tt->isSignalSource();
}
void DiodeTile::animateTick(Level *level, int xt, int yt, int zt, Random *random)
int DiodeTile::getOutputSignal(LevelSource *level, int x, int y, int z, int data)
{
return Redstone::SIGNAL_MAX;
}
bool DiodeTile::isDiode(int id)
{
return Tile::diode_off->isSameDiode(id) || Tile::comparator_off->isSameDiode(id);
}
bool DiodeTile::isSameDiode(int id)
{
return id == getOnTile()->id || id == getOffTile()->id;
}
bool DiodeTile::shouldPrioritize(Level *level, int x, int y, int z, int data)
{
if (!on) return;
int data = level->getData(xt, yt, zt);
int dir = getDirection(data);
double x = xt + 0.5f + (random->nextFloat() - 0.5f) * 0.2;
double y = yt + 0.4f + (random->nextFloat() - 0.5f) * 0.2;
double z = zt + 0.5f + (random->nextFloat() - 0.5f) * 0.2;
double xo = 0;
double zo = 0;
if (random->nextInt(2) == 0)
if (isDiode(level->getTile(x - Direction::STEP_X[dir], y, z - Direction::STEP_Z[dir])))
{
// spawn on receiver
switch (dir)
{
case Direction::SOUTH:
zo = -5.0f / 16.0f;
break;
case Direction::NORTH:
zo = 5.0f / 16.0f;
break;
case Direction::EAST:
xo = -5.0f / 16.0f;
break;
case Direction::WEST:
xo = 5.0f / 16.0f;
break;
}
int odata = level->getData(x - Direction::STEP_X[dir], y, z - Direction::STEP_Z[dir]);
int odir = getDirection(odata);
return odir != dir;
}
else
{
// spawn on transmitter
int delay = (data & DELAY_MASK) >> DELAY_SHIFT;
switch (dir)
{
case Direction::SOUTH:
zo = DiodeTile::DELAY_RENDER_OFFSETS[delay];
break;
case Direction::NORTH:
zo = -DiodeTile::DELAY_RENDER_OFFSETS[delay];
break;
case Direction::EAST:
xo = DiodeTile::DELAY_RENDER_OFFSETS[delay];
break;
case Direction::WEST:
xo = -DiodeTile::DELAY_RENDER_OFFSETS[delay];
break;
}
}
level->addParticle(eParticleType_reddust, x + xo, y, z + zo, 0, 0, 0);
return false;
}
int DiodeTile::cloneTileId(Level *level, int x, int y, int z)
int DiodeTile::getTurnOffDelay(int data)
{
return Item::diode_Id;
return getTurnOnDelay(data);
}
bool DiodeTile::isMatching(int id)
{
return isSameDiode(id);
}