Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port changes on 1.20.1 to 1.20.4 #456

Merged
merged 11 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.github.minecraftschurlimods.helperplugin.sourceSets

plugins {
idea
id("net.neoforged.gradle.userdev")
id ("com.github.minecraftschurlimods.helperplugin")
}

Expand Down Expand Up @@ -150,15 +151,20 @@ dependencies {
jarJar(codeclib)
"apiCompileOnly"(codeclib)
implementation(codeclib)
"dataImplementation"(codeclib)
testImplementation(codeclib)

val betterkeybindlib = project.localGradleProperty("dependency.betterkeybindlib.version").map { "com.github.minecraftschurlimods:betterkeybindlib:$it" }
jarJar(betterkeybindlib)
implementation(betterkeybindlib)
"dataImplementation"(betterkeybindlib)
testImplementation(betterkeybindlib)

val betterhudlib = project.localGradleProperty("dependency.betterhudlib.version").map { "com.github.minecraftschurlimods:betterhudlib:$it" }
jarJar(betterhudlib)
implementation(betterhudlib)
"dataImplementation"(betterhudlib)
testImplementation(betterhudlib)

val easyDatagenLibVersion = project.localGradleProperty("dependency.easydatagenlib.version")
val easyDatagenLibApiDep = easyDatagenLibVersion.map { "com.github.minecraftschurlimods:easydatagenlib:${it}:api" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginManagement {
plugins {
id("net.neoforged.gradle.userdev") version "7.0.106"
id("com.github.minecraftschurlimods.helperplugin") version "1.11"
id("net.neoforged.gradle.userdev") version "7.0.154"
id("com.github.minecraftschurlimods.helperplugin") version "1.14"
}
repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
Expand Down Expand Up @@ -137,4 +138,19 @@ private static TagKey<Biome> tag(String name) {
return TagKey.create(Registries.BIOME, new ResourceLocation(ArsMagicaAPI.MOD_ID, name));
}
}

/**
* Holds the mod's damage type tags.
*/
public static final class DamageTypes {
public static final TagKey<DamageType> SPELL = tag("spell");

private static TagKey<DamageType> forgeTag(String name) {
return TagKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(FORGE, name));
}

private static TagKey<DamageType> tag(String name) {
return TagKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, name));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.minecraftschurlimods.arsmagicalegacy.api.event;

import net.minecraft.world.entity.player.Player;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;

/**
* Event that fires when the player's magic level changes.
*/
public final class PlayerLevelChangeEvent extends PlayerEvent {
private final int level;
private final int oldLevel;

public PlayerLevelChangeEvent(Player player, int level, int oldLevel) {
super(player);
this.level = level;
this.oldLevel = oldLevel;
}

/**
* @return The new level of the player.
*/
public int getLevel() {
return level;
}

/**
* @return The old level of the player.
*/
public int getOldLevel() {
return oldLevel;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public interface IMagicHelper {
*/
boolean knowsMagic(Player player);

/**
* Initiate leveling (set level 1) for the given player.
*
* @param player The player to initiate leveling for.
*/
void initiateLeveling(Player player);

/**
* @param player The player to check.
* @return True if the player has magic vision, false otherwise.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.github.minecraftschurlimods.arsmagicalegacy.api.spell;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import org.jetbrains.annotations.ApiStatus.OverrideOnly;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Set;
Expand All @@ -14,7 +16,7 @@
*/
public interface ISpellComponent extends ISpellPart {
/**
* Invoke this spell component for an entity. Called only on the server.
* Invoke this spell component for an entity. Called only on the server. Deprecated, use variant with directEntity parameter below instead.
*
* @param spell The spell being cast.
* @param caster The caster of the spell.
Expand All @@ -25,11 +27,14 @@ public interface ISpellComponent extends ISpellPart {
* @param ticksUsed The amount of ticks the spell is being cast for.
* @return The spell cast result (success if anything was affected).
*/
@Deprecated(forRemoval = true)
@OverrideOnly
SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List<ISpellModifier> modifiers, EntityHitResult target, int index, int ticksUsed);
default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List<ISpellModifier> modifiers, EntityHitResult target, int index, int ticksUsed) {
return invoke(spell, caster, null, level, modifiers, target, index, ticksUsed);
}

/**
* Invoke this spell component for a block. Called only on the server.
* Invoke this spell component for a block. Called only on the server. Deprecated, use variant with directEntity parameter below instead.
*
* @param spell The spell being cast.
* @param caster The caster of the spell.
Expand All @@ -40,8 +45,11 @@ public interface ISpellComponent extends ISpellPart {
* @param ticksUsed The amount of ticks the spell is being cast for.
* @return The spell cast result (success if anything was affected).
*/
@Deprecated(forRemoval = true)
@OverrideOnly
SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List<ISpellModifier> modifiers, BlockHitResult target, int index, int ticksUsed);
default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List<ISpellModifier> modifiers, BlockHitResult target, int index, int ticksUsed) {
return invoke(spell, caster, null, level, modifiers, target, index, ticksUsed);
}

/**
* @return The stats used by this spell part.
Expand All @@ -52,4 +60,36 @@ public interface ISpellComponent extends ISpellPart {
default SpellPartType getType() {
return SpellPartType.COMPONENT;
}

/**
* Invoke this spell component for an entity. Called only on the server.
*
* @param spell The spell being cast.
* @param caster The caster of the spell.
* @param directEntity The direct entity casting the spell, e.g. a projectile.
* @param level The level the spell is being cast in.
* @param modifiers The modifiers modifying this component.
* @param target The target.
* @param index The index of this spell component in the spell execution stack.
* @param ticksUsed The amount of ticks the spell is being cast for.
* @return The spell cast result (success if anything was affected).
*/
@OverrideOnly
SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List<ISpellModifier> modifiers, EntityHitResult target, int index, int ticksUsed);

