Files
neoLegacy/Minecraft.World/Dimension.cpp
T
Tranqlmao 9abd52985e TU53 + Bug Fixes (Many)
Patch Notes:
Blocks
+ Colored shulker boxes
+ Concrete powder
+ Concrete
+ Glazed terracotta
Items
+ Shulker shell
+ Iron nugget
UI Changes
+ Added Custom Controls to Keyboard & Mouse, as well as Controller
+ Added Custom SuperFlat
+ Added Edit Server Menu
+ Added Firework Crafting
Feature Changes
+ Host Options
+ Added Pick Block
+ Added off-hand slot for maps and arrows.
Bug Fixes & changes
+ TU47: Banner hitbox wrong (and inventory model fixed)
+ TU47/48: Ice not melting properly
+ TU48: Dead bushes not dropping sticks
+ TU48: Guardians and polar bears not dropping cooked fish when on fire
+ TU48: Bonus chest missing saplings and seeds
+ TU48: Frosted ice obtainable
+ TU48: Hoppers not collecting items
+ TU48: Wither skeletons spawning in 2-high gaps
+ TU48: End crystals exploding with “TNT Explodes” off
+ TU48: Tamed ocelots staying hostile
+ TU48: Signs not placing on tall grass
+ TU51: Skeleton hitbox wrong
+ TU53: Fall damage in shallow water
+ TU53: Squids not spawning in man-made pools
+ Elytra has been improved to be more accurate to the source material
+ Removed Spectral Arrow from crafting
+ Fixed several broken item descriptions
+ You can no longer cook Pufferfish or Clownfish
+ Fixed scaling issue with paperdoll and chat
+ Iron and gold armor can now be smelted into nuggets.
+ More items can now be used as fuel in a furnace.
+ Using a firework rocket while gliding with elytra will now give the player a boost.
+ Changed the color of dyes, wool, carpets, and banners.
+ Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items.
+ Fishing rods can now hook on entities without causing knockback or pseudo-damage.
+ Fixed banner crafting
+ Fixed Map colors for certain blocks
+ Fixed Path block height
+ Fixed String block issues
+ Fixed Item frame culling.
+ Fixed Tutorial world NBT/Block State issues
+ Fixed World Slider
+ Fixed Enderman AI
+ Fixed Player animation bug
+ HUD Flash text changes
+ Generation accuracy changes
+ Many other small accuracy changes and fixes
2026-11-24 13:44:06 -05:00

265 lines
6.6 KiB
C++

