public function onActivate(Item $item, Player $player = \null) { $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3 | ~$this->meta & 0x4; $this->getLevel()->setBlock($this, $this, \true); return \true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $directions = [0 => 1, 1 => 3, 2 => 0, 3 => 2]; if ($player !== null) { $this->meta = $directions[$player->getDirection() & 0x3]; } if ($fy > 0.5 and $face !== self::SIDE_UP or $face === self::SIDE_DOWN) { $this->meta |= 0b100; //top half of block } $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function spawnDiscourager() { $dir = $this->player->getDirectionVector(); if ($this->player->pitch > 45 or $this->player->pitch < -45) { $face = 0; // y } else { $face = self::$conversionTable[$this->player->getDirection()]; } $center = $this->player->subtract($dir->multiply($this->main->getDistance()))->add(0, $this->player->eyeHeight)->floor(); $l = $this->player->getLevel(); if ($face === self::Y) { $this->overridenBlocks = [$l->getBlock($center->add(1, 0, 1)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, 0, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(-1, 0, 1)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, 0, -1))]; } elseif ($face === self::X) { $this->overridenBlocks = [$l->getBlock($center->add(0, 1, 1)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center->add(0, 1, -1)), $l->getBlock($center->add(0, 0, 1)), $l->getBlock($center), $l->getBlock($center->add(0, 0, -1)), $l->getBlock($center->add(0, -1, 1)), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(0, -1, -1))]; } elseif ($face === self::Z) { $this->overridenBlocks = [$l->getBlock($center->add(1, 1, 0)), $l->getBlock($center->add(1, 0, 0)), $l->getBlock($center->add(1, -1, 0)), $l->getBlock($center->add(0, 1, 0)), $l->getBlock($center), $l->getBlock($center->add(0, -1, 0)), $l->getBlock($center->add(-1, 1, 0)), $l->getBlock($center->add(-1, 0, 0)), $l->getBlock($center->add(-1, -1, 0))]; } foreach ($this->overridenBlocks as $b) { $pk = new UpdateBlockPacket(); $pk->x = $b->x; $pk->y = $b->y; $pk->z = $b->z; $pk->block = $this->main->getBlockType()->getId(); $pk->meta = $this->main->getBlockType()->getDamage(); $this->player->dataPacket($pk); } }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $direction = ($player !== null ? $player->getDirection() : 0) & 0x3; $this->meta = $this->meta & 0xc | $direction; $this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->addSound(new AnvilFallSound($this)); }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $pitch = $player->getPitch(); if (abs($pitch) >= 45) { if ($pitch < 0) { $f = 0; } else { $f = 1; } } else { $f = $player->getDirection() + 2; } } else { $f = 0; } $faces = [0 => 0, 1 => 1, 2 => 4, 3 => 2, 4 => 5, 5 => 3]; $this->meta = $faces[$f]; $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::DROPPER), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); if ($item->hasCustomName()) { $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile(Tile::DROPPER, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3]; $chest = null; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; for ($side = 2; $side <= 5; ++$side) { if (($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)) { continue; } elseif (($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)) { continue; } $c = $this->getSide($side); if ($c instanceof Chest and $c->getDamage() === $this->meta) { $tile = $this->getLevel()->getTile($c); if ($tile instanceof TileChest and !$tile->isPaired()) { $chest = $tile; break; } } } $this->getLevel()->setBlock($block, $this, true, true); $nbt = new Compound(false, [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); if ($chest instanceof TileChest and $tile instanceof TileChest) { $chest->pairWith($tile); $tile->pairWith($chest); } return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null) { $faces = [0 => 0, 1 => 1, 2 => 0, 3 => 1]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; //for($side = 2; $side <= 5; ++$side){} $this->getLevel()->setBlock($block, $this, \true, \true); return \true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($this->id === self::ANVIL) { $this->meta = ($player instanceof Player ? $player->getDirection() : 0) + $this->meta; } $ret = $this->getLevel()->setBlock($this, $this, true, true); return $ret; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($target->isTransparent() === false) { $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3]; $damage = $this->getDamage(); $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x4; if ($damage >= 0 && $damage <= 3) { $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; } elseif ($damage >= 4 && $damage <= 7) { $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x4; } elseif ($damage >= 8 && $damage <= 11) { $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x8; } $this->getLevel()->setBlock($block, $this, true); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($target->isTransparent() === false) { $faces = [3 => 3, 2 => 4, 4 => 2, 5 => 1]; if ($face === 0) { $to = $player instanceof Player ? $player->getDirection() : 0; $this->meta = $to ^ 0x1 === 0x1 ? 0 : 7; } elseif ($face === 1) { $to = $player instanceof Player ? $player->getDirection() : 0; $this->meta = $to ^ 0x1 === 0x1 ? 6 : 5; } else { $this->meta = $faces[$face]; } $this->getLevel()->setBlock($block, $this, true, true); return true; } return false; }
public function onRun(array $args, Player $player) { if (!isset($args[0])) { return self::WRONG_USE; } $center = $player->floor(); $level = $player->getLevel(); $radius = floatval(array_shift($args)); $height = (int) array_shift($args); $axis = WorldEditArt::directionNumber2Array($player->getDirection()); while (count($args) > 0) { $arg = array_shift($args); switch ($arg) { case "a": case "anchor": $anchor = $this->getMain()->getAnchor($player); if (!$anchor instanceof Position) { return self::NO_ANCHOR; } $center = $anchor->floor(); break; case "d": $d = array_shift($args); switch (strtolower($d)) { case "m": case "me": break; case "u": case "up": $axis = [CylinderSpace::Y, CylinderSpace::PLUS]; break; case "d": case "down": $axis = [CylinderSpace::Y, CylinderSpace::MINUS]; break; case "l": case "left": $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 3)); break; case "r": case "right": $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 1)); break; case "b": case "back": $axis = WorldEditArt::directionNumber2Array(WorldEditArt::rotateDirectionNumberClockwise($player->getDirection(), 2)); break; } break; } } $center = Position::fromObject($center, $level); $space = new CylinderSpace($axis[0], $radius, $center, $height * $axis[1]); $this->getMain()->setSelection($player, $space); return "Your selection is now {$space}."; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($target->isTransparent() === false) { $faces = [2 => 3, 3 => 0, 0 => 1, 1 => 2]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true, true); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true, true); $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $block->getSide(0); if ($down->getId() === self::AIR) { return false; } $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3; $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $block->getSide(0); if ($down->isTransparent() && !($down instanceof Slab && ($down->meta & 0x8) === 0x8) || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) { return false; } if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, true); if ($player != null) { // interesting for snow golem AND iron golem (this can be the body) $firstBlock = $this->getLevel()->getBlock($block->add(0, -1, 0)); $secondBlock = $this->getLevel()->getBlock($block->add(0, -2, 0)); // interesting for iron golem (checking arms and air beyond the feet) $armBlock1 = $this->getLevel()->getBlock($block->add(0, -1, -1)); // arm 1 $armBlock2 = $this->getLevel()->getBlock($block->add(0, -1, 1)); // arm2 $airBlock1 = $this->getLevel()->getBlock($block->add(0, -2, -1)); // beneath arms $airBlock2 = $this->getLevel()->getBlock($block->add(0, -2, 1)); // beneath arms // we've to test in all 3d! $armBlock3 = $this->getLevel()->getBlock($block->add(-1, -1, 0)); // arm 1 $armBlock4 = $this->getLevel()->getBlock($block->add(1, -1, 0)); // arm2 $airBlock3 = $this->getLevel()->getBlock($block->add(-1, -2, 0)); // beneath arms $airBlock4 = $this->getLevel()->getBlock($block->add(1, -2, 0)); // beneath arms // $player->getServer()->getLogger()->debug("[1st:$firstBlock] [2nd:$secondBlock] [arm1:$armBlock1] [arm2:$armBlock2] [arm3:$armBlock3] [arm4:$armBlock4] [air1:$airBlock1] [air2:$airBlock2] [air3:$airBlock3] [air4:$airBlock4]"); if ($firstBlock->getId() === Item::SNOW_BLOCK && $secondBlock->getId() === Item::SNOW_BLOCK) { //Block match snowgolem $this->getLevel()->setBlock($block, new Air()); $this->getLevel()->setBlock($firstBlock, new Air()); $this->getLevel()->setBlock($secondBlock, new Air()); $snowGolem = new SnowGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])])); $snowGolem->spawnToAll(); } elseif ($firstBlock->getId() === Item::IRON_BLOCK && $secondBlock->getId() === Item::IRON_BLOCK) { // possible iron golem if ($armBlock1->getId() === Item::IRON_BLOCK && $armBlock2->getId() === Item::IRON_BLOCK && $airBlock1->getId() === Item::AIR && $airBlock2->getId() === Item::AIR || $armBlock3->getId() === Item::IRON_BLOCK && $armBlock4->getId() === Item::IRON_BLOCK && $airBlock3->getId() === Item::AIR && $airBlock4->getId() === Item::AIR) { $this->getLevel()->setBlock($block, new Air()); $this->getLevel()->setBlock($firstBlock, new Air()); $this->getLevel()->setBlock($secondBlock, new Air()); $this->getLevel()->setBlock($armBlock1, new Air()); $this->getLevel()->setBlock($armBlock2, new Air()); $this->getLevel()->setBlock($armBlock3, new Air()); $this->getLevel()->setBlock($armBlock4, new Air()); $ironGolem = new IronGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])])); $ironGolem->spawnToAll(); } } } return true; }
public function onActivate(Item $item, Player $player = null) { $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2]; if ($player !== null) { $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3 | ~$this->meta & 0x4; } else { $this->meta ^= 0x4; } $this->getLevel()->setBlock($this, $this, true); $this->level->addSound(new DoorSound($this)); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $this->getSide(0); if ($down->isTransparent() === false) { if ($face === 0 || $face === 1) { $to = $player instanceof Player ? $player->getDirection() : 0; $this->meta = $to ^ 0x1 === 0x1 ? 0 : 1; } $this->getLevel()->setBlock($block, Block::get(Item::POWERED_RAIL, $this->meta), true, true); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $this->getSide(0); if ($down->isTransparent() === false) { $faces = [0 => 3, 1 => 4, 2 => 2, 3 => 5]; $d = $player instanceof Player ? $player->getDirection() : 0; $next = $this->getSide($faces[($d + 3) % 4]); $downNext = $this->getSide(0); if ($next->canBeReplaced() === true and $downNext->isTransparent() === false) { $meta = ($d + 3) % 4 & 0x3; $this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true); $this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x8), true, true); return true; } } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::FURNACE), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z)]); $nbt->Items->setTagType(NBT::TAG_Compound); if ($item->hasCustomName()) { $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } if ($item->hasCustomBlockData()) { foreach ($item->getCustomBlockData() as $key => $v) { $nbt->{$key} = $v; } } Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, true); if ($player != null) { $firstBlock = $this->getLevel()->getBlock($block->add(0, -1, 0)); $secondBlock = $this->getLevel()->getBlock($block->add(0, -2, 0)); $thirdBlock = $this->getLevel()->getBlock($block->add(0, -1, -1)); $fourthBlock = $this->getLevel()->getBlock($block->add(0, -1, 1)); $fifthBlock = $this->getLevel()->getBlock($block->add(0, -2, -1)); $sixthBlock = $this->getLevel()->getBlock($block->add(0, -2, 1)); if ($firstBlock->getId() === Item::SNOW_BLOCK && $secondBlock->getId() === Item::SNOW_BLOCK) { //Block match snowgolem $this->getLevel()->setBlock($block, new Air()); $this->getLevel()->setBlock($firstBlock, new Air()); $this->getLevel()->setBlock($secondBlock, new Air()); $snowGolem = new SnowGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])])); $snowGolem->spawnToAll(); } elseif ($firstBlock->getId() === Item::IRON_BLOCK && $secondBlock->getId() === Item::IRON_BLOCK) { if ($thirdBlock->getId() === Item::IRON_BLOCK && $fourthBlock->getId() === Item::IRON_BLOCK && $fifthBlock->getId() === Item::AIR && $sixthBlock->getId() === Item::AIR) { $this->getLevel()->setBlock($thirdBlock, new Air()); $this->getLevel()->setBlock($fourthBlock, new Air()); } elseif ($fifthBlock->getId() === Item::IRON_BLOCK && $sixthBlock->getId() === Item::IRON_BLOCK && $thirdBlock->getId() === Item::AIR && $fourthBlock->getId() === Item::AIR) { $this->getLevel()->setBlock($fifthBlock, new Air()); $this->getLevel()->setBlock($sixthBlock, new Air()); } else { return true; } $this->getLevel()->setBlock($block, new Air()); $this->getLevel()->setBlock($firstBlock, new Air()); $this->getLevel()->setBlock($secondBlock, new Air()); $ironGolem = new IronGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])])); $ironGolem->spawnToAll(); } } return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $pitch = $player->getPitch(); if (abs($pitch) >= 45) { if ($pitch < 0) { $f = 0; } else { $f = 1; } } else { $f = $player->getDirection() + 2; } } else { $f = 0; } $faces = [0 => 0, 1 => 1, 2 => 5, 3 => 3, 4 => 4, 5 => 2]; $this->meta = $faces[$f]; $this->getLevel()->setBlock($block, $this, true, true); $nbt = new CompoundTag("", [new StringTag("id", Tile::PISTON), new IntTag("x", $this->x), new IntTag("y", $this->y), new IntTag("z", $this->z), new IntTag("blockData", 0), new IntTag("blockId", Item::PISTON_HEAD), new ByteTag("extending", 0), new IntTag("facing", $faces[$f]), new FloatTag("progress", 0.0)]); $tile = Tile::createTile("Piston", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, false); if ($this->checkPower($this)) { $this->activate(); } }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($face === 1) { $blockUp = $this->getSide(1); $blockDown = $this->getSide(0); if ($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true && !($blockDown instanceof Slab && ($blockDown->meta & 0x8) === 0x8) || $blockDown instanceof WoodSlab && ($blockDown->meta & 0x8) === 0x8 || $blockDown instanceof Stair && ($blockDown->meta & 0x4) === 0x4) { return false; } $direction = $player instanceof Player ? $player->getDirection() : 0; $face = [0 => 3, 1 => 4, 2 => 2, 3 => 5]; $next = $this->getSide($face[($direction + 2) % 4]); $next2 = $this->getSide($face[$direction]); $metaUp = 0x8; if ($next->getId() === $this->getId() or $next2->isTransparent() === false and $next->isTransparent() === true) { // Door hinge $metaUp |= 0x1; } $this->setDamage($player->getDirection() & 0x3); $this->getLevel()->setBlock($block, $this, true, true); // Bottom $this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true); // Top $this->onRedstoneUpdate(null, null); return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($face === 1) { $blockUp = $this->getSide(Vector3::SIDE_UP); $blockDown = $this->getSide(Vector3::SIDE_DOWN); if ($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true) { return false; } $direction = $player instanceof Player ? $player->getDirection() : 0; $face = [0 => 3, 1 => 4, 2 => 2, 3 => 5]; $next = $this->getSide($face[($direction + 2) % 4]); $next2 = $this->getSide($face[$direction]); $metaUp = 0x8; if ($next->getId() === $this->getId() or $next2->isTransparent() === false and $next->isTransparent() === true) { //Door hinge $metaUp |= 0x1; } $this->setDamage($player->getDirection() & 0x3); $this->getLevel()->setBlock($block, $this, true, true); //Bottom $this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true); //Top return true; } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $faces = [0 => 0, 1 => 2, 2 => 1, 3 => 3]; $this->meta = $faces[$player->getDirection()] & 0x3; if ($fy > 0.5 and $face !== 1 or $face === 0) { $this->meta |= 0x4; //Upside-down stairs } $this->getLevel()->setBlock($block, $this, true, true); return true; }
public function onActivate(Item $item, Player $player = null) { $faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3 | ~$this->meta & 0x4; if (($this->meta & 0x4) === 0x4) { $this->isFullBlock = true; } else { $this->isFullBlock = false; } $this->getLevel()->setBlock($this, $this, true); return true; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { if ($player instanceof Player) { $this->meta = ((int) $player->getDirection() + 5) % 4; } $this->getLevel()->setBlock($block, $this, true, true); if ($player != null) { $level = $this->getLevel(); if ($player->getServer()->allowSnowGolem) { $block0 = $level->getBlock($block->add(0, -1, 0)); $block1 = $level->getBlock($block->add(0, -2, 0)); if ($block0->getId() == Item::SNOW_BLOCK and $block1->getId() == Item::SNOW_BLOCK) { $level->setBlock($block, new Air()); $level->setBlock($block0, new Air()); $level->setBlock($block1, new Air()); $golem = new SnowGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])])); $golem->spawnToAll(); } } if ($player->getServer()->allowIronGolem) { $block0 = $level->getBlock($block->add(0, -1, 0)); $block1 = $level->getBlock($block->add(0, -2, 0)); $block2 = $level->getBlock($block->add(-1, -1, 0)); $block3 = $level->getBlock($block->add(1, -1, 0)); $block4 = $level->getBlock($block->add(0, -1, -1)); $block5 = $level->getBlock($block->add(0, -1, 1)); if ($block0->getId() == Item::IRON_BLOCK and $block1->getId() == Item::IRON_BLOCK) { if ($block2->getId() == Item::IRON_BLOCK and $block3->getId() == Item::IRON_BLOCK and $block4->getId() == Item::AIR and $block5->getId() == Item::AIR) { $level->setBlock($block2, new Air()); $level->setBlock($block3, new Air()); } elseif ($block4->getId() == Item::IRON_BLOCK and $block5->getId() == Item::IRON_BLOCK and $block2->getId() == Item::AIR and $block3->getId() == Item::AIR) { $level->setBlock($block4, new Air()); $level->setBlock($block5, new Air()); } else { return; } $level->setBlock($block, new Air()); $level->setBlock($block0, new Air()); $level->setBlock($block1, new Air()); $golem = new IronGolem($player->getLevel()->getChunk($this->getX() >> 4, $this->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])])); $golem->spawnToAll(); } } } return true; }