Make event horizon smaller

This commit is contained in:
DBotThePony 2022-09-17 14:11:31 +07:00
parent 0fff4c003b
commit e83075b5f1
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 28 additions and 22 deletions

View File

@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRegistry import ru.dbotthepony.mc.otm.registry.MRegistry
import ru.dbotthepony.mc.otm.container.set import ru.dbotthepony.mc.otm.container.set
import ru.dbotthepony.mc.otm.core.set import ru.dbotthepony.mc.otm.core.set
import kotlin.math.pow
import kotlin.math.roundToInt import kotlin.math.roundToInt
import kotlin.math.sqrt import kotlin.math.sqrt
@ -261,31 +262,35 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : BlockEn
val center = Vec3.atCenterOf(blockPos) val center = Vec3.atCenterOf(blockPos)
for (living in level.getEntitiesOfClass(LivingEntity::class.java, affectedBoundsAABB)) { kotlin.run {
val distance = living.position().distanceTo(center) val gravitationStrength = gravitationStrength.pow(0.5)
if (living !is Player || !living.abilities.mayfly && living.getItemBySlot(EquipmentSlot.CHEST).item != MItems.PORTABLE_GRAVITATION_STABILIZER) { for (living in level.getEntitiesOfClass(LivingEntity::class.java, affectedBoundsAABB)) {
setDeltaMovement(living, center, distance, living !is Player) 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) { for (item in level.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) {
living.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) val distance = item.position().distanceTo(center)
} setDeltaMovement(item, center, distance, false)
}
for (item in level.getEntitiesOfClass(ItemEntity::class.java, affectedBoundsAABB)) { if (distance < gravitationStrength + 1) {
val distance = item.position().distanceTo(center) if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) {
setDeltaMovement(item, center, distance, false) if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) {
collapse()
} else {
val mass = getMatterValue(item.item)
if (distance < gravitationStrength + 1) { if (!mass.isZero)
if (item.hurt(MRegistry.DAMAGE_EVENT_HORIZON, (gravitationStrength / distance).toFloat()) && item.isRemoved) { this.mass += mass.value * item.item.count
if (item.item.item === MItems.GRAVITATIONAL_DISRUPTOR) { }
collapse()
} else {
val mass = getMatterValue(item.item)
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 this.mass += HAWKING_MASS_LOSE_STEP
} }
if (gravitationStrength > 0.4f) { if (gravitationStrength > 0.4) {
val sphere = getSphericalShape((gravitationStrength * 6.0).roundToInt()) val sphere = getSphericalShape((gravitationStrength * 6.0).roundToInt())
if (sphere.size != lastSphereSizeOuter) { if (sphere.size != lastSphereSizeOuter) {

View File

@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.render.*
import ru.dbotthepony.mc.otm.core.* import ru.dbotthepony.mc.otm.core.*
import ru.dbotthepony.mc.otm.registry.MItems import ru.dbotthepony.mc.otm.registry.MItems
import kotlin.math.PI import kotlin.math.PI
import kotlin.math.pow
private const val BEAM_WIDTH = 0.2 private const val BEAM_WIDTH = 0.2
@ -103,7 +104,7 @@ class BlackHoleRenderer(private val context: BlockEntityRendererProvider.Context
poseStack.pushPose() poseStack.pushPose()
poseStack.translate(0.5, -tile.gravitationStrength / 2 + 0.5, 0.5) 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.enableCull()
RenderSystem.enableTexture() RenderSystem.enableTexture()