#include "stdafx.h"
#include "net.minecraft.world.level.levelgen.flat.h"
#include "net.minecraft.world.level.levelgen.h"
#include "net.minecraft.world.level.h"
#include "net.minecraft.world.level.storage.h"
#include "Dimension.h"
#include "BiomeSource.h"
#include "FixedBiomeSource.h"
#include "OldChunkStorage.h"
#include "HellDimension.h"
#include "NormalDimension.h"
#include "TheEndDimension.h"
#include "net.minecraft.world.level.tile.h"
#include "../Minecraft.Client/Minecraft.h"
#include "../Minecraft.Client/Common/Colours/ColourTable.h"
const float Dimension::MOON_BRIGHTNESS_PER_PHASE[8] = {1.0f, 0.75f, 0.5f, 0.25f, 0, 0.25f, 0.5f, 0.75f};
void Dimension::init(Level *level)
{
this->level = level;
levelType = level->getLevelData()->getGenerator();
levelTypeOptions = level->getLevelData()->getGeneratorOptions();
init();
updateLightRamp();
}
void Dimension::updateLightRamp()
{
float ambientLight = 0.00f;
for (int i = 0; i <= Level::MAX_BRIGHTNESS; i++)
{
float v = (1 - i / static_cast<float>(Level::MAX_BRIGHTNESS));
brightnessRamp[i] = ((1 - v) / (v * 3 + 1)) * (1 - ambientLight) + ambientLight;
}
}
void Dimension::init()
{
#ifdef _OVERRIDE_HEIGHTMAP
// 4J Stu - Added to enable overriding the heightmap from a loaded in data file
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_EnableBiomeOverride))
{
biomeSource = new BiomeSource(level);
}
else
#endif
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat)
{
FlatGeneratorInfo generator = FlatGeneratorInfo::fromValue(level->getLevelData()->getGeneratorOptions());
Biome *flatBiome = Biome::biomes[generator.getBiome()];
if (flatBiome == nullptr)
flatBiome = Biome::plains;
biomeSource = new FixedBiomeSource(flatBiome, flatBiome->temperature, flatBiome->downfall);
}
else
{
biomeSource = new BiomeSource(level);
}
}
Dimension::Dimension()
{
ultraWarm = false;
hasCeiling = false;
brightnessRamp = new float[Level::MAX_BRIGHTNESS + 1];
id = 0;
levelTypeOptions = L"";
}
Dimension::~Dimension()
{
delete[] brightnessRamp;
if(biomeSource != nullptr)
delete biomeSource;
}
ChunkSource *Dimension::createRandomLevelSource() const
{
#ifdef _OVERRIDE_HEIGHTMAP
// 4J Stu - Added to enable overriding the heightmap from a loaded in data file
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_EnableHeightWaterOverride))
{
return new CustomLevelSource(level, level->getSeed(), level->getLevelData()->isGenerateMapFeatures());
}
else
#endif
if (levelType == LevelType::lvl_flat)
{
return new FlatLevelSource(level, level->getSeed(), level->getLevelData()->isGenerateMapFeatures());
}
else
{
return new RandomLevelSource(level, level->getSeed(), level->getLevelData()->isGenerateMapFeatures());
}
}
ChunkSource *Dimension::createFlatLevelSource() const
{
return new FlatLevelSource(level, level->getSeed(), level->getLevelData()->isGenerateMapFeatures());
}
ChunkStorage *Dimension::createStorage(File dir)
{
return new OldChunkStorage(dir, true);
}
bool Dimension::isValidSpawn(int x, int z) const
{
int topTile = level->getTopTile(x, z);
if (topTile != Tile::grass_Id) return false;
return true;
}
float Dimension::getTimeOfDay(int64_t time, float a) const
{
int dayStep = static_cast<int>(time % Level::TICKS_PER_DAY);
float td = (dayStep + a) / Level::TICKS_PER_DAY - 0.25f;
if (td < 0) td += 1;
if (td > 1) td -= 1;
float tdo = td;
td = 1 - (float) ((cos(td * PI) + 1) / 2);
td = tdo + (td - tdo) / 3.0f;
return td;
}
int Dimension::getMoonPhase(int64_t time) const
{
return static_cast<int>(time / Level::TICKS_PER_DAY) % 8;
}
bool Dimension::isNaturalDimension()
{
return true;
}
float *Dimension::getSunriseColor(float td, float a)
{
unsigned int clr1 = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Sky_Dawn_Dark ); // 0xB23333
double r1 = ( (clr1>>16)&0xFF )/255.0f, g1 = ( (clr1>>8)&0xFF )/255.0, b1 = ( clr1&0xFF )/255.0;
unsigned int clr2 = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Sky_Dawn_Bright ); // 0xFFE533
double r2 = ( (clr2>>16)&0xFF )/255.0f, g2 = ( (clr2>>8)&0xFF )/255.0, b2 = ( clr2&0xFF )/255.0;
float span = 0.4f;
float tt = Mth::cos(td * PI * 2) - 0.0f;
float mid = -0.0f;
if (tt >= mid - span && tt <= mid + span)
{
float aa = ((tt - mid) / span) * 0.5f + 0.5f;
float mix = 1 - (((1 - sin(aa * PI))) * 0.99f);
mix = mix * mix;
//sunriseCol[0] = (aa * 0.3f + 0.7f);
//sunriseCol[1] = (aa * aa * 0.7f + 0.2f);
//sunriseCol[2] = (aa * aa * 0.0f + 0.2f);
sunriseCol[0] = (aa * (r2-r1) + r1);
sunriseCol[1] = (aa * (g2-g1) + g1);
sunriseCol[2] = (aa * (b2-b1) + b1);
sunriseCol[3] = mix;
return sunriseCol;
}
return nullptr;
}
Vec3 *Dimension::getFogColor(float td, float a) const
{
float br = Mth::cos(td * PI * 2) * 2 + 0.5f;
if (br < 0.0f) br = 0.0f;
if (br > 1.0f) br = 1.0f;
unsigned int baseFogColour = 0x808080; // Gray default
Minecraft* pMc = Minecraft::GetInstance();
if (pMc && pMc->getColourTable())
{
baseFogColour = pMc->getColourTable()->getColor(eMinecraftColour_Default_Fog_Colour);
}
float r = ((baseFogColour >> 16) & 0xff) / 255.0f;
float g = ((baseFogColour >> 8) & 0xff) / 255.0f;
float b = ((baseFogColour) & 0xff) / 255.0f;
r *= br * 0.94f + 0.06f;
g *= br * 0.94f + 0.06f;
b *= br * 0.91f + 0.09f;
return Vec3::newTemp(r, g, b);
}
bool Dimension::mayRespawn() const
{
return true;
}
Dimension *Dimension::getNew(int id)
{
if (id == -1) return new HellDimension();
if (id == 0) return new NormalDimension();
if (id == 1) return new TheEndDimension();
return nullptr;
}
float Dimension::getCloudHeight()
{
return static_cast<float>(Level::genDepth);
}
bool Dimension::hasGround()
{
return true;
}
Pos *Dimension::getSpawnPos()
{
return nullptr;
}
int Dimension::getSpawnYPosition()
{
if (levelType == LevelType::lvl_flat)
{
return 4;
}
return Level::genDepth / 2;
}
bool Dimension::hasBedrockFog()
{
// 4J-PB - turn off bedrock fog if the host player doesn't want it
if(app.GetGameHostOption(eGameHostOption_BedrockFog)==0)
{
return false;
}
return (levelType != LevelType::lvl_flat && !hasCeiling);
}
double Dimension::getClearColorScale()
{
if (levelType == LevelType::lvl_flat)
{
return 1.0;
}
return 1.0 / 32.0;
}
bool Dimension::isFoggyAt(int x, int z)
{
return false;
}
int Dimension::getXZSize()
{
return level->getLevelData()->getXZSize();
}
bool Dimension::isOutsideWorldEdge(int x, int z)
{
int maxxz = ( getXZSize() * 16 ) / 2;
int minxz = -maxxz;
return ( x < minxz ) || ( x >= maxxz ) || ( z < minxz ) || ( z >= maxxz );
}