Added Buckets

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-13 13:42:55 +02:00
parent c334bbce12
commit 452df5b2f8
5 changed files with 139 additions and 0 deletions

View File

@ -95,6 +95,10 @@ define("PAINTING", 321);
define("GOLDEN_APPLE", 322);
define("SIGN", 323);
define("WOODEN_DOOR", 324);
define("BUCKET", 325);
define("WATER_BUCKET", 326);
define("LAVA_BUCKET", 327);
define("IRON_DOOR", 330);

View File

@ -32,6 +32,9 @@ class Item{
MELON_SEEDS => "MelonSeedsItem",
SIGN => "SignItem",
WOODEN_DOOR => "WoodenDoorItem",
BUCKET => "BucketItem",
WATER_BUCKET => "WaterBucketItem",
LAVA_BUCKET => "LavaBucketItem",
IRON_DOOR => "IronDoorItem",
BED => "BedItem",
PAINTING => "PaintingItem",

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 BucketItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(BUCKET, 0, $count, "Empty Bucket");
$this->isActivable = true;
$this->maxStackSize = 1;
}
public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->getID() === STILL_WATER or $target->getID() === STILL_LAVA){
$level->setBlock($target, AIR, 0);
$player->removeItem($this->getID(), $this->getMetadata(), $this->count);
$player->addItem(($target->getID() === STILL_LAVA ? LAVA_BUCKET:WATER_BUCKET), 0, 1);
return true;
}
return false;
}
}

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 LavaBucketItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(LAVA_BUCKET, 0, $count, "Lava Bucket");
$this->isActivable = true;
$this->maxStackSize = 1;
}
public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->getID() === AIR){
$level->setBlock($target, STILL_LAVA, 0);
$player->removeItem($this->getID(), $this->getMetadata(), $this->count);
$player->addItem(BUCKET, 0, 1);
return true;
}
return false;
}
}

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 WaterBucketItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(WATER_BUCKET, 0, $count, "Water Bucket");
$this->isActivable = true;
$this->maxStackSize = 1;
}
public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->getID() === AIR){
$level->setBlock($target, STILL_WATER, 0);
$player->removeItem($this->getID(), $this->getMetadata(), $this->count);
$player->addItem(BUCKET, 0, 1);
return true;
}
return false;
}
}