parent
cef1ead810
commit
56d1501d61
@ -22,6 +22,7 @@ import net.minecraft.world.phys.shapes.BooleanOp
|
|||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
import net.minecraft.world.phys.shapes.Shapes
|
import net.minecraft.world.phys.shapes.Shapes
|
||||||
import net.minecraftforge.client.event.RenderLevelStageEvent
|
import net.minecraftforge.client.event.RenderLevelStageEvent
|
||||||
|
import net.minecraftforge.event.ForgeEventFactory
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent
|
import net.minecraftforge.event.entity.living.LivingDeathEvent
|
||||||
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
|
||||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
import ru.dbotthepony.mc.otm.OverdriveThatMatters
|
||||||
@ -290,32 +291,21 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
|
|||||||
override fun activate(isClient: Boolean): Boolean {
|
override fun activate(isClient: Boolean): Boolean {
|
||||||
val canUse = canUse()
|
val canUse = canUse()
|
||||||
|
|
||||||
if (!canUse && isClient) {
|
if (!canUse && isClient) return false
|
||||||
return false
|
if (isClient) return true
|
||||||
}
|
|
||||||
|
|
||||||
if (!isClient) {
|
|
||||||
putOnCooldown()
|
|
||||||
|
|
||||||
if (!canUse) {
|
|
||||||
android.androidEnergy.extractEnergyInnerExact(ServerConfig.EnderTeleporter.ENERGY_COST, false)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val (blockPos) = trace()
|
val (blockPos) = trace()
|
||||||
blockPos ?: return false
|
blockPos ?: return false
|
||||||
|
|
||||||
val server = ply.server
|
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
|
||||||
|
if (event.isCanceled) return false
|
||||||
|
|
||||||
if (server != null)
|
lastTeleport = ply.server!!.tickCount
|
||||||
lastTeleport = server.tickCount
|
android.androidEnergy.extractEnergyInner(ServerConfig.EnderTeleporter.ENERGY_COST, false)
|
||||||
|
|
||||||
if (!isClient) android.androidEnergy.extractEnergyInner(ServerConfig.EnderTeleporter.ENERGY_COST, false)
|
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||||
|
ply.teleportTo(event.targetX, event.targetY, event.targetZ)
|
||||||
ply.level.playSound(ply, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 0.3f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
ply.level.playSound(null, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
||||||
ply.setPos(Vector(blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5))
|
|
||||||
ply.level.playSound(ply, ply, SoundEvents.ENDERMAN_TELEPORT, SoundSource.PLAYERS, 1f, 0.8f + ply.level.random.nextFloat() * 0.4f)
|
|
||||||
|
|
||||||
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
ply.deltaMovement = Vector(0.0, 0.0, 0.0)
|
||||||
ply.resetFallDistance()
|
ply.resetFallDistance()
|
||||||
|
Loading…
Reference in New Issue
Block a user