Skip to content

Commit

Permalink
Add config to disable oxygen, temperature, and gravity
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNijjar committed Jan 29, 2024
1 parent 81cdc83 commit f316f70
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 3 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ See https://modrinth.com/mod/ad-astra/version/1.15.7 for the full changelog.
- Fixed missing blocks in mars temple and lunarian tower.
- Re-added planet sky rendering resource pack support.
- Added German radio station (#438)
- Fixed crash with cryo freezer moving fluids
- Fixed crash with cryo freezer moving fluids
- Added config to disable oxygen, temperature, and gravity
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2024-01-18T12:09:44.06362 Languages: en_us
27f0a0ed01afb10330690ac08af1585b1772bd44 assets/ad_astra/lang/en_us.json
// 1.20.1 2024-01-28T18:23:26.412941 Languages: en_us
01ab723b3fbb3d5ea4975fc96bc99429d52f913e assets/ad_astra/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@
"config.ad_astra.deshTierEnergyCapacity": "Desh tier energy capacity",
"config.ad_astra.deshTierFluidCapacity": "Desh tier max fluid capacity",
"config.ad_astra.deshTierMaxEnergyInOut": "Desh tier max energy in/out",
"config.ad_astra.disableGravity": "Disable gravity",
"config.ad_astra.disableOxygen": "Disable oxygen",
"config.ad_astra.disableTemperature": "Disable temperature",
"config.ad_astra.disabledPlanets": "Disabled planets",
"config.ad_astra.distributionRefreshRate": "Distribution refresh rate",
"config.ad_astra.energizerEnergyCapacity": "Energizer energy capacity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ public static void clientConfig() {
@Comment("A comma-separated list of planet IDs that should be hidden from the planets screen. e.g. minecraft:overworld,ad_astra:moon,ad_astra:mars,ad_astra:venus,ad_astra:mercury,ad_astra:glacio")
public static String disabledPlanets = "";

@ConfigEntry(
id = "disableOxygen",
type = EntryType.BOOLEAN,
translation = "config.ad_astra.disableOxygen"
)
@Comment("Disables oxygen damage.")
public static boolean disableOxygen;

@ConfigEntry(
id = "disableTemperature",
type = EntryType.BOOLEAN,
translation = "config.ad_astra.disableTemperature"
)
@Comment("Disables temperature damage.")
public static boolean disableTemperature;

@ConfigEntry(
id = "disableGravity",
type = EntryType.BOOLEAN,
translation = "config.ad_astra.disableGravity"
)
@Comment("Uses normal gravity for all planets.")
public static boolean disableGravity;

@InlineCategory
public static MachineConfig machineConfig;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import earth.terrarium.adastra.api.events.AdAstraEvents;
import earth.terrarium.adastra.api.planets.PlanetApi;
import earth.terrarium.adastra.api.systems.GravityApi;
import earth.terrarium.adastra.common.config.AdAstraConfig;
import earth.terrarium.adastra.common.constants.PlanetConstants;
import earth.terrarium.adastra.common.handlers.PlanetHandler;
import earth.terrarium.adastra.common.planets.Planet;
Expand Down Expand Up @@ -40,6 +41,7 @@ public float getGravity(Level level, BlockPos pos) {

@Override
public float getGravity(Entity entity) {
if (AdAstraConfig.disableGravity) return 1;
float gravity = getGravity(entity.level(), BlockPos.containing(entity.getX(), entity.getEyeY(), entity.getZ()));
return AdAstraEvents.EntityGravityEvent.post(entity, gravity);
}
Expand Down Expand Up @@ -68,6 +70,7 @@ public void removeGravity(Level level, Collection<BlockPos> positions) {

@Override
public void entityTick(Level level, LivingEntity entity, Vec3 travelVector, BlockPos movementAffectingPos) {
if (AdAstraConfig.disableGravity) return;
if (!entity.isControlledByLocalInstance()) return;

boolean touchingSomething = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import earth.terrarium.adastra.api.events.AdAstraEvents;
import earth.terrarium.adastra.api.planets.PlanetApi;
import earth.terrarium.adastra.api.systems.OxygenApi;
import earth.terrarium.adastra.common.config.AdAstraConfig;
import earth.terrarium.adastra.common.handlers.PlanetHandler;
import earth.terrarium.adastra.common.items.armor.SpaceSuitItem;
import earth.terrarium.adastra.common.planets.Planet;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void removeOxygen(Level level, Collection<BlockPos> positions) {

@Override
public void entityTick(ServerLevel level, LivingEntity entity) {
if (AdAstraConfig.disableOxygen) return;
if (entity.getType().is(ModEntityTypeTags.LIVES_WITHOUT_OXYGEN)) return;
if (entity.getType().is(ModEntityTypeTags.CAN_SURVIVE_IN_SPACE)) return;
if (SpaceSuitItem.hasFullSet(entity) && SpaceSuitItem.hasOxygen(entity)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import earth.terrarium.adastra.api.events.AdAstraEvents;
import earth.terrarium.adastra.api.planets.PlanetApi;
import earth.terrarium.adastra.api.systems.TemperatureApi;
import earth.terrarium.adastra.common.config.AdAstraConfig;
import earth.terrarium.adastra.common.constants.PlanetConstants;
import earth.terrarium.adastra.common.handlers.PlanetHandler;
import earth.terrarium.adastra.common.items.armor.SpaceSuitItem;
Expand Down Expand Up @@ -85,6 +86,7 @@ public boolean isCold(Level level, BlockPos pos) {

@Override
public void entityTick(ServerLevel level, LivingEntity entity) {
if (AdAstraConfig.disableTemperature) return;
if (entity.getType().is(ModEntityTypeTags.CAN_SURVIVE_IN_SPACE)) return;
if (this.isHot(level, entity.blockPosition())) {
if (entity.getType().is(ModEntityTypeTags.CAN_SURVIVE_EXTREME_HEAT)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ protected void addTranslations() {
add("config.ad_astra.forcePlanetTick", "Force planet tick");
add("config.ad_astra.disabledPlanets", "Disabled planets");
add("config.ad_astra.atmosphereLeave", "Atmosphere leave");
add("config.ad_astra.disableOxygen", "Disable oxygen");
add("config.ad_astra.disableTemperature", "Disable temperature");
add("config.ad_astra.disableGravity", "Disable gravity");

add("config.ad_astra.machines", "Machines");
add("config.ad_astra.ironTierMaxEnergyInOut", "Iron tier max energy in/out");
Expand Down

0 comments on commit f316f70

Please sign in to comment.