Skip to content

Commit

Permalink
RemnantOfWar, Gyroscopic, Stave recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Sefiraat committed Oct 28, 2021
1 parent 750b04d commit a48f9aa
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void onInvulnerablePlayerDamaged(EntityDamageEvent event) {
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onnWitherWeatherDeath(EntityDeathEvent event) {
public void onWitherWeatherDeath(EntityDeathEvent event) {
NamespacedKey key = Keys.PDC_IS_WEATHER_WITHER;
if (event.getEntity() instanceof WitherSkeleton
&& PersistentDataAPI.getBoolean(event.getEntity(), key)
Expand All @@ -129,5 +129,16 @@ public void onnWitherWeatherDeath(EntityDeathEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onMagicSummonDeath(EntityDeathEvent event) {
NamespacedKey key = Keys.PDC_IS_SPAWN_OWNER;
if (PersistentDataAPI.hasBoolean(event.getEntity(), key)) {
event.setCancelled(true);
event.getEntity().remove();
}
}




}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Fireball;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.FlameSprite;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.FrostNova;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Gyroscopic;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Heal;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.HealingMist;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Hellscape;
Expand All @@ -32,6 +33,7 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Push;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Quake;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.RainOfFire;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.RemnantOfWar;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Shroud;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.SpawnFiends;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Squall;
Expand Down Expand Up @@ -73,6 +75,7 @@ public enum SpellType {
HEALING_MIST(new HealingMist()),
HELLSCAPE(new Hellscape()),
HOLY_COW(new HolyCow()),
GYROSCOPIC(new Gyroscopic()),
KNOWLEDGE_SHARE(new KnowledgeShare()),
LAVA_LAKE(new LavaLake()),
LOVE_POTION(new LovePotion()),
Expand All @@ -83,6 +86,7 @@ public enum SpellType {
PUSH(new Push()),
QUAKE(new Quake()),
RAIN_OF_FIRE(new RainOfFire()),
REMNANT_OF_WAR(new RemnantOfWar()),
SHROUD(new Shroud()),
SPAWN_FIENDS(new SpawnFiends()),
SQUALL(new Squall()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package io.github.sefiraat.crystamaehistoria.magic.spells.tier1;

import io.github.sefiraat.crystamaehistoria.magic.CastInformation;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.Spell;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.SpellCoreBuilder;
import io.github.sefiraat.crystamaehistoria.slimefun.machines.liquefactionbasin.SpellRecipe;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.Keys;
import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

public class Gyroscopic extends Spell {

public Gyroscopic() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(40, true, 15, false, 50, true)
.makeTickingSpell(this::cast, 20, true, 5, false);
setSpellCore(spellCoreBuilder.build());
}

@ParametersAreNonnullByDefault
public void cast(CastInformation castInformation) {
final Location location = castInformation.getCasterAsPlayer().getLocation().clone().add(0, 1, 0);
final double range = getRange(castInformation);
final double effectRange = range * 0.75;
final int density = 30;
// Particles
for (double height = 0; height <= Math.PI; height += Math.PI / density) {
final double r = range * Math.sin(height);
final double y = range * Math.cos(height);
for (double a = 0; a < Math.PI * 2; a += Math.PI / density) {
final double x = Math.cos(a) * r;
final double z = Math.sin(a) * r;
final Location point = location.clone().add(x, y, z);
displayParticleEffect(point, Particle.GLOW, 0.1, 1);
}
}
for (Entity entity : location.getWorld().getNearbyEntities(location, effectRange, effectRange, effectRange)) {
if (entity instanceof LivingEntity
&& hasPermission(castInformation.getCaster(), entity.getLocation(), Interaction.INTERACT_ENTITY)
&& entity.getUniqueId() != castInformation.getCaster()
) {
// Todo mobs dont spin?
Location newLocation = entity.getLocation().clone();
newLocation.setYaw(entity.getLocation().getYaw() + 10F);
entity.teleport(newLocation);
displayParticleEffect(entity, Particle.SPELL, 1, 1);
}
}
}

@Nonnull
@Override
public String getId() {
return "GYROSCOPIC";
}

@Nonnull
@Override
public String[] getLore() {
return new String[]{
"You spin me right round baby..."
};
}

@Nonnull
@Override
public Material getMaterial() {
return Material.MUSIC_DISC_CAT;
}

@NotNull
@Override
public SpellRecipe getRecipe() {
return new SpellRecipe(
1,
StoryType.MECHANICAL,
StoryType.ANIMAL,
StoryType.CELESTIAL
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package io.github.sefiraat.crystamaehistoria.magic.spells.tier1;

import io.github.sefiraat.crystamaehistoria.magic.CastInformation;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.MagicSummon;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.Spell;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.SpellCoreBuilder;
import io.github.sefiraat.crystamaehistoria.slimefun.machines.liquefactionbasin.SpellRecipe;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.SpellUtils;
import io.github.sefiraat.crystamaehistoria.utils.mobgoals.BoringGoal;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Zombie;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

public class RemnantOfWar extends Spell {

public RemnantOfWar() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(5, true, 0, false, 50, true)
.makeInstantSpell(this::cast);
setSpellCore(spellCoreBuilder.build());
}

@ParametersAreNonnullByDefault
public void cast(CastInformation castInformation) {
UUID caster = castInformation.getCaster();
Location location = castInformation.getCastLocation();
Location spawnLocation = location.clone().add(
ThreadLocalRandom.current().nextDouble(-3,3),
0,
ThreadLocalRandom.current().nextDouble(-3,3)
);
MagicSummon magicSummon = SpellUtils.summonTemporaryMob(
EntityType.ZOMBIE,
caster,
spawnLocation,
new BoringGoal(caster),
180,
this::onTick
);
Zombie zombie = (Zombie) magicSummon.getMob();
gearZombie(zombie, castInformation.getStaveLevel());
}

public void gearZombie(Zombie zombie, int tier) {
ItemStack helmet;
ItemStack chestplate;
ItemStack leggings;
ItemStack boots;
ItemStack sword;
switch (tier) {
case 1:
helmet = new ItemStack(Material.LEATHER_HELMET);
chestplate = new ItemStack(Material.LEATHER_CHESTPLATE);
leggings = new ItemStack(Material.LEATHER_LEGGINGS);
boots = new ItemStack(Material.LEATHER_BOOTS);
sword = new ItemStack(Material.WOODEN_SWORD);
break;
case 2:
helmet = new ItemStack(Material.CHAINMAIL_HELMET);
chestplate = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
leggings = new ItemStack(Material.CHAINMAIL_LEGGINGS);
boots = new ItemStack(Material.CHAINMAIL_BOOTS);
sword = new ItemStack(Material.STONE_SWORD);
break;
case 3:
helmet = new ItemStack(Material.IRON_HELMET);
chestplate = new ItemStack(Material.IRON_CHESTPLATE);
leggings = new ItemStack(Material.IRON_LEGGINGS);
boots = new ItemStack(Material.IRON_BOOTS);
sword = new ItemStack(Material.IRON_SWORD);
break;
case 4:
helmet = new ItemStack(Material.DIAMOND_HELMET);
chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
boots = new ItemStack(Material.DIAMOND_BOOTS);
sword = new ItemStack(Material.DIAMOND_SWORD);
break;
case 5:
helmet = new ItemStack(Material.NETHERITE_HELMET);
chestplate = new ItemStack(Material.NETHERITE_CHESTPLATE);
leggings = new ItemStack(Material.NETHERITE_LEGGINGS);
boots = new ItemStack(Material.NETHERITE_BOOTS);
sword = new ItemStack(Material.NETHERITE_SWORD);
break;
default:
throw new IllegalStateException("Unexpected value: " + tier);
}
EntityEquipment entityEquipment = zombie.getEquipment();
entityEquipment.setHelmet(helmet);
entityEquipment.setChestplate(chestplate);
entityEquipment.setLeggings(leggings);
entityEquipment.setBoots(boots);
entityEquipment.setItemInMainHand(sword);
}

public void onTick(MagicSummon magicSummon) {
displayParticleEffect(magicSummon.getMob(), Particle.SOUL, 1, 1);
}

@Nonnull
@Override
public String getId() {
return "REMNANT_OF_WAR";
}

@Nonnull
@Override
public String[] getLore() {
return new String[]{
"Summons a remnant of war from the dead",
"to your side. Their gear scales with tier."
};
}

@Nonnull
@Override
public Material getMaterial() {
return Material.ZOMBIE_SPAWN_EGG;
}

@NotNull
@Override
public SpellRecipe getRecipe() {
return new SpellRecipe(
1,
StoryType.HISTORICAL,
StoryType.HUMAN,
StoryType.VOID
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.slimefun.itemgroups.ItemGroups;
import io.github.sefiraat.crystamaehistoria.slimefun.tools.stave.Stave;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryRarity;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.theme.ThemeType;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import org.bukkit.Material;
Expand All @@ -20,7 +22,9 @@ public Tools(CrystamaeHistoria p) {
}

public void setup() {
new Stave(
final ItemStack ingot = CrystamaeHistoria.getStructure().getMaterials().amalgamateIngot.getItem();

Stave basic = new Stave(
ItemGroups.TOOLS,
ThemeType.themedSlimefunItemStack(
"CRY_STAVE_1",
Expand All @@ -30,9 +34,35 @@ public void setup() {
"A stave with the ability to hold",
"magically charged plates."
),
RecipeType.SMELTERY,
new ItemStack[]{},
RecipeType.MAGIC_WORKBENCH,
new ItemStack[]{
null, null, CrystamaeHistoria.getStructure().getMaterials().getCrystalMap().get(StoryRarity.UNIQUE).get(StoryType.ELEMENTAL).getItem(),
null, new ItemStack(Material.STICK), null,
new ItemStack(Material.STICK), null, null
},
1
).register(plugin);
);

Stave advanced = new Stave(
ItemGroups.TOOLS,
ThemeType.themedSlimefunItemStack(
"CRY_STAVE_2",
new ItemStack(Material.STICK),
ThemeType.STAVE,
"Advanced Stave",
"A stave with the ability to hold",
"magically charged plates."
),
RecipeType.MAGIC_WORKBENCH,
new ItemStack[]{
ingot, ingot, ingot,
ingot, basic.getItem(), ingot,
ingot, ingot, ingot
},
2
);

basic.register(plugin);
advanced.register(plugin);
}
}

0 comments on commit a48f9aa

Please sign in to comment.