the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "Color.h"
3#include "..\Minecraft.Client\Minecraft.h"
4#include "net.minecraft.world.level.levelgen.feature.h"
5#include "net.minecraft.world.level.tile.h"
6#include "net.minecraft.world.level.h"
7#include "net.minecraft.world.entity.animal.h"
8#include "net.minecraft.world.entity.monster.h"
9#include "net.minecraft.world.entity.h"
10#include "Biome.h"
11#include "net.minecraft.world.level.biome.h"
12
13//public static final Biome[] biomes = new Biome[256];
14Biome *Biome::biomes[256];
15
16Biome *Biome::ocean = NULL;
17Biome *Biome::plains = NULL;
18Biome *Biome::desert = NULL;
19
20Biome *Biome::extremeHills = NULL;
21Biome *Biome::forest = NULL;
22Biome *Biome::taiga = NULL;
23
24Biome *Biome::swampland = NULL;
25Biome *Biome::river = NULL;
26
27Biome *Biome::hell = NULL;
28Biome *Biome::sky = NULL;
29
30Biome *Biome::frozenOcean = NULL;
31Biome *Biome::frozenRiver = NULL;
32Biome *Biome::iceFlats = NULL;
33Biome *Biome::iceMountains = NULL;
34Biome *Biome::mushroomIsland = NULL;
35Biome *Biome::mushroomIslandShore = NULL;
36Biome *Biome::beaches = NULL;
37Biome *Biome::desertHills = NULL;
38Biome *Biome::forestHills = NULL;
39Biome *Biome::taigaHills = NULL;
40Biome *Biome::smallerExtremeHills = NULL;
41
42Biome *Biome::jungle = NULL;
43Biome *Biome::jungleHills = NULL;
44
45
46void Biome::staticCtor()
47{
48 //public static final Biome[] biomes = new Biome[256];
49
50 Biome::ocean = (new OceanBiome(0))->setColor(0x000070)->setName(L"Ocean")->setDepthAndScale(-1, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Ocean, eMinecraftColour_Foliage_Ocean, eMinecraftColour_Water_Ocean,eMinecraftColour_Sky_Ocean);
51 Biome::plains = (new PlainsBiome(1))->setColor(0x8db360)->setName(L"Plains")->setTemperatureAndDownfall(0.8f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Plains, eMinecraftColour_Foliage_Plains, eMinecraftColour_Water_Plains,eMinecraftColour_Sky_Plains);
52 Biome::desert = (new DesertBiome(2))->setColor(0xFA9418)->setName(L"Desert")->setNoRain()->setTemperatureAndDownfall(2, 0)->setDepthAndScale(0.1f, 0.2f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Desert, eMinecraftColour_Foliage_Desert, eMinecraftColour_Water_Desert,eMinecraftColour_Sky_Desert);
53
54 Biome::extremeHills = (new ExtremeHillsBiome(3))->setColor(0x606060)->setName(L"Extreme Hills")->setDepthAndScale(0.3f, 1.5f)->setTemperatureAndDownfall(0.2f, 0.3f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ExtremeHills, eMinecraftColour_Foliage_ExtremeHills, eMinecraftColour_Water_ExtremeHills,eMinecraftColour_Sky_ExtremeHills);
55 Biome::forest = (new ForestBiome(4))->setColor(0x056621)->setName(L"Forest")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.7f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Forest, eMinecraftColour_Foliage_Forest, eMinecraftColour_Water_Forest,eMinecraftColour_Sky_Forest);
56 // 4J - brought forward Taiga temperature change from 0.3f to 0.05f, from 1.2.3
57 Biome::taiga = (new TaigaBiome(5))->setColor(0x0b6659)->setName(L"Taiga")->setLeafColor(0x4EBA31)->setSnowCovered()->setTemperatureAndDownfall(0.05f, 0.8f)->setDepthAndScale(0.1f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Taiga, eMinecraftColour_Foliage_Taiga, eMinecraftColour_Water_Taiga,eMinecraftColour_Sky_Taiga);
58
59 Biome::swampland = (new SwampBiome(6))->setColor(0x07F9B2)->setName(L"Swampland")->setLeafColor(0x8BAF48)->setDepthAndScale(-0.2f, 0.1f)->setTemperatureAndDownfall(0.8f, 0.9f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Swampland, eMinecraftColour_Foliage_Swampland, eMinecraftColour_Water_Swampland,eMinecraftColour_Sky_Swampland);
60 Biome::river = (new RiverBiome(7))->setColor(0x0000ff)->setName(L"River")->setDepthAndScale(-0.5f, 0)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_River, eMinecraftColour_Foliage_River, eMinecraftColour_Water_River,eMinecraftColour_Sky_River);
61
62 Biome::hell = (new HellBiome(8))->setColor(0xff0000)->setName(L"Hell")->setNoRain()->setTemperatureAndDownfall(2, 0)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Hell, eMinecraftColour_Foliage_Hell, eMinecraftColour_Water_Hell,eMinecraftColour_Sky_Hell);
63 Biome::sky = (new TheEndBiome(9))->setColor(0x8080ff)->setName(L"Sky")->setNoRain()->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Sky, eMinecraftColour_Foliage_Sky, eMinecraftColour_Water_Sky,eMinecraftColour_Sky_Sky);
64
65 Biome::frozenOcean = (new OceanBiome(10))->setColor(0x9090a0)->setName(L"FrozenOcean")->setSnowCovered()->setDepthAndScale(-1, 0.5f)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenOcean, eMinecraftColour_Foliage_FrozenOcean, eMinecraftColour_Water_FrozenOcean,eMinecraftColour_Sky_FrozenOcean);
66 Biome::frozenRiver = (new RiverBiome(11))->setColor(0xa0a0ff)->setName(L"FrozenRiver")->setSnowCovered()->setDepthAndScale(-0.5f, 0)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_FrozenRiver, eMinecraftColour_Foliage_FrozenRiver, eMinecraftColour_Water_FrozenRiver,eMinecraftColour_Sky_FrozenRiver);
67 Biome::iceFlats = (new IceBiome(12))->setColor(0xffffff)->setName(L"Ice Plains")->setSnowCovered()->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_IcePlains, eMinecraftColour_Foliage_IcePlains, eMinecraftColour_Water_IcePlains,eMinecraftColour_Sky_IcePlains);
68 Biome::iceMountains = (new IceBiome(13))->setColor(0xa0a0a0)->setName(L"Ice Mountains")->setSnowCovered()->setDepthAndScale(0.3f, 1.3f)->setTemperatureAndDownfall(0, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_IceMountains, eMinecraftColour_Foliage_IceMountains, eMinecraftColour_Water_IceMountains,eMinecraftColour_Sky_IceMountains);
69
70 Biome::mushroomIsland = (new MushroomIslandBiome(14))->setColor(0xff00ff)->setName(L"MushroomIsland")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(0.2f, 1.0f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIsland, eMinecraftColour_Foliage_MushroomIsland, eMinecraftColour_Water_MushroomIsland,eMinecraftColour_Sky_MushroomIsland);
71 Biome::mushroomIslandShore = (new MushroomIslandBiome(15))->setColor(0xa000ff)->setName(L"MushroomIslandShore")->setTemperatureAndDownfall(0.9f, 1.0f)->setDepthAndScale(-1, 0.1f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_MushroomIslandShore, eMinecraftColour_Foliage_MushroomIslandShore, eMinecraftColour_Water_MushroomIslandShore,eMinecraftColour_Sky_MushroomIslandShore);
72
73 Biome::beaches = (new BeachBiome(16))->setColor(0xfade55)->setName(L"Beach")->setTemperatureAndDownfall(0.8f, 0.4f)->setDepthAndScale(0.0f, 0.1f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Beach, eMinecraftColour_Foliage_Beach, eMinecraftColour_Water_Beach,eMinecraftColour_Sky_Beach);
74 Biome::desertHills = (new DesertBiome(17))->setColor(0xd25f12)->setName(L"DesertHills")->setNoRain()->setTemperatureAndDownfall(2, 0)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_DesertHills, eMinecraftColour_Foliage_DesertHills, eMinecraftColour_Water_DesertHills,eMinecraftColour_Sky_DesertHills);
75 Biome::forestHills = (new ForestBiome(18))->setColor(0x22551c)->setName(L"ForestHills")->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.7f, 0.8f)->setDepthAndScale(0.3f, 0.7f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ForestHills, eMinecraftColour_Foliage_ForestHills, eMinecraftColour_Water_ForestHills,eMinecraftColour_Sky_ForestHills);
76 Biome::taigaHills = (new TaigaBiome(19))->setColor(0x163933)->setName(L"TaigaHills")->setSnowCovered()->setLeafColor(0x4EBA31)->setTemperatureAndDownfall(0.05f, 0.8f)->setDepthAndScale(0.3f, 0.8f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_TaigaHills, eMinecraftColour_Foliage_TaigaHills, eMinecraftColour_Water_TaigaHills,eMinecraftColour_Sky_TaigaHills);
77 Biome::smallerExtremeHills = (new ExtremeHillsBiome(20))->setColor(0x72789a)->setName(L"Extreme Hills Edge")->setDepthAndScale(0.2f, 0.8f)->setTemperatureAndDownfall(0.2f, 0.3f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_ExtremeHillsEdge, eMinecraftColour_Foliage_ExtremeHillsEdge, eMinecraftColour_Water_ExtremeHillsEdge,eMinecraftColour_Sky_ExtremeHillsEdge);
78
79 Biome::jungle = (new JungleBiome(21))->setColor(0x537b09)->setName(L"Jungle")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(0.2f, 0.4f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_Jungle, eMinecraftColour_Foliage_Jungle, eMinecraftColour_Water_Jungle,eMinecraftColour_Sky_Jungle);
80 Biome::jungleHills = (new JungleBiome(22))->setColor(0x2c4205)->setName(L"JungleHills")->setLeafColor(0x537b09)->setTemperatureAndDownfall(1.2f, 0.9f)->setDepthAndScale(1.8f, 0.5f)->setLeafFoliageWaterSkyColor(eMinecraftColour_Grass_JungleHills, eMinecraftColour_Foliage_JungleHills, eMinecraftColour_Water_JungleHills,eMinecraftColour_Sky_JungleHills);
81}
82
83Biome::Biome(int id) : id(id)
84{
85 // 4J Stu Default inits
86 color = 0;
87 // snowCovered = false; // 4J - this isn't set by the java game any more so removing to save confusion
88
89 topMaterial = (byte) Tile::grass_Id;
90 material = (byte) Tile::dirt_Id;
91 leafColor = 0x4EE031;
92 _hasRain = true;
93 depth = 0.1f;
94 scale = 0.3f;
95 temperature = 0.5f;
96 downfall = 0.5f;
97 //waterColor = 0xffffff; // 4J Stu - Not used
98 decorator = NULL;
99
100 m_grassColor = eMinecraftColour_NOT_SET;
101 m_foliageColor = eMinecraftColour_NOT_SET;
102 m_waterColor = eMinecraftColour_NOT_SET;
103
104 /* 4J - removing these so that we can consistently return newly created trees via getTreeFeature, and let the calling function be resposible for deleting the returned tree
105 normalTree = new TreeFeature();
106 fancyTree = new BasicTree();
107 birchTree = new BirchFeature();
108 swampTree = new SwampTreeFeature();
109 */
110
111 biomes[id] = this;
112 decorator = createDecorator();
113
114 friendlies.push_back(new MobSpawnerData(eTYPE_SHEEP, 12, 4, 4));
115 friendlies.push_back(new MobSpawnerData(eTYPE_PIG, 10, 4, 4));
116 friendlies_chicken.push_back(new MobSpawnerData(eTYPE_CHICKEN, 10, 4, 4)); // 4J - moved chickens to their own category
117 friendlies.push_back(new MobSpawnerData(eTYPE_COW, 8, 4, 4));
118
119 enemies.push_back(new MobSpawnerData(eTYPE_SPIDER, 10, 4, 4));
120 enemies.push_back(new MobSpawnerData(eTYPE_ZOMBIE, 10, 4, 4));
121 enemies.push_back(new MobSpawnerData(eTYPE_SKELETON, 10, 4, 4));
122 enemies.push_back(new MobSpawnerData(eTYPE_CREEPER, 10, 4, 4));
123 enemies.push_back(new MobSpawnerData(eTYPE_SLIME, 10, 4, 4));
124 enemies.push_back(new MobSpawnerData(eTYPE_ENDERMAN, 1, 1, 4));
125
126 // wolves are added to forests and taigas
127
128 waterFriendlies.push_back(new MobSpawnerData(eTYPE_SQUID, 10, 4, 4));
129
130 ambientFriendlies.push_back(new MobSpawnerData(eTYPE_BAT, 10, 8, 8));
131}
132
133Biome::~Biome()
134{
135 if(decorator != NULL) delete decorator;
136}
137
138BiomeDecorator *Biome::createDecorator()
139{
140 return new BiomeDecorator(this);
141}
142
143// 4J Added
144Biome *Biome::setLeafFoliageWaterSkyColor(eMinecraftColour grassColor, eMinecraftColour foliageColor, eMinecraftColour waterColour, eMinecraftColour skyColour)
145{
146 m_grassColor = grassColor;
147 m_foliageColor = foliageColor;
148 m_waterColor = waterColour;
149 m_skyColor = skyColour;
150 return this;
151}
152
153Biome *Biome::setTemperatureAndDownfall(float temp, float downfall)
154{
155 temperature = temp;
156 this->downfall = downfall;
157 return this;
158}
159
160Biome *Biome::setDepthAndScale(float depth, float scale)
161{
162 this->depth = depth;
163 this->scale = scale;
164 return this;
165}
166
167Biome *Biome::setNoRain()
168{
169 _hasRain = false;
170 return this;
171}
172
173Feature *Biome::getTreeFeature(Random *random)
174{
175 if (random->nextInt(10) == 0)
176 {
177 return new BasicTree(false); // 4J used to return member fancyTree, now returning newly created object so that caller can be consistently resposible for cleanup
178 }
179 return new TreeFeature(false); // 4J used to return member normalTree, now returning newly created object so that caller can be consistently resposible for cleanup
180}
181
182Feature *Biome::getGrassFeature(Random *random)
183{
184 return new TallGrassFeature(Tile::tallgrass_Id, TallGrass::TALL_GRASS);
185}
186
187Biome *Biome::setSnowCovered()
188{
189 snowCovered = true;
190 return this;
191}
192
193Biome *Biome::setName(const wstring &name)
194{
195 this->m_name = name;
196 return this;
197}
198
199Biome *Biome::setLeafColor(int leafColor)
200{
201 this->leafColor = leafColor;
202 return this;
203}
204
205Biome *Biome::setColor(int color)
206{
207 this->color = color;
208 return this;
209}
210
211int Biome::getSkyColor(float temp)
212{
213 //temp /= 3.0f;
214 //if (temp < -1) temp = -1;
215 //if (temp > 1) temp = 1;
216 //return Color::getHSBColor(224 / 360.0f - temp * 0.05f, 0.50f + temp * 0.1f, 1.0f).getRGB();
217
218 // 4J Stu - Load colour from texture pack
219 return Minecraft::GetInstance()->getColourTable()->getColor( m_skyColor );
220}
221
222vector<Biome::MobSpawnerData *> *Biome::getMobs(MobCategory *category)
223{
224 if (category == MobCategory::monster) return &enemies;
225 if (category == MobCategory::creature) return &friendlies;
226 if (category == MobCategory::waterCreature) return &waterFriendlies;
227 if (category == MobCategory::creature_chicken) return &friendlies_chicken;
228 if (category == MobCategory::creature_wolf) return &friendlies_wolf;
229 if (category == MobCategory::creature_mushroomcow) return &friendlies_mushroomcow;
230 if (category == MobCategory::ambient) return &ambientFriendlies;
231 return NULL;
232}
233
234bool Biome::hasSnow()
235{
236 // 4J - snowCovered flag removed as it wasn't being set by the game anymore - snow is now temperature dependent to match code in rain rendering, shouldFreeze functions etc.
237 if( !_hasRain ) return false;
238
239 if( getTemperature() >= 0.15f ) return false;
240
241 return true;
242}
243
244bool Biome::hasRain()
245{
246 // 4J - snowCovered flag removed as it wasn't being set by the game anymore, replaced by call to hasSnow()
247 if( hasSnow() ) return false;
248 // if (snowCovered) return false;
249 return _hasRain;
250}
251
252bool Biome::isHumid()
253{
254 return downfall > .85f;
255}
256
257float Biome::getCreatureProbability()
258{
259 return 0.1f;
260}
261
262int Biome::getDownfallInt()
263{
264 return (int) (downfall * 65536);
265}
266
267int Biome::getTemperatureInt()
268{
269 return (int) (temperature * 65536);
270}
271
272// 4J - brought forward from 1.2.3
273float Biome::getDownfall()
274{
275 return downfall;
276}
277
278// 4J - brought forward from 1.2.3
279float Biome::getTemperature()
280{
281 return temperature;
282}
283
284void Biome::decorate(Level *level, Random *random, int xo, int zo)
285{
286 decorator->decorate(level, random, xo, zo);
287}
288
289int Biome::getGrassColor()
290{
291 //double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f);
292 //double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f);
293
294 //return GrassColor::get(temp, rain);
295 return Minecraft::GetInstance()->getColourTable()->getColor( m_grassColor );
296}
297
298int Biome::getFolageColor()
299{
300 //double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f);
301 //double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f);
302
303 //return FoliageColor::get(temp, rain);
304 return Minecraft::GetInstance()->getColourTable()->getColor( m_foliageColor );
305}
306
307// 4J Added
308int Biome::getWaterColor()
309{
310 return Minecraft::GetInstance()->getColourTable()->getColor( m_waterColor );
311}