Energy cost for shockwave
This commit is contained in:
parent
cc268332f8
commit
24805fb15f
@ -153,6 +153,7 @@ object ServerConfig {
|
|||||||
val RADIUS_VERTICAL: Double by specBuilder.comment("In meters").defineInRange("radiusVertical", 1.0, 0.0)
|
val RADIUS_VERTICAL: Double by specBuilder.comment("In meters").defineInRange("radiusVertical", 1.0, 0.0)
|
||||||
val BREAK_BLOCKS: Boolean by specBuilder.comment("Break blocks without any blast resistance").define("breakBlocks", true)
|
val BREAK_BLOCKS: Boolean by specBuilder.comment("Break blocks without any blast resistance").define("breakBlocks", true)
|
||||||
val DAMAGE: Double by specBuilder.comment("Max potential damage done by shockwave").defineInRange("damage", 12.0, 0.0, Float.MAX_VALUE.toDouble())
|
val DAMAGE: Double by specBuilder.comment("Max potential damage done by shockwave").defineInRange("damage", 12.0, 0.0, Float.MAX_VALUE.toDouble())
|
||||||
|
val ENERGY_COST by specBuilder.defineImpreciseFraction("energyCost", ImpreciseFraction(2048), ImpreciseFraction.ZERO)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
specBuilder.pop()
|
specBuilder.pop()
|
||||||
|
@ -8,6 +8,7 @@ import net.minecraft.world.phys.AABB
|
|||||||
import ru.dbotthepony.mc.otm.ServerConfig
|
import ru.dbotthepony.mc.otm.ServerConfig
|
||||||
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
import ru.dbotthepony.mc.otm.android.AndroidSwitchableFeature
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||||
|
import ru.dbotthepony.mc.otm.capability.extractEnergyInnerExact
|
||||||
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
import ru.dbotthepony.mc.otm.client.render.ResearchIcons
|
||||||
import ru.dbotthepony.mc.otm.core.Vector
|
import ru.dbotthepony.mc.otm.core.Vector
|
||||||
import ru.dbotthepony.mc.otm.core.getEllipsoidBlockPositions
|
import ru.dbotthepony.mc.otm.core.getEllipsoidBlockPositions
|
||||||
@ -33,7 +34,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
override fun tickClient() {
|
override fun tickClient() {
|
||||||
if (isActive && ply.isSteppingCarefully && cooldown <= 0) {
|
if (isActive && ply.isSteppingCarefully && cooldown <= 0 && android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, true).isPositive) {
|
||||||
ply.deltaMovement += Vector(0.0, -ServerConfig.Shockwave.ACCELERATION / 20.0, 0.0)
|
ply.deltaMovement += Vector(0.0, -ServerConfig.Shockwave.ACCELERATION / 20.0, 0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +42,12 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun shockwave() {
|
fun shockwave() {
|
||||||
|
if (cooldown > 0 || !android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, false).isPositive) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cooldown = ServerConfig.Shockwave.COOLDOWN
|
||||||
|
|
||||||
// TODO: raycasting
|
// TODO: raycasting
|
||||||
val entities = ply.level.getEntities(ply, AABB(
|
val entities = ply.level.getEntities(ply, AABB(
|
||||||
ply.position.x - ServerConfig.Shockwave.RADIUS_HORIZONTAL,
|
ply.position.x - ServerConfig.Shockwave.RADIUS_HORIZONTAL,
|
||||||
@ -110,7 +117,7 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
|||||||
airTicks = (airTicks - 1).coerceAtLeast(0)
|
airTicks = (airTicks - 1).coerceAtLeast(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isActive && cooldown <= 0) {
|
if (isActive && cooldown <= 0 && android.androidEnergy.extractEnergyInnerExact(ServerConfig.Shockwave.ENERGY_COST, true).isPositive) {
|
||||||
val old = wasMidair
|
val old = wasMidair
|
||||||
wasMidair = !ply.isOnGround
|
wasMidair = !ply.isOnGround
|
||||||
|
|
||||||
@ -119,12 +126,11 @@ class ShockwaveFeature(capability: MatteryPlayerCapability) : AndroidSwitchableF
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (old != wasMidair && !wasMidair && ServerConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isSteppingCarefully) {
|
if (old != wasMidair && !wasMidair && ServerConfig.Shockwave.TERMINAL_VELOCITY <= (highestSpeed * 20.0) && ply.isSteppingCarefully) {
|
||||||
cooldown = ServerConfig.Shockwave.COOLDOWN
|
|
||||||
|
|
||||||
if (isClient) {
|
if (isClient) {
|
||||||
// I HATE SELF-UPDATING PLAYERS
|
// I HATE SELF-UPDATING PLAYERS
|
||||||
// I HATE SELF-UPDATING PLAYERS
|
// I HATE SELF-UPDATING PLAYERS
|
||||||
// fix "bug" where shockwave doesn't trigger even when player is falling faster than orbiting satellite
|
// fix "bug" where shockwave doesn't trigger even when player is falling faster than orbiting satellite
|
||||||
|
cooldown = ServerConfig.Shockwave.COOLDOWN
|
||||||
MatteryPlayerNetworkChannel.sendToServer(TriggerShockwavePacket)
|
MatteryPlayerNetworkChannel.sendToServer(TriggerShockwavePacket)
|
||||||
} else {
|
} else {
|
||||||
shockwave()
|
shockwave()
|
||||||
|
Loading…
Reference in New Issue
Block a user