/**
* Invoke this spell component for a block. Called only on the server.
*
* @param spell The spell being cast.
* @param caster The caster of the spell.
* @param directEntity The direct entity casting the spell, e.g. a projectile.
* @param level The level the spell is being cast in.
* @param modifiers The modifiers modifying this component.
* @param target The target.
* @param index The index of this spell component in the spell execution stack.
* @param ticksUsed The amount of ticks the spell is being cast for.
* @return The spell cast result (success if anything was affected).
*/
@OverrideOnly
SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List<ISpellModifier> modifiers, BlockHitResult target, int index, int ticksUsed);
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,23 @@ public interface ISpellHelper {
*/
float getModifiedStat(float baseValue, ISpellPartStat stat, List<ISpellModifier> modifiers, ISpell spell, LivingEntity caster, @Nullable HitResult target, int componentIndex);

/**
* Casts the spell. Deprecated, use variant with directEntity parameter below.
*
* @param spell The spell to cast.
* @param caster The entity casting the spell.
* @param level The level the spell is cast in.
* @param target The target of the spell cast.
* @param castingTicks How long the spell has already been cast.
* @param index The 1 based index of the currently invoked part.
* @param awardXp The magic xp awarded for casting this spell.
* @return A SpellCastResult that represents the spell casting outcome.
*/
@Deprecated(forRemoval = true)
default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp) {
return invoke(spell, caster, null, level, target, castingTicks, index, awardXp);
}

/**
* Casts the spell.
*
Expand All @@ -168,7 +185,7 @@ public interface ISpellHelper {
* @param awardXp The magic xp awarded for casting this spell.
* @return A SpellCastResult that represents the spell casting outcome.
*/
SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp);
SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp);

