/** * Get a furnace facing in the given direction. * * @param int $blockRef Which furnace to use * @param int $facing The direction it faces; one of the class constants * @param \MME\Stack|null $input Data for the stack in the input slot * @param \MME\Stack|null $fuel Data for the stack in the fuel slot * @param \MME\Stack|null $output Data for the stack in the output slot * @param int $burnTime Time left for fuel to burn * @param int $cookTime Time left for item to finish cooking * @param int $cookTimeTotal Total time for item to cook * * @throws \Exception */ public function __construct($blockRef, $facing, $input = null, $fuel = null, $output = null, $burnTime = 0, $cookTime = 0, $cookTimeTotal = 0) { $this->checkBlock($blockRef, Ref::getStartsWith('FURNACE')); $this->checkDataRefValidAll($facing, 'Invalid facing reference for furnace'); $this->setBlockData($facing); $this->initEntityData('Furnace'); $this->addItemsForSlots([0 => $input, 1 => $fuel, 2 => $output]); $this->entityData->addChild(\Nbt\Tag::tagShort('BurnTime', $burnTime)); $this->entityData->addChild(\Nbt\Tag::tagShort('CookTime', $cookTime)); $this->entityData->addChild(\Nbt\Tag::tagShort('CookTimeTotal', $cookTimeTotal)); }
/** * Set block data for this stack. * * @param \MME\Block $block * * @return \MME\Stack */ public function setBlock(Block $block) { // We need the name for the block, not the id... $this->node->addChild(\Nbt\Tag::tagString('id', Block\Names::$list[$block->ref])); $this->node->addChild(\Nbt\Tag::tagShort('Damage', $block->data)); if ($block->entityData) { $this->addTag(); $this->tag->addChild(\Nbt\Tag::tagCompound('BlockEntityData', $block->entityData->getChildren())); } return $this; }
/** * Create a mob spawner. There's no checking of the information passed yet. * I don't know the valid values, etc; proper error checking is still to come. * Test your creations well! * * @param \Nbt\Node|null $spawnPotentials List of potential spawns * @param string $entityID Entity name to spawn * @param \Nbt\Node|null $spawnData Data to pass to the spawned mobs * @param int $spawnCount Number of mobs to attempt to spawn * @param int $spawnRange Radius of the spawn range * @param int $delay Ticks until next spawn * @param int $minSpawnDelay Minimum random delay to the next spawn * @param int $maxSpawnDelay Maximum random delay to the next spawn * @param int $maxNearbyEntities Can override the max number of entities nearby * @param int $requiredPlayerRange Override the activation radius * * @throws \Exception */ public function __construct($spawnPotentials, $entityID, $spawnData, $spawnCount, $spawnRange, $delay, $minSpawnDelay, $maxSpawnDelay, $maxNearbyEntities, $requiredPlayerRange) { $this->setBlockIDAndDataFor(Ref::MOB_SPAWNER); $this->initEntityData('MobSpawner'); if ($spawnPotentials) { $this->entityData->addChild($spawnPotentials); } $this->entityData->addChild(\Nbt\Tag::tagString('EntityId', $entityID)); if ($spawnData) { $this->entityData->addChild($spawnData); } $this->entityData->addChild(\Nbt\Tag::tagShort('SpawnCount', $spawnCount)); $this->entityData->addChild(\Nbt\Tag::tagShort('SpawnRange', $spawnRange)); $this->entityData->addChild(\Nbt\Tag::tagShort('Delay', $delay)); $this->entityData->addChild(\Nbt\Tag::tagShort('MinSpawnDelay', $minSpawnDelay)); $this->entityData->addChild(\Nbt\Tag::tagShort('MaxSpawnDelay', $maxSpawnDelay)); $this->entityData->addChild(\Nbt\Tag::tagShort('MaxNearbyEntities', $maxNearbyEntities)); $this->entityData->addChild(\Nbt\Tag::tagShort('RequiredPlayerRange', $requiredPlayerRange)); }