From d117c0d0df403b79db4792b4b10cf455fd3b75d6 Mon Sep 17 00:00:00 2001 From: Boy Date: Fri, 2 Feb 2024 11:24:01 +0100 Subject: [PATCH] fix: hotfix all old broken bonfires missing hitboxes --- .../listeners/FixUntrackedBonfiresListener.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/kotlin/com/mineinabyss/bonfire/listeners/FixUntrackedBonfiresListener.kt b/src/main/kotlin/com/mineinabyss/bonfire/listeners/FixUntrackedBonfiresListener.kt index cf76e10..e05594a 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/listeners/FixUntrackedBonfiresListener.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/listeners/FixUntrackedBonfiresListener.kt @@ -1,9 +1,13 @@ package com.mineinabyss.bonfire.listeners import com.mineinabyss.blocky.api.BlockyFurnitures +import com.mineinabyss.blocky.components.core.BlockyFurniture import com.mineinabyss.bonfire.bonfire +import com.mineinabyss.bonfire.components.Bonfire +import com.mineinabyss.geary.modules.geary import com.mineinabyss.geary.papermc.datastore.decodePrefabs import com.mineinabyss.geary.papermc.datastore.hasComponentsEncoded +import com.mineinabyss.geary.papermc.tracking.entities.events.GearyEntityAddToWorldEvent import com.mineinabyss.geary.prefabs.PrefabKey import org.bukkit.Bukkit import org.bukkit.entity.ItemDisplay @@ -31,4 +35,14 @@ class FixUntrackedBonfiresListener : Listener { } } } + + @EventHandler + fun GearyEntityAddToWorldEvent.onOldBonfireLoad() { + if (entity !is ItemDisplay || gearyEntity.has() || !gearyEntity.has()) return + + Bukkit.getScheduler().scheduleSyncDelayedTask(bonfire.plugin, { + BlockyFurnitures.placeFurniture(bonfireItemKey, entity.location, entity.yaw) + entity.remove() + }, 1) + } }