Change blackhole gravity formula to square, change model to singularity
This commit is contained in:
parent
a39dd28199
commit
5b9760c2ed
100
shapenator.js
100
shapenator.js
@ -24,38 +24,18 @@ process.stdout.write('Regenerating data files\n')
|
||||
|
||||
// сфера
|
||||
const layers = 32
|
||||
const radius = 16
|
||||
const checked = new Array(Math.pow(layers, 3))
|
||||
const radius = 2
|
||||
|
||||
// создание + слияние вдоль Y
|
||||
// создание
|
||||
for (let y = -layers / 2; y < layers / 2; y++) {
|
||||
for (let x = -layers / 2; x < layers / 2; x++) {
|
||||
for (let z = -layers / 2; z < layers / 2; z++) {
|
||||
const dist1 = Math.sqrt(x * x + y * y + z * z)
|
||||
|
||||
if (dist1 <= radius) {
|
||||
const index1 = x + layers / 2 + (z + layers / 2) * layers + (y + layers / 2) * layers * layers
|
||||
|
||||
if (!checked[index1]) {
|
||||
let height = 0
|
||||
let index
|
||||
|
||||
for (let y2 = 0; y2 < layers; y2++) {
|
||||
const dist = Math.sqrt(x * x + (y + y2) * (y + y2) + z * z)
|
||||
const index2 = x + layers / 2 + (z + layers / 2) * layers + (y + y2 + layers / 2) * layers * layers
|
||||
|
||||
if (dist <= radius && !checked[index2]) {
|
||||
height = y2
|
||||
index = index2
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (height > 0) {
|
||||
checked[index] = {
|
||||
elements.push({
|
||||
"from": [4 + (x + layers / 2) / layers * 8, 4 + (y + layers / 2) / layers * 8, 4 + (z + layers / 2) / layers * 8],
|
||||
"to": [4 + (x + layers / 2 + 1) / layers * 8, 4 + (y + layers / 2 + height) / layers * 8, 4 + (z + layers / 2 + 1) / layers * 8],
|
||||
"to": [4 + (x + layers / 2 + 1) / layers * 8, 4 + (y + layers / 2 + 1) / layers * 8, 4 + (z + layers / 2 + 1) / layers * 8],
|
||||
"faces": {
|
||||
"down": { "texture": "#black_hole" },
|
||||
"up": { "texture": "#black_hole" },
|
||||
@ -64,76 +44,8 @@ process.stdout.write('Regenerating data files\n')
|
||||
"west": { "texture": "#black_hole" },
|
||||
"east": { "texture": "#black_hole" }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
elements.push(checked[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// слияние вдоль X
|
||||
for (let y = -layers / 2; y < layers / 2; y++) {
|
||||
for (let z = -layers / 2; z < layers / 2; z++) {
|
||||
let last_element = null
|
||||
|
||||
for (let x = -layers / 2; x < layers / 2; x++) {
|
||||
const index = x + layers / 2 + (z + layers / 2) * layers + (y + layers / 2) * layers * layers
|
||||
|
||||
if (checked[index]) {
|
||||
if (last_element) {
|
||||
const from1 = checked[index].from
|
||||
const from2 = last_element.from
|
||||
|
||||
if (from1[1] == from2[1] && from1[2] == from2[2]) {
|
||||
last_element.to[0] = checked[index].to[0]
|
||||
checked[index] = last_element
|
||||
} else {
|
||||
last_element = checked[index]
|
||||
}
|
||||
} else {
|
||||
last_element = checked[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const merged_z = []
|
||||
|
||||
// слияние вдоль Z
|
||||
for (let y = -layers / 2; y < layers / 2; y++) {
|
||||
for (let x = -layers / 2; x < layers / 2; x++) {
|
||||
let last_element = null
|
||||
|
||||
for (let z = -layers / 2; z < layers / 2; z++) {
|
||||
const index = x + layers / 2 + (z + layers / 2) * layers + (y + layers / 2) * layers * layers
|
||||
|
||||
if (checked[index]) {
|
||||
if (last_element) {
|
||||
const from1 = checked[index].from
|
||||
const from2 = last_element.from
|
||||
|
||||
if (from1[0] == from2[0] && from1[1] == from2[1]) {
|
||||
last_element.to[2] = checked[index].to[2]
|
||||
checked[index] = last_element
|
||||
} else {
|
||||
if (!merged_z.includes(last_element)) {
|
||||
merged_z.push(last_element)
|
||||
}
|
||||
|
||||
last_element = checked[index]
|
||||
}
|
||||
} else {
|
||||
last_element = checked[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (last_element && !merged_z.includes(last_element)) {
|
||||
merged_z.push(last_element)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +55,7 @@ process.stdout.write('Regenerating data files\n')
|
||||
"textures": {
|
||||
"black_hole": "overdrive_that_matters:block/black_hole"
|
||||
},
|
||||
"elements": merged_z
|
||||
"elements": elements
|
||||
}, null, '\t'))
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
setMass(mass);
|
||||
}
|
||||
|
||||
public static final BigDecimal NORMAL_MASS = new BigDecimal(10_000);
|
||||
public static final BigDecimal NORMAL_MASS = new BigDecimal(1_000);
|
||||
private BigDecimal mass = NORMAL_MASS;
|
||||
private double gravitation_strength = 1;
|
||||
private boolean suppress_updates = true;
|
||||
@ -60,7 +60,9 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
gravitation_strength = mass.divide(NORMAL_MASS, MatteryCapability.ROUND_RULES).doubleValue();
|
||||
|
||||
if (gravitation_strength > 1) {
|
||||
gravitation_strength = Math.min(20, Math.log(gravitation_strength));
|
||||
gravitation_strength = Math.min(20, Math.sqrt(gravitation_strength));
|
||||
} else {
|
||||
gravitation_strength = Math.max(0.08, Math.pow(gravitation_strength, 2));
|
||||
}
|
||||
|
||||
if (level != null && !level.isClientSide && !suppress_updates)
|
||||
@ -203,8 +205,8 @@ public class BlockEntityBlackHole extends BlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду
|
||||
if (level.random.nextDouble() < 0.01 * 0.05) {
|
||||
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду * силу гравитации дыры ^ -1
|
||||
if (level.random.nextDouble() < 0.01 * 0.05 * (1 / tile.gravitation_strength)) {
|
||||
tile.addMass(HAWKING_MASS_LOSE_STEP);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class BlackHoleRenderer implements BlockEntityRenderer<BlockEntityBlackHo
|
||||
RenderSystem.disableCull();
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.5, -blockEntityBlackHole.getGravitationStrength() / 2, 0.5);
|
||||
poseStack.translate(0.5, -blockEntityBlackHole.getGravitationStrength() / 2 + 0.5, 0.5);
|
||||
|
||||
RenderHelper.colorSphere(poseStack, (float) blockEntityBlackHole.getGravitationStrength());
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 139 B |
Loading…
Reference in New Issue
Block a user