mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
empty buckets can be stacked now
This commit is contained in:
parent
938637b2a2
commit
012f03a52b
4 changed files with 35 additions and 6 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -23,3 +23,6 @@ Desktop.ini
|
||||||
|
|
||||||
# Mac crap
|
# Mac crap
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# nano
|
||||||
|
*.swp
|
||||||
|
|
|
||||||
|
|
@ -1524,7 +1524,7 @@ class Player{
|
||||||
if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
|
if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($packet->pid()){
|
switch($packet->pid()){
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
|
|
@ -2495,6 +2495,7 @@ class Player{
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($item->getID() !== AIR and $slot->getID() == $item->getID()){
|
if($item->getID() !== AIR and $slot->getID() == $item->getID()){
|
||||||
if($slot->count < $item->count){
|
if($slot->count < $item->count){
|
||||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
|
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
|
||||||
|
|
@ -2735,7 +2736,7 @@ class Player{
|
||||||
$s = $this->getSlot($slot);
|
$s = $this->getSlot($slot);
|
||||||
if($s->count <= 0 or $s->getID() === AIR){
|
if($s->count <= 0 or $s->getID() === AIR){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
||||||
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->maxStackSize){
|
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->getMaxStackSize()){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
||||||
}else{
|
}else{
|
||||||
$f1 = 0.3;
|
$f1 = 0.3;
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,10 @@ class Item{
|
||||||
public $id;
|
public $id;
|
||||||
public $meta;
|
public $meta;
|
||||||
public $count;
|
public $count;
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
* Max stack size of the item. Use Item::getMaxStackSize to get stack size for specific item.
|
||||||
|
*/
|
||||||
public $maxStackSize = 64;
|
public $maxStackSize = 64;
|
||||||
public $durability = 0;
|
public $durability = 0;
|
||||||
public $name;
|
public $name;
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,31 @@ class BucketItem extends Item{
|
||||||
public function __construct($meta = 0, $count = 1){
|
public function __construct($meta = 0, $count = 1){
|
||||||
parent::__construct(BUCKET, $meta, $count, "Bucket");
|
parent::__construct(BUCKET, $meta, $count, "Bucket");
|
||||||
$this->isActivable = true;
|
$this->isActivable = true;
|
||||||
$this->maxStackSize = 1;
|
$this->maxStackSize = 16;
|
||||||
$this->name = BucketItem::$possiblenames[$this->meta];
|
$this->name = BucketItem::$possiblenames[$this->meta];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMaxStackSize(){
|
||||||
|
if($this->getMetadata() == 0) return 16;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($this->meta === AIR){
|
if($this->meta === AIR){
|
||||||
if($target instanceof LiquidBlock && $target->getMetadata() == 0){
|
if($target instanceof LiquidBlock && $target->getMetadata() == 0){
|
||||||
$level->setBlock($target, new AirBlock(), true, false, true);
|
$level->setBlock($target, new AirBlock(), true, false, true);
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$this->meta = match($target->getID()){
|
$meta = match($target->getID()){
|
||||||
WATER, STILL_WATER => WATER,
|
WATER, STILL_WATER => WATER,
|
||||||
LAVA, STILL_LAVA => LAVA,
|
LAVA, STILL_LAVA => LAVA,
|
||||||
default => 0
|
default => 0
|
||||||
};
|
};
|
||||||
|
if($this->count <= 1){
|
||||||
|
$this->meta = $meta;
|
||||||
|
}else{
|
||||||
|
--$this->count;
|
||||||
|
$player->addItem(BUCKET, $meta, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -33,7 +44,12 @@ class BucketItem extends Item{
|
||||||
$level->setBlock($block, $water, true, false, true);
|
$level->setBlock($block, $water, true, false, true);
|
||||||
//$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
|
//$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$this->meta = 0;
|
if($this->count <= 1){
|
||||||
|
$this->meta = 0;
|
||||||
|
}else{
|
||||||
|
--$this->count;
|
||||||
|
$player->addItem(BUCKET, $meta, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +59,12 @@ class BucketItem extends Item{
|
||||||
$level->setBlock($block, $lava, true, false, true);
|
$level->setBlock($block, $lava, true, false, true);
|
||||||
//$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
//$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||||
if(($player->gamemode & 0x01) === 0){
|
if(($player->gamemode & 0x01) === 0){
|
||||||
$this->meta = 0;
|
if($this->count <= 1){
|
||||||
|
$this->meta = 0;
|
||||||
|
}else{
|
||||||
|
--$this->count;
|
||||||
|
$player->addItem(BUCKET, $meta, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue