This commit is contained in:
Pyritie 2025-10-21 12:23:09 +01:00
commit 35d667e50a
4 changed files with 110 additions and 95 deletions

View file

@ -1,78 +1,75 @@
//"use strict"; // This is all debug code! Uncomment it if you want to test stuff related to the mars sandstorms
//const $Vec2 = Java.loadClass("net.minecraft.world.phys.Vec2") /*"use strict";
//ItemEvents.firstLeftClicked('gtceu:long_copper_rod', event => { const $Vec2 = Java.loadClass("net.minecraft.world.phys.Vec2")
// //if (event.getItem().getHoverName().getString() !== "zippity") return;
// let player = event.player; ItemEvents.firstLeftClicked('gtceu:long_copper_rod', event => {
// player.sendSystemMessage(event.getItem().getHoverName()); let player = event.player;
// let biome = event.getLevel().getBiome(player.blockPosition()); player.sendSystemMessage(event.getItem().getHoverName());
let biome = event.getLevel().getBiome(player.blockPosition());
// // player.sendSystemMessage("debug stick of dooooom!"); let currentWind = TFC.climate.getWindVector(player.level, player.blockPosition());
// let currentWind = TFC.climate.getWindVector(player.level, player.blockPosition());
// let tags = Array( let tags = Array(
// ResourceLocation.tryParse("tfg:has_light_sand_particles"), ResourceLocation.tryParse("tfg:has_light_sand_particles"),
// ResourceLocation.tryParse("tfg:has_medium_sand_particles"), ResourceLocation.tryParse("tfg:has_medium_sand_particles"),
// ResourceLocation.tryParse("tfg:has_dark_sand_particles") ResourceLocation.tryParse("tfg:has_dark_sand_particles")
// ) )
// // player.sendSystemMessage(`current biome tags are ${biome.getTagKeys().toString()}`);
// player.sendSystemMessage(biome.tags().map(tag => tag.location()).filter(element => tags.indexOf(element) > -1).toList());
// let text = `current wind vector is x: ${currentWind.x.toPrecision(2)} z: ${currentWind.y.toPrecision(2)}`;
// player.sendSystemMessage(text);
//});
//// scale wind up (down) on (crouch +) left click player.sendSystemMessage(biome.tags().map(tag => tag.location()).filter(element => tags.indexOf(element) > -1).toList());
//ItemEvents.firstLeftClicked('gtceu:long_tin_rod', event => { let text = `current wind vector is x: ${currentWind.x.toPrecision(2)} z: ${currentWind.y.toPrecision(2)}`;
// //if (event.getItem().getHoverName().getString() !== "zippity") return; player.sendSystemMessage(text);
// const player = event.getPlayer() });
// const climateManager = global.getMarsClimateController(); // scale wind up (down) on (crouch +) left click
// const wind = climateManager.getWind(); ItemEvents.firstLeftClicked('gtceu:long_tin_rod', event => {
// const windVec = new $Vec2(wind.x, wind.z); const player = event.getPlayer();
// const increment = player.isCrouching() ? -0.1 : 0.1;
// player.sendSystemMessage(`current x: ${windVec.x.toFixed(1)}, z: ${windVec.y.toFixed(1)}`); const climateManager = global.getMarsClimateController();
const wind = climateManager.getWind();
const windVec = new $Vec2(wind.x, wind.z);
const increment = player.isCrouching() ? -0.1 : 0.1;
// let scaledVec = windVec.add(increment); player.sendSystemMessage(`current x: ${windVec.x.toFixed(1)}, z: ${windVec.y.toFixed(1)}`);
// let newX = 0.0;
// let newY = 0.0;
// // i can't modify windVec's properties without rhino throwing a shitfit so here have some extra variables let scaledVec = windVec.add(increment);
// newX = scaledVec.x let newX = 0.0;
// newY = scaledVec.y let newY = 0.0;
// if (scaledVec.lengthSquared() >= 1.0) { // i can't modify windVec's properties without rhino throwing a shitfit so here have some extra variables
// newX = scaledVec.normalized().scale(0.99).x; newX = scaledVec.x;
// newY = scaledVec.normalized().scale(0.99).y; newY = scaledVec.y;
// }
// newX = newX <= 0.1 ? 0.1 : newX
// newY = newY <= 0.1 ? 0.1 : newY
// climateManager.setWind({x: newX, z: newY}) if (scaledVec.lengthSquared() >= 1.0) {
// player.sendSystemMessage(`new x: ${newX.toFixed(1)}, z: ${newY.toFixed(1)}`); newX = scaledVec.normalized().scale(0.99).x;
//}); newY = scaledVec.normalized().scale(0.99).y;
}
newX = newX <= 0.1 ? 0.1 : newX;
newY = newY <= 0.1 ? 0.1 : newY;
//ItemEvents.firstRightClicked('gtceu:long_tin_rod', event => { climateManager.setWind({x: newX, z: newY});
// //if (event.getItem().getHoverName().getString() !== "zippity") return; player.sendSystemMessage(`new x: ${newX.toFixed(1)}, z: ${newY.toFixed(1)}`);
// const player = event.getPlayer(); });
// const climateManager = global.getMarsClimateController(); ItemEvents.firstRightClicked('gtceu:long_tin_rod', event => {
// const wind = climateManager.getWind(); const player = event.getPlayer();
// const windVec = new $Vec2(wind.x, wind.z);
// const initAngle = Math.atan2(windVec.y, windVec.x); // angle to x axis const climateManager = global.getMarsClimateController();
// let increment = player.isCrouching() ? 15 : -15; const wind = climateManager.getWind();
// increment = JavaMath.toRadians(increment) const windVec = new $Vec2(wind.x, wind.z);
// player.sendSystemMessage(`current angle: ${JavaMath.toDegrees(initAngle).toFixed(1)}`); const initAngle = Math.atan2(windVec.y, windVec.x); // angle to x axis
let increment = player.isCrouching() ? 15 : -15;
increment = JavaMath.toRadians(increment)
// let newX = (windVec.x * JavaMath.cos(increment)) - (windVec.y * JavaMath.sin(increment)) player.sendSystemMessage(`current angle: ${JavaMath.toDegrees(initAngle).toFixed(1)}`);
// let newY = (windVec.x * JavaMath.sin(increment)) + (windVec.y * JavaMath.cos(increment))
// player.sendSystemMessage(`new x: ${newX.toFixed(1)}, z: ${newY.toFixed(1)}`); let newX = (windVec.x * JavaMath.cos(increment)) - (windVec.y * JavaMath.sin(increment))
let newY = (windVec.x * JavaMath.sin(increment)) + (windVec.y * JavaMath.cos(increment))
// climateManager.setWind({x: newX, z: newY}); player.sendSystemMessage(`new x: ${newX.toFixed(1)}, z: ${newY.toFixed(1)}`);
// player.sendSystemMessage(`new angle: ${JavaMath.toDegrees(Math.atan2(newY, newX)).toFixed(1)}`);
//}); climateManager.setWind({x: newX, z: newY});
player.sendSystemMessage(`new angle: ${JavaMath.toDegrees(Math.atan2(newY, newX)).toFixed(1)}`);
});*/

