use of icbm.classic.content.items.ItemTracker in project ICBM-Classic by BuiltBrokenModding.
the class MissileHoming method onInteract.
@Override
public boolean onInteract(EntityMissile missileObj, EntityPlayer entityPlayer) {
if (!missileObj.worldObj.isRemote && missileObj.getTicksInAir() <= 0) {
if (entityPlayer.getCurrentEquippedItem() != null) {
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemTracker) {
Entity trackingEntity = ((ItemTracker) entityPlayer.getCurrentEquippedItem().getItem()).getTrackingEntity(missileObj.worldObj, entityPlayer.getCurrentEquippedItem());
if (trackingEntity != null) {
if (missileObj.trackingVar != trackingEntity.getEntityId()) {
missileObj.trackingVar = trackingEntity.getEntityId();
entityPlayer.addChatMessage(new ChatComponentText("Missile target locked to: " + trackingEntity.getCommandSenderName()));
if (missileObj.getLauncher() != null && missileObj.getLauncher().getController() != null) {
Pos newTarget = new Pos(trackingEntity.posX, 0, trackingEntity.posZ);
missileObj.getLauncher().getController().setTarget(newTarget);
}
return true;
}
}
}
}
}
return false;
}
Aggregations