Extend mind control overlay effect to possessed creatures

This commit is contained in:
Electroblob77
2020-08-21 23:24:18 +01:00
parent c48b4ea0fe
commit dac40ecf98
2 changed files with 10 additions and 4 deletions
@@ -2,6 +2,7 @@ package electroblob.wizardry.client.renderer.entity.layers;
import electroblob.wizardry.Wizardry; import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardryPotions; import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.spell.Possession;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor; import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor; import net.minecraft.client.renderer.GlStateManager.SourceFactor;
@@ -26,7 +27,7 @@ public class LayerMindControl extends LayerTiledOverlay<EntityLivingBase> {
@Override @Override
public boolean shouldRender(EntityLivingBase entity, float partialTicks){ public boolean shouldRender(EntityLivingBase entity, float partialTicks){
return !entity.isInvisible() && entity.isPotionActive(WizardryPotions.mind_control); return !entity.isInvisible() && (entity.isPotionActive(WizardryPotions.mind_control) || entity.getEntityData().getBoolean(Possession.NBT_KEY));
} }
@Override @Override
@@ -18,8 +18,11 @@ import electroblob.wizardry.packet.WizardryPacketHandler;
import electroblob.wizardry.potion.PotionSlowTime; import electroblob.wizardry.potion.PotionSlowTime;
import electroblob.wizardry.registry.Spells; import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardryItems; import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.*; import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.NBTExtras;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.*; import net.minecraft.entity.*;
@@ -76,8 +79,8 @@ public class Possession extends SpellRay {
/** A {@code ResourceLocation} representing the shader file used when possessing an entity. */ /** A {@code ResourceLocation} representing the shader file used when possessing an entity. */
public static final ResourceLocation SHADER = new ResourceLocation(Wizardry.MODID, "shaders/post/possession.json"); public static final ResourceLocation SHADER = new ResourceLocation(Wizardry.MODID, "shaders/post/possession.json");
/** The NBT tag name for storing the possessing entity's UUID in the target's tag compound. */ /** The NBT tag name for storing the possessed flag in the target's tag compound, used only for rendering. */
public static final String NBT_KEY = "possessor"; public static final String NBT_KEY = "possessed";
/** The NBT tag name for storing the possessor's previous inventory in their tag compound. */ /** The NBT tag name for storing the possessor's previous inventory in their tag compound. */
public static final String INVENTORY_NBT_KEY = "prevInventory"; public static final String INVENTORY_NBT_KEY = "prevInventory";
@@ -215,6 +218,7 @@ public class Possession extends SpellRay {
target.setDead(); target.setDead();
target.setNoAI(true); target.setNoAI(true);
target.setAttackTarget(null); target.setAttackTarget(null);
target.getEntityData().setBoolean(NBT_KEY, true);
// Attributes // Attributes
@@ -322,6 +326,7 @@ public class Possession extends SpellRay {
victim.isDead = false; victim.isDead = false;
victim.setNoAI(false); victim.setNoAI(false);
victim.getEntityData().removeTag(NBT_KEY);
victim.setPosition(player.posX, player.posY, player.posZ); victim.setPosition(player.posX, player.posY, player.posZ);
if(!player.world.isRemote) player.world.spawnEntity(victim); if(!player.world.isRemote) player.world.spawnEntity(victim);