Basic implementation of Fire

This commit is contained in:
Shoghi Cervantes 2013-06-09 14:59:02 +02:00
parent 2f6ddb6aa4
commit 2976db25c3
14 changed files with 73 additions and 5 deletions

View File

@ -210,7 +210,9 @@ class Player{
));
$inv = array();
foreach($this->inventory as $slot => $item){
$inv[$slot] = array($item->getID(), $item->getMetadata(), $item->count);
if($slot < (($this->gamemode & 0x01) === 0 ? PLAYER_SURVIVAL_SLOTS:PLAYER_CREATIVE_SLOTS)){
$inv[$slot] = array($item->getID(), $item->getMetadata(), $item->count);
}
}
$this->data->set("inventory", $inv);

View File

@ -29,6 +29,7 @@ define("IRON_SHOVEL", 256);//Implemented
define("IRON_PICKAXE", 257);//Implemented
define("IRON_AXE", 258);//Implemented
define("FLINT_STEEL", 259);
define("FLINT_AND_STEEL", 259);
define("APPLE", 260);//Implemented
define("BOW", 261);
define("ARROW", 262);

View File

@ -55,6 +55,7 @@ class Item{
WOODEN_SHOVEL => "WoodenShovelItem",
WOODEN_PICKAXE => "WoodenPickaxeItem",
WOODEN_AXE => "WoodenAxeItem",
FLINT_STEEL => "FlintSteelItem",
);
protected $block;
protected $id;
@ -74,6 +75,9 @@ class Item{
$this->block = BlockAPI::get($this->id, $this->meta);
$this->name = $this->block->getName();
}
if($this->isTool() !== false){
$this->maxStackSize = 1;
}
}
final public function getName(){
@ -138,7 +142,7 @@ class Item{
}
final public function isTool(){
return ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false or $this->isHoe() !== false);
return ($this->id === FLINT_STEEL or $this->id === SHEARS or $this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false or $this->isSword() !== false or $this->isHoe() !== false);
}
final public function isPickaxe(){ //Returns false or level of the pickaxe

View File

@ -31,7 +31,25 @@ class FireBlock extends FlowableBlock{
$this->isReplaceable = true;
$this->breakable = false;
$this->isFullBlock = true;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
for($s = 0; $s <= 5; ++$s){
$side = $this->getSide($s);
if($side->getID() !== AIR and !($side instanceof LiquidBlock)){
return false;
}
}
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}elseif($type === BLOCK_UPDATE_RANDOM){
if($this->getSide(0)->getID() !== NETHERRACK){
$this->level->setBlock($this, new AirBlock(), false);
return BLOCK_UPDATE_NORMAL;
}
}
return false;
}
}

View File

@ -27,8 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
class BucketItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(BUCKET, 0, $count, "Bucket");
$this->meta = $meta;
parent::__construct(BUCKET, $meta, $count, "Bucket");
$this->isActivable = true;
$this->maxStackSize = 1;
}

View File

@ -0,0 +1,44 @@
<?php
/*
-
/ \
/ \
/ PocketMine \
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
*/
class FlintSteelItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(FLINT_STEEL, $meta, $count, "Flint and Steel");
$this->isActivable = true;
$this->maxStackSize = 1;
}
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($block->getID() === AIR){
$level->setBlock($block, new FireBlock(), true, false, true);
$block->level->scheduleBlockUpdate(new Position($block, 0, 0, $block->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
return true;
}
$this->useOn($block);
return false;
}
}