mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
PMF & Multiworld [part 2]
This commit is contained in:
parent
9b212ae034
commit
5938747083
39 changed files with 239 additions and 301 deletions
|
|
@ -32,7 +32,7 @@ class BurningFurnaceBlock extends SolidBlock{
|
|||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$faces = array(
|
||||
0 => 4,
|
||||
|
|
@ -40,14 +40,14 @@ class BurningFurnaceBlock extends SolidBlock{
|
|||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
$level->setBlock($block, $this->id, $faces[$player->entity->getDirection()]);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||
if($this->inWorld === true){
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tileentity->get($this);
|
||||
if($t !== false){
|
||||
|
|
@ -61,16 +61,12 @@ class BurningFurnaceBlock extends SolidBlock{
|
|||
$server->api->tileentity->remove($t->id);
|
||||
}
|
||||
}
|
||||
$level->setBlock($this, 0, 0);
|
||||
$this->level->setBlock($this, new AirBlock());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
if($this->inWorld !== true){
|
||||
return false;
|
||||
}
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tileentity->get($this);
|
||||
$furnace = false;
|
||||
|
|
@ -81,7 +77,7 @@ class BurningFurnaceBlock extends SolidBlock{
|
|||
$furnace = $t;
|
||||
}
|
||||
}else{
|
||||
$furnace = $server->api->tileentity->add(TILE_FURNACE, $this->x, $this->y, $this->z, array(
|
||||
$furnace = $server->api->tileentity->add($this->level, TILE_FURNACE, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
"id" => TILE_FURNACE,
|
||||
"x" => $this->x,
|
||||
|
|
|
|||
|
|
@ -30,12 +30,11 @@ class ChestBlock extends TransparentBlock{
|
|||
parent::__construct(CHEST, $meta, "Chest");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$block0 = $level->getBlockFace($block, 2);
|
||||
$block1 = $level->getBlockFace($block, 3);
|
||||
$block2 = $level->getBlockFace($block, 4);
|
||||
$block3 = $level->getBlockFace($block, 5);
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$block0 = $this->getSide(2);
|
||||
$block1 = $this->getSide(3);
|
||||
$block2 = $this->getSide(4);
|
||||
$block3 = $this->getSide(5);
|
||||
if($block0->getID() !== CHEST and $block1->getID() !== CHEST and $block2->getID() !== CHEST and $block3->getID() !== CHEST){
|
||||
$faces = array(
|
||||
0 => 4,
|
||||
|
|
@ -43,9 +42,10 @@ class ChestBlock extends TransparentBlock{
|
|||
2 => 5,
|
||||
3 => 3,
|
||||
);
|
||||
$level->setBlock($block, $this->id, $faces[$player->entity->getDirection()]);
|
||||
$this->meta = $faces[$player->entity->getDirection()];
|
||||
$this->level->setBlock($block, $this);
|
||||
$server = ServerAPI::request();
|
||||
$server->api->tileentity->add(TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
$server->api->tileentity->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
|
|
@ -54,12 +54,10 @@ class ChestBlock extends TransparentBlock{
|
|||
));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onBreak(BlockAPI $level, Item $item, Player $player){
|
||||
if($this->inWorld === true){
|
||||
public function onBreak(Item $item, Player $player){
|
||||
$server = ServerAPI::request();
|
||||
$t = $server->api->tileentity->get($this);
|
||||
if($t !== false){
|
||||
|
|
@ -73,17 +71,12 @@ class ChestBlock extends TransparentBlock{
|
|||
$server->api->tileentity->remove($t->id);
|
||||
}
|
||||
}
|
||||
$level->setBlock($this, 0, 0);
|
||||
$this->level->setBlock($this, new AirBlock());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
if($this->inWorld !== true){
|
||||
return false;
|
||||
}
|
||||
$top = $level->getBlockFace($this, 1);
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$top = $this->getSide(1);
|
||||
if($top->isTransparent !== true){
|
||||
return true;
|
||||
}
|
||||
|
|
@ -98,7 +91,7 @@ class ChestBlock extends TransparentBlock{
|
|||
$chest = $t;
|
||||
}
|
||||
}else{
|
||||
$chest = $server->api->tileentity->add(TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
$chest = $server->api->tileentity->add($this->level, TILE_CHEST, $this->x, $this->y, $this->z, array(
|
||||
"Items" => array(),
|
||||
"id" => TILE_CHEST,
|
||||
"x" => $this->x,
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ class DirtBlock extends SolidBlock{
|
|||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->isHoe()){
|
||||
$level->setBlock($this, FARMLAND, 0);
|
||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
parent::__construct(FENCE_GATE, $meta, "Fence Gate");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$faces = array(
|
||||
0 => 3,
|
||||
|
|
@ -39,7 +39,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
3 => 2,
|
||||
);
|
||||
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
|
||||
$level->setBlock($block, $this->id, $this->meta);
|
||||
$this->level->setBlock($block, $this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -49,7 +49,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
array($this->id, 0, 1),
|
||||
);
|
||||
}
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$faces = array(
|
||||
0 => 3,
|
||||
1 => 0,
|
||||
|
|
@ -57,7 +57,7 @@ class FenceGateBlock extends TransparentBlock{
|
|||
3 => 2,
|
||||
);
|
||||
$this->meta = ($faces[$player->entity->getDirection()] & 0x03) | ((~$this->meta) & 0x04);
|
||||
$level->setBlock($this, $this->id, $this->meta);
|
||||
$this->level->setBlock($this, $this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -36,13 +36,13 @@ class GrassBlock extends SolidBlock{
|
|||
);
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
|
||||
for($c = 0; $c < 15; ++$c){
|
||||
$x = mt_rand($this->x - 2, $this->x + 2);
|
||||
$z = mt_rand($this->z - 2, $this->z + 2);
|
||||
$b = $level->getBlock(new Vector3($x, $this->y + 1, $z));
|
||||
$d = $level->getBlock(new Vector3($x, $this->y, $z));
|
||||
$b = $this->level->getBlock(new Vector3($x, $this->y + 1, $z));
|
||||
$d = $this->level->getBlock(new Vector3($x, $this->y, $z));
|
||||
if($b->getID() === AIR and $d->getID() === GRASS){
|
||||
$arr = array(
|
||||
array(DANDELION, 0),
|
||||
|
|
@ -54,12 +54,12 @@ class GrassBlock extends SolidBlock{
|
|||
array(AIR, 0),
|
||||
);
|
||||
$t = $arr[mt_rand(0, count($arr) - 1)];
|
||||
$level->setBlock($b, $t[0], $t[1]);
|
||||
$this->level->setBlock($b, BlockAPI::get($t[0], $t[1]));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}elseif($item->isHoe()){
|
||||
$level->setBlock($this, FARMLAND, 0);
|
||||
$this->level->setBlock($this, new FarmlandBlock());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -41,25 +41,24 @@ class SlabBlock extends TransparentBlock{
|
|||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
|
||||
}
|
||||
|
||||
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($block->inWorld === true){
|
||||
$this->meta = $this->meta & 0x07;
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$this->meta &= 0x07;
|
||||
if($face === 0){
|
||||
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
|
||||
$level->setBlock($target, DOUBLE_SLAB, $this->meta & 0x07);
|
||||
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta));
|
||||
return true;
|
||||
}else{
|
||||
$this->meta |= 0x08;
|
||||
}
|
||||
}elseif($face === 1){
|
||||
if($target->getID() === SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){
|
||||
$level->setBlock($target, DOUBLE_SLAB, $this->meta & 0x07);
|
||||
$this->level->setBlock($target, BlockAPI::get(DOUBLE_SLAB, $this->meta));
|
||||
return true;
|
||||
}
|
||||
}elseif(!$player->entity->inBlock($block->x, $block->y, $block->z)){
|
||||
if($block->getID() === SLAB){
|
||||
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){
|
||||
$level->setBlock($block, DOUBLE_SLAB, $this->meta & 0x07);
|
||||
$this->level->setBlock($block, BlockAPI::get(DOUBLE_SLAB, $this->meta));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -74,10 +73,8 @@ class SlabBlock extends TransparentBlock{
|
|||
if($block->getID() === SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){
|
||||
return false;
|
||||
}
|
||||
$level->setBlock($block, $this->id, $this->meta);
|
||||
$this->level->setBlock($block, $this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue