Skip to content

Commit

Permalink
Merge pull request #19 from StellarWitch7/drop-my-stuff-please
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai authored Jul 14, 2024
2 parents 21b542e + 93f04d0 commit 1c6bd15
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/dev/enjarai/trickster/Trickster.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dev.enjarai.trickster.item.ModItems;
import dev.enjarai.trickster.item.component.ModComponents;
import dev.enjarai.trickster.item.recipe.ModRecipes;
import dev.enjarai.trickster.misc.ModDamageTypes;
import dev.enjarai.trickster.net.ModNetworking;
import dev.enjarai.trickster.particle.ModParticles;
import dev.enjarai.trickster.screen.ModScreenHandlers;
Expand Down Expand Up @@ -44,6 +45,7 @@ public void onInitialize() {
ModSounds.register();
ModAttachments.register();
ModRecipes.register();
ModDamageTypes.register();
Tricks.register();
SpellCircleEvent.register();
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/dev/enjarai/trickster/cca/ManaComponent.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package dev.enjarai.trickster.cca;

import dev.enjarai.trickster.entity.ModEntities;
import dev.enjarai.trickster.misc.ModDamageTypes;
import dev.enjarai.trickster.spell.ManaPool;
import dev.enjarai.trickster.spell.SimpleManaPool;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.server.network.ServerPlayerEntity;
import org.ladysnake.cca.api.v3.component.sync.AutoSyncedComponent;
Expand Down Expand Up @@ -66,10 +71,8 @@ public boolean decrease(float amount) {
float f = mana - amount;
mana = Math.max(Math.min(mana - amount, maxMana), 0);

if (f < 0) { //TODO: funny death messages
if (!entity.isInCreativeMode())
entity.setHealth(entity.getHealth() - ManaPool.healthFromMana(f * -1));

if (f < 0) {
entity.damage(ModDamageTypes.of(entity.getWorld(), ModDamageTypes.MANA_OVERFLUX), ManaPool.healthFromMana(f * -1));
return entity.isAlive();
}

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/dev/enjarai/trickster/misc/ModDamageTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.enjarai.trickster.misc;

import dev.enjarai.trickster.Trickster;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.world.World;

public class ModDamageTypes {
public static final RegistryKey<DamageType> MANA_OVERFLUX = register("mana_overflux");

public static DamageSource of(World world, RegistryKey<DamageType> key) {
return new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key));
}

private static RegistryKey<DamageType> register(String name) {
return RegistryKey.of(RegistryKeys.DAMAGE_TYPE, Trickster.id(name));
}

public static void register() {

}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/trickster/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ tag.item.trickster:
scrolls: Scrolls
spell_cost: Spell Cost

death.attack:
mana_overflux: "%1$s's magic show has met an untimely end."

key:
categories:
trickster: Trickster
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"trickster:mana_overflux"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"exhaustion": 0.1,
"message_id": "mana_overflux",
"scaling": "never"
}

0 comments on commit 1c6bd15

Please sign in to comment.