Added kill evil entities snap

This commit is contained in:
Timo Ley 2019-06-08 13:17:51 +02:00
parent ba91b9db69
commit 90d2609af9
3 changed files with 47 additions and 7 deletions

View File

@ -5,9 +5,11 @@ import anvil.infinity.config.ConfigHandler;
import anvil.infinity.capabilities.GauntletUserInformation;
import anvil.infinity.helpers.GauntelHelper;
import anvil.infinity.registry.Effects;
import lucraft.mods.lucraftcore.karma.capabilities.CapabilityKarma;
import lucraft.mods.lucraftcore.superpowers.abilities.supplier.IAbilityProvider;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityRabbit;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -96,11 +98,25 @@ public class SnapHelper {
entities.addAll(worlds[i].loadedEntityList);
}
PlayerList players = server.getPlayerList();
TextComponentString msg = new TextComponentString(entity.getName() + ": ");
msg.appendSibling(new TextComponentTranslation("infinity.snap.irontext"));
msg.getStyle().setColor(TextFormatting.RED);
msg.getStyle().setBold(true);
players.sendMessage(msg);
Random random = new Random();
for (int i = 0; i < entities.size(); i++) {
if (entities.get(i) != entity && entities.get(i) instanceof EntityLivingBase) {
EntityLivingBase e = ((EntityLivingBase) entities.get(i));
e.addPotionEffect(new PotionEffect(Effects.snapEffect, random.nextInt((1200 - 10) + 1) - 10));
if (e instanceof EntityMob) {
e.addPotionEffect(new PotionEffect(Effects.snapEffect, random.nextInt((1200 - 10) + 1) - 10));
} else if (e instanceof EntityPlayer && e.hasCapability(CapabilityKarma.KARMA_CAP, null)) {
if (e.getCapability(CapabilityKarma.KARMA_CAP, null).getKarma() < 1) {
e.addPotionEffect(new PotionEffect(Effects.snapEffect, random.nextInt((1200 - 10) + 1) - 10));
}
}
}
}

View File

@ -8,14 +8,23 @@ public enum SnapResult {
DESTROYSTONES,
BRINGBACK,
RECREATE,
KILLEVIL,
CREATIVE;
final static String KILLHALFID = "Kill half";
final static String DESTROYSTONESID = "Destroy the Stones";
final static String BRINGBACKID = "Bring back the dusted (WIP)";
final static String RECREATEID = "Recreate the Universe (WIP)";
final static String KILLEVILID = "Kill evil entities";
final static String CREATIVEID = "Change to Creative";
public SnapResult next() {
switch(this) {
case KILLHALF: return DESTROYSTONES;
case DESTROYSTONES: return BRINGBACK;
case BRINGBACK: return RECREATE;
case RECREATE: if (ConfigHandler.snapCreative) {return CREATIVE;} else {return KILLHALF;}
case RECREATE: return KILLEVIL;
case KILLEVIL: if (ConfigHandler.snapCreative) {return CREATIVE;} else {return KILLHALF;}
case CREATIVE: return KILLHALF;
}
return KILLHALF;
@ -25,12 +34,26 @@ public enum SnapResult {
@Override
public String toString() {
switch (this) {
case KILLHALF: return "Kill half";
case DESTROYSTONES: return "Destroy the Stones";
case BRINGBACK: return "Bring back the dusted (WIP)";
case RECREATE: return "Recreate the Universe (WIP)";
case CREATIVE: return "Change to Creative";
case KILLHALF: return KILLHALFID;
case DESTROYSTONES: return DESTROYSTONESID;
case BRINGBACK: return BRINGBACKID;
case RECREATE: return RECREATEID;
case KILLEVIL: return KILLEVILID;
case CREATIVE: return CREATIVEID;
}
return "Kill half";
}
public static SnapResult fromString(String s) {
switch (s) {
case KILLHALFID: return KILLHALF;
case DESTROYSTONESID: return DESTROYSTONES;
case BRINGBACKID: return BRINGBACK;
case RECREATEID: return RECREATE;
case KILLEVILID: return KILLEVIL;
case CREATIVEID: return CREATIVE;
}
return KILLHALF;
}
}

View File

@ -4,6 +4,7 @@ item.soul_stone.name=Soul Stone
item.time_stone.name=Time Stone
item.mind_stone.name=Mind Stone
infinity.snap.text=You should have gone for the head.
infinity.snap.irontext=And I am ... Iron Man
infinity.snap.death=was dusted away