forked from Kolyah35/minecraft-pe-0.6.1
the whole game
This commit is contained in:
23
src/world/level/material/DecorationMaterial.h
Executable file
23
src/world/level/material/DecorationMaterial.h
Executable file
@@ -0,0 +1,23 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_LEVEL_MATERIAL__DecorationMaterial_H__
|
||||
#define NET_MINECRAFT_WORLD_LEVEL_MATERIAL__DecorationMaterial_H__
|
||||
|
||||
//package net.minecraft.world.level.material;
|
||||
#include "Material.h"
|
||||
|
||||
class DecorationMaterial: public Material
|
||||
{
|
||||
public:
|
||||
bool isSolid() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool blocksLight() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool blocksMotion() const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL_MATERIAL__DecorationMaterial_H__*/
|
||||
27
src/world/level/material/GasMaterial.h
Executable file
27
src/world/level/material/GasMaterial.h
Executable file
@@ -0,0 +1,27 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_LEVEL_MATERIAL__GasMaterial_H__
|
||||
#define NET_MINECRAFT_WORLD_LEVEL_MATERIAL__GasMaterial_H__
|
||||
|
||||
//package net.minecraft.world.level.material;
|
||||
#include "Material.h"
|
||||
|
||||
class GasMaterial: public Material
|
||||
{
|
||||
public:
|
||||
GasMaterial() {
|
||||
replaceable();
|
||||
}
|
||||
|
||||
bool isSolid() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool blocksLight() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool blocksMotion() const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL_MATERIAL__GasMaterial_H__*/
|
||||
27
src/world/level/material/LiquidMaterial.h
Executable file
27
src/world/level/material/LiquidMaterial.h
Executable file
@@ -0,0 +1,27 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_LEVEL_MATERIAL__LiquidMaterial_H__
|
||||
#define NET_MINECRAFT_WORLD_LEVEL_MATERIAL__LiquidMaterial_H__
|
||||
|
||||
//package net.minecraft.world.level.material;
|
||||
#include "Material.h"
|
||||
|
||||
class LiquidMaterial: public Material
|
||||
{
|
||||
public:
|
||||
LiquidMaterial() {
|
||||
replaceable();
|
||||
}
|
||||
|
||||
bool isLiquid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool blocksMotion() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSolid() const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL_MATERIAL__LiquidMaterial_H__*/
|
||||
99
src/world/level/material/Material.cpp
Executable file
99
src/world/level/material/Material.cpp
Executable file
@@ -0,0 +1,99 @@
|
||||
#include "Material.h"
|
||||
#include "GasMaterial.h"
|
||||
#include "LiquidMaterial.h"
|
||||
#include "DecorationMaterial.h"
|
||||
#include "WebMaterial.h"
|
||||
#include <cstdlib>
|
||||
|
||||
const Material* Material::air = NULL;
|
||||
const Material* Material::dirt = NULL;
|
||||
const Material* Material::wood = NULL;
|
||||
const Material* Material::stone = NULL;
|
||||
const Material* Material::metal = NULL;
|
||||
const Material* Material::water = NULL;
|
||||
const Material* Material::lava = NULL;
|
||||
const Material* Material::leaves = NULL;
|
||||
const Material* Material::plant = NULL;
|
||||
const Material* Material::replaceable_plant = NULL;
|
||||
const Material* Material::sponge = NULL;
|
||||
const Material* Material::cloth = NULL;
|
||||
const Material* Material::fire = NULL;
|
||||
const Material* Material::sand = NULL;
|
||||
const Material* Material::decoration= NULL;
|
||||
const Material* Material::glass = NULL;
|
||||
const Material* Material::explosive = NULL;
|
||||
const Material* Material::coral = NULL;
|
||||
const Material* Material::ice = NULL;
|
||||
const Material* Material::topSnow = NULL;
|
||||
const Material* Material::snow = NULL;
|
||||
const Material* Material::cactus = NULL;
|
||||
const Material* Material::clay = NULL;
|
||||
const Material* Material::vegetable = NULL;
|
||||
const Material* Material::portal = NULL;
|
||||
const Material* Material::cake = NULL;
|
||||
const Material* Material::web = NULL;
|
||||
|
||||
/*static*/
|
||||
void Material::initMaterials()
|
||||
{
|
||||
air = new GasMaterial();
|
||||
dirt = new Material();
|
||||
wood = (new Material())->flammable();
|
||||
stone = (new Material())->notAlwaysDestroyable();
|
||||
metal = (new Material())->notAlwaysDestroyable();
|
||||
water = new LiquidMaterial();
|
||||
lava = new LiquidMaterial();
|
||||
leaves = (new Material())->flammable()->neverBuildable();
|
||||
plant = new DecorationMaterial();
|
||||
replaceable_plant = (new DecorationMaterial())->replaceable()->flammable();
|
||||
sponge = new Material();
|
||||
cloth = (new Material())->flammable();
|
||||
fire = new GasMaterial();
|
||||
sand = new Material();
|
||||
decoration= new DecorationMaterial();
|
||||
glass = (new Material())->neverBuildable();
|
||||
explosive = (new Material())->flammable()->neverBuildable();
|
||||
coral = new Material();
|
||||
ice = (new Material())->neverBuildable();
|
||||
topSnow = (new DecorationMaterial())->neverBuildable()->notAlwaysDestroyable()->replaceable();
|
||||
snow = (new Material())->notAlwaysDestroyable();
|
||||
cactus = (new Material())->neverBuildable();
|
||||
clay = new Material();
|
||||
vegetable = new Material();
|
||||
portal = new Material();
|
||||
cake = new Material();
|
||||
web = (new WebMaterial());
|
||||
}
|
||||
|
||||
#define SAFEDEL(x) if (x) { delete x; x = NULL; }
|
||||
|
||||
/*static*/
|
||||
void Material::teardownMaterials() {
|
||||
SAFEDEL(air);
|
||||
SAFEDEL(dirt);
|
||||
SAFEDEL(wood);
|
||||
SAFEDEL(stone);
|
||||
SAFEDEL(metal);
|
||||
SAFEDEL(water);
|
||||
SAFEDEL(lava);
|
||||
SAFEDEL(leaves);
|
||||
SAFEDEL(plant);
|
||||
SAFEDEL(replaceable_plant);
|
||||
SAFEDEL(sponge);
|
||||
SAFEDEL(cloth);
|
||||
SAFEDEL(fire);
|
||||
SAFEDEL(sand);
|
||||
SAFEDEL(decoration);
|
||||
SAFEDEL(glass);
|
||||
SAFEDEL(explosive);
|
||||
SAFEDEL(coral);
|
||||
SAFEDEL(ice);
|
||||
SAFEDEL(topSnow);
|
||||
SAFEDEL(snow);
|
||||
SAFEDEL(cactus);
|
||||
SAFEDEL(clay);
|
||||
SAFEDEL(vegetable);
|
||||
SAFEDEL(portal);
|
||||
SAFEDEL(cake);
|
||||
SAFEDEL(web);
|
||||
}
|
||||
116
src/world/level/material/Material.h
Executable file
116
src/world/level/material/Material.h
Executable file
@@ -0,0 +1,116 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_LEVEL_MATERIAL__Material_H__
|
||||
#define NET_MINECRAFT_WORLD_LEVEL_MATERIAL__Material_H__
|
||||
|
||||
//package net.minecraft.world.level.material;
|
||||
|
||||
class Material
|
||||
{
|
||||
public:
|
||||
static const Material* air;
|
||||
static const Material* dirt;
|
||||
static const Material* wood;
|
||||
static const Material* stone;
|
||||
static const Material* metal;
|
||||
static const Material* water;
|
||||
static const Material* lava;
|
||||
static const Material* leaves;
|
||||
static const Material* plant;
|
||||
static const Material* replaceable_plant;
|
||||
static const Material* sponge;
|
||||
static const Material* cloth;
|
||||
static const Material* fire;
|
||||
static const Material* sand;
|
||||
static const Material* decoration;
|
||||
static const Material* glass;
|
||||
static const Material* explosive;
|
||||
static const Material* coral;
|
||||
static const Material* ice;
|
||||
static const Material* topSnow;
|
||||
static const Material* snow;
|
||||
static const Material* cactus;
|
||||
static const Material* clay;
|
||||
static const Material* vegetable;
|
||||
static const Material* portal;
|
||||
static const Material* cake;
|
||||
static const Material* web;
|
||||
|
||||
static void initMaterials();
|
||||
static void teardownMaterials();
|
||||
|
||||
virtual bool isLiquid() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool letsWaterThrough() const {
|
||||
return (!isLiquid() && !isSolid());
|
||||
}
|
||||
|
||||
virtual bool isSolid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool blocksLight() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool isSolidBlocking() const {
|
||||
if (_neverBuildable) return false;
|
||||
return blocksMotion();
|
||||
}
|
||||
|
||||
virtual bool isAlwaysDestroyable() const {
|
||||
// these materials will always drop resources when destroyed,
|
||||
// regardless of player's equipment
|
||||
return _isAlwaysDestroyable;
|
||||
}
|
||||
|
||||
virtual bool blocksMotion() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool isFlammable() const {
|
||||
return _flammable;
|
||||
}
|
||||
|
||||
virtual bool isReplaceable() const {
|
||||
return _replaceable;
|
||||
}
|
||||
|
||||
virtual ~Material () {}
|
||||
|
||||
protected:
|
||||
Material()
|
||||
: _flammable(false),
|
||||
_neverBuildable(false),
|
||||
_isAlwaysDestroyable(true),
|
||||
_replaceable(false)
|
||||
{}
|
||||
|
||||
Material* flammable() {
|
||||
_flammable = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
Material* neverBuildable() {
|
||||
_neverBuildable = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
Material* notAlwaysDestroyable() {
|
||||
_isAlwaysDestroyable = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
Material* replaceable() {
|
||||
_replaceable = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
bool _flammable;
|
||||
bool _neverBuildable;
|
||||
bool _isAlwaysDestroyable;
|
||||
bool _replaceable;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL_MATERIAL__Material_H__*/
|
||||
19
src/world/level/material/WebMaterial.h
Executable file
19
src/world/level/material/WebMaterial.h
Executable file
@@ -0,0 +1,19 @@
|
||||
#ifndef NET_MINECRAFT_WORLD_LEVEL_MATERIAL__WebMaterial_H__
|
||||
#define NET_MINECRAFT_WORLD_LEVEL_MATERIAL__WebMaterial_H__
|
||||
|
||||
//package net.minecraft.world.level.material;
|
||||
#include "Material.h"
|
||||
|
||||
class WebMaterial: public Material
|
||||
{
|
||||
public:
|
||||
WebMaterial() {
|
||||
notAlwaysDestroyable();
|
||||
}
|
||||
|
||||
bool blocksMotion() const {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_WORLD_LEVEL_MATERIAL__WebMaterial_H__*/
|
||||
Reference in New Issue
Block a user