View file

@ -38,6 +38,12 @@ const registerTFGItemTags = (event) => {
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/hematitic_sand_covering') event.add('c:hidden_from_recipe_viewers', 'tfg:pile/hematitic_sand_covering')
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/mars_snow_covering') event.add('c:hidden_from_recipe_viewers', 'tfg:pile/mars_snow_covering')
// Actually "piles", the kind that can hide plants inside them
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/mars_sand_covering')
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/venus_sand_covering')
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/hematitic_sand_covering')
event.add('c:hidden_from_recipe_viewers', 'tfg:pile/mars_snow_covering')
//Decorative Vases //Decorative Vases
global.MINECRAFT_DYE_NAMES.forEach(color => { global.MINECRAFT_DYE_NAMES.forEach(color => {
event.add('c:hidden_from_recipe_viewers', `tfg:decorative_vase/generated/${color}`) event.add('c:hidden_from_recipe_viewers', `tfg:decorative_vase/generated/${color}`)

View file

@ -36,34 +36,49 @@ function invLerp(x, y, a) {
* allows runtime control of wind vector; called every tick * allows runtime control of wind vector; called every tick
* @returns {Object} singleton manager object * @returns {Object} singleton manager object
*/ */
global.getMarsClimateController = function() { global.getMarsClimateController = function () {
if (!global._MARS_CLIMATE_CONTROLLER) { if (!global._MARS_CLIMATE_CONTROLLER) {
console.info("Initializing MARS_CLIMATE_CONTROLLER..."); console.info("Initializing MARS_CLIMATE_CONTROLLER...");
global._MARS_CLIMATE_CONTROLLER = { global._MARS_CLIMATE_CONTROLLER = {
windX: 0, windX: 0,
windZ: 0, windZ: 0,
getWind: function() { getWind: function () {
return {x: this.windX, z: this.windZ}; return { x: this.windX, z: this.windZ };
}, },
setWind: function(vector) { setWind: function (vector) {
const strength = Math.hypot(vector.x, vector.z); this.windX = vector.x;
// if (strength > 1.0) throw new RangeError("Vector length > 1"); this.windZ = vector.z;
this.windX = vector.x; },
this.windZ = vector.z;
},
createCallbackForBuilder: function(builder) { createWindCallback: function (builder) {
var self = this; var self = this;
return function() { return function (level, pos, calendarTicks) {
const wind = self.getWind(); const strength = Max.max(0, (Math.sin(calendarTicks / 10000) -0.6) / 1.5);
return builder.vector(wind.x, wind.z);
}; const newX = Math.cos(calendarTicks / 2400) * strength;
} const newZ = Math.sin(calendarTicks / 2400) * strength;
};
} self.setWind({x: newX, z: newZ});
return global._MARS_CLIMATE_CONTROLLER; return builder.vector(newX, newZ);
};
},
createFogCallback: function (builder) {
var self = this;
return function (level, pos, calendarTicks) {
const wind = self.getWind();
const strength = Math.hypot(wind.x, wind.z);
if (strength < 0.2)
return 0;
else
return Math.max(0, strength);
}
}
};
}
return global._MARS_CLIMATE_CONTROLLER;
}; };
@ -150,7 +165,6 @@ TFCEvents.registerClimateModel(event => {
}) })
event.register('tfg:orbit_climate', builder => { event.register('tfg:orbit_climate', builder => {
builder.setCurrentTemperatureCalculation((level, pos, calendarTicks, daysInMonth) => { builder.setCurrentTemperatureCalculation((level, pos, calendarTicks, daysInMonth) => {
if (OxygenAPI.hasOxygen(level, pos.above())) { if (OxygenAPI.hasOxygen(level, pos.above())) {
return OXYGENATED_TEMP; return OXYGENATED_TEMP;
@ -194,22 +208,20 @@ TFCEvents.registerClimateModel(event => {
}) })
builder.setAverageTemperatureCalculation((level, pos) => { builder.setAverageTemperatureCalculation((level, pos) => {
// Earth is 10k to each pole, and mars is about half as big as earth, so 5k to each pole sounds good // Earth is 10k to each pole, and mars is about half as big as earth, so 5k to each pole sounds good
return calcAverage(pos.z, global.MARS_PLANET_SIZE, -110, -15); return calcAverage(pos.z, global.MARS_PLANET_SIZE, -110, -15);
}) })
builder.setAverageRainfallCalculation((level, pos) => { builder.setAverageRainfallCalculation((level, pos) => {
// irl mars' poles have a snowfall of 0.13mm but that's barely noticeable here. // irl mars' poles have a snowfall of 0.13mm but that's barely noticeable here.
// Use a negative rainfall to stop it snowing closer to the equator. TFC clamps negatives to zero so it's fine // Use a negative rainfall to stop it snowing closer to the equator. TFC clamps negatives to zero so it's fine
return calcAverage(pos.x, global.MARS_PLANET_SIZE, -25, 13) return calcAverage(pos.x, global.MARS_PLANET_SIZE, -25, 13)
}) })
builder.setAirFog((level, pos, calendarTicks) => 0) builder.setWaterFog((level, pos, calendarTicks) => 0.02);
builder.setWaterFog((level, pos, calendarTicks) => 0.1)
const controller = global.getMarsClimateController(); const controller = global.getMarsClimateController();
builder.setWindVector(controller.createCallbackForBuilder(builder)); builder.setAirFog(controller.createFogCallback(builder));
builder.setWindVector(controller.createWindCallback(builder));
}) })
}) })