Created
July 21, 2019 10:28
-
-
Save Davoleo/821d0e84f5ff27ef588351d5b393626d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean cast(EntityPlayer player, List<SpellModule> modules) { | |
List<Entity> entities = Util.getEntitiesWithinRadius(player.world, Entity.class, player.getPosition(), 4, 5, 4); | |
if (entities.size() > 0) { | |
for (Entity e : entities) { | |
Set<Class<?>> classWhiteList = readConfigWhitelist(); | |
if (classWhiteList.contains(e.getClass()) || checkInterfaces(e, classWhiteList)) { | |
if (e.getUniqueID().compareTo(player.getUniqueID()) != 0) { | |
if (Math.pow((e.posX - player.posX), 2) + Math.pow((e.posY - player.posY), 2) + Math.pow((e.posZ - player.posZ), 2) < 9.0f) { | |
e.motionX = 0.125f * (e.posX - player.posX); | |
e.motionY = 0.125f * (e.posY - player.posY); | |
e.motionZ = 0.125f * (e.posZ - player.posZ); | |
e.velocityChanged = true; | |
if (!e.isInvisible()) { | |
PacketHandler.sendToAllTracking(new MessageSanctuaryBurstFX(e.posX, e.posY + 0.6f * e.getEyeHeight(), e.posZ), e); | |
} | |
} | |
} | |
} | |
} | |
} | |
if (player.ticksExisted % 2 == 0) { | |
PacketHandler.sendToAllTracking(new MessageSanctuaryRingFX(player.posX, player.posY + 0.875f, player.posZ), player); | |
} | |
return true; | |
} | |
private boolean checkInterfaces(Entity e, Set<Class<?>> whiteList) { | |
Class<?>[] interfaces = e.getClass().getInterfaces(); | |
for (Class<?> inteface : interfaces) | |
{ | |
if (whiteList.contains(inteface)) | |
return true; | |
} | |
return false; | |
} | |
private Set<Class<?>> readConfigWhitelist() { | |
Set<Class<?>> classSet = new HashSet<>(); | |
for (String className : SpellConfig.spellFeaturesCategory.sanctuaryEntitiesWhitelist) | |
{ | |
try { | |
classSet.add(Class.forName(className)); | |
}catch (ClassNotFoundException exception) { | |
Roots.logger.error("ERROR: One of the Sanctuary whitelist classes does not exist!"); | |
} | |
} | |
return classSet; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment