That's one heck of a commit you've got there...

I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
Electroblob77
2019-08-18 00:04:18 +01:00
parent 2680d02304
commit f37812be3e
1564 changed files with 47652 additions and 12984 deletions
@@ -1,31 +1,27 @@
package electroblob.wizardry.spell;
import java.util.Arrays;
import java.util.List;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.entity.living.EntityEvilWizard;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.AllyDesignationSystem;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.INpc;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
@@ -33,45 +29,57 @@ import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Arrays;
import java.util.List;
@Mod.EventBusSubscriber
public class MindControl extends SpellRay {
/** The NBT tag name for storing the controlling entity's UUID in the target's tag compound. */
public static final String NBT_KEY = "controllingEntity";
private static final int BASE_DURATION = 600;
public MindControl(){
super("mind_control", Tier.ADVANCED, Element.NECROMANCY, SpellType.ATTACK, 40, 150, false, 8, WizardrySounds.SPELL_SUMMONING);
super("mind_control", false, EnumAction.NONE);
addProperties(EFFECT_DURATION);
}
@Override public boolean canBeCastByNPCs() { return false; }
@Override public boolean canBeCastByDispensers() { return false; }
@Override
protected boolean onEntityHit(World world, Entity target, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
if(WizardryUtilities.isLiving(target)){
if(!world.isRemote){
if(!canControl(target)){
// Adds a message saying that the player/boss entity/wizard resisted mind control
((EntityPlayer)caster).sendStatusMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()), true);
}else if(target instanceof EntityLiving){
if(!canControl(target)){
if(!world.isRemote){
if(caster instanceof EntityPlayer){
// Adds a message saying that the player/boss entity/wizard resisted mind control
((EntityPlayer)caster).sendStatusMessage(new TextComponentTranslation("spell.resist", target.getName(),
this.getNameForTranslationFormatted()), true);
}
}
}else if(target instanceof EntityLiving){
if(!world.isRemote){
if(!MindControl.findMindControlTarget((EntityLiving)target, caster, world)){
// If no valid target was found, this just acts like mind trick.
((EntityLiving)target).setAttackTarget(null);
}
NBTTagCompound entityNBT = target.getEntityData();
if(entityNBT != null) entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
((EntityLiving)target).addPotionEffect(new PotionEffect(WizardryPotions.mind_control,
(int)(BASE_DURATION * modifiers.get(WizardryItems.duration_upgrade)), 0));
}
}else{
if(target instanceof EntitySheep && ((EntitySheep)target).getFleeceColor() == EnumDyeColor.BLUE
&& WizardryUtilities.canDamageBlocks(caster, world)){
if(!world.isRemote) ((EntitySheep)target).setFleeceColor(EnumDyeColor.RED); // Wololo!
world.playSound(caster.posX, caster.posY, caster.posZ, SoundEvents.EVOCATION_ILLAGER_PREPARE_WOLOLO, WizardrySounds.SPELLS, 1, 1, false);
}
if(!world.isRemote) startControlling((EntityLiving)target, caster,
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)));
}
if(world.isRemote){
for(int i=0; i<10; i++){
ParticleBuilder.create(Type.DARK_MAGIC, world.rand, target.posX,
@@ -90,12 +98,12 @@ public class MindControl extends SpellRay {
}
@Override
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
protected boolean onMiss(World world, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onMiss(World world, EntityLivingBase caster, Vec3d origin, Vec3d direction, int ticksInUse, SpellModifiers modifiers){
return false;
}
@@ -106,6 +114,11 @@ public class MindControl extends SpellRay {
.contains(EntityList.getKey(target.getClass()));
}
public static void startControlling(EntityLiving target, EntityLivingBase controller, int duration){
target.getEntityData().setUniqueId(NBT_KEY, controller.getUniqueID());
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_control, duration, 0));
}
/**
* Finds the nearest creature to the given target which it is allowed to attack according to the given caster and
* sets it as the target's attack target. Handles both new and old AI and takes follow range into account. Defined
@@ -122,7 +135,7 @@ public class MindControl extends SpellRay {
// no longer lasts until the creature dies; instead it is a potion effect which continues to
// set the target until it wears off.
List<EntityLivingBase> possibleTargets = WizardryUtilities.getEntitiesWithinRadius(
((EntityLiving)target).getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(),
target.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(),
target.posX, target.posY, target.posZ, world);
possibleTargets.remove(target);
@@ -131,7 +144,7 @@ public class MindControl extends SpellRay {
EntityLivingBase newAITarget = null;
for(EntityLivingBase possibleTarget : possibleTargets){
if(WizardryUtilities.isValidTarget(caster, possibleTarget) && (newAITarget == null
if(AllyDesignationSystem.isValidTarget(caster, possibleTarget) && (newAITarget == null
|| target.getDistance(possibleTarget) < target.getDistance(newAITarget))){
newAITarget = possibleTarget;
}
@@ -140,7 +153,7 @@ public class MindControl extends SpellRay {
if(newAITarget != null){
// From 1.7.10 - this seems not to work quite right; the entity appears to continue attacking this target
// after it gets killed (not noticeable in survival since it will target the player again immediately.)
((EntityLiving)target).setAttackTarget(newAITarget);
target.setAttackTarget(newAITarget);
return true;
}
@@ -163,7 +176,7 @@ public class MindControl extends SpellRay {
if(caster instanceof EntityLivingBase){
// If the current target is already a valid mind control target, nothing happens.
if(WizardryUtilities.isValidTarget(caster, currentTarget)) return;
if(AllyDesignationSystem.isValidTarget(caster, currentTarget)) return;
if(MindControl.findMindControlTarget(entity, (EntityLivingBase)caster, world)){
// If it worked, skip setting the target to null.