Skip to content

Commit

Permalink
Conduit's Ploy: Exploitative Edition is now discontinued
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarWitch7 committed Jul 8, 2024
1 parent 3f701ae commit 3a676e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/dev/enjarai/trickster/cca/ManaComponent.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package dev.enjarai.trickster.cca;

import dev.enjarai.trickster.entity.ModEntities;
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.DamageTypes;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.registry.RegistryWrapper;
Expand All @@ -14,10 +13,12 @@

public class ManaComponent extends SimpleManaPool implements AutoSyncedComponent, CommonTickingComponent {
private final LivingEntity entity;
private final boolean manaDevoid;

public ManaComponent(LivingEntity entity) {
super(0); // Max mana gets updated later
this.entity = entity;
this.manaDevoid = entity.getType().isIn(ModEntities.MANA_DEVOID);
}

@Override
Expand All @@ -42,6 +43,9 @@ public void writeSyncPacket(RegistryByteBuf buf, ServerPlayerEntity recipient) {

@Override
public void tick() {
if (manaDevoid)
return;

maxMana = ManaPool.manaFromHealth(entity.getMaxHealth());
stdIncrease();
}
Expand All @@ -56,12 +60,15 @@ public void increase(float amount) {
*/
@Override
public boolean decrease(float amount) {
if (manaDevoid)
return true;

float f = mana - amount;
mana = Math.max(Math.min(mana - amount, maxMana), 0);

if (f < 0) { //TODO: funny death messages
entity.damage(new DamageSource(entity.getRegistryManager().get(DamageTypes.MAGIC.getRegistryRef()).entryOf(DamageTypes.MAGIC)),
ManaPool.healthFromMana(f * -1));
if (!entity.isInCreativeMode())
entity.setHealth(entity.getHealth() - ManaPool.healthFromMana(f * -1));

return entity.isAlive();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/enjarai/trickster/entity/ModEntities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.enjarai.trickster.entity;

import dev.enjarai.trickster.Trickster;
import net.minecraft.entity.EntityType;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;

public class ModEntities {
public static final TagKey<EntityType<?>> MANA_DEVOID = TagKey.of(RegistryKeys.ENTITY_TYPE, Trickster.id("mana_devoid"));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:armor_stand"
]
}

0 comments on commit 3a676e6

Please sign in to comment.