add waterwheel generators
This commit is contained in:
parent
8f4bc2a096
commit
ce6518ab43
Binary file not shown.
After Width: | Height: | Size: 757 B |
Binary file not shown.
After Width: | Height: | Size: 597 B |
|
@ -9394,6 +9394,39 @@ void content_mapnode_init()
|
|||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
||||
i = CONTENT_CIRCUIT_WATERWHEEL;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Water Wheel");
|
||||
f->setAllTextures("circuit_waterwheel.png");
|
||||
f->setTexture(2,"circuit_waterwheel_side.png");
|
||||
f->setTexture(3,"circuit_waterwheel_side.png^[transformFX");
|
||||
f->param_type = CPT_LIGHT;
|
||||
f->param2_type = CPT_FACEDIR_SIMPLE;
|
||||
f->draw_type = CDT_NODEBOX;
|
||||
f->energy_type = CET_SWITCH;
|
||||
f->energy_drop = 0;
|
||||
f->light_propagates = true;
|
||||
f->sunlight_propagates = true;
|
||||
f->rotate_tile_with_nodebox = true;
|
||||
f->solidness = 0; // drawn separately, makes no faces
|
||||
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
|
||||
f->type = CMT_WOOD;
|
||||
f->hardness = 0.10;
|
||||
content_nodebox_waterwheel(f);
|
||||
f->setInventoryTextureNodeBox(i,"circuit_waterwheel.png","circuit_waterwheel.png","circuit_waterwheel_side.png");
|
||||
if (f->initial_metadata == NULL)
|
||||
f->initial_metadata = new WaterWheelNodeMetadata();
|
||||
{
|
||||
u16 r[9] = {
|
||||
CONTENT_STONE, CONTENT_WOOD_SLAB, CONTENT_STONE,
|
||||
CONTENT_CRAFTITEM_MESEDUST, CONTENT_CRAFTITEM_STEEL_INGOT, CONTENT_CRAFTITEM_QUARTZ_DUST,
|
||||
CONTENT_STONE, CONTENT_WOOD_SLAB, CONTENT_STONE
|
||||
};
|
||||
crafting::setRecipe(r,CONTENT_CIRCUIT_WATERWHEEL,1);
|
||||
}
|
||||
lists::add("craftguide",i);
|
||||
lists::add("creative",i);
|
||||
|
||||
i = CONTENT_CIRCUIT_SWITCH;
|
||||
f = &content_features(i);
|
||||
f->description = std::string("Switch");
|
||||
|
@ -9401,6 +9434,7 @@ void content_mapnode_init()
|
|||
f->setTexture(5,"circuit_switch_front.png");
|
||||
f->param_type = CPT_FACEDIR_WALLMOUNT;
|
||||
f->draw_type = CDT_NODEBOX;
|
||||
f->rotate_tile_with_nodebox = true;
|
||||
f->is_ground_content = true;
|
||||
f->energy_type = CET_SWITCH;
|
||||
f->energy_drop = 0;
|
||||
|
|
|
@ -1319,3 +1319,28 @@ void content_nodebox_pistonarm_down(ContentFeatures *f)
|
|||
));
|
||||
}
|
||||
|
||||
void content_nodebox_waterwheel(ContentFeatures *f)
|
||||
{
|
||||
f->setNodeBox(core::aabbox3d<f32>(
|
||||
0.375*BS,-0.5*BS,-0.5*BS,0.5*BS,0.5*BS,0.5*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.5*BS,-0.5*BS,-0.5*BS,-0.375*BS,0.5*BS,0.5*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.375*BS,-0.0625*BS,-0.0625*BS,0.375*BS,0.0625*BS,0.0625*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.375*BS,0.0625*BS,0.*BS,0.375*BS,0.5*BS,0.0625*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.375*BS,-0.0625*BS,0.0625*BS,0.375*BS,0.*BS,0.5*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.375*BS,-0.5*BS,-0.0625*BS,0.375*BS,-0.0625*BS,0.*BS
|
||||
));
|
||||
f->addNodeBox(core::aabbox3d<f32>(
|
||||
-0.375*BS,0.*BS,-0.5*BS,0.375*BS,0.0625*BS,-0.0625*BS
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,5 +55,6 @@ void content_nodebox_piston_up(ContentFeatures *f);
|
|||
void content_nodebox_pistonarm_up(ContentFeatures *f);
|
||||
void content_nodebox_piston_down(ContentFeatures *f);
|
||||
void content_nodebox_pistonarm_down(ContentFeatures *f);
|
||||
void content_nodebox_waterwheel(ContentFeatures *f);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2282,6 +2282,99 @@ bool SolarPanelNodeMetadata::energise(u8 level, v3s16 powersrc, v3s16 signalsrc,
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
WaterWheelNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
WaterWheelNodeMetadata proto_WaterWheelNodeMetadata;
|
||||
|
||||
WaterWheelNodeMetadata::WaterWheelNodeMetadata()
|
||||
{
|
||||
m_energy = 0;
|
||||
m_ptime = 0;
|
||||
m_sources.clear();
|
||||
NodeMetadata::registerType(typeId(), create);
|
||||
}
|
||||
u16 WaterWheelNodeMetadata::typeId() const
|
||||
{
|
||||
return CONTENT_CIRCUIT_WATERWHEEL;
|
||||
}
|
||||
NodeMetadata* WaterWheelNodeMetadata::create(std::istream &is)
|
||||
{
|
||||
WaterWheelNodeMetadata *d = new WaterWheelNodeMetadata();
|
||||
int temp;
|
||||
is>>temp;
|
||||
d->m_energy = temp;
|
||||
is>>temp;
|
||||
d->m_ptime = (float)temp/10;
|
||||
int i;
|
||||
is>>i;
|
||||
v3s16 p;
|
||||
for (; i > 0; i--) {
|
||||
is>>temp;
|
||||
p.X = temp;
|
||||
is>>temp;
|
||||
p.Y = temp;
|
||||
is>>temp;
|
||||
p.Z = temp;
|
||||
is>>temp;
|
||||
d->m_sources[p] = temp;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* WaterWheelNodeMetadata::clone()
|
||||
{
|
||||
WaterWheelNodeMetadata *d = new WaterWheelNodeMetadata();
|
||||
return d;
|
||||
}
|
||||
bool WaterWheelNodeMetadata::step(float dtime, v3s16 pos, ServerEnvironment *env)
|
||||
{
|
||||
MapNode n = env->getMap().getNodeNoEx(pos);
|
||||
v3s16 dir = n.getRotation();
|
||||
if (dir == v3s16(1,1,1)) {
|
||||
dir = v3s16(0,0,-1);
|
||||
}else if (dir == v3s16(-1,1,1)) {
|
||||
dir = v3s16(-1,0,0);
|
||||
}else if (dir == v3s16(-1,1,-1)) {
|
||||
dir = v3s16(0,0,1);
|
||||
}else if (dir == v3s16(1,1,-1)) {
|
||||
dir = v3s16(1,0,0);
|
||||
}
|
||||
MapNode inlet = env->getMap().getNodeNoEx(pos-dir);
|
||||
MapNode outlet = env->getMap().getNodeNoEx(pos+dir);
|
||||
if (inlet.getContent() != CONTENT_WATERSOURCE) {
|
||||
if (outlet.getContent() == CONTENT_WATERSOURCE)
|
||||
env->getMap().removeNodeWithEvent(pos+dir);
|
||||
if (m_energy) {
|
||||
m_energy = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (outlet.getContent() != CONTENT_WATERSOURCE) {
|
||||
if (outlet.getContent() != CONTENT_AIR) {
|
||||
if (m_energy) {
|
||||
m_energy = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
outlet.setContent(CONTENT_WATERSOURCE);
|
||||
env->getMap().addNodeWithEvent(pos+dir,outlet);
|
||||
}
|
||||
|
||||
m_energy = ENERGY_MAX;
|
||||
env->propogateEnergy(ENERGY_MAX,pos,pos,pos);
|
||||
return true;
|
||||
}
|
||||
bool WaterWheelNodeMetadata::energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos)
|
||||
{
|
||||
if (!m_energy)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
SourceNodeMetadata
|
||||
*/
|
||||
|
|
|
@ -510,6 +510,17 @@ public:
|
|||
virtual bool energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos);
|
||||
};
|
||||
|
||||
class WaterWheelNodeMetadata : public CircuitNodeMetadata
|
||||
{
|
||||
public:
|
||||
WaterWheelNodeMetadata();
|
||||
virtual u16 typeId() const;
|
||||
static NodeMetadata* create(std::istream &is);
|
||||
virtual NodeMetadata* clone();
|
||||
virtual bool step(float dtime, v3s16 pos, ServerEnvironment *env);
|
||||
virtual bool energise(u8 level, v3s16 powersrc, v3s16 signalsrc, v3s16 pos);
|
||||
};
|
||||
|
||||
class NotGateNodeMetadata : public CircuitNodeMetadata
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue