-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63fd7d8
commit 8d402d0
Showing
73 changed files
with
1,403 additions
and
1,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/sammy/malum/common/capabilities/CachedSpiritDropsData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.*; | ||
import com.mojang.serialization.codecs.*; | ||
import com.sammy.malum.common.capabilities.soul_data.*; | ||
import net.minecraft.core.*; | ||
import net.minecraft.world.item.*; | ||
|
||
import java.util.*; | ||
|
||
public class CachedSpiritDropsData { | ||
|
||
public static final Codec<CachedSpiritDropsData> CODEC = RecordCodecBuilder.create(obj -> obj.group( | ||
Codec.list(ItemStack.CODEC).optionalFieldOf("spiritDrops", Collections.emptyList()).forGetter(c -> c.spiritDrops), | ||
UUIDUtil.CODEC.optionalFieldOf("spiritOwner", null).forGetter(c -> c.spiritOwner) | ||
).apply(obj, CachedSpiritDropsData::new)); | ||
|
||
private List<ItemStack> spiritDrops = new ArrayList<>(); | ||
private UUID spiritOwner; | ||
|
||
public CachedSpiritDropsData() { | ||
|
||
} | ||
public CachedSpiritDropsData(List<ItemStack> spiritDrops, UUID spiritOwner) { | ||
this.spiritDrops = spiritDrops; | ||
this.spiritOwner = spiritOwner; | ||
} | ||
|
||
public List<ItemStack> getSpiritDrops() { | ||
return spiritDrops; | ||
} | ||
|
||
public UUID getSpiritOwner() { | ||
return spiritOwner; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/sammy/malum/common/capabilities/CurioData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.*; | ||
import com.mojang.serialization.codecs.*; | ||
|
||
public class CurioData { | ||
|
||
public static Codec<CurioData> CODEC = RecordCodecBuilder.create(obj -> obj.group( | ||
Codec.INT.fieldOf("watcherNecklaceCooldown").forGetter(c -> c.watcherNecklaceCooldown), | ||
Codec.INT.fieldOf("hiddenBladeNecklaceCooldown").forGetter(c -> c.hiddenBladeNecklaceCooldown) | ||
).apply(obj, CurioData::new)); | ||
|
||
public int watcherNecklaceCooldown; | ||
public int hiddenBladeNecklaceCooldown; | ||
|
||
public CurioData() { | ||
} | ||
|
||
public CurioData(int watcherNecklaceCooldown, int hiddenBladeNecklaceCooldown) { | ||
this.watcherNecklaceCooldown = hiddenBladeNecklaceCooldown; | ||
this.hiddenBladeNecklaceCooldown = hiddenBladeNecklaceCooldown; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/sammy/malum/common/capabilities/MalignantInfluenceData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.*; | ||
import com.mojang.serialization.codecs.*; | ||
import net.minecraft.core.*; | ||
import net.minecraft.world.entity.ai.attributes.*; | ||
|
||
import java.util.*; | ||
|
||
public class MalignantInfluenceData { | ||
|
||
public static Codec<MalignantInfluenceData> CODEC = Codec.unit(MalignantInfluenceData::new); | ||
|
||
public final HashMap<Holder<Attribute>, Double> cachedAttributeValues = new HashMap<>(); | ||
public boolean skipConversionLogic; | ||
|
||
public MalignantInfluenceData() { | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/sammy/malum/common/capabilities/ProgressionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.*; | ||
import com.mojang.serialization.codecs.*; | ||
|
||
public class ProgressionData { | ||
|
||
public static Codec<ProgressionData> CODEC = RecordCodecBuilder.create(obj -> obj.group( | ||
Codec.BOOL.fieldOf("obtainedEncyclopedia").forGetter(c -> c.obtainedEncyclopedia), | ||
Codec.BOOL.fieldOf("hasBeenRejected").forGetter(c -> c.hasBeenRejected) | ||
).apply(obj, ProgressionData::new)); | ||
|
||
public boolean obtainedEncyclopedia; | ||
public boolean hasBeenRejected; | ||
|
||
public ProgressionData() { | ||
} | ||
|
||
public ProgressionData(boolean obtainedEncyclopedia, boolean hasBeenRejected) { | ||
this.obtainedEncyclopedia = obtainedEncyclopedia; | ||
this.hasBeenRejected = hasBeenRejected; | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
src/main/java/com/sammy/malum/common/capabilities/SoulWardData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.*; | ||
import com.mojang.serialization.codecs.*; | ||
import com.sammy.malum.config.*; | ||
import com.sammy.malum.registry.common.*; | ||
import net.minecraft.network.*; | ||
import net.minecraft.network.codec.*; | ||
import net.minecraft.util.*; | ||
import net.minecraft.world.entity.*; | ||
import net.minecraft.world.entity.ai.attributes.*; | ||
import net.minecraft.world.entity.player.*; | ||
import team.lodestar.lodestone.helpers.*; | ||
|
||
import java.util.*; | ||
|
||
public class SoulWardData { | ||
|
||
public static Codec<SoulWardData> CODEC = RecordCodecBuilder.create(obj -> obj.group( | ||
Codec.DOUBLE.fieldOf("soulWard").forGetter(sw -> sw.soulWard), | ||
Codec.DOUBLE.fieldOf("soulWardProgress").forGetter(sw -> sw.soulWardCooldown) | ||
).apply(obj, SoulWardData::new)); | ||
|
||
public static StreamCodec<FriendlyByteBuf, SoulWardData> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.DOUBLE, p -> p.soulWard, | ||
ByteBufCodecs.DOUBLE, p -> p.soulWardCooldown, | ||
SoulWardData::new); | ||
|
||
private double soulWard; | ||
private double soulWardCooldown; | ||
|
||
private boolean isDirty; | ||
|
||
public SoulWardData() { | ||
} | ||
|
||
public SoulWardData(double soulWard, double soulWardCooldown) { | ||
this.soulWard = soulWard; | ||
this.soulWardCooldown = soulWardCooldown; | ||
} | ||
|
||
public void recoverSoulWard(LivingEntity entity, double amount) { | ||
var multiplier = Optional.ofNullable(entity.getAttribute(AttributeRegistry.SOUL_WARD_RECOVERY_MULTIPLIER)).map(AttributeInstance::getValue).orElse(1.0); | ||
addSoulWard(amount * multiplier); | ||
if (!(entity instanceof Player player) || !player.isCreative()) { | ||
var capacity = entity.getAttribute(AttributeRegistry.SOUL_WARD_CAPACITY); | ||
if (capacity != null) { | ||
var sound = soulWard >= capacity.getValue() ? SoundRegistry.SOUL_WARD_CHARGE : SoundRegistry.SOUL_WARD_GROW; | ||
double pitchOffset = (soulWard / capacity.getValue()) * 0.5f + (Mth.ceil(soulWard) % 3) * 0.25f; | ||
SoundHelper.playSound(entity, sound.get(), 0.25f, (float) (1f + pitchOffset)); | ||
} | ||
} | ||
addCooldown(entity, 1); | ||
} | ||
|
||
public void addSoulWard(double added) { | ||
setSoulWard(soulWard + added); | ||
} | ||
|
||
public void reduceSoulWard(double removed) { | ||
setSoulWard(soulWard - removed); | ||
} | ||
|
||
public void setSoulWard(double soulWard) { | ||
this.soulWard = Math.max(soulWard, 0); | ||
isDirty = true; | ||
} | ||
|
||
public double getSoulWard() { | ||
return soulWard; | ||
} | ||
|
||
public void addCooldown(LivingEntity living, double multiplier) { | ||
final double newCooldown = getSoulWardCooldown(living) * multiplier; | ||
if (soulWardCooldown < newCooldown) { | ||
soulWardCooldown = newCooldown; | ||
setDirty(true); | ||
} | ||
} | ||
|
||
public void tickCooldown() { | ||
if (soulWardCooldown > 0) { | ||
soulWardCooldown--; | ||
} | ||
} | ||
|
||
public double getCooldown() { | ||
return soulWardCooldown; | ||
} | ||
|
||
public boolean isDirty() { | ||
return isDirty; | ||
} | ||
|
||
public void setDirty(boolean dirty) { | ||
isDirty = dirty; | ||
} | ||
|
||
public boolean isDepleted() { | ||
return soulWard <= 0; | ||
} | ||
|
||
public static float getSoulWardCooldown(LivingEntity living) { | ||
return getSoulWardCooldown(living.getAttributeValue(AttributeRegistry.SOUL_WARD_RECOVERY_RATE)); | ||
} | ||
|
||
public static float getSoulWardCooldown(double recoverySpeed) { | ||
return Mth.floor(CommonConfig.SOUL_WARD_RATE.getConfigValue() / recoverySpeed); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/sammy/malum/common/capabilities/StaffAbilityData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.sammy.malum.common.capabilities; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
|
||
public class StaffAbilityData { | ||
|
||
public static Codec<StaffAbilityData> CODEC = RecordCodecBuilder.create(obj -> obj.group( | ||
Codec.INT.fieldOf("reserveChargeCount").forGetter(c -> c.reserveChargeCount), | ||
Codec.FLOAT.fieldOf("reserveChargeProgress").forGetter(c -> c.reserveChargeProgress) | ||
).apply(obj, StaffAbilityData::new)); | ||
|
||
public int reserveChargeCount; | ||
public float reserveChargeProgress; | ||
|
||
public StaffAbilityData() { | ||
} | ||
|
||
public StaffAbilityData(int reserveChargeCount, float reserveChargeProgress) { | ||
this.reserveChargeCount = reserveChargeCount; | ||
this.reserveChargeProgress = reserveChargeProgress; | ||
} | ||
} |
Oops, something went wrong.