From e83075b5f1eec7df2ec13d294661e84ee5a2786b Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 17 Sep 2022 14:11:31 +0700 Subject: [PATCH] Make event horizon smaller --- .../entity/blackhole/BlackHoleBlockEntity.kt | 47 ++++++++++--------- .../render/blockentity/BlackHoleRenderer.kt | 3 +- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt index e5d9fd8c2..eb3411d8c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt @@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.core.set +import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sqrt @@ -261,31 +262,35 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : BlockEn val center = Vec3.atCenterOf(blockPos) - for (living in level.getEntitiesOfClass(LivingEntity::class.java, affectedBoundsAABB)) { - val distance = living.position().distanceTo(center) + kotlin.run { + val gravitationStrength = gravitationStrength.pow(0.5) - if (living !is Player || !living.abilities.mayfly && living.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { - setDeltaMovement(living, center, distance, living !is Player) + for (living in level.getEntitiesOfClass(LivingEntity::class.java, affectedBoundsAABB)) { + val distance = living.position().distanceTo(center) + + if (living !is Player || !living.abilities.mayfly && living.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { + setDeltaMovement(living, center, distance, living !is Player) + } + + if (distance < gravitationStrength + 1) { + living.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) + } } - if (distance < gravitationStrength + 1) { - living.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) - } - } + for (item in level.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) { + val distance = item.position().distanceTo(center) + setDeltaMovement(item, center, distance, false) - for (item in level.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) { - val distance = item.position().distanceTo(center) - setDeltaMovement(item, center, distance, false) + if (distance < gravitationStrength + 1) { + if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) { + if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) { + collapse() + } else { + val mass = getMatterValue(item.item) - if (distance < gravitationStrength + 1) { - if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) { - if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) { - collapse() - } else { - val mass = getMatterValue(item.item) - - if (!mass.isZero) - this.mass += mass.value * item.item.count + if (!mass.isZero) + this.mass += mass.value * item.item.count + } } } } @@ -296,7 +301,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : BlockEn this.mass += HAWKING_MASS_LOSE_STEP } - if (gravitationStrength > 0.4f) { + if (gravitationStrength > 0.4) { val sphere = getSphericalShape((gravitationStrength * 6.0).roundToInt()) if (sphere.size != lastSphereSizeOuter) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt index d0e455e9c..fba929ffd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/BlackHoleRenderer.kt @@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.render.* import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.registry.MItems import kotlin.math.PI +import kotlin.math.pow private const val BEAM_WIDTH = 0.2 @@ -103,7 +104,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context poseStack.pushPose() poseStack.translate(0.5, -tile.gravitationStrength / 2 + 0.5, 0.5) - colorSphere(poseStack, tile.gravitationStrength.toFloat()) + colorSphere(poseStack, tile.gravitationStrength.pow(0.5).toFloat()) RenderSystem.enableCull() RenderSystem.enableTexture()