-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pose and illager spell registries (#1124)
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...ght-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftSpellcasterMixin.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,40 @@ | ||
package io.izzel.arclight.common.mixin.bukkit; | ||
|
||
import io.izzel.arclight.api.EnumHelper; | ||
import io.izzel.arclight.common.mod.ArclightMod; | ||
import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; | ||
import net.minecraft.world.entity.monster.SpellcasterIllager; | ||
import org.bukkit.craftbukkit.v.entity.CraftSpellcaster; | ||
import org.bukkit.entity.EnderDragon; | ||
import org.bukkit.entity.Spellcaster; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Mixin(CraftSpellcaster.class) | ||
public class CraftSpellcasterMixin { | ||
|
||
/** | ||
* @author IzzelAliz | ||
* @reason | ||
*/ | ||
@Overwrite | ||
public static Spellcaster.Spell toBukkitSpell(SpellcasterIllager.IllagerSpell spell) { | ||
try { | ||
return Spellcaster.Spell.valueOf(spell.name()); | ||
} catch (IllegalArgumentException e) { | ||
var newTypes = new ArrayList<Spellcaster.Spell>(); | ||
var forgeCount = SpellcasterIllager.IllagerSpell.values().length; | ||
for (var id = Spellcaster.Spell.values().length; id < forgeCount; id++) { | ||
var name = SpellcasterIllager.IllagerSpell.values()[id].name(); | ||
var newPhase = EnumHelper.makeEnum(Spellcaster.Spell.class, name, id, List.of(), List.of()); | ||
newTypes.add(newPhase); | ||
ArclightMod.LOGGER.debug("Registered {} as illager spell {}", name, newPhase); | ||
} | ||
EnumHelper.addEnums(Spellcaster.Spell.class, newTypes); | ||
return toBukkitSpell(spell); | ||
} | ||
} | ||
} |
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