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
|
||||
.DS_Store
|
||||
|
||||
# nano
|
||||
*.swp
|
||||
|
|
|
|||
|
|
@ -2495,6 +2495,7 @@ class Player{
|
|||
$this->dataPacket($pk);
|
||||
break;
|
||||
}
|
||||
|
||||
if($item->getID() !== AIR and $slot->getID() == $item->getID()){
|
||||
if($slot->count < $item->count){
|
||||
if($this->removeItem($item->getID(), $item->getMetadata(), $item->count - $slot->count, false) === false){
|
||||
|
|
@ -2735,7 +2736,7 @@ class Player{
|
|||
$s = $this->getSlot($slot);
|
||||
if($s->count <= 0 or $s->getID() === AIR){
|
||||
$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);
|
||||
}else{
|
||||
$f1 = 0.3;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,10 @@ class Item{
|
|||
public $id;
|
||||
public $meta;
|
||||
public $count;
|
||||
/**
|
||||
* @var int
|
||||
* Max stack size of the item. Use Item::getMaxStackSize to get stack size for specific item.
|
||||
*/
|
||||
public $maxStackSize = 64;
|
||||
public $durability = 0;
|
||||
public $name;
|
||||
|
|
|
|||
|
|
@ -10,20 +10,31 @@ class BucketItem extends Item{
|
|||
public function __construct($meta = 0, $count = 1){
|
||||
parent::__construct(BUCKET, $meta, $count, "Bucket");
|
||||
$this->isActivable = true;
|
||||
$this->maxStackSize = 1;
|
||||
$this->maxStackSize = 16;
|
||||
$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){
|
||||
if($this->meta === AIR){
|
||||
if($target instanceof LiquidBlock && $target->getMetadata() == 0){
|
||||
$level->setBlock($target, new AirBlock(), true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = match($target->getID()){
|
||||
$meta = match($target->getID()){
|
||||
WATER, STILL_WATER => WATER,
|
||||
LAVA, STILL_LAVA => LAVA,
|
||||
default => 0
|
||||
};
|
||||
if($this->count <= 1){
|
||||
$this->meta = $meta;
|
||||
}else{
|
||||
--$this->count;
|
||||
$player->addItem(BUCKET, $meta, 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -33,7 +44,12 @@ class BucketItem extends Item{
|
|||
$level->setBlock($block, $water, true, false, true);
|
||||
//$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
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;
|
||||
}
|
||||
|
|
@ -43,7 +59,12 @@ class BucketItem extends Item{
|
|||
$level->setBlock($block, $lava, true, false, true);
|
||||
//$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue