Some tweaks to black hole
This commit is contained in:
parent
fde2ab46ee
commit
b304a5f12a
@ -156,26 +156,19 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
for (var item : tile.level.getEntitiesOfClass(ItemEntity.class, tile.affected_bounds_aabb)) {
|
||||
final double distance = item.position().distanceTo(center);
|
||||
tile.setDeltaMovement(item, center, distance);
|
||||
|
||||
if (distance < tile.gravitation_strength * 2) {
|
||||
if (item.hurt(Registry.DAMAGE_EVENT_HORIZON, (float) (tile.gravitation_strength / distance)) && item.isRemoved()) {
|
||||
var mass = MatterRegistry.getMatterValue(item.getItem());
|
||||
|
||||
if (mass.compareTo(BigDecimal.ZERO) > 0)
|
||||
tile.addMass(mass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final BigDecimal HAWKING_MASS_LOSE_STEP = new BigDecimal("-0.1");
|
||||
|
||||
public static <T extends BlockEntity> void ticker(Level level, BlockPos blockPos, BlockState blockState, T t) {
|
||||
if (t instanceof BlockEntityBlackHole tile) {
|
||||
tile.suppress_updates = false;
|
||||
|
||||
final var center = Vec3.atCenterOf(tile.getBlockPos());
|
||||
|
||||
for (var living : tile.level.getEntitiesOfClass(LivingEntity.class, tile.affected_bounds_aabb)) {
|
||||
for (var living : level.getEntitiesOfClass(LivingEntity.class, tile.affected_bounds_aabb)) {
|
||||
final double distance = living.position().distanceTo(center);
|
||||
|
||||
if (!(living instanceof Player ply) || !ply.getAbilities().mayfly) {
|
||||
@ -187,7 +180,7 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
for (var item : tile.level.getEntitiesOfClass(ItemEntity.class, tile.affected_bounds_aabb)) {
|
||||
for (var item : level.getEntitiesOfClass(ItemEntity.class, tile.affected_bounds_aabb)) {
|
||||
final double distance = item.position().distanceTo(center);
|
||||
tile.setDeltaMovement(item, center, distance);
|
||||
|
||||
@ -200,6 +193,11 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду
|
||||
if (level.random.nextDouble() < 0.01 * 0.05) {
|
||||
tile.addMass(HAWKING_MASS_LOSE_STEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user