Kill Ability

This commit is contained in:
Timo Ley 2019-05-18 20:40:12 +02:00
parent ae0569ec92
commit d66f0bba92
3 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,57 @@
package anvil.infinity.abilities;
import anvil.infinity.conditions.ICondition;
import anvil.infinity.registry.Effects;
import lucraft.mods.lucraftcore.superpowers.abilities.AbilityAction;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
public class AbilityKill extends AbilityAction {
ICondition condition;
public AbilityKill(EntityLivingBase entity) {
super(entity);
condition = new ICondition<EntityLivingBase>() {
@Override
public boolean isFulfilled(EntityLivingBase information) {
return true;
}
};
}
public AbilityKill(EntityLivingBase entity, ICondition condition) {
super(entity);
this.condition = condition;
}
@Override
public boolean action() {
if (condition.isFulfilled(entity)) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
World w = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld();
RayTraceResult result = Minecraft.getMinecraft().objectMouseOver;
System.out.println(result.typeOfHit);
if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
Entity e = w.getEntityByID(result.entityHit.getEntityId());
if (e instanceof EntityLivingBase) {
((EntityLivingBase) e).addPotionEffect(new PotionEffect(Effects.snapEffect, 1));
return true;
}
}
}
}
return false;
}
}

View file

@ -1,8 +1,11 @@
package anvil.infinity.items;
import anvil.infinity.abilities.AbilityHasSoulStone;
import anvil.infinity.abilities.AbilityKill;
import anvil.infinity.abilities.AbilitySnap;
import anvil.infinity.conditions.ICondition;
import anvil.infinity.config.ConfigHandler;
import anvil.infinity.helpers.GauntelHelper;
import lucraft.mods.lucraftcore.infinity.EnumInfinityStone;
import lucraft.mods.lucraftcore.infinity.ModuleInfinity;
import lucraft.mods.lucraftcore.infinity.items.ItemInfinityStone;
@ -15,6 +18,13 @@ import net.minecraft.entity.EntityLivingBase;
public class ItemSoulStone extends ItemInfinityStone {
ICondition killCond = new ICondition<EntityLivingBase>() {
@Override
public boolean isFulfilled(EntityLivingBase information) {
return GauntelHelper.hasPowerStone(information) && GauntelHelper.hasSpaceStone(information) && GauntelHelper.hasRealityStone(information) && GauntelHelper.hasSoulStone(information);
}
};
public ItemSoulStone(String name) {
this.setTranslationKey(name);
this.setRegistryName(StringHelper.unlocalizedToResourceName(name));
@ -40,6 +50,7 @@ public class ItemSoulStone extends ItemInfinityStone {
}
abilities.put("healing", new AbilityHealing(entity).setDataValue(AbilityHealing.FREQUENCY, 1));
abilities.put("soul", new AbilityHasSoulStone(entity));
abilities.put("kill", new AbilityKill(entity, killCond));
abilities.put("snap", new AbilitySnap(entity));
return super.addStoneAbilities(entity, abilities, context);
}

View file

@ -21,6 +21,7 @@ public class Abilities {
e.getRegistry().register(new AbilityEntry(AbilityHasSoulStone.class, new ResourceLocation(Infinity.MOD_ID, "soul")));
e.getRegistry().register(new AbilityEntry(AbilityHasTimeStone.class, new ResourceLocation(Infinity.MOD_ID, "time")));
e.getRegistry().register(new AbilityEntry(AbilityHasMindStone.class, new ResourceLocation(Infinity.MOD_ID, "mind")));
e.getRegistry().register(new AbilityEntry(AbilityKill.class, new ResourceLocation(Infinity.MOD_ID, "kill")));
e.getRegistry().register(new AbilityEntry(AbilityChangeSnap.class, new ResourceLocation(Infinity.MOD_ID, "changesnap")));
e.getRegistry().register(new AbilityEntry(AbilitySaturation.class, new ResourceLocation(Infinity.MOD_ID, "saturation")));
}