What could be a possible reason my spawner can't place? My place() function. PHP: public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null): bool { parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); if($item->getDamage() > 9 and $item instanceof CustomItem) { /** @var CompoundTag $tag */ $tag = $item->getNamedTagEntry(CustomItem::SPECIAL); $tier = $tag->getInt("tier"); $this->setTier($tier); $tile = $this->getLevel()->getTile($this); $this->entityId = $item->getDamage(); if(!$tile instanceof MobSpawner) { /** @var CompoundTag $nbt */ $nbt = new CompoundTag("", [ new StringTag(Tile::TAG_ID, Tile::MOB_SPAWNER), new IntTag(Tile::TAG_X, (int)$this->x), new IntTag(Tile::TAG_Y, (int)$this->y), new IntTag(Tile::TAG_Z, (int)$this->z), new IntTag(MobSpawner::TAG_ENTITY_ID, $this->entityId), new IntTag(MobSpawner::TAG_SPAWN_COUNT, 4), new IntTag(MobSpawner::TAG_MIN_SPAWN_DELAY, floor(200 / $tier)), new IntTag(MobSpawner::TAG_MAX_SPAWN_DELAY, floor(800 / $tier)) ]); /** @var MobSpawner $tile */ $tile = Tile::createTile(Tile::MOB_SPAWNER, $this->getLevel(), $nbt); $tile->setEntityId($this->entityId); return true; } } return true;}
Can I see where you registered the block? I assume it's a class that overrides the existing MonsterSpawner class, right?
PHP: protected function addAdditionalSpawnData(CompoundTag $nbt): void { $nbt->setInt(self::TAG_ENTITY_ID, $this->getSpawnCompound()->getInt(self::TAG_ENTITY_ID)); $nbt->setInt(self::TAG_DELAY, $this->getSpawnCompound()->getInt(self::TAG_DELAY)); $nbt->setInt(self::TAG_SPAWN_COUNT, $this->getSpawnCompound()->getInt(self::TAG_SPAWN_COUNT)); $nbt->setInt(self::TAG_SPAWN_RANGE, $this->getSpawnCompound()->getInt(self::TAG_SPAWN_RANGE)); $nbt->setInt(self::TAG_MIN_SPAWN_DELAY, $this->getSpawnCompound()->getInt(self::TAG_MIN_SPAWN_DELAY)); $nbt->setInt(self::TAG_MAX_SPAWN_DELAY, $this->getSpawnCompound()->getInt(self::TAG_MAX_SPAWN_DELAY));}