Initial 1.11.2 update
This commit is contained in:
@@ -27,14 +27,15 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@Mod.EventBusSubscriber
|
||||
public class MindTrick extends Spell {
|
||||
|
||||
public MindTrick() {
|
||||
public MindTrick(){
|
||||
super(Tier.BASIC, 10, Element.NECROMANCY, "mind_trick", SpellType.ATTACK, 40, EnumAction.NONE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers) {
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster, 8*modifiers.get(WizardryItems.range_upgrade));
|
||||
RayTraceResult rayTrace = WizardryUtilities.standardEntityRayTrace(world, caster,
|
||||
8 * modifiers.get(WizardryItems.range_upgrade));
|
||||
|
||||
if(rayTrace != null && rayTrace.entityHit != null && rayTrace.entityHit instanceof EntityLivingBase){
|
||||
|
||||
@@ -44,19 +45,22 @@ public class MindTrick extends Spell {
|
||||
|
||||
if(target instanceof EntityPlayer){
|
||||
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,
|
||||
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
|
||||
}else if(target instanceof EntityLiving){
|
||||
|
||||
((EntityLiving)target).setAttackTarget(null);
|
||||
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick,
|
||||
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
}
|
||||
}else{
|
||||
for(int i=0; i<10; i++){
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
|
||||
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
|
||||
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
|
||||
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
|
||||
for(int i = 0; i < 10; i++){
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
|
||||
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
|
||||
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
|
||||
+ world.rand.nextDouble() * 0.5,
|
||||
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,26 +72,30 @@ public class MindTrick extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers) {
|
||||
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
|
||||
SpellModifiers modifiers){
|
||||
|
||||
if(target != null){
|
||||
if(!world.isRemote){
|
||||
if(target instanceof EntityPlayer){
|
||||
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.NAUSEA,
|
||||
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
|
||||
}else if(target instanceof EntityLiving){
|
||||
|
||||
((EntityLiving)target).setAttackTarget(null);
|
||||
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick, (int)(300*modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
target.addPotionEffect(new PotionEffect(WizardryPotions.mind_trick,
|
||||
(int)(300 * modifiers.get(WizardryItems.duration_upgrade)), 0));
|
||||
|
||||
}
|
||||
}else{
|
||||
for(int i=0; i<10; i++){
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world, target.posX - 0.25 + world.rand.nextDouble()*0.5,
|
||||
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25 + world.rand.nextDouble()*0.5,
|
||||
target.posZ - 0.25 + world.rand.nextDouble()*0.5,
|
||||
0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
|
||||
for(int i = 0; i < 10; i++){
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.DARK_MAGIC, world,
|
||||
target.posX - 0.25 + world.rand.nextDouble() * 0.5,
|
||||
target.getEntityBoundingBox().minY + target.getEyeHeight() - 0.25
|
||||
+ world.rand.nextDouble() * 0.5,
|
||||
target.posZ - 0.25 + world.rand.nextDouble() * 0.5, 0, 0, 0, 0, 0.8f, 0.2f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +107,7 @@ public class MindTrick extends Spell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeCastByNPCs() {
|
||||
public boolean canBeCastByNPCs(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,7 +115,8 @@ public class MindTrick extends Spell {
|
||||
public static void onLivingAttackEvent(LivingAttackEvent event){
|
||||
if(event.getSource() != null && event.getSource().getEntity() instanceof EntityLivingBase){
|
||||
// Cancels the mind trick effect if the creature takes damage
|
||||
// This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it doesn't
|
||||
// This has been moved to within an (event.getSource().getEntity() instanceof EntityLivingBase) check so it
|
||||
// doesn't
|
||||
// crash the game with a ConcurrentModificationException. If you think about it, mind trick only ought to be
|
||||
// cancelled if something attacks the entity since potions, drowning, cacti etc. don't affect the targeting.
|
||||
if(event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)){
|
||||
@@ -120,7 +129,9 @@ public class MindTrick extends Spell {
|
||||
public static void onLivingSetAttackTargetEvent(LivingSetAttackTargetEvent event){
|
||||
// Mind trick
|
||||
// If the target is null already, no need to set it to null, or infinite loops will occur.
|
||||
if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick) || event.getEntityLiving().isPotionActive(WizardryPotions.fear)) && event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){
|
||||
if((event.getEntityLiving().isPotionActive(WizardryPotions.mind_trick)
|
||||
|| event.getEntityLiving().isPotionActive(WizardryPotions.fear))
|
||||
&& event.getEntityLiving() instanceof EntityLiving && event.getTarget() != null){
|
||||
((EntityLiving)event.getEntityLiving()).setAttackTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user