mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/LegacyNetherFork.git
synced 2026-05-22 00:09:57 +00:00
Add files via upload
This commit is contained in:
@@ -1,339 +1,349 @@
|
||||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
#include "net.minecraft.world.level.levelgen.feature.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "HerobrineFeature.h"
|
||||
|
||||
BiomeDecorator::BiomeDecorator(Biome *biome)
|
||||
{
|
||||
_init();
|
||||
|
||||
// 4J inits
|
||||
level = NULL;
|
||||
random = NULL;
|
||||
xo = 0;
|
||||
zo = 0;
|
||||
|
||||
this->biome = biome;
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
|
||||
{
|
||||
if (this->level != NULL)
|
||||
{
|
||||
app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n");
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
__debugbreak();
|
||||
//throw new RuntimeException("Already decorating!!");
|
||||
#endif
|
||||
}
|
||||
this->level = level;
|
||||
this->random = random;
|
||||
this->xo = xo;
|
||||
this->zo = zo;
|
||||
|
||||
decorate();
|
||||
|
||||
this->level = NULL;
|
||||
this->random = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BiomeDecorator::_init()
|
||||
{
|
||||
clayFeature = new ClayFeature(4);
|
||||
sandFeature = new SandFeature(7, Tile::sand_Id);
|
||||
gravelFeature = new SandFeature(6, Tile::gravel_Id);
|
||||
dirtOreFeature = new OreFeature(Tile::dirt_Id, 32);
|
||||
gravelOreFeature = new OreFeature(Tile::gravel_Id, 32);
|
||||
coalOreFeature = new OreFeature(Tile::coalOre_Id, 16);
|
||||
ironOreFeature = new OreFeature(Tile::ironOre_Id, 11);
|
||||
goldOreFeature = new OreFeature(Tile::goldOre_Id, 8);
|
||||
redStoneOreFeature = new OreFeature(Tile::redStoneOre_Id, 7);
|
||||
diamondOreFeature = new OreFeature(Tile::diamondOre_Id, 7);
|
||||
lapisOreFeature = new OreFeature(Tile::lapisOre_Id, 6);
|
||||
yellowFlowerFeature = new FlowerFeature(Tile::flower_Id);
|
||||
roseFlowerFeature = new FlowerFeature(Tile::rose_Id);
|
||||
brownMushroomFeature = new FlowerFeature(Tile::mushroom_brown_Id);
|
||||
redMushroomFeature = new FlowerFeature(Tile::mushroom_red_Id);
|
||||
hugeMushroomFeature = new HugeMushroomFeature();
|
||||
reedsFeature = new ReedsFeature();
|
||||
cactusFeature = new CactusFeature();
|
||||
waterlilyFeature = new WaterlilyFeature();
|
||||
|
||||
herobrineFeature = new HerobrineFeature(Tile::goldBlock_Id);
|
||||
|
||||
waterlilyCount = 0;
|
||||
treeCount = 0;
|
||||
flowerCount = 2;
|
||||
grassCount = 1;
|
||||
deadBushCount = 0;
|
||||
mushroomCount = 0;
|
||||
reedsCount = 0;
|
||||
cactusCount = 0;
|
||||
gravelCount = 1;
|
||||
sandCount = 3;
|
||||
clayCount = 1;
|
||||
hugeMushrooms = 0;
|
||||
liquids = true;
|
||||
}
|
||||
|
||||
|
||||
void BiomeDecorator::decorate()
|
||||
{
|
||||
PIXBeginNamedEvent(0,"Decorate ores");
|
||||
decorateOres();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Decorate sand/clay/gravel");
|
||||
for (int i = 0; i < sandCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < clayCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
clayFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gravelCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0, "Decorate forests");
|
||||
int forests = treeCount;
|
||||
if (random->nextInt(10) == 0) forests += 1;
|
||||
|
||||
for (int i = 0; i < forests; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
Feature *tree = biome->getTreeFeature(random);
|
||||
tree->init(1, 1, 1);
|
||||
tree->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
delete tree;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Decorate mushrooms/flowers/grass");
|
||||
for (int i = 0; i < hugeMushrooms; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
hugeMushroomFeature->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < flowerCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
yellowFlowerFeature->place(level, random, x, y, z);
|
||||
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
x = xo + random->nextInt(16) + 8;
|
||||
y = random->nextInt(Level::genDepth);
|
||||
z = zo + random->nextInt(16) + 8;
|
||||
roseFlowerFeature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < grassCount; i++)
|
||||
{
|
||||
//int grassType = TallGrass::TALL_GRASS;
|
||||
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
MemSect(50);
|
||||
Feature *grassFeature = biome->getGrassFeature(random);
|
||||
MemSect(0);
|
||||
grassFeature->place(level, random, x, y, z);
|
||||
delete grassFeature;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Decorate bush/waterlily/mushroom/reeds/pumpkins/cactuses");
|
||||
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
// I assume there is a case where deadBushCount could be 0
|
||||
DeadBushFeature *deadBushFeature = NULL;
|
||||
if(deadBushCount > 0) deadBushFeature = new DeadBushFeature(Tile::deadBush_Id);
|
||||
for (int i = 0; i < deadBushCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
//new DeadBushFeature(Tile::deadBush_Id)->place(level, random, x, y, z);
|
||||
deadBushFeature->place(level, random, x, y, z);
|
||||
}
|
||||
if(deadBushFeature != NULL)delete deadBushFeature;
|
||||
|
||||
for (int i = 0; i < waterlilyCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
while (y > 0 && level->getTile(x, y - 1, z) == 0)
|
||||
y--;
|
||||
waterlilyFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < mushroomCount; i++)
|
||||
{
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = level->getHeightmap(x, z);
|
||||
brownMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(8) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
redMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
brownMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(8) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
redMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < reedsCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
reedsFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
reedsFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(32) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
PumpkinFeature *pumpkinFeature = new PumpkinFeature();
|
||||
pumpkinFeature->place(level, random, x, y, z);
|
||||
delete pumpkinFeature;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cactusCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
cactusFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
herobrineFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Decorate liquids");
|
||||
|
||||
if( liquids )
|
||||
{
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
SpringFeature *waterSpringFeature = new SpringFeature(Tile::water_Id);
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(random->nextInt(Level::genDepth - 8) + 8);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
waterSpringFeature->place(level, random, x, y, z);
|
||||
}
|
||||
delete waterSpringFeature;
|
||||
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
SpringFeature *lavaSpringFeature = new SpringFeature(Tile::lava_Id);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(random->nextInt(random->nextInt(Level::genDepth - 16) + 8) + 8);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
lavaSpringFeature->place(level, random, x, y, z);
|
||||
}
|
||||
delete lavaSpringFeature;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate(int count, Feature *feature)
|
||||
{
|
||||
decorateDepthSpan(count, feature, 0, Level::genDepth);
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateDepthSpan(int count, Feature *feature, int y0, int y1)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16);
|
||||
int y = random->nextInt(y1 - y0) + y0;
|
||||
int z = zo + random->nextInt(16);
|
||||
feature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateDepthAverage(int count, Feature *feature, int yMid, int ySpan)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16);
|
||||
int y = random->nextInt(ySpan) + random->nextInt(ySpan) + (yMid - ySpan);
|
||||
int z = zo + random->nextInt(16);
|
||||
feature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateOres()
|
||||
{
|
||||
level->setInstaTick(true); // 4J - optimisation
|
||||
decorateDepthSpan(20, dirtOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(10, gravelOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(20, coalOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(20, ironOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(2, goldOreFeature, 0, Level::genDepth / 4);
|
||||
decorateDepthSpan(8, redStoneOreFeature, 0, Level::genDepth / 8);
|
||||
decorateDepthSpan(1, diamondOreFeature, 0, Level::genDepth / 8);
|
||||
decorateDepthAverage(1, lapisOreFeature, Level::genDepth / 8, Level::genDepth / 8);
|
||||
level->setInstaTick(false);
|
||||
}
|
||||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
#include "net.minecraft.world.level.levelgen.feature.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "HerobrineFeature.h"
|
||||
#include "SwampMushroomHugeFeature.h"
|
||||
|
||||
BiomeDecorator::BiomeDecorator(Biome *biome)
|
||||
{
|
||||
_init();
|
||||
|
||||
// 4J inits
|
||||
level = NULL;
|
||||
random = NULL;
|
||||
xo = 0;
|
||||
zo = 0;
|
||||
|
||||
this->biome = biome;
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate(Level *level, Random *random, int xo, int zo)
|
||||
{
|
||||
if (this->level != NULL)
|
||||
{
|
||||
app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n");
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
__debugbreak();
|
||||
//throw new RuntimeException("Already decorating!!");
|
||||
#endif
|
||||
}
|
||||
this->level = level;
|
||||
this->random = random;
|
||||
this->xo = xo;
|
||||
this->zo = zo;
|
||||
|
||||
decorate();
|
||||
|
||||
this->level = NULL;
|
||||
this->random = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BiomeDecorator::_init()
|
||||
{
|
||||
clayFeature = new ClayFeature(4);
|
||||
sandFeature = new SandFeature(7, Tile::sand_Id);
|
||||
gravelFeature = new SandFeature(6, Tile::gravel_Id);
|
||||
dirtOreFeature = new OreFeature(Tile::dirt_Id, 32);
|
||||
gravelOreFeature = new OreFeature(Tile::gravel_Id, 32);
|
||||
coalOreFeature = new OreFeature(Tile::coalOre_Id, 16);
|
||||
ironOreFeature = new OreFeature(Tile::ironOre_Id, 11);
|
||||
goldOreFeature = new OreFeature(Tile::goldOre_Id, 8);
|
||||
redStoneOreFeature = new OreFeature(Tile::redStoneOre_Id, 7);
|
||||
diamondOreFeature = new OreFeature(Tile::diamondOre_Id, 7);
|
||||
lapisOreFeature = new OreFeature(Tile::lapisOre_Id, 6);
|
||||
yellowFlowerFeature = new FlowerFeature(Tile::flower_Id);
|
||||
roseFlowerFeature = new FlowerFeature(Tile::rose_Id);
|
||||
brownMushroomFeature = new FlowerFeature(Tile::mushroom_brown_Id);
|
||||
redMushroomFeature = new FlowerFeature(Tile::mushroom_red_Id);
|
||||
hugeMushroomFeature = new HugeMushroomFeature();
|
||||
swampMushroomHugeFeature = new SwampMushroomHugeFeature();
|
||||
reedsFeature = new ReedsFeature();
|
||||
cactusFeature = new CactusFeature();
|
||||
waterlilyFeature = new WaterlilyFeature();
|
||||
|
||||
herobrineFeature = new HerobrineFeature(Tile::goldBlock_Id);
|
||||
|
||||
waterlilyCount = 0;
|
||||
treeCount = 0;
|
||||
flowerCount = 2;
|
||||
grassCount = 1;
|
||||
deadBushCount = 0;
|
||||
mushroomCount = 0;
|
||||
reedsCount = 0;
|
||||
cactusCount = 0;
|
||||
gravelCount = 1;
|
||||
sandCount = 3;
|
||||
clayCount = 1;
|
||||
hugeMushrooms = 0;
|
||||
hugeSwampMushrooms = 0;
|
||||
liquids = true;
|
||||
}
|
||||
|
||||
|
||||
void BiomeDecorator::decorate()
|
||||
{
|
||||
PIXBeginNamedEvent(0,"Decorate ores");
|
||||
decorateOres();
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Decorate sand/clay/gravel");
|
||||
for (int i = 0; i < sandCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < clayCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
clayFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < gravelCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z);
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0, "Decorate forests");
|
||||
int forests = treeCount;
|
||||
if (random->nextInt(10) == 0) forests += 1;
|
||||
|
||||
for (int i = 0; i < forests; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
Feature *tree = biome->getTreeFeature(random);
|
||||
tree->init(1, 1, 1);
|
||||
tree->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
delete tree;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
|
||||
PIXBeginNamedEvent(0,"Decorate mushrooms/flowers/grass");
|
||||
for (int i = 0; i < hugeMushrooms; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
hugeMushroomFeature->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < hugeSwampMushrooms; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
swampMushroomHugeFeature->place(level, random, x, level->getHeightmap(x, z), z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < flowerCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
yellowFlowerFeature->place(level, random, x, y, z);
|
||||
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
x = xo + random->nextInt(16) + 8;
|
||||
y = random->nextInt(Level::genDepth);
|
||||
z = zo + random->nextInt(16) + 8;
|
||||
roseFlowerFeature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < grassCount; i++)
|
||||
{
|
||||
//int grassType = TallGrass::TALL_GRASS;
|
||||
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
MemSect(50);
|
||||
Feature *grassFeature = biome->getGrassFeature(random);
|
||||
MemSect(0);
|
||||
grassFeature->place(level, random, x, y, z);
|
||||
delete grassFeature;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Decorate bush/waterlily/mushroom/reeds/pumpkins/cactuses");
|
||||
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
// I assume there is a case where deadBushCount could be 0
|
||||
DeadBushFeature *deadBushFeature = NULL;
|
||||
if(deadBushCount > 0) deadBushFeature = new DeadBushFeature(Tile::deadBush_Id);
|
||||
for (int i = 0; i < deadBushCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
//new DeadBushFeature(Tile::deadBush_Id)->place(level, random, x, y, z);
|
||||
deadBushFeature->place(level, random, x, y, z);
|
||||
}
|
||||
if(deadBushFeature != NULL)delete deadBushFeature;
|
||||
|
||||
for (int i = 0; i < waterlilyCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
while (y > 0 && level->getTile(x, y - 1, z) == 0)
|
||||
y--;
|
||||
waterlilyFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < mushroomCount; i++)
|
||||
{
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = level->getHeightmap(x, z);
|
||||
brownMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(8) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
redMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (random->nextInt(4) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
brownMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(8) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
redMushroomFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < reedsCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
reedsFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
reedsFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
if (random->nextInt(32) == 0)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
PumpkinFeature *pumpkinFeature = new PumpkinFeature();
|
||||
pumpkinFeature->place(level, random, x, y, z);
|
||||
delete pumpkinFeature;
|
||||
}
|
||||
|
||||
for (int i = 0; i < cactusCount; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
cactusFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(Level::genDepth);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
herobrineFeature->place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
PIXEndNamedEvent();
|
||||
PIXBeginNamedEvent(0,"Decorate liquids");
|
||||
|
||||
if( liquids )
|
||||
{
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
SpringFeature *waterSpringFeature = new SpringFeature(Tile::water_Id);
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(random->nextInt(Level::genDepth - 8) + 8);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
waterSpringFeature->place(level, random, x, y, z);
|
||||
}
|
||||
delete waterSpringFeature;
|
||||
|
||||
// 4J Stu - For some reason this was created each time round in the loop
|
||||
SpringFeature *lavaSpringFeature = new SpringFeature(Tile::lava_Id);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16) + 8;
|
||||
int y = random->nextInt(random->nextInt(random->nextInt(Level::genDepth - 16) + 8) + 8);
|
||||
int z = zo + random->nextInt(16) + 8;
|
||||
lavaSpringFeature->place(level, random, x, y, z);
|
||||
}
|
||||
delete lavaSpringFeature;
|
||||
}
|
||||
PIXEndNamedEvent();
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorate(int count, Feature *feature)
|
||||
{
|
||||
decorateDepthSpan(count, feature, 0, Level::genDepth);
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateDepthSpan(int count, Feature *feature, int y0, int y1)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16);
|
||||
int y = random->nextInt(y1 - y0) + y0;
|
||||
int z = zo + random->nextInt(16);
|
||||
feature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateDepthAverage(int count, Feature *feature, int yMid, int ySpan)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int x = xo + random->nextInt(16);
|
||||
int y = random->nextInt(ySpan) + random->nextInt(ySpan) + (yMid - ySpan);
|
||||
int z = zo + random->nextInt(16);
|
||||
feature->place(level, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void BiomeDecorator::decorateOres()
|
||||
{
|
||||
level->setInstaTick(true); // 4J - optimisation
|
||||
decorateDepthSpan(20, dirtOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(10, gravelOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(20, coalOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(20, ironOreFeature, 0, Level::genDepth);
|
||||
decorateDepthSpan(2, goldOreFeature, 0, Level::genDepth / 4);
|
||||
decorateDepthSpan(8, redStoneOreFeature, 0, Level::genDepth / 8);
|
||||
decorateDepthSpan(1, diamondOreFeature, 0, Level::genDepth / 8);
|
||||
decorateDepthAverage(1, lapisOreFeature, Level::genDepth / 8, Level::genDepth / 8);
|
||||
level->setInstaTick(false);
|
||||
}
|
||||
|
||||
@@ -1,77 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
class Level;
|
||||
class Random;
|
||||
class Biome;
|
||||
class Feature;
|
||||
|
||||
class BiomeDecorator
|
||||
{
|
||||
friend class DesertBiome;
|
||||
friend class ForestBiome;
|
||||
friend class PlainsBiome;
|
||||
friend class SwampBiome;
|
||||
friend class TaigaBiome;
|
||||
friend class MushroomIslandBiome;
|
||||
friend class BeachBiome;
|
||||
friend class JungleBiome;
|
||||
protected:
|
||||
Level *level;
|
||||
Random *random;
|
||||
int xo;
|
||||
int zo;
|
||||
Biome *biome;
|
||||
|
||||
public:
|
||||
BiomeDecorator(Biome *biome);
|
||||
|
||||
void decorate(Level *level, Random *random, int xo, int zo);
|
||||
|
||||
protected:
|
||||
Feature *clayFeature;
|
||||
Feature *sandFeature;
|
||||
Feature *gravelFeature;
|
||||
Feature *dirtOreFeature;
|
||||
Feature *gravelOreFeature;
|
||||
Feature *coalOreFeature;
|
||||
Feature *ironOreFeature;
|
||||
Feature *goldOreFeature;
|
||||
Feature *redStoneOreFeature;
|
||||
Feature *diamondOreFeature;
|
||||
Feature *lapisOreFeature;
|
||||
Feature *yellowFlowerFeature;
|
||||
Feature *roseFlowerFeature;
|
||||
Feature *brownMushroomFeature;
|
||||
Feature *redMushroomFeature;
|
||||
Feature *hugeMushroomFeature;
|
||||
Feature *reedsFeature;
|
||||
Feature *cactusFeature;
|
||||
Feature *waterlilyFeature;
|
||||
|
||||
Feature *herobrineFeature;
|
||||
|
||||
int waterlilyCount;
|
||||
int treeCount;
|
||||
int flowerCount;
|
||||
int grassCount;
|
||||
int deadBushCount;
|
||||
int mushroomCount;
|
||||
int reedsCount;
|
||||
int cactusCount;
|
||||
int gravelCount;
|
||||
int sandCount;
|
||||
int clayCount;
|
||||
int hugeMushrooms;
|
||||
bool liquids;
|
||||
|
||||
void _init();
|
||||
|
||||
protected:
|
||||
virtual void decorate();
|
||||
|
||||
|
||||
void decorate(int count, Feature *feature);
|
||||
void decorateDepthSpan(int count, Feature *feature, int y0, int y1);
|
||||
void decorateDepthAverage(int count, Feature *feature, int yMid, int ySpan);
|
||||
void decorateOres();
|
||||
};
|
||||
#pragma once
|
||||
|
||||
class Level;
|
||||
class Random;
|
||||
class Biome;
|
||||
class Feature;
|
||||
|
||||
class BiomeDecorator
|
||||
{
|
||||
friend class DesertBiome;
|
||||
friend class ForestBiome;
|
||||
friend class PlainsBiome;
|
||||
friend class SwampBiome;
|
||||
friend class TaigaBiome;
|
||||
friend class MushroomIslandBiome;
|
||||
friend class BeachBiome;
|
||||
friend class JungleBiome;
|
||||
protected:
|
||||
Level *level;
|
||||
Random *random;
|
||||
int xo;
|
||||
int zo;
|
||||
Biome *biome;
|
||||
|
||||
public:
|
||||
BiomeDecorator(Biome *biome);
|
||||
|
||||
void decorate(Level *level, Random *random, int xo, int zo);
|
||||
|
||||
protected:
|
||||
Feature *clayFeature;
|
||||
Feature *sandFeature;
|
||||
Feature *gravelFeature;
|
||||
Feature *dirtOreFeature;
|
||||
Feature *gravelOreFeature;
|
||||
Feature *coalOreFeature;
|
||||
Feature *ironOreFeature;
|
||||
Feature *goldOreFeature;
|
||||
Feature *redStoneOreFeature;
|
||||
Feature *diamondOreFeature;
|
||||
Feature *lapisOreFeature;
|
||||
Feature *yellowFlowerFeature;
|
||||
Feature *roseFlowerFeature;
|
||||
Feature *brownMushroomFeature;
|
||||
Feature *redMushroomFeature;
|
||||
Feature *hugeMushroomFeature;
|
||||
Feature *swampMushroomHugeFeature;
|
||||
Feature *reedsFeature;
|
||||
Feature *cactusFeature;
|
||||
Feature *waterlilyFeature;
|
||||
|
||||
Feature *herobrineFeature;
|
||||
|
||||
int waterlilyCount;
|
||||
int treeCount;
|
||||
int flowerCount;
|
||||
int grassCount;
|
||||
int deadBushCount;
|
||||
int mushroomCount;
|
||||
int reedsCount;
|
||||
int cactusCount;
|
||||
int gravelCount;
|
||||
int sandCount;
|
||||
int clayCount;
|
||||
int hugeMushrooms;
|
||||
int hugeSwampMushrooms;
|
||||
bool liquids;
|
||||
|
||||
void _init();
|
||||
|
||||
protected:
|
||||
virtual void decorate();
|
||||
|
||||
|
||||
void decorate(int count, Feature *feature);
|
||||
void decorateDepthSpan(int count, Feature *feature, int y0, int y1);
|
||||
void decorateDepthAverage(int count, Feature *feature, int yMid, int ySpan);
|
||||
void decorateOres();
|
||||
};
|
||||
|
||||
18
Minecraft.World/BlueIce.cpp
Normal file
18
Minecraft.World/BlueIce.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "stdafx.h"
|
||||
#include "BlueIce.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
|
||||
BlueIceTile::BlueIceTile(int id) : Tile(id, Material::ice)
|
||||
{
|
||||
friction = 0.999f;
|
||||
}
|
||||
|
||||
int BlueIceTile::getResourceCount(Random *random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> BlueIceTile::getSilkTouchItemInstance(int data)
|
||||
{
|
||||
return shared_ptr<ItemInstance>(new ItemInstance(Tile::blueIce));
|
||||
}
|
||||
13
Minecraft.World/BlueIce.h
Normal file
13
Minecraft.World/BlueIce.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "Tile.h"
|
||||
|
||||
class BlueIceTile : public Tile
|
||||
{
|
||||
friend class Tile;
|
||||
protected:
|
||||
BlueIceTile(int id);
|
||||
virtual shared_ptr<ItemInstance> getSilkTouchItemInstance(int data);
|
||||
|
||||
public:
|
||||
virtual int getResourceCount(Random *random);
|
||||
};
|
||||
26
Minecraft.World/ChestPair.cpp
Normal file
26
Minecraft.World/ChestPair.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "stdafx.h"
|
||||
#include "ChestPair.h"
|
||||
|
||||
namespace ChestPair
|
||||
{
|
||||
bool chooseByPriority(const CandidateDecision &firstDecision, const CandidateDecision &secondDecision, bool &outChooseFirst)
|
||||
{
|
||||
CandidateCheck checks[] =
|
||||
{
|
||||
{ firstDecision.prefersThisChest, secondDecision.prefersThisChest, false },
|
||||
{ firstDecision.committedElsewhere, secondDecision.committedElsewhere, true },
|
||||
{ firstDecision.matchesFacingData, secondDecision.matchesFacingData, false },
|
||||
{ firstDecision.available, secondDecision.available, false },
|
||||
};
|
||||
|
||||
for (const CandidateCheck &check : checks)
|
||||
{
|
||||
if (check.first == check.second) continue;
|
||||
|
||||
outChooseFirst = check.invertFirst ? !check.first : check.first;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
130
Minecraft.World/ChestPair.h
Normal file
130
Minecraft.World/ChestPair.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
namespace ChestPair
|
||||
{
|
||||
struct CandidateRef
|
||||
{
|
||||
bool exists;
|
||||
int candidateX;
|
||||
int candidateZ;
|
||||
};
|
||||
|
||||
struct CandidateDecision
|
||||
{
|
||||
bool prefersThisChest;
|
||||
bool committedElsewhere;
|
||||
bool matchesFacingData;
|
||||
bool available;
|
||||
};
|
||||
|
||||
struct CandidateCheck
|
||||
{
|
||||
bool first;
|
||||
bool second;
|
||||
bool invertFirst;
|
||||
};
|
||||
|
||||
struct PreferredNeighborInput
|
||||
{
|
||||
int firstX;
|
||||
int firstZ;
|
||||
int secondX;
|
||||
int secondZ;
|
||||
bool hasFirst;
|
||||
bool hasSecond;
|
||||
bool hasPlacementIntent;
|
||||
int intendedPartnerX;
|
||||
int intendedPartnerY;
|
||||
int intendedPartnerZ;
|
||||
int selfY;
|
||||
bool strictPlacementIntent;
|
||||
bool hasCachedPartner;
|
||||
int cachedPartnerX;
|
||||
int cachedPartnerZ;
|
||||
bool rightIsFirst;
|
||||
};
|
||||
|
||||
bool chooseByPriority(const CandidateDecision &firstDecision, const CandidateDecision &secondDecision, bool &outChooseFirst);
|
||||
|
||||
template <typename IsCommittedElsewhereFn, typename BuildCandidateDecisionFn>
|
||||
bool choosePreferredNeighbor(
|
||||
const PreferredNeighborInput &input,
|
||||
IsCommittedElsewhereFn &&isCommittedElsewhere,
|
||||
BuildCandidateDecisionFn &&buildCandidateDecision,
|
||||
int &outX,
|
||||
int &outZ)
|
||||
{
|
||||
CandidateRef candidates[2] =
|
||||
{
|
||||
{ input.hasFirst, input.firstX, input.firstZ },
|
||||
{ input.hasSecond, input.secondX, input.secondZ },
|
||||
};
|
||||
|
||||
int candidateCount = 0;
|
||||
const CandidateRef *onlyCandidate = nullptr;
|
||||
for (const CandidateRef &candidate : candidates)
|
||||
{
|
||||
if (!candidate.exists) continue;
|
||||
candidateCount++;
|
||||
onlyCandidate = &candidate;
|
||||
}
|
||||
|
||||
if (candidateCount == 0) return false;
|
||||
|
||||
if (input.hasPlacementIntent && input.strictPlacementIntent)
|
||||
{
|
||||
for (const CandidateRef &candidate : candidates)
|
||||
{
|
||||
if (!candidate.exists) continue;
|
||||
if (input.intendedPartnerX != candidate.candidateX || input.intendedPartnerY != input.selfY || input.intendedPartnerZ != candidate.candidateZ) continue;
|
||||
|
||||
if (isCommittedElsewhere(candidate.candidateX, candidate.candidateZ))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
outX = candidate.candidateX;
|
||||
outZ = candidate.candidateZ;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.hasCachedPartner)
|
||||
{
|
||||
for (const CandidateRef &candidate : candidates)
|
||||
{
|
||||
if (!candidate.exists) continue;
|
||||
if (input.cachedPartnerX != candidate.candidateX || input.cachedPartnerZ != candidate.candidateZ) continue;
|
||||
|
||||
outX = candidate.candidateX;
|
||||
outZ = candidate.candidateZ;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (candidateCount == 1 && onlyCandidate != nullptr)
|
||||
{
|
||||
if (isCommittedElsewhere(onlyCandidate->candidateX, onlyCandidate->candidateZ)) return false;
|
||||
outX = onlyCandidate->candidateX;
|
||||
outZ = onlyCandidate->candidateZ;
|
||||
return true;
|
||||
}
|
||||
|
||||
CandidateDecision firstDecision = buildCandidateDecision(input.firstX, input.firstZ);
|
||||
CandidateDecision secondDecision = buildCandidateDecision(input.secondX, input.secondZ);
|
||||
|
||||
bool chooseFirstCandidate = false;
|
||||
if (chooseByPriority(firstDecision, secondDecision, chooseFirstCandidate))
|
||||
{
|
||||
outX = chooseFirstCandidate ? input.firstX : input.secondX;
|
||||
outZ = chooseFirstCandidate ? input.firstZ : input.secondZ;
|
||||
return true;
|
||||
}
|
||||
|
||||
outX = input.rightIsFirst ? input.firstX : input.secondX;
|
||||
outZ = input.rightIsFirst ? input.firstZ : input.secondZ;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,60 +1,58 @@
|
||||
#pragma once
|
||||
#include "BaseEntityTile.h"
|
||||
#include "Material.h"
|
||||
|
||||
class Player;
|
||||
class Random;
|
||||
|
||||
class ChestTile : public BaseEntityTile
|
||||
{
|
||||
friend class Tile;
|
||||
friend class Minecraft;
|
||||
|
||||
public:
|
||||
static const int TYPE_BASIC = 0;
|
||||
static const int TYPE_TRAP = 1;
|
||||
|
||||
static const int EVENT_SET_OPEN_COUNT = 1;
|
||||
|
||||
private:
|
||||
Random *random;
|
||||
|
||||
public:
|
||||
int type;
|
||||
|
||||
protected:
|
||||
ChestTile(int id, int type);
|
||||
~ChestTile();
|
||||
|
||||
public:
|
||||
virtual bool isSolidRender(bool isServerLevel = false);
|
||||
virtual bool isCubeShaped();
|
||||
virtual int getRenderShape();
|
||||
virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>());
|
||||
virtual void onPlace(Level *level, int x, int y, int z);
|
||||
virtual void setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance);
|
||||
void recalcLockDir(Level *level, int x, int y, int z);
|
||||
virtual bool mayPlace(Level *level, int x, int y, int z);
|
||||
|
||||
private:
|
||||
bool isFullChest(Level *level, int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual void neighborChanged(Level *level, int x, int y, int z, int type);
|
||||
virtual void onRemove(Level *level, int x, int y, int z, int id, int data);
|
||||
virtual bool TestUse();
|
||||
virtual bool 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
|
||||
virtual shared_ptr<Container> getContainer(Level *level, int x, int y, int z);
|
||||
virtual shared_ptr<TileEntity> newTileEntity(Level *level);
|
||||
virtual bool isSignalSource();
|
||||
virtual int getSignal(LevelSource *level, int x, int y, int z, int dir);
|
||||
virtual int getDirectSignal(LevelSource *level, int x, int y, int z, int dir);
|
||||
|
||||
private:
|
||||
bool isCatSittingOnChest(Level *level, int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual bool hasAnalogOutputSignal();
|
||||
virtual int getAnalogOutputSignal(Level *level, int x, int y, int z, int dir);
|
||||
virtual void registerIcons(IconRegister *iconRegister);
|
||||
#pragma once
|
||||
#include "BaseEntityTile.h"
|
||||
#include "Material.h"
|
||||
|
||||
class Player;
|
||||
class Random;
|
||||
|
||||
class ChestTile : public BaseEntityTile
|
||||
{
|
||||
friend class Tile;
|
||||
friend class Minecraft;
|
||||
|
||||
public:
|
||||
static const int TYPE_BASIC = 0;
|
||||
static const int TYPE_TRAP = 1;
|
||||
|
||||
static const int EVENT_SET_OPEN_COUNT = 1;
|
||||
|
||||
private:
|
||||
Random *random;
|
||||
|
||||
public:
|
||||
int type;
|
||||
|
||||
protected:
|
||||
ChestTile(int id, int type);
|
||||
~ChestTile();
|
||||
|
||||
public:
|
||||
virtual bool isSolidRender(bool isServerLevel = false);
|
||||
virtual bool isCubeShaped();
|
||||
virtual int getRenderShape();
|
||||
virtual AABB *getTileAABB(Level *level, int x, int y, int z);
|
||||
virtual AABB *getAABB(Level *level, int x, int y, int z);
|
||||
virtual int getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue);
|
||||
virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity = shared_ptr<TileEntity>());
|
||||
virtual void onPlace(Level *level, int x, int y, int z);
|
||||
virtual void setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance);
|
||||
void recalcLockDir(Level *level, int x, int y, int z);
|
||||
virtual bool mayPlace(Level *level, int x, int y, int z);
|
||||
virtual void neighborChanged(Level *level, int x, int y, int z, int type);
|
||||
virtual void onRemove(Level *level, int x, int y, int z, int id, int data);
|
||||
virtual bool TestUse();
|
||||
virtual bool 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
|
||||
virtual shared_ptr<Container> getContainer(Level *level, int x, int y, int z);
|
||||
virtual shared_ptr<TileEntity> newTileEntity(Level *level);
|
||||
virtual bool isSignalSource();
|
||||
virtual int getSignal(LevelSource *level, int x, int y, int z, int dir);
|
||||
virtual int getDirectSignal(LevelSource *level, int x, int y, int z, int dir);
|
||||
|
||||
private:
|
||||
bool isCatSittingOnChest(Level *level, int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual bool hasAnalogOutputSignal();
|
||||
virtual int getAnalogOutputSignal(Level *level, int x, int y, int z, int dir);
|
||||
virtual void registerIcons(IconRegister *iconRegister);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,87 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "TileEntity.h"
|
||||
#include "Container.h"
|
||||
|
||||
#include "ListTag.h"
|
||||
|
||||
class Player;
|
||||
class CompoundTag;
|
||||
|
||||
class ChestTileEntity : public TileEntity, public Container
|
||||
{
|
||||
public:
|
||||
eINSTANCEOF GetType() { return eTYPE_CHESTTILEENTITY; }
|
||||
static TileEntity *create() { return new ChestTileEntity(); }
|
||||
|
||||
int getContainerType(); // 4J-Added;
|
||||
|
||||
using TileEntity::setChanged;
|
||||
|
||||
private:
|
||||
void _init(bool isBonusChest);
|
||||
|
||||
public:
|
||||
ChestTileEntity(bool isBonusChest = false); // 4J added param
|
||||
ChestTileEntity(int type, bool isBonusChest = false); // 4J added param
|
||||
virtual ~ChestTileEntity();
|
||||
|
||||
private:
|
||||
ItemInstanceArray *items;
|
||||
|
||||
public:
|
||||
bool isBonusChest; // 4J added
|
||||
bool hasCheckedNeighbors;
|
||||
weak_ptr<ChestTileEntity> n;
|
||||
weak_ptr<ChestTileEntity> e;
|
||||
weak_ptr<ChestTileEntity> w;
|
||||
weak_ptr<ChestTileEntity> s;
|
||||
|
||||
float openness, oOpenness;
|
||||
int openCount;
|
||||
private:
|
||||
int tickInterval;
|
||||
|
||||
int type;
|
||||
wstring name;
|
||||
|
||||
public:
|
||||
virtual unsigned int getContainerSize();
|
||||
virtual shared_ptr<ItemInstance> getItem(unsigned int slot);
|
||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||
virtual wstring getName();
|
||||
virtual wstring getCustomName();
|
||||
virtual bool hasCustomName();
|
||||
virtual void setCustomName(const wstring &name);
|
||||
virtual void load(CompoundTag *base);
|
||||
virtual void save(CompoundTag *base);
|
||||
virtual int getMaxStackSize() const;
|
||||
virtual bool stillValid(shared_ptr<Player> player);
|
||||
virtual void setChanged();
|
||||
virtual void clearCache();
|
||||
|
||||
private:
|
||||
virtual void heyImYourNeighbor(shared_ptr<ChestTileEntity> neighbor, int from);
|
||||
|
||||
public:
|
||||
virtual void checkNeighbors();
|
||||
|
||||
private:
|
||||
bool isSameChest(int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual void tick();
|
||||
virtual bool triggerEvent(int b0, int b1);
|
||||
virtual void startOpen();
|
||||
virtual void stopOpen();
|
||||
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
||||
virtual void setRemoved();
|
||||
virtual int getType();
|
||||
|
||||
// 4J Added
|
||||
virtual shared_ptr<TileEntity> clone();
|
||||
#pragma once
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "TileEntity.h"
|
||||
#include "Container.h"
|
||||
|
||||
#include "ListTag.h"
|
||||
|
||||
class Player;
|
||||
class CompoundTag;
|
||||
|
||||
class ChestTileEntity : public TileEntity, public Container
|
||||
{
|
||||
public:
|
||||
eINSTANCEOF GetType() { return eTYPE_CHESTTILEENTITY; }
|
||||
static TileEntity *create() { return new ChestTileEntity(); }
|
||||
|
||||
int getContainerType(); // 4J-Added;
|
||||
|
||||
using TileEntity::setChanged;
|
||||
|
||||
private:
|
||||
void _init(bool isBonusChest);
|
||||
|
||||
public:
|
||||
ChestTileEntity(bool isBonusChest = false); // 4J added param
|
||||
ChestTileEntity(int type, bool isBonusChest = false); // 4J added param
|
||||
virtual ~ChestTileEntity();
|
||||
|
||||
private:
|
||||
ItemInstanceArray *items;
|
||||
|
||||
public:
|
||||
bool isBonusChest; // 4J added
|
||||
bool hasCheckedNeighbors;
|
||||
weak_ptr<ChestTileEntity> n;
|
||||
weak_ptr<ChestTileEntity> e;
|
||||
weak_ptr<ChestTileEntity> w;
|
||||
weak_ptr<ChestTileEntity> s;
|
||||
bool hasPlacementPartnerIntent;
|
||||
int placementPartnerX;
|
||||
int placementPartnerY;
|
||||
int placementPartnerZ;
|
||||
bool placementPartnerStrict;
|
||||
|
||||
float openness, oOpenness;
|
||||
int openCount;
|
||||
private:
|
||||
int tickInterval;
|
||||
|
||||
int type;
|
||||
wstring name;
|
||||
|
||||
public:
|
||||
virtual unsigned int getContainerSize();
|
||||
virtual shared_ptr<ItemInstance> getItem(unsigned int slot);
|
||||
virtual shared_ptr<ItemInstance> removeItem(unsigned int slot, int count);
|
||||
virtual shared_ptr<ItemInstance> removeItemNoUpdate(int slot);
|
||||
virtual void setItem(unsigned int slot, shared_ptr<ItemInstance> item);
|
||||
virtual wstring getName();
|
||||
virtual wstring getCustomName();
|
||||
virtual bool hasCustomName();
|
||||
virtual void setCustomName(const wstring &name);
|
||||
virtual void load(CompoundTag *base);
|
||||
virtual void save(CompoundTag *base);
|
||||
virtual int getMaxStackSize() const;
|
||||
virtual bool stillValid(shared_ptr<Player> player);
|
||||
virtual void setChanged();
|
||||
virtual void clearCache();
|
||||
virtual void setPlacementPartnerIntent(int partnerX, int partnerY, int partnerZ, bool strict);
|
||||
virtual void clearPlacementPartnerIntent();
|
||||
virtual bool getPlacementPartnerIntent(int &partnerX, int &partnerY, int &partnerZ, bool &strict) const;
|
||||
|
||||
private:
|
||||
virtual void heyImYourNeighbor(shared_ptr<ChestTileEntity> neighbor, int from);
|
||||
|
||||
public:
|
||||
virtual void checkNeighbors();
|
||||
|
||||
private:
|
||||
bool isSameChest(int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual void tick();
|
||||
virtual bool triggerEvent(int b0, int b1);
|
||||
virtual void startOpen();
|
||||
virtual void stopOpen();
|
||||
virtual bool canPlaceItem(int slot, shared_ptr<ItemInstance> item);
|
||||
virtual void setRemoved();
|
||||
virtual int getType();
|
||||
|
||||
// 4J Added
|
||||
virtual shared_ptr<TileEntity> clone();
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -191,4 +191,7 @@ public:
|
||||
virtual float getHealth() { return LivingEntity::getHealth(); };
|
||||
virtual float getMaxHealth() { return LivingEntity::getMaxHealth(); };
|
||||
virtual int getDimension() { return Entity::dimension; };
|
||||
|
||||
protected:
|
||||
virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
|
||||
};
|
||||
|
||||
@@ -93,6 +93,7 @@ public:
|
||||
eMaterial_nethanium,
|
||||
eMaterial_bread,
|
||||
eMaterial_endorium,
|
||||
eMaterial_ice,
|
||||
|
||||
}
|
||||
eMaterial;
|
||||
|
||||
17
Minecraft.World/PackedGlassTile.cpp
Normal file
17
Minecraft.World/PackedGlassTile.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "stdafx.h"
|
||||
#include "PackedGlassTile.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
|
||||
PackedGlassTile::PackedGlassTile(int id) : Tile(id, Material::glass)
|
||||
{
|
||||
}
|
||||
|
||||
int PackedGlassTile::getResourceCount(Random *random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> PackedGlassTile::getSilkTouchItemInstance(int data)
|
||||
{
|
||||
return shared_ptr<ItemInstance>(new ItemInstance(Tile::blueIce));
|
||||
}
|
||||
13
Minecraft.World/PackedGlassTile.h
Normal file
13
Minecraft.World/PackedGlassTile.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "Tile.h"
|
||||
|
||||
class PackedGlassTile : public Tile
|
||||
{
|
||||
friend class Tile;
|
||||
protected:
|
||||
PackedGlassTile(int id);
|
||||
virtual shared_ptr<ItemInstance> getSilkTouchItemInstance(int data);
|
||||
|
||||
public:
|
||||
virtual int getResourceCount(Random *random);
|
||||
};
|
||||
18
Minecraft.World/PackedIce.cpp
Normal file
18
Minecraft.World/PackedIce.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "stdafx.h"
|
||||
#include "PackedIce.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
|
||||
PackedIceTile::PackedIceTile(int id) : Tile(id, Material::ice)
|
||||
{
|
||||
friction = 0.98f;
|
||||
}
|
||||
|
||||
int PackedIceTile::getResourceCount(Random *random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> PackedIceTile::getSilkTouchItemInstance(int data)
|
||||
{
|
||||
return shared_ptr<ItemInstance>(new ItemInstance(Tile::packedIce));
|
||||
}
|
||||
13
Minecraft.World/PackedIce.h
Normal file
13
Minecraft.World/PackedIce.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "Tile.h"
|
||||
|
||||
class PackedIceTile : public Tile
|
||||
{
|
||||
friend class Tile;
|
||||
protected:
|
||||
PackedIceTile(int id);
|
||||
virtual shared_ptr<ItemInstance> getSilkTouchItemInstance(int data);
|
||||
|
||||
public:
|
||||
virtual int getResourceCount(Random *random);
|
||||
};
|
||||
@@ -721,6 +721,22 @@ Recipes::Recipes()
|
||||
L'#', Item::netherQuartz,
|
||||
L'S');
|
||||
|
||||
addShapedRecipy(new ItemInstance(Tile::packedIce, 1), //
|
||||
L"ssctg",
|
||||
L"##", //
|
||||
L"##", //
|
||||
|
||||
L'#', Tile::ice,
|
||||
L'S');
|
||||
|
||||
addShapedRecipy(new ItemInstance(Tile::blueIce, 1), //
|
||||
L"ssctg",
|
||||
L"##", //
|
||||
L"##", //
|
||||
|
||||
L'#', Tile::packedIce,
|
||||
L'S');
|
||||
|
||||
addShapedRecipy(new ItemInstance(Tile::lever, 1), //
|
||||
L"ssctcig",
|
||||
L"X", //
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "SwampTreeFeature.h"
|
||||
|
||||
SwampBiome::SwampBiome(int id) : Biome(id)
|
||||
{
|
||||
decorator->treeCount = 2;
|
||||
decorator->flowerCount = -999;
|
||||
decorator->deadBushCount = 1;
|
||||
decorator->mushroomCount = 8;
|
||||
decorator->reedsCount = 10;
|
||||
decorator->clayCount = 1;
|
||||
decorator->waterlilyCount = 4;
|
||||
|
||||
// waterColor = 0xe0ffae;
|
||||
|
||||
enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 1, 1, 1));
|
||||
}
|
||||
|
||||
|
||||
Feature *SwampBiome::getTreeFeature(Random *random)
|
||||
{
|
||||
return new SwampTreeFeature(); // 4J used to return member swampTree, now returning newly created object so that caller can be consistently resposible for cleanup
|
||||
}
|
||||
|
||||
// 4J Stu - Not using these any more
|
||||
//int SwampBiome::getGrassColor()
|
||||
//{
|
||||
// double temp = getTemperature();
|
||||
// double rain = getDownfall();
|
||||
//
|
||||
// return ((GrassColor::get(temp, rain) & 0xfefefe) + 0x4e0e4e) / 2;
|
||||
//}
|
||||
//
|
||||
//int SwampBiome::getFolageColor()
|
||||
//{
|
||||
// double temp = getTemperature();
|
||||
// double rain = getDownfall();
|
||||
//
|
||||
// return ((FoliageColor::get(temp, rain) & 0xfefefe) + 0x4e0e4e) / 2;
|
||||
//}
|
||||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.biome.h"
|
||||
#include "SwampTreeFeature.h"
|
||||
#include "SwampMushroomHugeFeature.h"
|
||||
|
||||
SwampBiome::SwampBiome(int id) : Biome(id)
|
||||
{
|
||||
decorator->treeCount = 2;
|
||||
decorator->flowerCount = -999;
|
||||
decorator->deadBushCount = 1;
|
||||
decorator->mushroomCount = 8;
|
||||
decorator->reedsCount = 10;
|
||||
decorator->clayCount = 1;
|
||||
decorator->waterlilyCount = 4;
|
||||
|
||||
decorator->hugeSwampMushrooms = 1;
|
||||
|
||||
enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 1, 1, 1));
|
||||
}
|
||||
|
||||
Feature *SwampBiome::getTreeFeature(Random *random)
|
||||
{
|
||||
return new SwampTreeFeature();
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
#pragma once
|
||||
#include "Biome.h"
|
||||
class LevelSource;
|
||||
|
||||
class SwampBiome : public Biome
|
||||
{
|
||||
// 4J Stu - No idea why this is protected in Java
|
||||
//protected:
|
||||
public:
|
||||
SwampBiome(int id);
|
||||
|
||||
public:
|
||||
virtual Feature *getTreeFeature(Random *random);
|
||||
|
||||
// 4J Stu - Not using these any more
|
||||
//virtual int getGrassColor();
|
||||
//virtual int getFolageColor();
|
||||
#pragma once
|
||||
#include "Biome.h"
|
||||
class LevelSource;
|
||||
|
||||
class SwampBiome : public Biome
|
||||
{
|
||||
public:
|
||||
SwampBiome(int id);
|
||||
|
||||
virtual Feature *getTreeFeature(Random *random);
|
||||
};
|
||||
107
Minecraft.World/SwampMushroomHugeFeature.cpp
Normal file
107
Minecraft.World/SwampMushroomHugeFeature.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#include "stdafx.h"
|
||||
#include "SwampMushroomHugeFeature.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
|
||||
SwampMushroomHugeFeature::SwampMushroomHugeFeature(int forcedType) : Feature(true)
|
||||
{
|
||||
this->forcedType = forcedType;
|
||||
}
|
||||
|
||||
SwampMushroomHugeFeature::SwampMushroomHugeFeature() : Feature(false)
|
||||
{
|
||||
this->forcedType = -1;
|
||||
}
|
||||
|
||||
bool SwampMushroomHugeFeature::place(Level *level, Random *random, int x, int y, int z)
|
||||
{
|
||||
int type = random->nextInt(2);
|
||||
if (forcedType >= 0) type = forcedType;
|
||||
|
||||
int treeHeight = random->nextInt(3) + 4;
|
||||
|
||||
bool free = true;
|
||||
if (y < 1 || y + treeHeight + 1 >= Level::maxBuildHeight) return false;
|
||||
|
||||
for (int yy = y; yy <= y + 1 + treeHeight; yy++)
|
||||
{
|
||||
int r = 3;
|
||||
if (yy <= (y + 3) ) r = 0;
|
||||
for (int xx = x - r; xx <= x + r && free; xx++)
|
||||
{
|
||||
for (int zz = z - r; zz <= z + r && free; zz++)
|
||||
{
|
||||
if (yy >= 0 && yy < Level::maxBuildHeight)
|
||||
{
|
||||
int tt = level->getTile(xx, yy, zz);
|
||||
if (tt != 0 && tt != Tile::leaves_Id)
|
||||
{
|
||||
free = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int belowTile = level->getTile(x, y - 1, z);
|
||||
if (belowTile != Tile::dirt_Id && belowTile != Tile::grass_Id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!free) return false;
|
||||
|
||||
int low = y + treeHeight;
|
||||
if (type == 1) {
|
||||
low = y + treeHeight - 3;
|
||||
}
|
||||
for (int yy = low; yy <= y + treeHeight; yy++)
|
||||
{
|
||||
int offs = 1;
|
||||
if (yy < y + treeHeight) offs += 1;
|
||||
if (type == 0) offs = 3;
|
||||
for (int xx = x - offs; xx <= x + offs; xx++)
|
||||
{
|
||||
for (int zz = z - offs; zz <= z + offs; zz++)
|
||||
{
|
||||
int data = 5;
|
||||
if (xx == x - offs) data--;
|
||||
if (xx == x + offs) data++;
|
||||
if (zz == z - offs) data -= 3;
|
||||
if (zz == z + offs) data += 3;
|
||||
|
||||
if (type == 0 || yy < y + treeHeight)
|
||||
{
|
||||
if ((xx == x - offs || xx == x + offs) && (zz == z - offs || zz == z + offs)) continue;
|
||||
if (xx == x - (offs - 1) && zz == z - offs) data = 1;
|
||||
if (xx == x - offs && zz == z - (offs - 1)) data = 1;
|
||||
|
||||
if (xx == x + (offs - 1) && zz == z - offs) data = 3;
|
||||
if (xx == x + offs && zz == z - (offs - 1)) data = 3;
|
||||
|
||||
if (xx == x - (offs - 1) && zz == z + offs) data = 7;
|
||||
if (xx == x - offs && zz == z + (offs - 1)) data = 7;
|
||||
|
||||
if (xx == x + (offs - 1) && zz == z + offs) data = 9;
|
||||
if (xx == x + offs && zz == z + (offs - 1)) data = 9;
|
||||
}
|
||||
|
||||
if (data == 5 && yy < y + treeHeight) data = 0;
|
||||
if (data != 0 || y >= y + treeHeight - 1)
|
||||
{
|
||||
if (!Tile::solid[level->getTile(xx, yy, zz)]) placeBlock(level, xx, yy, zz, Tile::hugeMushroom_brown_Id + type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int hh = 0; hh < treeHeight; hh++)
|
||||
{
|
||||
int t = level->getTile(x, y + hh, z);
|
||||
if (!Tile::solid[t]) placeBlock(level, x, y + hh, z, Tile::hugeMushroom_brown_Id + type, 10);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
13
Minecraft.World/SwampMushroomHugeFeature.h
Normal file
13
Minecraft.World/SwampMushroomHugeFeature.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "Feature.h"
|
||||
|
||||
class SwampMushroomHugeFeature : public Feature
|
||||
{
|
||||
private:
|
||||
int forcedType;
|
||||
|
||||
public:
|
||||
SwampMushroomHugeFeature(int forcedType);
|
||||
SwampMushroomHugeFeature();
|
||||
virtual bool place(Level *level, Random *random, int x, int y, int z);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user