/**
* Selects the next shape group of the given spell item stack, wrapping around.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ public AMDamageTypeProvider() {

@Override
public void generate() {
register(AMDamageSources.NATURE_SCYTHE, 0.1F);
register(AMDamageSources.SHOCKWAVE, 0.1F);
register(AMDamageSources.THROWN_ROCK, 0.1F);
register(AMDamageSources.WIND, 0.0F);
register(AMDamageSources.FALLING_STAR, 0.1F);
register(AMDamageSources.SPELL_DROWNING, 0.0f, "drown", DamageEffects.DROWNING);
register(AMDamageSources.SPELL_FIRE, 0.1f, "inFire", DamageEffects.BURNING);
register(AMDamageSources.SPELL_FROST, 0.1f, "freeze", DamageEffects.FREEZING);
register(AMDamageSources.SPELL_LIGHTNING, 0.1f, "lightningBolt");
register(AMDamageSources.SPELL_MAGIC, 0.0f, "magic");
register(AMDamageSources.SPELL_PHYSICAL, 0.1f, "mob");
register(AMDamageSources.SPELL_PHYSICAL_PLAYER, 0.1f, "player");
register(AMDamageSources.NATURE_SCYTHE, 0.1f);
register(AMDamageSources.SHOCKWAVE, 0.1f);
register(AMDamageSources.THROWN_ROCK, 0.1f);
register(AMDamageSources.WIND, 0.0f);
register(AMDamageSources.FALLING_STAR, 0.1f);
}

protected void register(ResourceKey<DamageType> key, DamageScaling scaling, float exhaustion, DamageEffects effects, DeathMessageType deathMessageType) {
super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion, effects, deathMessageType));
}

protected void register(ResourceKey<DamageType> key, DamageScaling scaling, float exhaustion) {
super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion));
}

protected void register(ResourceKey<DamageType> key, DamageScaling scaling, float exhaustion, DamageEffects effects) {
super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion, effects));
protected void register(ResourceKey<DamageType> key, float exhaustion, String messageId, DamageEffects effects) {
super.add(key.location(), new DamageType(messageId, exhaustion, effects));
}

protected void register(ResourceKey<DamageType> key, float exhaustion, DamageEffects effects) {
super.add(key.location(), new DamageType(key.location().getPath(), exhaustion, effects));
protected void register(ResourceKey<DamageType> key, float exhaustion, String messageId) {
super.add(key.location(), new DamageType(messageId, exhaustion));
}

protected void register(ResourceKey<DamageType> key, float exhaustion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,26 @@ protected void addTranslations() {
skillTranslation(AMTalents.MANA_REGEN_BOOST_3, "Mana Regeneration III", "...just to get back every single mana point I have consumed before.", "talents", "Your mana regeneration is boosted by 15%%. This replaces the boosts of $(l:talents/mana_regen_1)Mana Regen I$() and $(l:talents/mana_regen_2)Mana Regen II$().");
skillTranslation(AMTalents.SHIELD_OVERLOAD, "Shield Overload", "No more wasting excess mana.", "talents", "When your mana bar is full, excess mana regenerated turns into a shield that protects you from 5%% of all incoming damage.");
skillTranslation(AMTalents.SPELL_MOTION, "Spell Motion", "I like to move it, move it.", "talents", "Manipulating the winds around you, you have found a way to move at normal speed while using spells.");
configTranslation("mana_x", "Horizontal position of the mana bar.");
configTranslation("mana_y", "Vertical position of the mana bar.");
configTranslation("mana_anchor_x", "Horizontal anchor of the mana bar.");
configTranslation("mana_anchor_y", "Vertical anchor of the mana bar.");
configTranslation("burnout_x", "Horizontal position of the burnout bar.");
configTranslation("burnout_y", "Vertical position of the burnout bar.");
configTranslation("burnout_anchor_x", "Horizontal anchor of the burnout bar.");
configTranslation("burnout_anchor_y", "Vertical anchor of the burnout bar.");
configTranslation("xp_x", "Horizontal position of the magic xp bar.");
configTranslation("xp_y", "Vertical position of the magic xp bar.");
configTranslation("xp_anchor_x", "Horizontal anchor of the magic xp bar.");
configTranslation("xp_anchor_y", "Vertical anchor of the magic xp bar.");
configTranslation("spell_book_x", "Horizontal position of the spell book hud.");
configTranslation("spell_book_y", "Vertical position of the spell book hud.");
configTranslation("spell_book_anchor_x", "Horizontal anchor of the spell book hud.");
configTranslation("spell_book_anchor_y", "Vertical anchor of the spell book hud.");
configTranslation("shape_group_x", "Horizontal position of the shape group hud.");
configTranslation("shape_group_y", "Vertical position of the shape group hud.");
configTranslation("shape_group_anchor_x", "Horizontal anchor of the shape group hud.");
configTranslation("shape_group_anchor_y", "Vertical anchor of the shape group hud.");
configTranslation("require_compendium_crafting", "Whether the player needs to craft the compendium before being able to use magic. If disabled, the player can use magic from the beginning.");
configTranslation("burnout_ratio", "The default mana to burnout ratio, used in calculating spell costs.");
configTranslation("crafting_altar_check_time", "The time in ticks between multiblock validation checks for the crafting altar.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected void addBooks(HolderLookup.Provider provider, Consumer<BookBuilder<?,
.addEntry("black_aurem", "Black Aurem", new ItemStack(AMItems.BLACK_AUREM.get()))
.addSimpleTextPage("The Black Aurem is the $(l:blocks/obelisk)Obelisk's$() dark counterpart, used to generate dark $(l:mechanics/etherium)Etherium$(). Instead of $(l:blocks/ores#vinteum)vinteum$(), it consumes the lifes of animals.$(br2)Similarly, it can be supported by a multiblock structure, which builds up in levels. The structure's different levels are shown on the later pages.")
.addSimpleSpotlightPage(new ItemStack(AMItems.BLACK_AUREM.get()), "The Black Aurem cannot be obtained through crafting. Instead, it must be created through a special corruption ritual. This ritual requires a multiblock structure, seen on the next page. Once built, throw a piece of $(l:blocks/ores#sunstone)Sunstone$() somewhere into the structure.")
.addSimpleMultiblockPage("Corruption Ritual", "Finally, to initiate the ritual, you must $(l:components/fire_damage)severely burn$() the Obelisk.", PatchouliCompat.CORRUPTION_RITUAL)
.addSimpleMultiblockPage("Corruption Ritual", "Finally, to initiate the ritual, you must $(l:components/fire_damage)severely burn$() the bottom of the Obelisk.", PatchouliCompat.CORRUPTION_RITUAL)
.addSimpleMultiblockPage("Black Aurem Chalk", PatchouliCompat.BLACK_AUREM_CHALK)
.addSimpleMultiblockPage("Black Aurem Level 1", PatchouliCompat.BLACK_AUREM_PILLAR1)
.addSimpleMultiblockPage("Black Aurem Level 2", PatchouliCompat.BLACK_AUREM_PILLAR2)
Expand All @@ -115,7 +115,7 @@ protected void addBooks(HolderLookup.Provider provider, Consumer<BookBuilder<?,
.addEntry("celestial_prism", "Celestial Prism", new ItemStack(AMItems.CELESTIAL_PRISM.get()))
.addSimpleTextPage("The Celestial Prism is the $(l:blocks/obelisk)Obelisk's$() light counterpart, used to generate light $(l:mechanics/etherium)Etherium$(). Instead of $(l:blocks/ores#vinteum)vinteum$(), it utilizes the sun's power.$(br2)Similarly, it can be supported by a multiblock structure, which builds up in levels. The structure's different levels are shown on the later pages.")
.addSimpleSpotlightPage(new ItemStack(AMItems.CELESTIAL_PRISM.get()), "The Celestial Prism cannot be obtained through crafting. Instead, it must be created through a special purification ritual. This ritual requires a multiblock structure, seen on the next page. Once built, throw a piece of $(l:blocks/ores#moonstone)Moonstone$() somewhere into the structure.")
.addSimpleMultiblockPage("Purification Ritual", "Finally, to initiate the ritual, simply place some $(l:components/light)light$() on the Obelisk.", PatchouliCompat.PURIFICATION_RITUAL)
.addSimpleMultiblockPage("Purification Ritual", "Finally, to initiate the ritual, simply place some $(l:components/light)light$() on the bottom of the Obelisk.", PatchouliCompat.PURIFICATION_RITUAL)
.addSimpleMultiblockPage("Celestial Prism Chalk", PatchouliCompat.CELESTIAL_PRISM_CHALK)
.addSimpleMultiblockPage("Celestial Prism Level 1", PatchouliCompat.CELESTIAL_PRISM_PILLAR1)
.addSimpleMultiblockPage("Celestial Prism Level 2", PatchouliCompat.CELESTIAL_PRISM_PILLAR2)
Expand Down
Loading