mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-02-27 15:46:01 +01:00
Add knockback multiplier to ExplosionBuilder & fix broken knockback
This commit is contained in:
parent
d6fe5c5589
commit
b50c876275
src
main/java/chylex/hee/game
system/src/main/java/chylex/hee/system/math
@ -136,8 +136,6 @@ class ItemTalismanOfGriefing(properties: Properties) : ItemAbstractTrinket(prope
|
||||
with(ExplosionBuilder()) {
|
||||
this.destroyBlocks = false
|
||||
this.damageEntities = false
|
||||
this.knockbackEntities = true
|
||||
|
||||
clone(explosion, source = null)
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import chylex.hee.game.world.isFullBlock
|
||||
import chylex.hee.game.world.playServer
|
||||
import chylex.hee.game.world.setBlock
|
||||
import chylex.hee.system.math.Vec
|
||||
import chylex.hee.system.math.Vec3
|
||||
import chylex.hee.system.math.component1
|
||||
import chylex.hee.system.math.component2
|
||||
import chylex.hee.system.math.component3
|
||||
@ -49,7 +50,7 @@ class ExplosionBuilder {
|
||||
var blockFireChance = 3
|
||||
|
||||
var damageEntities = true
|
||||
var knockbackEntities = true
|
||||
var knockbackMultiplier = Vec3.ONE
|
||||
|
||||
fun trigger(world: World, source: Entity? = null, x: Double, y: Double, z: Double, strength: Float) {
|
||||
if (world.isRemote) {
|
||||
@ -145,7 +146,7 @@ class ExplosionBuilder {
|
||||
|
||||
private fun determineAffectedEntitiesAndKnockback() {
|
||||
val damageEntities = builder.damageEntities
|
||||
val knockbackEntities = builder.knockbackEntities
|
||||
val knockbackEntities = builder.knockbackMultiplier != Vec3.ZERO
|
||||
|
||||
if (!damageEntities && !knockbackEntities) {
|
||||
return
|
||||
@ -193,9 +194,9 @@ class ExplosionBuilder {
|
||||
|
||||
if (knockbackEntities) {
|
||||
val knockbackPower = (entity as? EntityLivingBase)?.let { ProtectionEnchantment.getBlastDamageReduction(it, blastPower) } ?: blastPower
|
||||
val knockbackVec = centerVec.directionTowards(lookPosVec).scale(knockbackPower)
|
||||
val knockbackVec = centerVec.directionTowards(lookPosVec).mul(builder.knockbackMultiplier.scale(knockbackPower))
|
||||
|
||||
entity.motion = entity.motion.mul(knockbackVec)
|
||||
entity.motion = entity.motion.add(knockbackVec)
|
||||
|
||||
if (entity is EntityPlayer) {
|
||||
playerKnockbackMap[entity] = knockbackVec // vanilla uses blastPower instead of knockbackPower here, bug?
|
||||
|
@ -11,6 +11,7 @@ inline fun Vec(x: Double, y: Double, z: Double) = Vec3d(x, y, z)
|
||||
|
||||
object Vec3 {
|
||||
val ZERO: Vec3d = Vec3d.ZERO
|
||||
val ONE = xyz(1.0)
|
||||
|
||||
inline fun xz(x: Double, z: Double): Vec3d {
|
||||
return Vec(x, 0.0, z)
|
||||
|
Loading…
Reference in New Issue
Block a user