Skip to content

Commit

Permalink
Speed upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 committed Aug 9, 2024
1 parent abf688b commit 32787fc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import whocraft.tardis_refined.common.capability.upgrades.SpeedUpgrade;
import whocraft.tardis_refined.common.capability.upgrades.Upgrade;
import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler;
import whocraft.tardis_refined.registry.TRUpgrades;
import whocraft.tardis_refined.common.tardis.TardisArchitectureHandler;
import whocraft.tardis_refined.common.tardis.TardisNavLocation;
import whocraft.tardis_refined.common.util.PlayerUtil;
Expand All @@ -36,6 +35,7 @@
import whocraft.tardis_refined.constants.NbtConstants;
import whocraft.tardis_refined.patterns.ConsolePattern;
import whocraft.tardis_refined.registry.TRSoundRegistry;
import whocraft.tardis_refined.registry.TRUpgrades;

import java.util.*;

Expand Down Expand Up @@ -1046,19 +1046,16 @@ private void onRestoreFuel() {
*/
private int getLatestSpeedModifier() {
UpgradeHandler upgradeHandler = this.operator.getUpgradeHandler();
Upgrade upgrade = TRUpgrades.SPEED_III.get();

for (int i = 0; i < 3; i++)
{
if (!(upgrade instanceof SpeedUpgrade))
return this.speedModifier;

if (upgradeHandler.isUpgradeUnlocked(upgrade))
return ((SpeedUpgrade) upgrade).getSpeedModifier();

upgrade = upgrade.getParent();
}

this.speedModifier = TRUpgrades.UPGRADE_DEFERRED_REGISTRY.entrySet().stream()
.map(Map.Entry::getValue)
.filter(upgrade -> upgrade instanceof SpeedUpgrade)
.map(upgrade -> (SpeedUpgrade) upgrade)
.filter(upgradeHandler::isUpgradeUnlocked)
.mapToInt(SpeedUpgrade::getSpeedModifier)
.max()
.orElse(1);
return this.speedModifier;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ public class TRUpgrades {
public static final RegistrySupplier<Upgrade> FLIGHT_SYSTEM = UPGRADE_DEFERRED_REGISTRY.register("flight_system", () -> new Upgrade(Items.ELYTRA::getDefaultInstance, TARDIS_XP, RegistryHelper.makeKey("flight_system"), Upgrade.UpgradeType.MAIN_UPGRADE)
.setSkillPointsRequired(1).setPosition(9, 1));

public static final RegistrySupplier<Upgrade> SPEED_I = UPGRADE_DEFERRED_REGISTRY.register("speed_i", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, FLIGHT_SYSTEM, RegistryHelper.makeKey("speed_i"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(2)
public static final RegistrySupplier<Upgrade> SPEED_I = UPGRADE_DEFERRED_REGISTRY.register("speed_i", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, FLIGHT_SYSTEM, RegistryHelper.makeKey("speed_i"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(5)
.setSkillPointsRequired(10).setPosition(9, 2));

public static final RegistrySupplier<Upgrade> SPEED_II = UPGRADE_DEFERRED_REGISTRY.register("speed_ii", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, SPEED_I, RegistryHelper.makeKey("speed_ii"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(5)
public static final RegistrySupplier<Upgrade> SPEED_II = UPGRADE_DEFERRED_REGISTRY.register("speed_ii", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, SPEED_I, RegistryHelper.makeKey("speed_ii"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(10)
.setSkillPointsRequired(20).setPosition(9, 3));

public static final RegistrySupplier<Upgrade> SPEED_III = UPGRADE_DEFERRED_REGISTRY.register("speed_iii", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, SPEED_II, RegistryHelper.makeKey("speed_iii"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(10)
public static final RegistrySupplier<Upgrade> SPEED_III = UPGRADE_DEFERRED_REGISTRY.register("speed_iii", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, SPEED_II, RegistryHelper.makeKey("speed_iii"), Upgrade.UpgradeType.SUB_UPGRADE).setSpeedModifier(25)
.setSkillPointsRequired(30).setPosition(9, 4));

public static final RegistrySupplier<Upgrade> SPEED_IV = UPGRADE_DEFERRED_REGISTRY.register("speed_iv", () -> new SpeedUpgrade(Items.FIREWORK_ROCKET::getDefaultInstance, SPEED_II, RegistryHelper.makeKey("speed_iv"), Upgrade.UpgradeType.SUB_UPGRADE)
.setSpeedModifier(50)
.setSkillPointsRequired(50)
.setPosition(9, 5));

}
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ protected void addTranslations() {
addUpgrade(TRUpgrades.IMPROVED_GENERATION_TIME_II.get(), "Improved Generation II", "Lowers desktop wait times to 60 seconds");
addUpgrade(TRUpgrades.IMPROVED_GENERATION_TIME_III.get(), "Improved Generation III", "Lowers desktop wait times to 10 seconds");
addUpgrade(TRUpgrades.FLIGHT_SYSTEM.get(), "Flight System", "Allows upgrades to the TARDIS Flight System");
addUpgrade(TRUpgrades.SPEED_I.get(), "Speed I", "Flight speed is 2x faster");
addUpgrade(TRUpgrades.SPEED_II.get(), "Speed II", "Flight speed is 5x faster");
addUpgrade(TRUpgrades.SPEED_III.get(), "Speed III", "Flight speed is 10x faster");
addUpgrade(TRUpgrades.SPEED_I.get(), "Speed I", "Flight speed is 5x faster");
addUpgrade(TRUpgrades.SPEED_II.get(), "Speed II", "Flight speed is 10x faster");
addUpgrade(TRUpgrades.SPEED_III.get(), "Speed III", "Flight speed is 25x faster");
addUpgrade(TRUpgrades.SPEED_IV.get(), "Speed IV", "Flight speed is 50x faster");

}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ neoforge_data_pack_format=18
##Mod Information

#Common Mod Information
mod_version=2.0.5
mod_version=2.0.6
license=https://github.com/Whocraft/TardisRefined/blob/minecraft/1.20/LICENSE.MD
credits=Commoble, Lucraft, starray1000000, Monsterwaill, TheJudge, LoxiGoose
mod_authors=CommandrMoose / River, Jeryn99, Magic Man, ILikePandas, Jacob K, 50ap5ud5
Expand Down

0 comments on commit 32787fc

Please sign in to comment.