Change blackhole gravity formula to square, change model to singularity
This commit is contained in:
parent
a39dd28199
commit
5b9760c2ed
116
shapenator.js
116
shapenator.js
@ -24,126 +24,38 @@ process.stdout.write('Regenerating data files\n')
|
|||||||
|
|
||||||
// сфера
|
// сфера
|
||||||
const layers = 32
|
const layers = 32
|
||||||
const radius = 16
|
const radius = 2
|
||||||
const checked = new Array(Math.pow(layers, 3))
|
|
||||||
|
|
||||||
// создание + слияние вдоль Y
|
// создание
|
||||||
for (let y = -layers / 2; y < layers / 2; y++) {
|
for (let y = -layers / 2; y < layers / 2; y++) {
|
||||||
for (let x = -layers / 2; x < layers / 2; x++) {
|
for (let x = -layers / 2; x < layers / 2; x++) {
|
||||||
for (let z = -layers / 2; z < layers / 2; z++) {
|
for (let z = -layers / 2; z < layers / 2; z++) {
|
||||||
const dist1 = Math.sqrt(x * x + y * y + z * z)
|
const dist1 = Math.sqrt(x * x + y * y + z * z)
|
||||||
|
|
||||||
if (dist1 <= radius) {
|
if (dist1 <= radius) {
|
||||||
const index1 = x + layers / 2 + (z + layers / 2) * layers + (y + layers / 2) * layers * layers
|
elements.push({
|
||||||
|
"from": [4 + (x + layers / 2) / layers * 8, 4 + (y + layers / 2) / layers * 8, 4 + (z + layers / 2) / layers * 8],
|
||||||
if (!checked[index1]) {
|
"to": [4 + (x + layers / 2 + 1) / layers * 8, 4 + (y + layers / 2 + 1) / layers * 8, 4 + (z + layers / 2 + 1) / layers * 8],
|
||||||
let height = 0
|
"faces": {
|
||||||
let index
|
"down": { "texture": "#black_hole" },
|
||||||
|
"up": { "texture": "#black_hole" },
|
||||||
for (let y2 = 0; y2 < layers; y2++) {
|
"north": { "texture": "#black_hole" },
|
||||||
const dist = Math.sqrt(x * x + (y + y2) * (y + y2) + z * z)
|
"south": { "texture": "#black_hole" },
|
||||||
const index2 = x + layers / 2 + (z + layers / 2) * layers + (y + y2 + layers / 2) * layers * layers
|
"west": { "texture": "#black_hole" },
|
||||||
|
"east": { "texture": "#black_hole" }
|
||||||
if (dist <= radius && !checked[index2]) {
|
|
||||||
height = y2
|
|
||||||
index = index2
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
if (height > 0) {
|
|
||||||
checked[index] = {
|
|
||||||
"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],
|
|
||||||
"faces": {
|
|
||||||
"down": { "texture": "#black_hole" },
|
|
||||||
"up": { "texture": "#black_hole" },
|
|
||||||
"north": { "texture": "#black_hole" },
|
|
||||||
"south": { "texture": "#black_hole" },
|
|
||||||
"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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(root + 'black_hole.json', JSON.stringify({
|
fs.writeFileSync(root + 'black_hole.json', JSON.stringify({
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
"textures": {
|
"textures": {
|
||||||
"black_hole": "overdrive_that_matters:block/black_hole"
|
"black_hole": "overdrive_that_matters:block/black_hole"
|
||||||
},
|
},
|
||||||
"elements": merged_z
|
"elements": elements
|
||||||
}, null, '\t'))
|
}, null, '\t'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class BlockEntityBlackHole extends BlockEntity {
|
|||||||
setMass(mass);
|
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 BigDecimal mass = NORMAL_MASS;
|
||||||
private double gravitation_strength = 1;
|
private double gravitation_strength = 1;
|
||||||
private boolean suppress_updates = true;
|
private boolean suppress_updates = true;
|
||||||
@ -60,7 +60,9 @@ public class BlockEntityBlackHole extends BlockEntity {
|
|||||||
gravitation_strength = mass.divide(NORMAL_MASS, MatteryCapability.ROUND_RULES).doubleValue();
|
gravitation_strength = mass.divide(NORMAL_MASS, MatteryCapability.ROUND_RULES).doubleValue();
|
||||||
|
|
||||||
if (gravitation_strength > 1) {
|
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)
|
if (level != null && !level.isClientSide && !suppress_updates)
|
||||||
@ -203,8 +205,8 @@ public class BlockEntityBlackHole extends BlockEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду
|
// шанс 1% что черная дыра потеряет 0.1 MtU каждую секунду * силу гравитации дыры ^ -1
|
||||||
if (level.random.nextDouble() < 0.01 * 0.05) {
|
if (level.random.nextDouble() < 0.01 * 0.05 * (1 / tile.gravitation_strength)) {
|
||||||
tile.addMass(HAWKING_MASS_LOSE_STEP);
|
tile.addMass(HAWKING_MASS_LOSE_STEP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class BlackHoleRenderer implements BlockEntityRenderer<BlockEntityBlackHo
|
|||||||
RenderSystem.disableCull();
|
RenderSystem.disableCull();
|
||||||
|
|
||||||
poseStack.pushPose();
|
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());
|
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