mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
rewritten how item durability/count is handled on serverside
This commit is contained in:
parent
4880be5452
commit
841e12b9ea
30 changed files with 128 additions and 152 deletions
|
|
@ -10,9 +10,7 @@ class TNTBlock extends SolidBlock{
|
|||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === FLINT_STEEL){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$item->useOn($this);
|
||||
}
|
||||
$item->hurtAndBreak(1, $player);
|
||||
$data = array(
|
||||
"x" => $this->x + 0.5,
|
||||
"y" => $this->y,
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ class BeetrootBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ class CarrotBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -34,11 +34,9 @@ class CyanFlowerBlock extends FlowableBlock{
|
|||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$random = new Random();
|
||||
self::placeFlowers($this->level, new Vector3($this->x, $this->y, $this->z), $random, $random->nextRange(2, 5), 2);
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -29,11 +29,9 @@ class DandelionBlock extends FlowableBlock{
|
|||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$random = new Random();
|
||||
self::placeFlowers($this->level, new Vector3($this->x, $this->y, $this->z), $random, $random->nextRange(2, 5), 2);
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -58,9 +58,7 @@ class MelonStemBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ class PotatoBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -58,9 +58,7 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ class SaplingBlock extends FlowableBlock{
|
|||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
$this->level->fastSetBlockUpdateMeta($this->x, $this->y, $this->z, $this->meta, true);
|
||||
}
|
||||
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ class WheatBlock extends FlowableBlock{
|
|||
$this->meta = 7;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -11,11 +11,7 @@ class DirtBlock extends SolidBlock{
|
|||
public function onActivate(Item $item, Player $player){
|
||||
if($item->isHoe()){
|
||||
if($this->getSide(1)->isTransparent === false) return false;
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$item->useOn($this);
|
||||
if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
|
||||
else $player->setSlot($player->slot, $item, true);
|
||||
}
|
||||
$item->hurtAndBreak(1, $player); //TODO move to ItemHoe
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, FARMLAND, 0, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,12 @@ class GrassBlock extends SolidBlock{
|
|||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$player->removeItem(DYE,0x0F,1);
|
||||
}
|
||||
$player->consumeSingleItem();
|
||||
TallGrassObject::growGrass($this->level, $this, new Random(), 8, 2);
|
||||
return true;
|
||||
}elseif($item->isHoe()){
|
||||
if($this->getSide(1)->isTransparent === false) return false;
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$item->useOn($this);
|
||||
if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
|
||||
else $player->setSlot($player->slot, $item, true);
|
||||
}
|
||||
$item->hurtAndBreak(1, $player); //TODO move to ItemHoe
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, FARMLAND, 0, true);
|
||||
$this->seedsDrop();
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue