Skip to content

Commit

Permalink
Added compatibility with Thirst Was Taken: Thirst reduces regeneratio…
Browse files Browse the repository at this point in the history
…n speed, being quenched increases it.

Added compatibility with Cold Sweat: Being cold induces Cold effect, being hot induces Hot effect.
Added new effect and potion "Hot", which reduces maximum feathers.
Added Spanish and German localizations.
Added alternate green feathers texture.
Added golden texture for Energized effect.
Refactored some code in overlay for easier addition of elements in the future.
  • Loading branch information
Darkona committed May 25, 2024
1 parent 8b0306a commit 0bfbacf
Show file tree
Hide file tree
Showing 33 changed files with 1,067 additions and 405 deletions.
25 changes: 25 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}

plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}

apply plugin: 'org.spongepowered.mixin'

version = mod_version
group = mod_group_id

Expand Down Expand Up @@ -93,11 +106,23 @@ repositories {
maven { // CurseForge
url "https://www.cursemaven.com"
}
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

implementation fg.deobf("curse.maven:serene-seasons-291874:${serene_seasons_file_id}")

implementation fg.deobf("curse.maven:cold-sweat-506194:${cold_sweat_file_id}-sources-5011470")
//implementation "curse.maven:cold-sweat-506194:${cold_sweat_file_id}-sources-5011470"

implementation fg.deobf("curse.maven:thirst-was-taken-679270:${thirst_was_taken_file_id}")

compileOnly("curse.maven:overflowing-bars-852662:4578581")
implementation fg.deobf("curse.maven:player-animator-658587:${player_animator_file_id}")
implementation fg.deobf("curse.maven:elenai-dodge-442962:${elenai_dodge_file_id}")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}


Expand Down
64 changes: 14 additions & 50 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,59 +1,23 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false


## Environment Properties

# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version=1.20.1
minecraft_version_range=[1.20,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=46.0.14
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[46,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[46,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
forge_version=47.2.0
forge_version_range=[47,)
loader_version_range=[47,)
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20
mapping_version=1.20.1


## Mod Properties

# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=feathers
# The human-readable display name for the mod.
mod_name=Feathers
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPU
# The mod version. See https://semver.org/
mod_version=1.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_version=1.2
mod_group_id=com.elenai.feathers
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=Elenai
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Feathers is a stamina system for Minecraft, it adds a set of blue feathers to the hotbar to be spent by other mods, as well as an armor weight system to the game.
mod_authors=Elenai, Darkona
mod_description=Feathers is a stamina system for Minecraft, it adds a set of blue feathers to the hotbar to be spent by other mods, as well as an armor weight system to the game.
player_animator_file_id=4587214
elenai_dodge_file_id=4814313

serene_seasons_file_id=4761603
cold_sweat_file_id=5349837
thirst_was_taken_file_id=5287289
4 changes: 4 additions & 0 deletions src/main/java/com/elenai/feathers/Feathers.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Feathers {
public static final String MODID = "feathers";
public static final Logger logger = LogManager.getLogger(MODID);
public static final boolean OB_LOADED = ModList.get().isLoaded("overflowingbars");
public static final boolean THIRST_LOADED = ModList.get().isLoaded("thirst");
public static final boolean COLD_SWEAT_LOADED = ModList.get().isLoaded("cold_sweat");

public Feathers() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
Expand All @@ -49,6 +51,8 @@ private void commonSetup(FMLCommonSetupEvent event) {
private void registerBrewingRecipes() {
// Cold
PotionBrewing.addMix(Potions.AWKWARD, Items.SNOWBALL, FeathersPotions.COLD_POTION.get());
//Hot
PotionBrewing.addMix(Potions.AWKWARD, Items.MAGMA_BLOCK, FeathersPotions.HOT_POTION.get());

// Endurance
PotionBrewing.addMix(Potions.AWKWARD, Items.FEATHER, FeathersPotions.ENDURANCE_POTION.get());
Expand Down
38 changes: 27 additions & 11 deletions src/main/java/com/elenai/feathers/api/FeathersHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.elenai.feathers.networking.packet.ColdSyncSTCPacket;
import com.elenai.feathers.networking.packet.FeatherSyncCTSPacket;
import com.elenai.feathers.networking.packet.FeatherSyncSTCPacket;
import com.elenai.feathers.networking.packet.HotSyncSTCPacket;
import com.elenai.feathers.util.ArmorHandler;

import net.minecraft.client.Minecraft;
Expand All @@ -33,7 +34,7 @@ public static void setFeathers(ServerPlayer player, int feathers) {
player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).ifPresent(f -> {
f.setFeathers(feathers);
f.setCooldown(0);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), getMaxFeathers()), player);
});
}

Expand All @@ -49,7 +50,7 @@ public static void setMaxFeathers(ServerPlayer player, int feathers) {
if (player.getAttributeValue(FeathersAttributes.MAX_FEATHERS.get()) != feathers)
player.getAttribute(FeathersAttributes.MAX_FEATHERS.get()).setBaseValue(feathers);
f.setMaxFeathers(feathers);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), f.getMaxCooldown()), player);
});
}

Expand All @@ -63,7 +64,7 @@ public static void setMaxFeathers(ServerPlayer player, int feathers) {
public static void setFeatherRegen(ServerPlayer player, int ticks) {
player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).ifPresent(f -> {
f.setRegen(ticks);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), f.getMaxCooldown()), player);
});
}

Expand Down Expand Up @@ -141,7 +142,7 @@ public static void addFeathers(ServerPlayer player, int feathers) {
player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).ifPresent(f -> {
f.addFeathers(feathers);
f.setCooldown(0);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), f.getMaxCooldown()), player);
});
}

Expand All @@ -160,7 +161,7 @@ public static void subFeathers(ServerPlayer player, int feathers) {
player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).ifPresent(f -> {
f.subFeathers(feathers);
f.setCooldown(0);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), f.getMaxCooldown()), player);
});
}

Expand Down Expand Up @@ -193,7 +194,7 @@ public static boolean spendFeathers(ServerPlayer player, int feathers) {
}

f.setCooldown(0);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers()), player);
FeathersMessages.sendToPlayer(new FeatherSyncSTCPacket(f.getFeathers(), f.getMaxFeathers(), f.getRegen(), getPlayerWeight(player), f.getEnduranceFeathers(), f.getMaxCooldown()), player);
});
return true;
}
Expand Down Expand Up @@ -299,9 +300,7 @@ public static int getPlayerWeight(ServerPlayer player) {
* @return if the player is cold
*/
public static boolean getCold(ServerPlayer player) {
return player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).map(f -> {
return f.isCold();
}).orElse(false);
return player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).map(PlayerFeathers::isCold).orElse(false);
}

/**
Expand All @@ -319,7 +318,7 @@ public static void setCold(ServerPlayer player, boolean cold) {
});
}

/**
/**e
* Checks whether the player has any feathers remaining
*
* @side client
Expand All @@ -328,5 +327,22 @@ public static void setCold(ServerPlayer player, boolean cold) {
public static boolean checkFeathersRemaining() {
return getFeathers() + getEndurance() > ClientFeathersData.getWeight();
}


public static void setHot(ServerPlayer player, boolean b) {
player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).ifPresent(f -> {
f.setHot(b);
FeathersMessages.sendToPlayer(new HotSyncSTCPacket(f.isHot()), player);
});
}

/**
* Returns the given player's hotness
*
* @side server
* @param player
* @return if the player is hot ;)
*/
public static boolean getHot(ServerPlayer player) {
return player.getCapability(PlayerFeathersProvider.PLAYER_FEATHERS).map(PlayerFeathers::isHot).orElse(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public class FeathersAttributes {
public static final HashMap<RegistryObject<Attribute>, UUID> UUIDS = new HashMap<>();
public static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(ForgeRegistries.ATTRIBUTES, Feathers.MODID);

public static final RegistryObject<Attribute> MAX_FEATHERS = registerAttribute("feathers.max_feathers", (id) -> new RangedAttribute(id, 20.0D, 0.0D, 1024.0D).setSyncable(true), "1ce4960d-c50e-44bf-ad23-7bcd77f4c1dc");
public static final RegistryObject<Attribute> FEATHER_REGEN = registerAttribute("feathers.feather_regen", (id) -> new RangedAttribute(id, 1.0D, 0.0D, 1024.0D).setSyncable(true), "d74ded8f-c5b6-4222-80e2-dbea7ccf8d02");
public static final RegistryObject<Attribute> MAX_FEATHERS = registerAttribute("feathers.max_feathers",
(id) -> new RangedAttribute(id, 20.0D, 0.0D, 1024.0D).setSyncable(true), "1ce4960d-c50e-44bf-ad23-7bcd77f4c1dc");
public static final RegistryObject<Attribute> FEATHER_REGEN = registerAttribute("feathers.feather_regen",
(id) -> new RangedAttribute(id, 1.0D, 0.0D, 1024.0D).setSyncable(true), "d74ded8f-c5b6-4222-80e2-dbea7ccf8d02");

public static RegistryObject<Attribute> registerAttribute(String name, Function<String, Attribute> attribute, String uuid) {
return registerAttribute(name, attribute, UUID.fromString(uuid));
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/com/elenai/feathers/capability/PlayerFeathers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,22 @@ public class PlayerFeathers {
private final int MIN_COOLDOWN = 0;

private boolean cold = false;
private boolean hot = true;

public int getMaxCooldown() {
return maxCooldown;
}

public void setMaxCooldown(int cooldown) {
this.maxCooldown = cooldown;
}
public void setHot(boolean hot){
this.hot = hot;
}

public boolean isHot(){
return hot;
}
public int getFeathers() {
return feathers;
}
Expand Down Expand Up @@ -80,7 +95,7 @@ public void loadNBTData(CompoundTag nbt) {
}

public int getCooldown() {
return cooldown;
return Math.round( cooldown);
}

public void setCooldown(int cooldown) {
Expand All @@ -90,7 +105,6 @@ public void setCooldown(int cooldown) {
public void addCooldown(int ticks) {
this.cooldown = Math.min(this.cooldown + ticks, maxCooldown);
}

public void subCooldown(int ticks) {
this.cooldown = Math.max(this.cooldown - ticks, MIN_COOLDOWN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.jetbrains.annotations.Nullable;

public class PlayerFeathersProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> {
public static Capability<PlayerFeathers> PLAYER_FEATHERS = CapabilityManager
.get(new CapabilityToken<PlayerFeathers>() {
});
public static Capability<PlayerFeathers> PLAYER_FEATHERS = CapabilityManager.get(new CapabilityToken<>() {});

private PlayerFeathers feathers = null;
private final LazyOptional<PlayerFeathers> optional = LazyOptional.of(this::createPlayerFeathers);
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/com/elenai/feathers/client/ClientFeathersData.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ public class ClientFeathersData {
private static int animationCooldown = 0;
private static int fadeCooldown = 0;
private static boolean cold = false;
private static boolean hot = false;
private static boolean energized = false;
private static boolean overflowing = false;
private static int maxCooldown;

public static void setFeathers(int feathers) {
public static void setFeathers(int feathers) {
ClientFeathersData.feathers = feathers;
}

Expand Down Expand Up @@ -55,6 +57,14 @@ public static void setCold(boolean cold) {
ClientFeathersData.cold = cold;
}

public static boolean isHot() {
return hot;
}

public static void setHot(boolean hot) {
ClientFeathersData.hot = hot;
}

public static boolean isOverflowing() {
return overflowing;
}
Expand Down Expand Up @@ -86,4 +96,12 @@ public static int getPreviousFeathers() {
public static void setPreviousFeathers(int previousFeathers) {
ClientFeathersData.previousFeathers = previousFeathers;
}

public static void setMaxCooldown(int maxCooldown) {
ClientFeathersData.maxCooldown = maxCooldown;
}

public static int getMaxCooldown() {
return maxCooldown;
}
}
Loading

0 comments on commit 0bfbacf

Please sign in to comment.