Fire teleport event on forge event bus

Fixes #219
This commit is contained in:
DBotThePony 2022-11-24 22:43:09 +07:00
parent 56d1501d61
commit 3d77f5c02f
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -9,6 +9,7 @@ import net.minecraft.client.renderer.LevelRenderer
import net.minecraft.core.BlockPos import net.minecraft.core.BlockPos
import net.minecraft.core.Direction import net.minecraft.core.Direction
import net.minecraft.core.Vec3i import net.minecraft.core.Vec3i
import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundEvents
@ -298,8 +299,13 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
blockPos ?: return false blockPos ?: return false
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
if (event.isCanceled) return false
if (event.isCanceled) {
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
return false
}
putOnCooldown()
lastTeleport = ply.server!!.tickCount lastTeleport = ply.server!!.tickCount
android.androidEnergy.extractEnergyInner(ServerConfig.EnderTeleporter.ENERGY_COST, false) android.androidEnergy.extractEnergyInner(ServerConfig.EnderTeleporter.ENERGY_COST, false)