Created
December 6, 2014 18:15
-
-
Save ollieread/6c17677c413eefc7284d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@SubscribeEvent | |
public void onEntityConstructing(EntityConstructing event) | |
{ | |
if (event.entity instanceof EntityAgeable) { | |
EntityAgeable child = (EntityAgeable) event.entity; | |
if (child.isChild()) { | |
List parents = child.worldObj.getEntitiesWithinAABBExcludingEntity(child, AxisAlignedBB.getBoundingBox(child.posX, child.posY, child.posZ, child.posX + 4D, child.posY + 4D, child.posZ + 4D)); | |
boolean flag = false; | |
int parentCount = 0; | |
for (Iterator i = parents.iterator(); i.hasNext();) { | |
Entity parent = (Entity) i.next(); | |
if (parent.getClass().equals(child.getClass())) { | |
parentCount++; | |
} | |
if (parentCount == 2) { | |
break; | |
} | |
} | |
if (parentCount == 2) { | |
List entities = child.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(child.posX, child.posY, child.posZ, child.posX + 4D, child.posY + 4D, child.posZ + 4D)); | |
for (Iterator i = entities.iterator(); i.hasNext();) { | |
EntityPlayer player = (EntityPlayer) i.next(); | |
if (player != null && player.canEntityBeSeen(child)) { | |
Class entityClass = child.getClass(); | |
String entityName = (String) EntityList.classToStringMapping.get(entityClass); | |
if (entityName != null && !entityName.isEmpty()) { | |
ExtendedPlayerKnowledge knowledge = ExtendedPlayerKnowledge.get(player); | |
if (knowledge != null && !knowledge.canSpecialise()) { | |
ResearchRegistry.researchEvent("birth" + StringUtils.capitalize(entityName), event, knowledge, true); | |
} | |
} | |
} | |
} | |
} | |
} | |
} else { | |
Set<Class> allowedEntities = ResearchRegistry.getMonitorableEntities(); | |
for (Iterator<Class> i = allowedEntities.iterator(); i.hasNext();) { | |
Class c = i.next(); | |
if (c.isInstance(event.entity) && ExtendedNanites.get(event.entity) == null) { | |
ExtendedNanites.register(event.entity); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment