From a5ba27cf6386c2e779db7e01e706838455abbc3d Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 22:04:26 +0700 Subject: [PATCH] More backporting --- .../mc/otm/block/tech/PhantomAttractorBlock.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt index b654f1e0a..189be0d22 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/tech/PhantomAttractorBlock.kt @@ -26,6 +26,7 @@ import net.minecraft.world.level.material.PushReaction import net.minecraft.world.phys.AABB import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape +import net.minecraftforge.common.ForgeHooks import net.minecraftforge.event.ForgeEventFactory import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock import ru.dbotthepony.mc.otm.block.getShapeForEachState @@ -63,7 +64,12 @@ class PhantomAttractorBlock : RotatableMatteryBlock(Properties.of(Material.METAL ) { val phantom = EntityType.PHANTOM.create(level) ?: continue phantom.moveTo(spawnPos, 0.0f, 0.0f) - groupData = ForgeEventFactory.onFinalizeSpawn(phantom, level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) + + if (ForgeHooks.canEntitySpawn(phantom, level, spawnPos.x.toDouble(), spawnPos.y.toDouble(), spawnPos.z.toDouble(), null, MobSpawnType.SPAWNER) == -1) { + continue + } + + groupData = phantom.finalizeSpawn(level, level.getCurrentDifficultyAt(spawnPos), MobSpawnType.SPAWNER, groupData, null) level.addFreshEntityWithPassengers(phantom) } }